UNPKG

@graphql-hive/laboratory

Version:

[Hive](https://the-guild.dev/graphql/hive) is a fully open-source schema registry, analytics, metrics and gateway for [GraphQL federation](https://the-guild.dev/graphql/hive/federation) and other GraphQL APIs.

36,489 lines 1.54 MB
import { $ as DEFAULT_FONT_FAMILY, $a as IEnvironmentService, $c as isLowerAsciiLetter, $i as listHighlightForeground, $l as illegalArgument, $n as mapObservableArrayCached, $o as registerEditorCommand, $r as LineTokens, $s as getDomNodePagePosition, $t as FindInput, A as observableCodeEditor, Aa as editorWarningBorder, Ac as disposableTimeout, Ai as renderLabelWithIcons, Al as URI, An as ActionBar, Ao as LRUCache, Ar as WORKSPACE_EXTENSION, As as ICodeEditorService, At as IStandaloneThemeService, Au as isObject, B as diffDeleteDecorationEmpty, Ba as foreground, Bc as commonSuffixLength, Bi as Widget, Bl as PauseableEmitter, Bn as IStorageService, Bo as ILanguageService, Br as EditOperation, Bs as ModifierKeyEmitter, Bt as HighlightedLabel, Bu as groupBy, C as EditorState, Ca as editorInlayHintForeground, Cc as AsyncIterableObject, Ci as fuzzyScoreGracefulAggressive, Cl as TokenizationRegistry, Cn as IMarkerDecorationsService, Co as UnicodeTextModelHighlighter, Cr as GoToLineNLS, Cs as ThemeIcon, Ct as RenderLineInput, Cu as deepClone, D as bindContextKey, Da as editorInlayHintTypeForeground, Dc as TimeoutTimer, Di as matchesWords, Dl as Selection, Dn as IMarkerService, Do as OverviewRulerLane, Dr as QuickOutlineNLS, Ds as toAction, Dt as AccessibilitySignal, Du as isDefined, E as DiffEditorWidget, Ea as editorInlayHintTypeBackground, Ec as RunOnceScheduler, Ei as matchesSubString, El as Codicon, En as IMarkerData, Eo as InjectedTextCursorStops, Er as QuickHelpNLS, Es as SubmenuAction, Et as registerEditorFeature, Eu as assertType, F as isHotReloadEnabled, Fa as overviewRulerSelectionHighlightForeground, Fc as StandardKeyboardEvent, Fi as HoverWidget, Fl as CancellationToken, Fn as defaultCountBadgeStyles, Fo as ILanguageConfigurationService, Fr as TernarySearchTree, Fs as PixelRatio, Ft as registerIcon, Fu as binarySearch, G as DisposableCancellationTokenSource, Ga as transparent, Gc as escapeRegExpCharacters, Gi as IContextMenuService, Gl as RefCountedDisposable, Gn as getBaseLayerHoverDelegate, Go as createTrustedTypesPolicy, Gr as status, Gs as append, Gt as WorkbenchTreeElementCanExpand, Gu as reverseOrder, H as diffLineDeleteDecorationBackgroundWithIndicator, Ha as asCssVariable, Hc as compareIgnoreCase, Hi as Gesture, Hl as Disposable, Hn as isLocalizedString, Ho as StringBuilder, Hr as IBulkEditService, Hs as addDisposableListener, Ht as WorkbenchAsyncDataTree, Hu as isNonEmptyArray, I as IDiffProviderFactoryService, Ia as widgetBorder, Ic as KeyCodeChord, Ii as KeyDownAction, Il as CancellationTokenSource, In as defaultInputBoxStyles, Io as PLAINTEXT_LANGUAGE_ID, Ir as IEditorProgressService, Is as $, It as widgetClose, Iu as coalesce, J as StableEditorScrollState, Ja as ISemanticTokensStylingService, Jc as getLeadingWhitespace, Ji as WorkbenchHoverDelegate, Jl as isDisposable, Jn as DataTransfers, Jo as EditorCommand, Jr as MarkdownRenderer, Js as createStyleSheet2, Jt as IsWindowsContext, K as appendRemoveOnDispose, Ka as score, Kc as firstNonWhitespaceIndex, Ki as IContextViewService, Kl as combinedDisposable, Kn as createInstantHoverDelegate, Ko as EditorAction, Kr as CONTEXT_ACCESSIBILITY_MODE_ENABLED, Ks as clearNode, Kt as InputFocusedContext, Ku as __commonJSMin, L as diffAddDecoration, La as widgetShadow, Lc as isFirefox, Li as getHoverAccessibleViewHint, Ll as cancelOnDispose, Ln as defaultListStyles, Lo as Extensions$1, Lr as IProgressService, Ls as Dimension, Lt as KeybindingLabel, Lu as compareBy, M as reactToChangeWithStore, Ma as editorWidgetBackground, Mc as raceCancellation, Mi as IOpenerService, Ml as dirname$1, Mn as TextOnlyMenuEntryActionViewItem, Mo as SetMap, Mr as isSingleFolderWorkspaceIdentifier, Ms as createDecorator, Mt as HC_LIGHT_THEME_NAME, Mu as isUndefined, N as WorkbenchToolBar, Na as editorWidgetBorder, Nc as timeout, Ni as ClickAction, Nl as sep, Nn as createActionViewItem, No as CharacterSet, Nr as isStandaloneEditorWorkspace, Ns as EditorZoom, Nt as VS_DARK_THEME_NAME, Nu as Permutation, O as observableConfigValue, Oa as editorSelectionBackground, Oc as createCancelableAsyncIterable, Oi as or, Ol as Range, On as MarkerSeverity, Oo as shouldSynchronizeModel, Or as ToggleHighContrastNLS, Os as ITextModelService, Ot as IAccessibilitySignalService, Ou as isFunction, P as readHotReloadableExport, Pa as overviewRulerFindMatchForeground, Pc as StandardMouseEvent, Pi as HoverAction, Pl as KeyChord, Pn as createAndFillInActionBarActions, Po as LcsDiff, Pr as toWorkspaceIdentifier, Ps as applyFontInfo, Pt as VS_LIGHT_THEME_NAME, Pu as asArray, Q as isModelDecorationVisible, Qa as ILanguageFeatureDebounceService, Qc as isLowSurrogate, Qi as listFocusHighlightForeground, Ql as CancellationError, Qn as derivedObservableWithCache, Qo as registerEditorAction, Qr as nullTokenizeEncoded, Qs as getComputedStyle, Qt as Sash, R as diffAddDecorationEmpty, Ra as activeContrastBorder, Rc as InvisibleCharacters, Ri as DomScrollableElement, Rl as Emitter, Rn as defaultToggleStyles, Ro as Mimes, Rr as Progress, Rs as EventHelper, Rt as unthemedKeybindingLabelOptions, Ru as distinct, S as isDiffEditor, Sa as editorInlayHintBackground, Sc as matchesSomeScheme, Si as fuzzyScore, Sl as SymbolKinds, Sn as CursorColumns, So as mapFindFirst, Sr as IWorkspaceTrustManagementService, Ss as ICommandService, St as TabFocus, Su as localize2, T as TextModelCancellationTokenSource, Ta as editorInlayHintParameterForeground, Tc as Delayer, Ti as matchesPrefix, Tl as isLocationLink, Tn as overviewRulerRangeHighlight, To as GlyphMarginLane, Tr as QuickCommandNLS, Ts as Separator, Tt as LineDecoration, Tu as assertIsDefined, U as diffWholeLineAddDecoration, Ua as oneOf, Uc as containsRTL, Ui as GlobalPointerMoveMonitor, Ul as DisposableStore, Un as ActionViewItem, Uo as VSBuffer, Ur as ResourceTextEdit, Us as addStandardDisposableGenericMouseDownListener, Ut as WorkbenchListFocusContextKey, Uu as numberComparator, V as diffLineAddDecorationBackgroundWithIndicator, Va as iconForeground, Vc as compare, Vi as EventType, Vl as StopWatch, Vn as WillSaveStateReason, Vo as IConfigurationService, Vr as editorConfigurationBaseNode, Vs as WindowIdleValue, Vt as IListService, Vu as isFalsyOrEmpty, W as diffWholeLineDeleteDecoration, Wa as registerColor, Wc as containsUppercaseCharacter, Wi as IKeybindingService, Wl as MutableDisposable, Wn as List, Wo as IndentAction, Wr as alert, Ws as addStandardDisposableListener, Wt as WorkbenchTreeElementCanCollapse, Wu as quickSelect, X as isModelDecorationInComment, Xa as countEOL, Xc as isFalsyOrWhitespace, Xi as quickInputListFocusForeground, Xl as createSingleCallFunction, Xn as waitForState, Xo as MultiCommand, Xr as NullState, Xs as getActiveElement, Xt as SplitView, Y as CodeEditorWidget, Ya as toMultilineTokens2, Yc as isBasicASCII, Yi as quickInputListFocusBackground, Yl as toDisposable, Yn as ObservablePromise, Yo as EditorExtensionsRegistry, Yr as openLinkFromMarkdown, Ys as getActiveDocument, Yt as Sizing, Yu as __toESM, Z as isModelDecorationInString, Za as TokenMetadata, Zc as isHighSurrogate, Zi as quickInputListFocusIconForeground, Zl as BugIndicatingError, Zn as constObservable, Zo as MultiEditorAction, Zr as nullTokenize, Zs as getClientArea, Zt as OrthogonalEdge, _ as formatDocumentWithSelectedProvider, _a as editorForeground, _c as svgElem, _i as stripIcons, _l as InlineEditTriggerKind, _n as DenseKeyProvider, _o as TextLength, _r as transaction, _s as ContextKeyEqualsExpr, _t as ClipboardEventUtils, _u as isNative, aa as inputForeground, ac as h, ai as isEmptyMarkdownString, al as stripWildcards, an as Button, ao as IThemeService, ar as autorunOpts, as as ITelemetryService, at as getIndentMetadata, au as EditorOptions, b as getCodeEditor, ba as editorInfoBorder, bc as Schemas, bi as anyScore, bl as SelectedSuggestionInfo, bn as lengthZero, bo as findFirstMax, br as itemsEquals, bs as RawContextKey, bt as getColumnOfNodeOffset, bu as language, ca as editorActiveLinkForeground, cc as isAncestor, ci as basename, cl as mainWindow, cn as ItemActivation, co as isDark, cr as derivedDisposable, cs as MenuId, ct as ProcessedIndentRulesSupport, cu as unicodeHighlightConfigKeys, da as editorErrorForeground, dc as reset, di as extUri, dl as DocumentHighlightKind, dn as ModelDecorationOptions, do as ITextResourceConfigurationService, dr as derivedWithSetter, ds as SubmenuItemAction, dt as WordPartOperations, du as Iterable, ea as inputActiveOptionBackground, ec as getShadowRoot, ei as getStandardTokenTypeAtPosition, el as isUpperAsciiLetter, en as HistoryInputBox, eo as clamp, er as observableFromEvent, es as registerEditorContribution, et as CoreEditingCommands, eu as isCancellationError, fa as editorFindMatchForeground, fc as runAtThisOrScheduleAtNextAnimationFrame, fi as extname, fl as DocumentPasteTriggerKind, fn as TextModel, fo as Color, fr as derivedWithStore, fs as isIMenuItem, ft as MoveOperations, fu as OS, g as formatDocumentRangesWithSelectedProvider, ga as editorFindRangeHighlightBorder, gc as size, gi as relativePath, gl as InlineCompletionTriggerKind, gn as TextBufferTokenizer, go as TextEdit, gr as subtransaction, gs as assertNever, gt as CursorState, gu as isMacintosh, ha as editorFindMatchHighlightForeground, hc as show, hi as originalFSPath, hl as InlayHintKind$1, hn as LanguageAgnosticBracketTokens, ho as SingleTextEdit, hr as observableValue, hs as Registry, ht as ReplaceCommandThatSelectsText, hu as isLittleEndian, ia as inputBorder, ic as getWindow, ii as MarkdownString, il as splitLinesIncludeSeparators, in as CountBadge, io as severity_default, ir as autorun, is as ILogService, it as getGoodIndentForLine, iu as EditorFontLigatures, j as reactToChange, ja as editorWarningForeground, jc as first, ji as DomEmitter, jl as basename$1, jn as MenuEntryActionViewItem, jo as ResourceMap, jr as isEmptyWorkspaceIdentifier, js as IInstantiationService, jt as HC_BLACK_THEME_NAME, ju as isString, k as HideUnchangedRegionsFeature, ka as editorSelectionHighlight, kc as createCancelablePromise, ki as renderIcon, kl as Position, kn as IEditorWorkerService, ko as getMapForWordSeparators, kr as IWorkspaceContextService, ks as IModelService, kt as IClipboardService, ku as isNumber, la as editorBackground, lc as isHTMLElement, li as basenameOrAuthority, ll as Command$1, ln as Extensions, lo as isHighContrast, lr as derivedHandleChanges, ls as MenuItemAction, lt as CursorMoveCommands, lu as USUAL_WORD_SEPARATORS, m as editor_api_exports, ma as editorFindMatchHighlightBorder, mc as setVisibility, mi as joinPath, ml as HoverVerbosityAction, mn as parseDocument, mo as RGBA, mr as disposableObservableValue, ms as KeybindingsRegistry, mt as ReplaceCommandThatPreservesSelection, mu as isLinux, na as inputActiveOptionForeground, nc as getTotalHeight, ni as IdGenerator, nl as noBreakWhitespace, nn as RegexToggle, no as Severity, nr as observableSignalFromEvent, ns as registerModelAndPositionCommand, nt as TypeOperations, nu as onUnexpectedExternalError, oa as minimapFindMatch, oc as hide, oi as isMarkdownString, ol as trim, on as Toggle, oo as registerThemingParticipant, or as autorunWithStore, os as Action2, ot as ShiftCommand, ou as ShowLightbulbIconMode, pa as editorFindMatchHighlight, pc as runWhenWindowIdle, pi as isEqual, pl as FoldingRangeKind, pn as computeIndentLevel, po as HSVA, pr as asyncTransaction, ps as registerAction2, pt as ReplaceCommand, pu as isIOS, q as applyStyle, qa as hasDriveLetter, qc as format, qi as IHoverService, ql as dispose, qn as getDefaultHoverDelegate, qo as EditorAction2, qr as IAccessibilityService, qs as createCSSRule, qt as IsWebContext, ra as inputBackground, rc as getTotalWidth, ri as defaultGenerator, rl as splitLines, rn as WholeWordsToggle, ro as IDialogService, rr as recomputeInitiallyAndOnChange, rs as registerMultiEditorAction, rt as EnterOperation, ru as EDITOR_FONT_DEFAULTS, sa as minimapSelectionOccurrenceHighlight, sc as isActiveElement, si as DataUri, sl as Lazy, sn as IQuickInputService, so as themeColorFromId, sr as derived, ss as IMenuService, st as getEnterAction, su as inUntrustedWorkspace, ta as inputActiveOptionBorder, tc as getTopLeftOffset, ti as renderMarkdown, tl as lastNonWhitespaceIndex, tn as CaseSensitiveToggle, to as INotificationService, tr as observableSignal, ts as registerInstantiatedEditorAction, tt as EditorContextKeys, tu as onUnexpectedError, ua as editorErrorBorder, uc as removeCSSRulesContainingSelector, ui as dirname, ul as CompletionItemKinds, un as ModelDecorationInjectedTextOptions, uo as ILanguageFeaturesService, ur as derivedOpts, us as MenuRegistry, ut as WordOperations, uu as LinkedList, v as getOnTypeFormattingEdits, va as editorHoverBackground, vc as trackFocus, vi as FuzzyScore, vl as NewSymbolNameTag, vn as lengthAdd, vo as LineRange, vr as equalsIfDefined, vs as ContextKeyExpr, vt as CopyOptions, vu as isWeb, w as EditorStateCancellationTokenSource, wa as editorInlayHintParameterBackground, wc as DeferredPromise, wi as matchesContiguousSubString, wl as getAriaLabelForSymbol, wn as ghostTextForeground, wo as SearchParams, wr as InspectTokensNLS, ws as Action, wt as renderViewLine, wu as mixin, x as isCodeEditor, xa as editorInfoForeground, xc as matchesScheme, xi as createMatches, xl as SignatureHelpTriggerKind, xn as normalizeIndentation, xo as findLast, xr as structuralEquals, xs as CommandsRegistry, xt as DynamicCssRules, xu as localize, y as FormattingEdit, ya as editorHoverBorder, yc as hash, yi as FuzzyScoreOptions, yl as NewSymbolNameTriggerKind, yn as lengthGetColumnCountIfZeroLineCount, yo as findFirstIdxMonotonousOrArrLen, yr as itemEquals, ys as IContextKeyService, yt as InMemoryClipboardMetadataManager, yu as isWindows, z as diffDeleteDecoration, za as contrastBorder, zc as commonPrefixLength, zi as ScrollableElement, zl as Event, zn as getListStyles, zo as registerSingleton, zr as ILabelService, zs as EventType$1, zt as IconLabel, zu as equals } from "./editor.api-DPgI1LYm.js";
function devAssert(e, _) {
	if (!e) throw Error(_);
}
function isObjectLike(e) {
	return typeof e == "object" && !!e;
}
function invariant(e, _) {
	if (!e) throw Error(_ ?? "Unexpected invariant triggered.");
}
var LineRegExp = /\r\n|[\n\r]/g;
function getLocation(e, _) {
	let v = 0, y = 1;
	for (let b of e.body.matchAll(LineRegExp)) {
		if (typeof b.index == "number" || invariant(!1), b.index >= _) break;
		v = b.index + b[0].length, y += 1;
	}
	return {
		line: y,
		column: _ + 1 - v
	};
}
function printLocation(e) {
	return printSourceLocation(e.source, getLocation(e.source, e.start));
}
function printSourceLocation(e, _) {
	let v = e.locationOffset.column - 1, y = "".padStart(v) + e.body, b = _.line - 1, x = e.locationOffset.line - 1, S = _.line + x, C = _.line === 1 ? v : 0, w = _.column + C, T = `${e.name}:${S}:${w}\n`, E = y.split(/\r\n|[\n\r]/g), D = E[b];
	if (D.length > 120) {
		let e = Math.floor(w / 80), _ = w % 80, v = [];
		for (let e = 0; e < D.length; e += 80) v.push(D.slice(e, e + 80));
		return T + printPrefixedLines([
			[`${S} |`, v[0]],
			...v.slice(1, e + 1).map((e) => ["|", e]),
			["|", "^".padStart(_)],
			["|", v[e + 1]]
		]);
	}
	return T + printPrefixedLines([
		[`${S - 1} |`, E[b - 1]],
		[`${S} |`, D],
		["|", "^".padStart(w)],
		[`${S + 1} |`, E[b + 1]]
	]);
}
function printPrefixedLines(e) {
	let _ = e.filter(([e, _]) => _ !== void 0), v = Math.max(..._.map(([e]) => e.length));
	return _.map(([e, _]) => e.padStart(v) + (_ ? " " + _ : "")).join("\n");
}
function toNormalizedOptions(e) {
	let _ = e[0];
	return _ == null || "kind" in _ || "length" in _ ? {
		nodes: _,
		source: e[1],
		positions: e[2],
		path: e[3],
		originalError: e[4],
		extensions: e[5]
	} : _;
}
var GraphQLError = class e extends Error {
	constructor(_, ...v) {
		let { nodes: y, source: b, positions: x, path: S, originalError: C, extensions: w } = toNormalizedOptions(v);
		super(_), this.name = "GraphQLError", this.path = S ?? void 0, this.originalError = C ?? void 0, this.nodes = undefinedIfEmpty(Array.isArray(y) ? y : y ? [y] : void 0);
		let T = undefinedIfEmpty(this.nodes?.map((e) => e.loc).filter((e) => e != null));
		this.source = b ?? T?.[0]?.source, this.positions = x ?? T?.map((e) => e.start), this.locations = x && b ? x.map((e) => getLocation(b, e)) : T?.map((e) => getLocation(e.source, e.start));
		let E = isObjectLike(C?.extensions) ? C?.extensions : void 0;
		/* c8 ignore start */
		this.extensions = w ?? E ?? Object.create(null), Object.defineProperties(this, {
			message: {
				writable: !0,
				enumerable: !0
			},
			name: { enumerable: !1 },
			nodes: { enumerable: !1 },
			source: { enumerable: !1 },
			positions: { enumerable: !1 },
			originalError: { enumerable: !1 }
		}), C != null && C.stack ? Object.defineProperty(this, "stack", {
			value: C.stack,
			writable: !0,
			configurable: !0
		}) : Error.captureStackTrace ? Error.captureStackTrace(this, e) : Object.defineProperty(this, "stack", {
			value: Error().stack,
			writable: !0,
			configurable: !0
		});
		/* c8 ignore stop */
	}
	get [Symbol.toStringTag]() {
		return "GraphQLError";
	}
	toString() {
		let e = this.message;
		if (this.nodes) for (let _ of this.nodes) _.loc && (e += "\n\n" + printLocation(_.loc));
		else if (this.source && this.locations) for (let _ of this.locations) e += "\n\n" + printSourceLocation(this.source, _);
		return e;
	}
	toJSON() {
		let e = { message: this.message };
		return this.locations != null && (e.locations = this.locations), this.path != null && (e.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (e.extensions = this.extensions), e;
	}
};
function undefinedIfEmpty(e) {
	return e === void 0 || e.length === 0 ? void 0 : e;
}
function syntaxError(e, _, v) {
	return new GraphQLError(`Syntax Error: ${v}`, {
		source: e,
		positions: [_]
	});
}
var Location$1 = class {
	constructor(e, _, v) {
		this.start = e.start, this.end = _.end, this.startToken = e, this.endToken = _, this.source = v;
	}
	get [Symbol.toStringTag]() {
		return "Location";
	}
	toJSON() {
		return {
			start: this.start,
			end: this.end
		};
	}
}, Token = class {
	constructor(e, _, v, y, b, x) {
		this.kind = e, this.start = _, this.end = v, this.line = y, this.column = b, this.value = x, this.prev = null, this.next = null;
	}
	get [Symbol.toStringTag]() {
		return "Token";
	}
	toJSON() {
		return {
			kind: this.kind,
			value: this.value,
			line: this.line,
			column: this.column
		};
	}
};
const QueryDocumentKeys = {
	Name: [],
	Document: ["definitions"],
	OperationDefinition: [
		"description",
		"name",
		"variableDefinitions",
		"directives",
		"selectionSet"
	],
	VariableDefinition: [
		"description",
		"variable",
		"type",
		"defaultValue",
		"directives"
	],
	Variable: ["name"],
	SelectionSet: ["selections"],
	Field: [
		"alias",
		"name",
		"arguments",
		"directives",
		"selectionSet"
	],
	Argument: ["name", "value"],
	FragmentSpread: ["name", "directives"],
	InlineFragment: [
		"typeCondition",
		"directives",
		"selectionSet"
	],
	FragmentDefinition: [
		"description",
		"name",
		"variableDefinitions",
		"typeCondition",
		"directives",
		"selectionSet"
	],
	IntValue: [],
	FloatValue: [],
	StringValue: [],
	BooleanValue: [],
	NullValue: [],
	EnumValue: [],
	ListValue: ["values"],
	ObjectValue: ["fields"],
	ObjectField: ["name", "value"],
	Directive: ["name", "arguments"],
	NamedType: ["name"],
	ListType: ["type"],
	NonNullType: ["type"],
	SchemaDefinition: [
		"description",
		"directives",
		"operationTypes"
	],
	OperationTypeDefinition: ["type"],
	ScalarTypeDefinition: [
		"description",
		"name",
		"directives"
	],
	ObjectTypeDefinition: [
		"description",
		"name",
		"interfaces",
		"directives",
		"fields"
	],
	FieldDefinition: [
		"description",
		"name",
		"arguments",
		"type",
		"directives"
	],
	InputValueDefinition: [
		"description",
		"name",
		"type",
		"defaultValue",
		"directives"
	],
	InterfaceTypeDefinition: [
		"description",
		"name",
		"interfaces",
		"directives",
		"fields"
	],
	UnionTypeDefinition: [
		"description",
		"name",
		"directives",
		"types"
	],
	EnumTypeDefinition: [
		"description",
		"name",
		"directives",
		"values"
	],
	EnumValueDefinition: [
		"description",
		"name",
		"directives"
	],
	InputObjectTypeDefinition: [
		"description",
		"name",
		"directives",
		"fields"
	],
	DirectiveDefinition: [
		"description",
		"name",
		"arguments",
		"directives",
		"locations"
	],
	SchemaExtension: ["directives", "operationTypes"],
	DirectiveExtension: ["name", "directives"],
	ScalarTypeExtension: ["name", "directives"],
	ObjectTypeExtension: [
		"name",
		"interfaces",
		"directives",
		"fields"
	],
	InterfaceTypeExtension: [
		"name",
		"interfaces",
		"directives",
		"fields"
	],
	UnionTypeExtension: [
		"name",
		"directives",
		"types"
	],
	EnumTypeExtension: [
		"name",
		"directives",
		"values"
	],
	InputObjectTypeExtension: [
		"name",
		"directives",
		"fields"
	],
	TypeCoordinate: ["name"],
	MemberCoordinate: ["name", "memberName"],
	ArgumentCoordinate: [
		"name",
		"fieldName",
		"argumentName"
	],
	DirectiveCoordinate: ["name"],
	DirectiveArgumentCoordinate: ["name", "argumentName"]
};
var kindValues = new Set(Object.keys(QueryDocumentKeys));
function isNode(e) {
	let _ = e?.kind;
	return typeof _ == "string" && kindValues.has(_);
}
var OperationTypeNode;
(function(e) {
	e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
})(OperationTypeNode ||= {});
var DirectiveLocation;
(function(e) {
	e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION", e.DIRECTIVE_DEFINITION = "DIRECTIVE_DEFINITION";
})(DirectiveLocation ||= {});
var Kind;
(function(e) {
	e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.DIRECTIVE_EXTENSION = "DirectiveExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension", e.TYPE_COORDINATE = "TypeCoordinate", e.MEMBER_COORDINATE = "MemberCoordinate", e.ARGUMENT_COORDINATE = "ArgumentCoordinate", e.DIRECTIVE_COORDINATE = "DirectiveCoordinate", e.DIRECTIVE_ARGUMENT_COORDINATE = "DirectiveArgumentCoordinate";
})(Kind ||= {});
function isWhiteSpace(e) {
	return e === 9 || e === 32;
}
function isDigit$1(e) {
	return e >= 48 && e <= 57;
}
function isLetter(e) {
	return e >= 97 && e <= 122 || e >= 65 && e <= 90;
}
function isNameStart(e) {
	return isLetter(e) || e === 95;
}
function isNameContinue(e) {
	return isLetter(e) || isDigit$1(e) || e === 95;
}
function dedentBlockStringLines(e) {
	let _ = 2 ** 53 - 1, v = null, y = -1;
	for (let b = 0; b < e.length; ++b) {
		let x = e[b], S = leadingWhitespace(x);
		S !== x.length && (v ??= b, y = b, b !== 0 && S < _ && (_ = S));
	}
	return e.map((e, v) => v === 0 ? e : e.slice(_)).slice(v ?? 0, y + 1);
}
function leadingWhitespace(e) {
	let _ = 0;
	for (; _ < e.length && isWhiteSpace(e.charCodeAt(_));) ++_;
	return _;
}
function isPrintableAsBlockString(e) {
	if (e === "") return !0;
	let _ = !0, v = !1, y = !0, b = !1;
	for (let x = 0; x < e.length; ++x) switch (e.codePointAt(x)) {
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
		case 8:
		case 11:
		case 12:
		case 14:
		case 15: return !1;
		case 13: return !1;
		case 10:
			if (_ && !b) return !1;
			b = !0, _ = !0, v = !1;
			break;
		case 9:
		case 32:
			v ||= _;
			break;
		default: y &&= v, _ = !1;
	}
	return !(_ || y && b);
}
function printBlockString(e, _) {
	let v = e.replace(/"""/g, "\\\"\"\""), y = v.split(/\r\n|[\n\r]/g), b = y.length === 1, x = y.length > 1 && y.slice(1).every((e) => e.length === 0 || isWhiteSpace(e.charCodeAt(0))), S = v.endsWith("\\\"\"\""), C = e.endsWith("\"") && !S, w = e.endsWith("\\"), T = C || w, E = !(_ != null && _.minimize) && (!b || e.length > 70 || T || x || S), D = "", O = b && isWhiteSpace(e.charCodeAt(0));
	return (E && !O || x) && (D += "\n"), D += v, (E || T) && (D += "\n"), "\"\"\"" + D + "\"\"\"";
}
var TokenKind;
(function(e) {
	e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.DOT = ".", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
})(TokenKind ||= {});
var Lexer = class {
	constructor(e) {
		let _ = new Token(TokenKind.SOF, 0, 0, 0, 0);
		this.source = e, this.lastToken = _, this.token = _, this.line = 1, this.lineStart = 0;
	}
	get [Symbol.toStringTag]() {
		return "Lexer";
	}
	advance() {
		return this.lastToken = this.token, this.token = this.lookahead();
	}
	lookahead() {
		let e = this.token;
		if (e.kind !== TokenKind.EOF) do
			if (e.next) e = e.next;
			else {
				let _ = readNextToken(this, e.end);
				e.next = _, _.prev = e, e = _;
			}
		while (e.kind === TokenKind.COMMENT);
		return e;
	}
};
function isPunctuatorTokenKind(e) {
	return e === TokenKind.BANG || e === TokenKind.DOLLAR || e === TokenKind.AMP || e === TokenKind.PAREN_L || e === TokenKind.PAREN_R || e === TokenKind.DOT || e === TokenKind.SPREAD || e === TokenKind.COLON || e === TokenKind.EQUALS || e === TokenKind.AT || e === TokenKind.BRACKET_L || e === TokenKind.BRACKET_R || e === TokenKind.BRACE_L || e === TokenKind.PIPE || e === TokenKind.BRACE_R;
}
function isUnicodeScalarValue(e) {
	return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
}
function isSupplementaryCodePoint(e, _) {
	return isLeadingSurrogate(e.charCodeAt(_)) && isTrailingSurrogate(e.charCodeAt(_ + 1));
}
function isLeadingSurrogate(e) {
	return e >= 55296 && e <= 56319;
}
function isTrailingSurrogate(e) {
	return e >= 56320 && e <= 57343;
}
function printCodePointAt(e, _) {
	let v = e.source.body.codePointAt(_);
	if (v === void 0) return TokenKind.EOF;
	if (v >= 32 && v <= 126) {
		let e = String.fromCodePoint(v);
		return e === "\"" ? "'\"'" : `"${e}"`;
	}
	return "U+" + v.toString(16).toUpperCase().padStart(4, "0");
}
function createToken(e, _, v, y, b) {
	let x = e.line, S = 1 + v - e.lineStart;
	return new Token(_, v, y, x, S, b);
}
function readNextToken(e, _) {
	let v = e.source.body, y = v.length, b = _;
	for (; b < y;) {
		let _ = v.charCodeAt(b);
		switch (_) {
			case 65279:
			case 9:
			case 32:
			case 44:
				++b;
				continue;
			case 10:
				++b, ++e.line, e.lineStart = b;
				continue;
			case 13:
				v.charCodeAt(b + 1) === 10 ? b += 2 : ++b, ++e.line, e.lineStart = b;
				continue;
			case 35: return readComment(e, b);
			case 33: return createToken(e, TokenKind.BANG, b, b + 1);
			case 36: return createToken(e, TokenKind.DOLLAR, b, b + 1);
			case 38: return createToken(e, TokenKind.AMP, b, b + 1);
			case 40: return createToken(e, TokenKind.PAREN_L, b, b + 1);
			case 41: return createToken(e, TokenKind.PAREN_R, b, b + 1);
			case 46:
				if (v.charCodeAt(b + 1) === 46 && v.charCodeAt(b + 2) === 46) return createToken(e, TokenKind.SPREAD, b, b + 3);
				break;
			case 58: return createToken(e, TokenKind.COLON, b, b + 1);
			case 61: return createToken(e, TokenKind.EQUALS, b, b + 1);
			case 64: return createToken(e, TokenKind.AT, b, b + 1);
			case 91: return createToken(e, TokenKind.BRACKET_L, b, b + 1);
			case 93: return createToken(e, TokenKind.BRACKET_R, b, b + 1);
			case 123: return createToken(e, TokenKind.BRACE_L, b, b + 1);
			case 124: return createToken(e, TokenKind.PIPE, b, b + 1);
			case 125: return createToken(e, TokenKind.BRACE_R, b, b + 1);
			case 34: return v.charCodeAt(b + 1) === 34 && v.charCodeAt(b + 2) === 34 ? readBlockString(e, b) : readString(e, b);
		}
		if (isDigit$1(_) || _ === 45) return readNumber(e, b, _);
		if (isNameStart(_)) return readName(e, b);
		throw syntaxError(e.source, b, _ === 39 ? "Unexpected single quote character ('), did you mean to use a double quote (\")?" : isUnicodeScalarValue(_) || isSupplementaryCodePoint(v, b) ? `Unexpected character: ${printCodePointAt(e, b)}.` : `Invalid character: ${printCodePointAt(e, b)}.`);
	}
	return createToken(e, TokenKind.EOF, y, y);
}
function readComment(e, _) {
	let v = e.source.body, y = v.length, b = _ + 1;
	for (; b < y;) {
		let e = v.charCodeAt(b);
		if (e === 10 || e === 13) break;
		if (isUnicodeScalarValue(e)) ++b;
		else if (isSupplementaryCodePoint(v, b)) b += 2;
		else break;
	}
	return createToken(e, TokenKind.COMMENT, _, b, v.slice(_ + 1, b));
}
function readNumber(e, _, v) {
	let y = e.source.body, b = _, x = v, S = !1;
	if (x === 45 && (x = y.charCodeAt(++b)), x === 48) {
		if (x = y.charCodeAt(++b), isDigit$1(x)) throw syntaxError(e.source, b, `Invalid number, unexpected digit after 0: ${printCodePointAt(e, b)}.`);
	} else b = readDigits(e, b, x), x = y.charCodeAt(b);
	if (x === 46 && (S = !0, x = y.charCodeAt(++b), b = readDigits(e, b, x), x = y.charCodeAt(b)), (x === 69 || x === 101) && (S = !0, x = y.charCodeAt(++b), (x === 43 || x === 45) && (x = y.charCodeAt(++b)), b = readDigits(e, b, x), x = y.charCodeAt(b)), x === 46 || isNameStart(x)) throw syntaxError(e.source, b, `Invalid number, expected digit but got: ${printCodePointAt(e, b)}.`);
	return createToken(e, S ? TokenKind.FLOAT : TokenKind.INT, _, b, y.slice(_, b));
}
function readDigits(e, _, v) {
	if (!isDigit$1(v)) throw syntaxError(e.source, _, `Invalid number, expected digit but got: ${printCodePointAt(e, _)}.`);
	let y = e.source.body, b = _ + 1;
	for (; isDigit$1(y.charCodeAt(b));) ++b;
	return b;
}
function readString(e, _) {
	let v = e.source.body, y = v.length, b = _ + 1, x = b, S = "";
	for (; b < y;) {
		let y = v.charCodeAt(b);
		if (y === 34) return S += v.slice(x, b), createToken(e, TokenKind.STRING, _, b + 1, S);
		if (y === 92) {
			S += v.slice(x, b);
			let _ = v.charCodeAt(b + 1) === 117 ? v.charCodeAt(b + 2) === 123 ? readEscapedUnicodeVariableWidth(e, b) : readEscapedUnicodeFixedWidth(e, b) : readEscapedCharacter(e, b);
			S += _.value, b += _.size, x = b;
			continue;
		}
		if (y === 10 || y === 13) break;
		if (isUnicodeScalarValue(y)) ++b;
		else if (isSupplementaryCodePoint(v, b)) b += 2;
		else throw syntaxError(e.source, b, `Invalid character within String: ${printCodePointAt(e, b)}.`);
	}
	throw syntaxError(e.source, b, "Unterminated string.");
}
function readEscapedUnicodeVariableWidth(e, _) {
	let v = e.source.body, y = 0, b = 3;
	for (; b < 12;) {
		let e = v.charCodeAt(_ + b++);
		if (e === 125) {
			if (b < 5 || !isUnicodeScalarValue(y)) break;
			return {
				value: String.fromCodePoint(y),
				size: b
			};
		}
		if (y = y << 4 | readHexDigit(e), y < 0) break;
	}
	throw syntaxError(e.source, _, `Invalid Unicode escape sequence: "${v.slice(_, _ + b)}".`);
}
function readEscapedUnicodeFixedWidth(e, _) {
	let v = e.source.body, y = read16BitHexCode(v, _ + 2);
	if (isUnicodeScalarValue(y)) return {
		value: String.fromCodePoint(y),
		size: 6
	};
	if (isLeadingSurrogate(y) && v.charCodeAt(_ + 6) === 92 && v.charCodeAt(_ + 7) === 117) {
		let e = read16BitHexCode(v, _ + 8);
		if (isTrailingSurrogate(e)) return {
			value: String.fromCodePoint(y, e),
			size: 12
		};
	}
	throw syntaxError(e.source, _, `Invalid Unicode escape sequence: "${v.slice(_, _ + 6)}".`);
}
function read16BitHexCode(e, _) {
	return readHexDigit(e.charCodeAt(_)) << 12 | readHexDigit(e.charCodeAt(_ + 1)) << 8 | readHexDigit(e.charCodeAt(_ + 2)) << 4 | readHexDigit(e.charCodeAt(_ + 3));
}
function readHexDigit(e) {
	return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
}
function readEscapedCharacter(e, _) {
	let v = e.source.body;
	switch (v.charCodeAt(_ + 1)) {
		case 34: return {
			value: "\"",
			size: 2
		};
		case 92: return {
			value: "\\",
			size: 2
		};
		case 47: return {
			value: "/",
			size: 2
		};
		case 98: return {
			value: "\b",
			size: 2
		};
		case 102: return {
			value: "\f",
			size: 2
		};
		case 110: return {
			value: "\n",
			size: 2
		};
		case 114: return {
			value: "\r",
			size: 2
		};
		case 116: return {
			value: "	",
			size: 2
		};
	}
	throw syntaxError(e.source, _, `Invalid character escape sequence: "${v.slice(_, _ + 2)}".`);
}
function readBlockString(e, _) {
	let v = e.source.body, y = v.length, b = e.lineStart, x = _ + 3, S = x, C = "", w = [];
	for (; x < y;) {
		let y = v.charCodeAt(x);
		if (y === 34 && v.charCodeAt(x + 1) === 34 && v.charCodeAt(x + 2) === 34) {
			C += v.slice(S, x), w.push(C);
			let y = createToken(e, TokenKind.BLOCK_STRING, _, x + 3, dedentBlockStringLines(w).join("\n"));
			return e.line += w.length - 1, e.lineStart = b, y;
		}
		if (y === 92 && v.charCodeAt(x + 1) === 34 && v.charCodeAt(x + 2) === 34 && v.charCodeAt(x + 3) === 34) {
			C += v.slice(S, x), S = x + 1, x += 4;
			continue;
		}
		if (y === 10 || y === 13) {
			C += v.slice(S, x), w.push(C), y === 13 && v.charCodeAt(x + 1) === 10 ? x += 2 : ++x, C = "", S = x, b = x;
			continue;
		}
		if (isUnicodeScalarValue(y)) ++x;
		else if (isSupplementaryCodePoint(v, x)) x += 2;
		else throw syntaxError(e.source, x, `Invalid character within String: ${printCodePointAt(e, x)}.`);
	}
	throw syntaxError(e.source, x, "Unterminated string.");
}
function readName(e, _) {
	let v = e.source.body, y = v.length, b = _ + 1;
	for (; b < y;) {
		let e = v.charCodeAt(b);
		if (isNameContinue(e)) ++b;
		else break;
	}
	return createToken(e, TokenKind.NAME, _, b, v.slice(_, b));
}
var MAX_ARRAY_LENGTH = 10, MAX_RECURSIVE_DEPTH = 2;
function inspect(e) {
	return formatValue(e, []);
}
function formatValue(e, _) {
	switch (typeof e) {
		case "string": return JSON.stringify(e);
		case "function": return e.name ? `[function ${e.name}]` : "[function]";
		case "object": return formatObjectValue(e, _);
		default: return String(e);
	}
}
function formatObjectValue(e, _) {
	if (e === null) return "null";
	if (_.includes(e)) return "[Circular]";
	let v = [..._, e];
	if (isJSONable(e)) {
		let _ = e.toJSON();
		if (_ !== e) return typeof _ == "string" ? _ : formatValue(_, v);
	} else if (Array.isArray(e)) return formatArray(e, v);
	return formatObject(e, v);
}
function isJSONable(e) {
	return typeof e.toJSON == "function";
}
function formatObject(e, _) {
	let v = Object.entries(e);
	return v.length === 0 ? "{}" : _.length > MAX_RECURSIVE_DEPTH ? "[" + getObjectTag(e) + "]" : "{ " + v.map(([e, v]) => e + ": " + formatValue(v, _)).join(", ") + " }";
}
function formatArray(e, _) {
	if (e.length === 0) return "[]";
	if (_.length > MAX_RECURSIVE_DEPTH) return "[Array]";
	let v = Math.min(MAX_ARRAY_LENGTH, e.length), y = e.length - v, b = [];
	for (let y = 0; y < v; ++y) b.push(formatValue(e[y], _));
	return y === 1 ? b.push("... 1 more item") : y > 1 && b.push(`... ${y} more items`), "[" + b.join(", ") + "]";
}
function getObjectTag(e) {
	let _ = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
	if (_ === "Object" && typeof e.constructor == "function") {
		let _ = e.constructor.name;
		if (typeof _ == "string" && _ !== "") return _;
	}
	return _;
}
const instanceOf = globalThis.process && process.env.NODE_ENV === "production" ? function(e, _) {
	return e instanceof _;
} : function(e, _) {
	if (e instanceof _) return !0;
	if (typeof e == "object" && e) {
		let v = _.prototype[Symbol.toStringTag], y = Symbol.toStringTag in e ? e[Symbol.toStringTag] : e.constructor?.name;
		if (v === y) {
			let _ = inspect(e);
			throw Error(`Cannot use ${v} "${_}" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.`);
		}
	}
	return !1;
};
var Source = class {
	constructor(e, _ = "GraphQL request", v = {
		line: 1,
		column: 1
	}) {
		typeof e == "string" || devAssert(!1, `Body must be a string. Received: ${inspect(e)}.`), this.body = e, this.name = _, this.locationOffset = v, this.locationOffset.line > 0 || devAssert(!1, "line in locationOffset is 1-indexed and must be positive."), this.locationOffset.column > 0 || devAssert(!1, "column in locationOffset is 1-indexed and must be positive.");
	}
	get [Symbol.toStringTag]() {
		return "Source";
	}
};
function isSource(e) {
	return instanceOf(e, Source);
}
function parse(e, _) {
	let v = new Parser(e, _), y = v.parseDocument();
	return Object.defineProperty(y, "tokenCount", {
		enumerable: !1,
		value: v.tokenCount
	}), y;
}
function parseValue(e, _) {
	let v = new Parser(e, _);
	v.expectToken(TokenKind.SOF);
	let y = v.parseValueLiteral(!1);
	return v.expectToken(TokenKind.EOF), y;
}
var Parser = class {
	constructor(e, _ = {}) {
		let { lexer: v,...y } = _;
		if (v) this._lexer = v;
		else {
			let _ = isSource(e) ? e : new Source(e);
			this._lexer = new Lexer(_);
		}
		this._options = y, this._tokenCounter = 0;
	}
	get tokenCount() {
		return this._tokenCounter;
	}
	parseName() {
		let e = this.expectToken(TokenKind.NAME);
		return this.node(e, {
			kind: Kind.NAME,
			value: e.value
		});
	}
	parseDocument() {
		return this.node(this._lexer.token, {
			kind: Kind.DOCUMENT,
			definitions: this.many(TokenKind.SOF, this.parseDefinition, TokenKind.EOF)
		});
	}
	parseDefinition() {
		if (this.peek(TokenKind.BRACE_L)) return this.parseOperationDefinition();
		let e = this.peekDescription(), _ = e ? this._lexer.lookahead() : this._lexer.token;
		if (e && _.kind === TokenKind.BRACE_L) throw syntaxError(this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries.");
		if (_.kind === TokenKind.NAME) {
			switch (_.value) {
				case "schema": return this.parseSchemaDefinition();
				case "scalar": return this.parseScalarTypeDefinition();
				case "type": return this.parseObjectTypeDefinition();
				case "interface": return this.parseInterfaceTypeDefinition();
				case "union": return this.parseUnionTypeDefinition();
				case "enum": return this.parseEnumTypeDefinition();
				case "input": return this.parseInputObjectTypeDefinition();
				case "directive": return this.parseDirectiveDefinition();
			}
			switch (_.value) {
				case "query":
				case "mutation":
				case "subscription": return this.parseOperationDefinition();
				case "fragment": return this.parseFragmentDefinition();
			}
			if (e) throw syntaxError(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions.");
			switch (_.value) {
				case "extend": return this.parseTypeSystemExtension();
			}
		}
		throw this.unexpected(_);
	}
	parseOperationDefinition() {
		let e = this._lexer.token;
		if (this.peek(TokenKind.BRACE_L)) return this.node(e, {
			kind: Kind.OPERATION_DEFINITION,
			operation: OperationTypeNode.QUERY,
			description: void 0,
			name: void 0,
			variableDefinitions: [],
			directives: [],
			selectionSet: this.parseSelectionSet()
		});
		let _ = this.parseDescription(), v = this.parseOperationType(), y;
		return this.peek(TokenKind.NAME) && (y = this.parseName()), this.node(e, {
			kind: Kind.OPERATION_DEFINITION,
			operation: v,
			description: _,
			name: y,
			variableDefinitions: this.parseVariableDefinitions(),
			directives: this.parseDirectives(!1),
			selectionSet: this.parseSelectionSet()
		});
	}
	parseOperationType() {
		let e = this.expectToken(TokenKind.NAME);
		switch (e.value) {
			case "query": return OperationTypeNode.QUERY;
			case "mutation": return OperationTypeNode.MUTATION;
			case "subscription": return OperationTypeNode.SUBSCRIPTION;
		}
		throw this.unexpected(e);
	}
	parseVariableDefinitions() {
		return this.optionalMany(TokenKind.PAREN_L, this.parseVariableDefinition, TokenKind.PAREN_R);
	}
	parseVariableDefinition() {
		return this.node(this._lexer.token, {
			kind: Kind.VARIABLE_DEFINITION,
			description: this.parseDescription(),
			variable: this.parseVariable(),
			type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
			defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
			directives: this.parseConstDirectives()
		});
	}
	parseVariable() {
		let e = this._lexer.token;
		return this.expectToken(TokenKind.DOLLAR), this.node(e, {
			kind: Kind.VARIABLE,
			name: this.parseName()
		});
	}
	parseSelectionSet() {
		return this.node(this._lexer.token, {
			kind: Kind.SELECTION_SET,
			selections: this.many(TokenKind.BRACE_L, this.parseSelection, TokenKind.BRACE_R)
		});
	}
	parseSelection() {
		return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
	}
	parseField() {
		let e = this._lexer.token, _ = this.parseName(), v, y;
		return this.expectOptionalToken(TokenKind.COLON) ? (v = _, y = this.parseName()) : y = _, this.node(e, {
			kind: Kind.FIELD,
			alias: v,
			name: y,
			arguments: this.parseArguments(!1),
			directives: this.parseDirectives(!1),
			selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
		});
	}
	parseArguments(e) {
		let _ = e ? this.parseConstArgument : this.parseArgument;
		return this.optionalMany(TokenKind.PAREN_L, _, TokenKind.PAREN_R);
	}
	parseArgument(e = !1) {
		let _ = this._lexer.token, v = this.parseName();
		return this.expectToken(TokenKind.COLON), this.node(_, {
			kind: Kind.ARGUMENT,
			name: v,
			value: this.parseValueLiteral(e)
		});
	}
	parseConstArgument() {
		return this.parseArgument(!0);
	}
	parseFragment() {
		let e = this._lexer.token;
		this.expectToken(TokenKind.SPREAD);
		let _ = this.expectOptionalKeyword("on");
		return !_ && this.peek(TokenKind.NAME) ? this.node(e, {
			kind: Kind.FRAGMENT_SPREAD,
			name: this.parseFragmentName(),
			directives: this.parseDirectives(!1)
		}) : this.node(e, {
			kind: Kind.INLINE_FRAGMENT,
			typeCondition: _ ? this.parseNamedType() : void 0,
			directives: this.parseDirectives(!1),
			selectionSet: this.parseSelectionSet()
		});
	}
	parseFragmentDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(e, {
			kind: Kind.FRAGMENT_DEFINITION,
			description: _,
			name: this.parseFragmentName(),
			variableDefinitions: this.parseVariableDefinitions(),
			typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
			directives: this.parseDirectives(!1),
			selectionSet: this.parseSelectionSet()
		}) : this.node(e, {
			kind: Kind.FRAGMENT_DEFINITION,
			description: _,
			name: this.parseFragmentName(),
			typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
			directives: this.parseDirectives(!1),
			selectionSet: this.parseSelectionSet()
		});
	}
	parseFragmentName() {
		if (this._lexer.token.value === "on") throw this.unexpected();
		return this.parseName();
	}
	parseValueLiteral(e) {
		let _ = this._lexer.token;
		switch (_.kind) {
			case TokenKind.BRACKET_L: return this.parseList(e);
			case TokenKind.BRACE_L: return this.parseObject(e);
			case TokenKind.INT: return this.advanceLexer(), this.node(_, {
				kind: Kind.INT,
				value: _.value
			});
			case TokenKind.FLOAT: return this.advanceLexer(), this.node(_, {
				kind: Kind.FLOAT,
				value: _.value
			});
			case TokenKind.STRING:
			case TokenKind.BLOCK_STRING: return this.parseStringLiteral();
			case TokenKind.NAME: switch (this.advanceLexer(), _.value) {
				case "true": return this.node(_, {
					kind: Kind.BOOLEAN,
					value: !0
				});
				case "false": return this.node(_, {
					kind: Kind.BOOLEAN,
					value: !1
				});
				case "null": return this.node(_, { kind: Kind.NULL });
				default: return this.node(_, {
					kind: Kind.ENUM,
					value: _.value
				});
			}
			case TokenKind.DOLLAR:
				if (e) if (this.expectToken(TokenKind.DOLLAR), this._lexer.token.kind === TokenKind.NAME) {
					let e = this._lexer.token.value;
					throw syntaxError(this._lexer.source, _.start, `Unexpected variable "$${e}" in constant value.`);
				} else throw this.unexpected(_);
				return this.parseVariable();
			default: throw this.unexpected();
		}
	}
	parseConstValueLiteral() {
		return this.parseValueLiteral(!0);
	}
	parseStringLiteral() {
		let e = this._lexer.token;
		return this.advanceLexer(), this.node(e, {
			kind: Kind.STRING,
			value: e.value,
			block: e.kind === TokenKind.BLOCK_STRING
		});
	}
	parseList(e) {
		return this.node(this._lexer.token, {
			kind: Kind.LIST,
			values: this.any(TokenKind.BRACKET_L, () => this.parseValueLiteral(e), TokenKind.BRACKET_R)
		});
	}
	parseObject(e) {
		return this.node(this._lexer.token, {
			kind: Kind.OBJECT,
			fields: this.any(TokenKind.BRACE_L, () => this.parseObjectField(e), TokenKind.BRACE_R)
		});
	}
	parseObjectField(e) {
		let _ = this._lexer.token, v = this.parseName();
		return this.expectToken(TokenKind.COLON), this.node(_, {
			kind: Kind.OBJECT_FIELD,
			name: v,
			value: this.parseValueLiteral(e)
		});
	}
	parseDirectives(e) {
		let _ = [];
		for (; this.peek(TokenKind.AT);) _.push(this.parseDirective(e));
		return _;
	}
	parseConstDirectives() {
		return this.parseDirectives(!0);
	}
	parseDirective(e) {
		let _ = this._lexer.token;
		return this.expectToken(TokenKind.AT), this.node(_, {
			kind: Kind.DIRECTIVE,
			name: this.parseName(),
			arguments: this.parseArguments(e)
		});
	}
	parseTypeReference() {
		let e = this._lexer.token, _;
		if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
			let v = this.parseTypeReference();
			this.expectToken(TokenKind.BRACKET_R), _ = this.node(e, {
				kind: Kind.LIST_TYPE,
				type: v
			});
		} else _ = this.parseNamedType();
		return this.expectOptionalToken(TokenKind.BANG) ? this.node(e, {
			kind: Kind.NON_NULL_TYPE,
			type: _
		}) : _;
	}
	parseNamedType() {
		return this.node(this._lexer.token, {
			kind: Kind.NAMED_TYPE,
			name: this.parseName()
		});
	}
	peekDescription() {
		return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
	}
	parseDescription() {
		if (this.peekDescription()) return this.parseStringLiteral();
	}
	parseSchemaDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("schema");
		let v = this.parseConstDirectives(), y = this.many(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
		return this.node(e, {
			kind: Kind.SCHEMA_DEFINITION,
			description: _,
			directives: v,
			operationTypes: y
		});
	}
	parseOperationTypeDefinition() {
		let e = this._lexer.token, _ = this.parseOperationType();
		this.expectToken(TokenKind.COLON);
		let v = this.parseNamedType();
		return this.node(e, {
			kind: Kind.OPERATION_TYPE_DEFINITION,
			operation: _,
			type: v
		});
	}
	parseScalarTypeDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("scalar");
		let v = this.parseName(), y = this.parseConstDirectives();
		return this.node(e, {
			kind: Kind.SCALAR_TYPE_DEFINITION,
			description: _,
			name: v,
			directives: y
		});
	}
	parseObjectTypeDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("type");
		let v = this.parseName(), y = this.parseImplementsInterfaces(), b = this.parseConstDirectives(), x = this.parseFieldsDefinition();
		return this.node(e, {
			kind: Kind.OBJECT_TYPE_DEFINITION,
			description: _,
			name: v,
			interfaces: y,
			directives: b,
			fields: x
		});
	}
	parseImplementsInterfaces() {
		return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
	}
	parseFieldsDefinition() {
		return this.optionalMany(TokenKind.BRACE_L, this.parseFieldDefinition, TokenKind.BRACE_R);
	}
	parseFieldDefinition() {
		let e = this._lexer.token, _ = this.parseDescription(), v = this.parseName(), y = this.parseArgumentDefs();
		this.expectToken(TokenKind.COLON);
		let b = this.parseTypeReference(), x = this.parseConstDirectives();
		return this.node(e, {
			kind: Kind.FIELD_DEFINITION,
			description: _,
			name: v,
			arguments: y,
			type: b,
			directives: x
		});
	}
	parseArgumentDefs() {
		return this.optionalMany(TokenKind.PAREN_L, this.parseInputValueDef, TokenKind.PAREN_R);
	}
	parseInputValueDef() {
		let e = this._lexer.token, _ = this.parseDescription(), v = this.parseName();
		this.expectToken(TokenKind.COLON);
		let y = this.parseTypeReference(), b;
		this.expectOptionalToken(TokenKind.EQUALS) && (b = this.parseConstValueLiteral());
		let x = this.parseConstDirectives();
		return this.node(e, {
			kind: Kind.INPUT_VALUE_DEFINITION,
			description: _,
			name: v,
			type: y,
			defaultValue: b,
			directives: x
		});
	}
	parseInterfaceTypeDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("interface");
		let v = this.parseName(), y = this.parseImplementsInterfaces(), b = this.parseConstDirectives(), x = this.parseFieldsDefinition();
		return this.node(e, {
			kind: Kind.INTERFACE_TYPE_DEFINITION,
			description: _,
			name: v,
			interfaces: y,
			directives: b,
			fields: x
		});
	}
	parseUnionTypeDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("union");
		let v = this.parseName(), y = this.parseConstDirectives(), b = this.parseUnionMemberTypes();
		return this.node(e, {
			kind: Kind.UNION_TYPE_DEFINITION,
			description: _,
			name: v,
			directives: y,
			types: b
		});
	}
	parseUnionMemberTypes() {
		return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
	}
	parseEnumTypeDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("enum");
		let v = this.parseName(), y = this.parseConstDirectives(), b = this.parseEnumValuesDefinition();
		return this.node(e, {
			kind: Kind.ENUM_TYPE_DEFINITION,
			description: _,
			name: v,
			directives: y,
			values: b
		});
	}
	parseEnumValuesDefinition() {
		return this.optionalMany(TokenKind.BRACE_L, this.parseEnumValueDefinition, TokenKind.BRACE_R);
	}
	parseEnumValueDefinition() {
		let e = this._lexer.token, _ = this.parseDescription(), v = this.parseEnumValueName(), y = this.parseConstDirectives();
		return this.node(e, {
			kind: Kind.ENUM_VALUE_DEFINITION,
			description: _,
			name: v,
			directives: y
		});
	}
	parseEnumValueName() {
		if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw syntaxError(this._lexer.source, this._lexer.token.start, `${getTokenDesc(this._lexer.token)} is reserved and cannot be used for an enum value.`);
		return this.parseName();
	}
	parseInputObjectTypeDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("input");
		let v = this.parseName(), y = this.parseConstDirectives(), b = this.parseInputFieldsDefinition();
		return this.node(e, {
			kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
			description: _,
			name: v,
			directives: y,
			fields: b
		});
	}
	parseInputFieldsDefinition() {
		return this.optionalMany(TokenKind.BRACE_L, this.parseInputValueDef, TokenKind.BRACE_R);
	}
	parseTypeSystemExtension() {
		let e = this._lexer.lookahead();
		if (e.kind === TokenKind.NAME) switch (e.value) {
			case "schema": return this.parseSchemaExtension();
			case "scalar": return this.parseScalarTypeExtension();
			case "type": return this.parseObjectTypeExtension();
			case "interface": return this.parseInterfaceTypeExtension();
			case "union": return this.parseUnionTypeExtension();
			case "enum": return this.parseEnumTypeExtension();
			case "input": return this.parseInputObjectTypeExtension();
			case "directive":
				if (this._options.experimentalDirectivesOnDirectiveDefinitions) return this.parseDirectiveDefinitionExtension();
				break;
		}
		throw this.unexpected(e);
	}
	parseSchemaExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("schema");
		let _ = this.parseConstDirectives(), v = this.optionalMany(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
		if (_.length === 0 && v.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.SCHEMA_EXTENSION,
			directives: _,
			operationTypes: v
		});
	}
	parseScalarTypeExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("scalar");
		let _ = this.parseName(), v = this.parseConstDirectives();
		if (v.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.SCALAR_TYPE_EXTENSION,
			name: _,
			directives: v
		});
	}
	parseObjectTypeExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("type");
		let _ = this.parseName(), v = this.parseImplementsInterfaces(), y = this.parseConstDirectives(), b = this.parseFieldsDefinition();
		if (v.length === 0 && y.length === 0 && b.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.OBJECT_TYPE_EXTENSION,
			name: _,
			interfaces: v,
			directives: y,
			fields: b
		});
	}
	parseInterfaceTypeExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("interface");
		let _ = this.parseName(), v = this.parseImplementsInterfaces(), y = this.parseConstDirectives(), b = this.parseFieldsDefinition();
		if (v.length === 0 && y.length === 0 && b.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.INTERFACE_TYPE_EXTENSION,
			name: _,
			interfaces: v,
			directives: y,
			fields: b
		});
	}
	parseUnionTypeExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("union");
		let _ = this.parseName(), v = this.parseConstDirectives(), y = this.parseUnionMemberTypes();
		if (v.length === 0 && y.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.UNION_TYPE_EXTENSION,
			name: _,
			directives: v,
			types: y
		});
	}
	parseEnumTypeExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("enum");
		let _ = this.parseName(), v = this.parseConstDirectives(), y = this.parseEnumValuesDefinition();
		if (v.length === 0 && y.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.ENUM_TYPE_EXTENSION,
			name: _,
			directives: v,
			values: y
		});
	}
	parseInputObjectTypeExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("input");
		let _ = this.parseName(), v = this.parseConstDirectives(), y = this.parseInputFieldsDefinition();
		if (v.length === 0 && y.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
			name: _,
			directives: v,
			fields: y
		});
	}
	parseDirectiveDefinitionExtension() {
		let e = this._lexer.token;
		this.expectKeyword("extend"), this.expectKeyword("directive"), this.expectToken(TokenKind.AT);
		let _ = this.parseName(), v = this.parseConstDirectives();
		if (v.length === 0) throw this.unexpected();
		return this.node(e, {
			kind: Kind.DIRECTIVE_EXTENSION,
			name: _,
			directives: v
		});
	}
	parseDirectiveDefinition() {
		let e = this._lexer.token, _ = this.parseDescription();
		this.expectKeyword("directive"), this.expectToken(TokenKind.AT);
		let v = this.parseName(), y = this.parseArgumentDefs(), b = this._options.experimentalDirectivesOnDirectiveDefinitions ? this.parseConstDirectives() : [], x = this.expectOptionalKeyword("repeatable");
		this.expectKeyword("on");
		let S = this.parseDirectiveLocations();
		return this.node(e, {
			kind: Kind.DIRECTIVE_DEFINITION,
			description: _,
			name: v,
			arguments: y,
			directives: b,
			repeatable: x,
			locations: S
		});
	}
	parseDirectiveLocations() {
		return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
	}
	parseDirectiveLocation() {
		let e = this._lexer.token, _ = this.parseName();
		if (Object.prototype.hasOwnProperty.call(DirectiveLocation, _.value)) return _;
		throw this.unexpected(e);
	}
	parseSchemaCoordinate() {
		let e = this._lexer.token, _ = this.expectOptionalToken(TokenKind.AT), v = this.parseName(), y;
		!_ && this.expectOptionalToken(TokenKind.DOT) && (y = this.parseName());
		let b;
		return (_ || y) && this.expectOptionalToken(TokenKind.PAREN_L) && (b = this.parseName(), this.expectToken(TokenKind.COLON), this.expectToken(TokenKind.PAREN_R)), _ ? b ? this.node(e, {
			kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE,
			name: v,
			argumentName: b
		}) : this.node(e, {
			kind: Kind.DIRECTIVE_COORDINATE,
			name: v
		}) : y ? b ? this.node(e, {
			kind: Kind.ARGUMENT_COORDINATE,
			name: v,
			fieldName: y,
			argumentName: b
		}) : this.node(e, {
			kind: Kind.MEMBER_COORDINATE,
			name: v,
			memberName: y
		}) : this.node(e, {
			kind: Kind.TYPE_COORDINATE,
			name: v
		});
	}
	node(e, _) {
		return this._options.noLocation !== !0 && (_.loc = new Location$1(e, this._lexer.lastToken, this._lexer.source)), _;
	}
	peek(e) {
		return this._lexer.token.kind === e;
	}
	expectToken(e) {
		let _ = this._lexer.token;
		if (_.kind === e) return this.advanceLexer(), _;
		throw syntaxError(this._lexer.source, _.start, `Expected ${getTokenKindDesc(e)}, found ${getTokenDesc(_)}.`);
	}
	expectOptionalToken(e) {
		return this._lexer.token.kind === e ? (this.advanceLexer(), !0) : !1;
	}
	expectKeyword(e) {
		let _ = this._lexer.token;
		if (_.kind === TokenKind.NAME && _.value === e) this.advanceLexer();
		else throw syntaxError(this._lexer.source, _.start, `Expected "${e}", found ${getTokenDesc(_)}.`);
	}
	expectOptionalKeyword(e) {
		let _ = this._lexer.token;
		return _.kind === TokenKind.NAME && _.value === e ? (this.advanceLexer(), !0) : !1;
	}
	unexpected(e) {
		let _ = e ?? this._lexer.token;
		return syntaxError(this._lexer.source, _.start, `Unexpected ${getTokenDesc(_)}.`);
	}
	any(e, _, v) {
		this.expectToken(e);
		let y = [];
		for (; !this.expectOptionalToken(v);) y.push(_.call(this));
		return y;
	}
	optionalMany(e, _, v) {
		if (this.expectOptionalToken(e)) {
			let e = [];
			do
				e.push(_.call(this));
			while (!this.expectOptionalToken(v));
			return e;
		}
		return [];
	}
	many(e, _, v) {
		this.expectToken(e);
		let y = [];
		do
			y.push(_.call(this));
		while (!this.expectOptionalToken(v));
		return y;
	}
	delimitedMany(e, _) {
		this.expectOptionalToken(e);
		let v = [];
		do
			v.push(_.call(this));
		while (this.expectOptionalToken(e));
		return v;
	}
	advanceLexer() {
		let { maxTokens: e } = this._options, _ = this._lexer.advance();
		if (_.kind !== TokenKind.EOF && (++this._tokenCounter, e !== void 0 && this._tokenCounter > e)) throw syntaxError(this._lexer.source, _.start, `Document contains more that ${e} tokens. Parsing aborted.`);
	}
};
function getTokenDesc(e) {
	let _ = e.value;
	return getTokenKindDesc(e.kind) + (_ == null ? "" : ` "${_}"`);
}
function getTokenKindDesc(e) {
	return isPunctuatorTokenKind(e) ? `"${e}"` : e;
}
var MAX_SUGGESTIONS = 5;
function didYouMean(e, _) {
	let [v, y] = _ ? [e, _] : [void 0, e], b = " Did you mean ";
	v && (b += v + " ");
	let x = y.map((e) => `"${e}"`);
	switch (x.length) {
		case 0: return "";
		case 1: return b + x[0] + "?";
		case 2: return b + x[0] + " or " + x[1] + "?";
	}
	let S = x.slice(0, MAX_SUGGESTIONS), C = S.pop();
	return b + S.join(", ") + ", or " + C + "?";
}
function identityFunc(e) {
	return e;
}
function keyMap(e, _) {
	let v = Object.create(null);
	for (let y of e) v[_(y)] = y;
	return v;
}
function keyValMap(e, _, v) {
	let y = Object.create(null);
	for (let b of e) y[_(b)] = v(b);
	return y;
}
function mapValue(e, _) {
	let v = Object.create(null);
	for (let y of Object.keys(e)) v[y] = _(e[y], y);
	return v;
}
function naturalCompare(e, _) {
	let v = 0, y = 0;
	for (; v < e.length && y < _.length;) {
		let b = e.charCodeAt(v), x = _.charCodeAt(y);
		if (isDigit(b) && isDigit(x)) {
			let S = 0;
			do
				++v, S = S * 10 + b - DIGIT_0, b = e.charCodeAt(v);
			while (isDigit(b) && S > 0);
			let C = 0;
			do
				++y, C = C * 10 + x - DIGIT_0, x = _.charCodeAt(y);
			while (isDigit(x) && C > 0);
			if (S < C) return -1;
			if (S > C) return 1;
		} else {
			if (b < x) return -1;
			if (b > x) return 1;
			++v, ++y;
		}
	}
	return e.length - _.length;
}
var DIGIT_0 = 48, DIGIT_9 = 57;
function isDigit(e) {
	return !isNaN(e) && DIGIT_0 <= e && e <= DIGIT_9;
}
function suggestionList(e, _) {
	let v = Object.create(null), y = new LexicalDistance(e), b = Math.floor(e.length * .4) + 1;
	for (let e of _) {
		let _ = y.measure(e, b);
		_ !== void 0 && (v[e] = _);
	}
	return Object.keys(v).sort((e, _) => {
		let y = v[e] - v[_];
		return y === 0 ? naturalCompare(e, _) : y;
	});
}
var LexicalDistance = class {
	constructor(e) {
		this._input = e, this._inputLowerCase = e.toLowerCase(), this._inputArray = stringToArray(this._inputLowerCase), this._rows = [
			Array(e.length + 1).fill(0),
			Array(e.length + 1).fill(0),
			Array(e.length + 1).fill(0)
		];
	}
	measure(e, _) {
		if (this._input === e) return 0;
		let v = e.toLowerCase();
		if (this._inputLowerCase === v) return 1;
		let y = stringToArray(v), b = this._inputArray;
		if (y.length < b.length) {
			let e = y;
			y = b, b = e;
		}
		let x = y.length, S = b.length;
		if (x - S > _) return;
		let C = this._rows;
		for (let e = 0; e <= S; e++) C[0][e] = e;
		for (let e = 1; e <= x; e++) {
			let v = C[(e - 1) % 3], x = C[e % 3], w = x[0] = e;
			for (let _ = 1; _ <= S; _++) {
				let S = y[e - 1] === b[_ - 1] ? 0 : 1, T = Math.min(v[_] + 1, x[_ - 1] + 1, v[_ - 1] + S);
				if (e > 1 && _ > 1 && y[e - 1] === b[_ - 2] && y[e - 2] === b[_ - 1]) {
					let v = C[(e - 2) % 3][_ - 2];
					T = Math.min(T, v + 1);
				}
				T < w && (w = T), x[_] = T;
			}
			if (w > _) return;
		}
		let w = C[x % 3][S];
		return w <= _ ? w : void 0;
	}
};
function stringToArray(e) {
	let _ = e.length, v = Array(_);
	for (let y = 0; y < _; ++y) v[y] = e.charCodeAt(y);
	return v;
}
function toObjMap(e) {
	if (e == null) return Object.create(null);
	if (Object.getPrototypeOf(e) === null) return e;
	let _ = Object.create(null);
	for (let [v, y] of Object.entries(e)) _[v] = y;
	return _;
}
function printString(e) {
	return `"${e.replace(escapedRegExp, escapedReplacer)}"`;
}
var escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
function escapedReplacer(e) {
	return escapeSequences[e.charCodeAt(0)];
}
var escapeSequences = /* @__PURE__ */ "\\u0000.\\u0001.\\u0002.\\u0003.\\u0004.\\u0005.\\u0006.\\u0007.\\b.\\t.\\n.\\u000B.\\f.\\r.\\u000E.\\u000F.\\u0010.\\u0011.\\u0012.\\u0013.\\u0014.\\u0015.\\u0016.\\u0017.\\u0018.\\u0019.\\u001A.\\u001B.\\u001C.\\u001D.\\u001E.\\u001F...\\\"..........................................................\\\\...................................\\u007F.\\u0080.\\u0081.\\u0082.\\u0083.\\u0084.\\u0085.\\u0086.\\u0087.\\u0088.\\u0089.\\u008A.\\u008B.\\u008C.\\u008D.\\u008E.\\u008F.\\u0090.\\u0091.\\u0092.\\u0093.\\u0094.\\u0095.\\u0096.\\u0097.\\u0098.\\u0099.\\u009A.\\u009B.\\u009C.\\u009D.\\u009E.\\u009F".split(".");
const BREAK = Object.freeze({});
function visit(e, _, v = QueryDocumentKeys) {
	let y = /* @__PURE__ */ new Map();
	for (let e of Object.values(Kind)) y.set(e, getEnterLeaveForKind(_, e));
	let b, x = Array.isArray(e), S = [e], C = -1, w = [], T = e, E, D, O = [], k = [];
	do {
		C++;
		let e = C === S.length, A = e && w.length !== 0;
		if (e) {
			if (E = k.length === 0 ? void 0 : O[O.length - 1], T = D, D = k.pop(), A) if (x) {
				T = T.slice();
				let e = 0;
				for (let [_, v] of w) {
					let y = _ - e;
					v === null ? (T.splice(y, 1), e++) : T[y] = v;
				}
			} else {
				T = { ...T };
				for (let [e, _] of w) T[e] = _;
			}
			C = b.index, S = b.keys, w = b.edits, x = b.inArray, b = b.prev;
		} else if (D) {
			if (E = x ? C : S[C], T = D[E], T == null) continue;
			O.push(E);
		}
		let j;
		if (!Array.isArray(T)) {
			if (isNode(T) || devAssert(!1, `Invalid AST Node: ${inspect(T)}.`), j = (e ? y.get(T.kind)?.leave : y.get(T.kind)?.enter)?.call(_, T, E, D, O, k), j === BREAK) break;
			if (j === !1) {
				if (!e) {
					O.pop();
					continue;
				}
			} else if (j !== void 0 && (w.push([E, j]), !e)) if (isNode(j)) T = j;
			else {
				O.pop();
				continue;
			}
		}
		j === void 0 && A && w.push([E, T]), e ? O.pop() : (b = {
			inArray: x,
			index: C,
			keys: S,
			edits: w,
			prev: b
		}, x = Array.isArray(T), S = x ? T : v[T.kind] ?? [], C = -1, w = [], D && k.push(D), D = T);
	} while (b !== void 0);
	return w.length === 0 ? e : w[w.length - 1][1];
}
function visitInParallel(e) {
	let _ = Array(e.length).fill(null), v = Object.create(null);
	for (let y of Object.values(Kind)) {
		let b = !1, x = Array(e.length).fill(void 0), S = Array(e.length).fill(void 0);
		for (let _ = 0; _ < e.length; ++_) {
			let { enter: v, leave: C } = getEnterLeaveForKind(e[_], y);
			b ||= v != null || C != null, x[_] = v, S[_] = C;
		}
		b && (v[y] = {
			enter(...v) {
				let y = v[0];
				for (let b = 0; b < e.length; b++) if (_[b] === null) {
					let S = x[b]?.apply(e[b], v);
					if (S === !1) _[b] = y;
					else if (S === BREAK) _[b] = BREAK;
					else if (S !== void 0) return S;
				}
			},
			leave(...v) {
				let y = v[0];
				for (let b = 0; b < e.length; b++) if (_[b] === null) {
					let y = S[b]?.apply(e[b], v);
					if (y === BREAK) _[b] = BREAK;
					else if (y !== void 0 && y !== !1) return y;
				} else _[b] === y && (_[b] = null);
			}
		});
	}
	return v;
}
function getEnterLeaveForKind(e, _) {
	let v = e[_];
	return typeof v == "object" ? v : typeof v == "function" ? {
		enter: v,
		leave: void 0
	} : {
		enter: e.enter,
		leave: e.leave
	};
}
function print(e) {
	return visit(e, printDocASTReducer);
}
var MAX_LINE_LENGTH = 80, printDocASTReducer = {
	Name: { leave: (e) => e.value },
	Variable: { leave: (e) => "$" + e.name },
	Document: { leave: (e) => join(e.definitions, "\n\n") },
	OperationDefinition: { leave(e) {
		let _ = hasMultilineItems(e.variableDefinitions) ? wrap("(\n", join(e.variableDefinitions, "\n"), "\n)") : wrap("(", join(e.variableDefinitions, ", "), ")"), v = wrap("", e.description, "\n") + join([
			e.operation,
			join([e.name, _]),
			join(e.directives, " ")
		], " ");
		return (v === "query" ? "" : v + " ") + e.selectionSet;
	} },
	VariableDefinition: { leave: ({ variable: e, type: _, defaultValue: v, directives: y, description: b }) => wrap("", b, "\n") + e + ": " + _ + wrap(" = ", v) + wrap(" ", join(y, " ")) },
	SelectionSet: { leave: ({ selections: e }) => block(e) },
	Field: { leave({ alias: e, name: _, arguments: v, directives: y, selectionSet: b }) {
		let x = wrap("", e, ": ") + _, S = x + wrap("(", join(v, ", "), ")");
		return S.length > MAX_LINE_LENGTH && (S = x + wrap("(\n", indent(join(v, "\n")), "\n)")), join([
			S,
			join(y, " "),
			b
		], " ");
	} },
	Argument: { leave: ({ name: e, value: _ }) => e + ": " + _ },
	FragmentSpread: { leave: ({ name: e, directives: _ }) => "..." + e + wrap(" ", join(_, " ")) },
	InlineFragment: { leave: ({ typeCondition: e, directives: _, selectionSet: v }) => join([
		"...",
		wrap("on ", e),
		join(_, " "),
		v
	], " ") },
	FragmentDefinition: { leave: ({ name: e, typeCondition: _, variableDefinitions: v, directives: y, selectionSet: b, description: x }) => wrap("", x, "\n") + `fragment ${e}${wrap("(", join(v, ", "), ")")} on ${_} ${wrap("", join(y, " "), " ")}` + b },
	IntValue: { leave: ({ value: e }) => e },
	FloatValue: { leave: ({ value: e }) => e },
	StringValue: { leave: ({ value: e, block: _ }) => _ ? printBlockString(e) : printString(e) },
	BooleanValue: { leave: ({ value: e }) => e ? "true" : "false" },
	NullValue: { leave: () => "null" },
	EnumValue: { leave: ({ value: e }) => e },
	ListValue: { leave: ({ values: e }) => "[" + join(e, ", ") + "]" },
	ObjectValue: { leave: ({ fields: e }) => "{" + join(e, ", ") + "}" },
	ObjectField: { leave: ({ name: e, value: _ }) => e + ": " + _ },
	Directive: { leave: ({ name: e, arguments: _ }) => "@" + e + wrap("(", join(_, ", "), ")") },
	NamedType: { leave: ({ name: e }) => e },
	ListType: { leave: ({ type: e }) => "[" + e + "]" },
	NonNullType: { leave: ({ type: e }) => e + "!" },
	SchemaDefinition: { leave: ({ description: e, directives: _, operationTypes: v }) => wrap("", e, "\n") + join([
		"schema",
		join(_, " "),
		block(v)
	], " ") },
	OperationTypeDefinition: { leave: ({ operation: e, type: _ }) => e + ": " + _ },
	ScalarTypeDefinition: { leave: ({ description: e, name: _, directives: v }) => wrap("", e, "\n") + join([
		"scalar",
		_,
		join(v, " ")
	], " ") },
	ObjectTypeDefinition: { leave: ({ description: e, name: _, interfaces: v, directives: y, fields: b }) => wrap("", e, "\n") + join([
		"type",
		_,
		wrap("implements ", join(v, " & ")),
		join(y, " "),
		block(b)
	], " ") },
	FieldDefinition: { leave: ({ description: e, name: _, arguments: v, type: y, directives: b }) => wrap("", e, "\n") + _ + (hasMultilineItems(v) ? wrap("(\n", indent(join(v, "\n")), "\n)") : wrap("(", join(v, ", "), ")")) + ": " + y + wrap(" ", join(b, " ")) },
	InputValueDefinition: { leave: ({ description: e, name: _, type: v, defaultValue: y, directives: b }) => wrap("", e, "\n") + join([
		_ + ": " + v,
		wrap("= ", y),
		join(b, " ")
	], " ") },
	InterfaceTypeDefinition: { leave: ({ description: e, name: _, interfaces: v, directives: y, fields: b }) => wrap("", e, "\n") + join([
		"interface",
		_,
		wrap("implements ", join(v, " & ")),
		join(y, " "),
		block(b)
	], " ") },
	UnionTypeDefinition: { leave: ({ description: e, name: _, directives: v, types: y }) => wrap("", e, "\n") + join([
		"union",
		_,
		join(v, " "),
		wrap("= ", join(y, " | "))
	], " ") },
	EnumTypeDefinition: { leave: ({ description: e, name: _, directives: v, values: y }) => wrap("", e, "\n") + join([
		"enum",
		_,
		join(v, " "),
		block(y)
	], " ") },
	EnumValueDefinition: { leave: ({ description: e, name: _, directives: v }) => wrap("", e, "\n") + join([_, join(v, " ")], " ") },
	InputObjectTypeDefinition: { leave: ({ description: e, name: _, directives: v, fields: y }) => wrap("", e, "\n") + join([
		"input",
		_,
		join(v, " "),
		block(y)
	], " ") },
	DirectiveDefinition: { leave: ({ description: e, name: _, arguments: v, directives: y, repeatable: b, locations: x }) => wrap("", e, "\n") + "directive @" + _ + (hasMultilineItems(v) ? wrap("(\n", indent(join(v, "\n")), "\n)") : wrap("(", join(v, ", "), ")")) + wrap(" ", join(y, " ")) + (b ? " repeatable" : "") + " on " + join(x, " | ") },
	SchemaExtension: { leave: ({ directives: e, operationTypes: _ }) => join([
		"extend schema",
		join(e, " "),
		block(_)
	], " ") },
	ScalarTypeExtension: { leave: ({ name: e, directives: _ }) => join([
		"extend scalar",
		e,
		join(_, " ")
	], " ") },
	ObjectTypeExtension: { leave: ({ name: e, interfaces: _, directives: v, fields: y }) => join([
		"extend type",
		e,
		wrap("implements ", join(_, " & ")),
		join(v, " "),
		block(y)
	], " ") },
	InterfaceTypeExtension: { leave: ({ name: e, interfaces: _, directives: v, fields: y }) => join([
		"extend interface",
		e,
		wrap("implements ", join(_, " & ")),
		join(v, " "),
		block(y)
	], " ") },
	UnionTypeExtension: { leave: ({ name: e, directives: _, types: v }) => join([
		"extend union",
		e,
		join(_, " "),
		wrap("= ", join(v, " | "))
	], " ") },
	EnumTypeExtension: { leave: ({ name: e, directives: _, values: v }) => join([
		"extend enum",
		e,
		join(_, " "),
		block(v)
	], " ") },
	InputObjectTypeExtension: { leave: ({ name: e, directives: _, fields: v }) => join([
		"extend input",
		e,
		join(_, " "),
		block(v)
	], " ") },
	DirectiveExtension: { leave: ({ name: e, directives: _ }) => join(["extend directive @" + e, join(_, " ")], " ") },
	TypeCoordinate: { leave: ({ name: e }) => e },
	MemberCoordinate: { leave: ({ name: e, memberName: _ }) => join([e, wrap(".", _)]) },
	ArgumentCoordinate: { leave: ({ name: e, fieldName: _, argumentName: v }) => join([
		e,
		wrap(".", _),
		wrap("(", v, ":)")
	]) },
	DirectiveCoordinate: { leave: ({ name: e }) => join(["@", e]) },
	DirectiveArgumentCoordinate: { leave: ({ name: e, argumentName: _ }) => join([
		"@",
		e,
		wrap("(", _, ":)")
	]) }
};
function join(e, _ = "") {
	return e?.filter((e) => e).join(_) ?? "";
}
function block(e) {
	return wrap("{\n", indent(join(e, "\n")), "\n}");
}
function wrap(e, _, v = "") {
	return _ != null && _ !== "" ? e + _ + v : "";
}
function indent(e) {
	return wrap("  ", e.replace(/\n/g, "\n  "));
}
function hasMultilineItems(e) {
	/* c8 ignore next */
	return e?.some((e) => e.includes("\n")) ?? !1;
}
function valueFromASTUntyped(e, _) {
	switch (e.kind) {
		case Kind.NULL: return null;
		case Kind.INT: return parseInt(e.value, 10);
		case Kind.FLOAT: return parseFloat(e.value);
		case Kind.STRING:
		case Kind.ENUM:
		case Kind.BOOLEAN: return e.value;
		case Kind.LIST: return e.values.map((e) => valueFromASTUntyped(e, _));
		case Kind.OBJECT: return keyValMap(e.fields, (e) => e.name.value, (e) => valueFromASTUntyped(e.value, _));
		case Kind.VARIABLE: return _?.[e.name.value];
	}
}
function assertName(e) {
	if (e ?? devAssert(!1, "Must provide name."), typeof e == "string" || devAssert(!1, "Expected name to be a string."), e.length === 0) throw new GraphQLError("Expected name to be a non-empty string.");
	for (let _ = 1; _ < e.length; ++_) if (!isNameContinue(e.charCodeAt(_))) throw new GraphQLError(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);
	if (!isNameStart(e.charCodeAt(0))) throw new GraphQLError(`Names must start with [_a-zA-Z] but "${e}" does not.`);
	return e;
}
function assertEnumValueName(e) {
	if (e === "true" || e === "false" || e === "null") throw new GraphQLError(`Enum values cannot be named: ${e}`);
	return assertName(e);
}
function isType(e) {
	return isScalarType(e) || isObjectType(e) || isInterfaceType(e) || isUnionType(e) || isEnumType(e) || isInputObjectType(e) || isListType(e) || isNonNullType(e);
}
function isScalarType(e) {
	return instanceOf(e, GraphQLScalarType);
}
function isObjectType(e) {
	return instanceOf(e, GraphQLObjectType);
}
function assertObjectType(e) {
	if (!isObjectType(e)) throw Error(`Expected ${inspect(e)} to be a GraphQL Object type.`);
	return e;
}
function isInterfaceType(e) {
	return instanceOf(e, GraphQLInterfaceType);
}
function assertInterfaceType(e) {
	if (!isInterfaceType(e)) throw Error(`Expected ${inspect(e)} to be a GraphQL Interface type.`);
	return e;
}
function isUnionType(e) {
	return instanceOf(e, GraphQLUnionType);
}
function isEnumType(e) {
	return instanceOf(e, GraphQLEnumType);
}
function isInputObjectType(e) {
	return instanceOf(e, GraphQLInputObjectType);
}
function isListType(e) {
	return instanceOf(e, GraphQLList);
}
function isNonNullType(e) {
	return instanceOf(e, GraphQLNonNull);
}
function isInputType(e) {
	return isScalarType(e) || isEnumType(e) || isInputObjectType(e) || isWrappingType(e) && isInputType(e.ofType);
}
function isOutputType(e) {
	return isScalarType(e) || isObjectType(e) || isInterfaceType(e) || isUnionType(e) || isEnumType(e) || isWrappingType(e) && isOutputType(e.ofType);
}
function isLeafType(e) {
	return isScalarType(e) || isEnumType(e);
}
function isCompositeType(e) {
	return isObjectType(e) || isInterfaceType(e) || isUnionType(e);
}
function isAbstractType(e) {
	return isInterfaceType(e) || isUnionType(e);
}
var GraphQLList = class {
	constructor(e) {
		isType(e) || devAssert(!1, `Expected ${inspect(e)} to be a GraphQL type.`), this.ofType = e;
	}
	get [Symbol.toStringTag]() {
		return "GraphQLList";
	}
	toString() {
		return "[" + String(this.ofType) + "]";
	}
	toJSON() {
		return this.toString();
	}
}, GraphQLNonNull = class {
	constructor(e) {
		isNullableType(e) || devAssert(!1, `Expected ${inspect(e)} to be a GraphQL nullable type.`), this.ofType = e;
	}
	get [Symbol.toStringTag]() {
		return "GraphQLNonNull";
	}
	toString() {
		return String(this.ofType) + "!";
	}
	toJSON() {
		return this.toString();
	}
};
function isWrappingType(e) {
	return isListType(e) || isNonNullType(e);
}
function isNullableType(e) {
	return isType(e) && !isNonNullType(e);
}
function assertNullableType(e) {
	if (!isNullableType(e)) throw Error(`Expected ${inspect(e)} to be a GraphQL nullable type.`);
	return e;
}
function getNullableType(e) {
	if (e) return isNonNullType(e) ? e.ofType : e;
}
function isNamedType(e) {
	return isScalarType(e) || isObjectType(e) || isInterfaceType(e) || isUnionType(e) || isEnumType(e) || isInputObjectType(e);
}
function getNamedType(e) {
	if (e) {
		let _ = e;
		for (; isWrappingType(_);) _ = _.ofType;
		return _;
	}
}
function resolveReadonlyArrayThunk(e) {
	return typeof e == "function" ? e() : e;
}
function resolveObjMapThunk(e) {
	return typeof e == "function" ? e() : e;
}
var GraphQLScalarType = class {
	constructor(e) {
		let _ = e.parseValue ?? identityFunc;
		this.name = assertName(e.name), this.description = e.description, this.specifiedByURL = e.specifiedByURL, this.serialize = e.serialize ?? identityFunc, this.parseValue = _, this.parseLiteral = e.parseLiteral ?? ((e, v) => _(valueFromASTUntyped(e, v))), this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], e.specifiedByURL == null || typeof e.specifiedByURL == "string" || devAssert(!1, `${this.name} must provide "specifiedByURL" as a string, but got: ${inspect(e.specifiedByURL)}.`), e.serialize == null || typeof e.serialize == "function" || devAssert(!1, `${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`), e.parseLiteral && (typeof e.parseValue == "function" && typeof e.parseLiteral == "function" || devAssert(!1, `${this.name} must provide both "parseValue" and "parseLiteral" functions.`));
	}
	get [Symbol.toStringTag]() {
		return "GraphQLScalarType";
	}
	toConfig() {
		return {
			name: this.name,
			description: this.description,
			specifiedByURL: this.specifiedByURL,
			serialize: this.serialize,
			parseValue: this.parseValue,
			parseLiteral: this.parseLiteral,
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes
		};
	}
	toString() {
		return this.name;
	}
	toJSON() {
		return this.toString();
	}
}, GraphQLObjectType = class {
	constructor(e) {
		this.name = assertName(e.name), this.description = e.description, this.isTypeOf = e.isTypeOf, this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], this._fields = () => defineFieldMap(e), this._interfaces = () => defineInterfaces(e), e.isTypeOf == null || typeof e.isTypeOf == "function" || devAssert(!1, `${this.name} must provide "isTypeOf" as a function, but got: ${inspect(e.isTypeOf)}.`);
	}
	get [Symbol.toStringTag]() {
		return "GraphQLObjectType";
	}
	getFields() {
		return typeof this._fields == "function" && (this._fields = this._fields()), this._fields;
	}
	getInterfaces() {
		return typeof this._interfaces == "function" && (this._interfaces = this._interfaces()), this._interfaces;
	}
	toConfig() {
		return {
			name: this.name,
			description: this.description,
			interfaces: this.getInterfaces(),
			fields: fieldsToFieldsConfig(this.getFields()),
			isTypeOf: this.isTypeOf,
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes
		};
	}
	toString() {
		return this.name;
	}
	toJSON() {
		return this.toString();
	}
};
function defineInterfaces(e) {
	let _ = resolveReadonlyArrayThunk(e.interfaces ?? []);
	return Array.isArray(_) || devAssert(!1, `${e.name} interfaces must be an Array or a function which returns an Array.`), _;
}
function defineFieldMap(e) {
	let _ = resolveObjMapThunk(e.fields);
	return isPlainObj(_) || devAssert(!1, `${e.name} fields must be an object with field names as keys or a function which returns such an object.`), mapValue(_, (_, v) => {
		isPlainObj(_) || devAssert(!1, `${e.name}.${v} field config must be an object.`), _.resolve == null || typeof _.resolve == "function" || devAssert(!1, `${e.name}.${v} field resolver must be a function if provided, but got: ${inspect(_.resolve)}.`);
		let y = _.args ?? {};
		return isPlainObj(y) || devAssert(!1, `${e.name}.${v} args must be an object with argument names as keys.`), {
			name: assertName(v),
			description: _.description,
			type: _.type,
			args: defineArguments(y),
			resolve: _.resolve,
			subscribe: _.subscribe,
			deprecationReason: _.deprecationReason,
			extensions: toObjMap(_.extensions),
			astNode: _.astNode
		};
	});
}
function defineArguments(e) {
	return Object.entries(e).map(([e, _]) => ({
		name: assertName(e),
		description: _.description,
		type: _.type,
		defaultValue: _.defaultValue,
		deprecationReason: _.deprecationReason,
		extensions: toObjMap(_.extensions),
		astNode: _.astNode
	}));
}
function isPlainObj(e) {
	return isObjectLike(e) && !Array.isArray(e);
}
function fieldsToFieldsConfig(e) {
	return mapValue(e, (e) => ({
		description: e.description,
		type: e.type,
		args: argsToArgsConfig(e.args),
		resolve: e.resolve,
		subscribe: e.subscribe,
		deprecationReason: e.deprecationReason,
		extensions: e.extensions,
		astNode: e.astNode
	}));
}
function argsToArgsConfig(e) {
	return keyValMap(e, (e) => e.name, (e) => ({
		description: e.description,
		type: e.type,
		defaultValue: e.defaultValue,
		deprecationReason: e.deprecationReason,
		extensions: e.extensions,
		astNode: e.astNode
	}));
}
function isRequiredArgument(e) {
	return isNonNullType(e.type) && e.defaultValue === void 0;
}
var GraphQLInterfaceType = class {
	constructor(e) {
		this.name = assertName(e.name), this.description = e.description, this.resolveType = e.resolveType, this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], this._fields = defineFieldMap.bind(void 0, e), this._interfaces = defineInterfaces.bind(void 0, e), e.resolveType == null || typeof e.resolveType == "function" || devAssert(!1, `${this.name} must provide "resolveType" as a function, but got: ${inspect(e.resolveType)}.`);
	}
	get [Symbol.toStringTag]() {
		return "GraphQLInterfaceType";
	}
	getFields() {
		return typeof this._fields == "function" && (this._fields = this._fields()), this._fields;
	}
	getInterfaces() {
		return typeof this._interfaces == "function" && (this._interfaces = this._interfaces()), this._interfaces;
	}
	toConfig() {
		return {
			name: this.name,
			description: this.description,
			interfaces: this.getInterfaces(),
			fields: fieldsToFieldsConfig(this.getFields()),
			resolveType: this.resolveType,
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes
		};
	}
	toString() {
		return this.name;
	}
	toJSON() {
		return this.toString();
	}
}, GraphQLUnionType = class {
	constructor(e) {
		this.name = assertName(e.name), this.description = e.description, this.resolveType = e.resolveType, this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], this._types = defineTypes.bind(void 0, e), e.resolveType == null || typeof e.resolveType == "function" || devAssert(!1, `${this.name} must provide "resolveType" as a function, but got: ${inspect(e.resolveType)}.`);
	}
	get [Symbol.toStringTag]() {
		return "GraphQLUnionType";
	}
	getTypes() {
		return typeof this._types == "function" && (this._types = this._types()), this._types;
	}
	toConfig() {
		return {
			name: this.name,
			description: this.description,
			types: this.getTypes(),
			resolveType: this.resolveType,
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes
		};
	}
	toString() {
		return this.name;
	}
	toJSON() {
		return this.toString();
	}
};
function defineTypes(e) {
	let _ = resolveReadonlyArrayThunk(e.types);
	return Array.isArray(_) || devAssert(!1, `Must provide Array of types or a function which returns such an array for Union ${e.name}.`), _;
}
var GraphQLEnumType = class {
	constructor(e) {
		this.name = assertName(e.name), this.description = e.description, this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], this._values = typeof e.values == "function" ? e.values : defineEnumValues(this.name, e.values), this._valueLookup = null, this._nameLookup = null;
	}
	get [Symbol.toStringTag]() {
		return "GraphQLEnumType";
	}
	getValues() {
		return typeof this._values == "function" && (this._values = defineEnumValues(this.name, this._values())), this._values;
	}
	getValue(e) {
		return this._nameLookup === null && (this._nameLookup = keyMap(this.getValues(), (e) => e.name)), this._nameLookup[e];
	}
	serialize(e) {
		this._valueLookup === null && (this._valueLookup = new Map(this.getValues().map((e) => [e.value, e])));
		let _ = this._valueLookup.get(e);
		if (_ === void 0) throw new GraphQLError(`Enum "${this.name}" cannot represent value: ${inspect(e)}`);
		return _.name;
	}
	parseValue(e) {
		if (typeof e != "string") {
			let _ = inspect(e);
			throw new GraphQLError(`Enum "${this.name}" cannot represent non-string value: ${_}.` + didYouMeanEnumValue(this, _));
		}
		let _ = this.getValue(e);
		if (_ == null) throw new GraphQLError(`Value "${e}" does not exist in "${this.name}" enum.` + didYouMeanEnumValue(this, e));
		return _.value;
	}
	parseLiteral(e, _) {
		if (e.kind !== Kind.ENUM) {
			let _ = print(e);
			throw new GraphQLError(`Enum "${this.name}" cannot represent non-enum value: ${_}.` + didYouMeanEnumValue(this, _), { nodes: e });
		}
		let v = this.getValue(e.value);
		if (v == null) {
			let _ = print(e);
			throw new GraphQLError(`Value "${_}" does not exist in "${this.name}" enum.` + didYouMeanEnumValue(this, _), { nodes: e });
		}
		return v.value;
	}
	toConfig() {
		let e = keyValMap(this.getValues(), (e) => e.name, (e) => ({
			description: e.description,
			value: e.value,
			deprecationReason: e.deprecationReason,
			extensions: e.extensions,
			astNode: e.astNode
		}));
		return {
			name: this.name,
			description: this.description,
			values: e,
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes
		};
	}
	toString() {
		return this.name;
	}
	toJSON() {
		return this.toString();
	}
};
function didYouMeanEnumValue(e, _) {
	let v = e.getValues().map((e) => e.name), y = suggestionList(_, v);
	return didYouMean("the enum value", y);
}
function defineEnumValues(e, _) {
	return isPlainObj(_) || devAssert(!1, `${e} values must be an object with value names as keys.`), Object.entries(_).map(([_, v]) => (isPlainObj(v) || devAssert(!1, `${e}.${_} must refer to an object with a "value" key representing an internal value but got: ${inspect(v)}.`), {
		name: assertEnumValueName(_),
		description: v.description,
		value: v.value === void 0 ? _ : v.value,
		deprecationReason: v.deprecationReason,
		extensions: toObjMap(v.extensions),
		astNode: v.astNode
	}));
}
var GraphQLInputObjectType = class {
	constructor(e) {
		this.name = assertName(e.name), this.description = e.description, this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], this.isOneOf = e.isOneOf ?? !1, this._fields = defineInputFieldMap.bind(void 0, e);
	}
	get [Symbol.toStringTag]() {
		return "GraphQLInputObjectType";
	}
	getFields() {
		return typeof this._fields == "function" && (this._fields = this._fields()), this._fields;
	}
	toConfig() {
		let e = mapValue(this.getFields(), (e) => ({
			description: e.description,
			type: e.type,
			defaultValue: e.defaultValue,
			deprecationReason: e.deprecationReason,
			extensions: e.extensions,
			astNode: e.astNode
		}));
		return {
			name: this.name,
			description: this.description,
			fields: e,
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes,
			isOneOf: this.isOneOf
		};
	}
	toString() {
		return this.name;
	}
	toJSON() {
		return this.toString();
	}
};
function defineInputFieldMap(e) {
	let _ = resolveObjMapThunk(e.fields);
	return isPlainObj(_) || devAssert(!1, `${e.name} fields must be an object with field names as keys or a function which returns such an object.`), mapValue(_, (_, v) => (!("resolve" in _) || devAssert(!1, `${e.name}.${v} field has a resolve property, but Input Types cannot define resolvers.`), {
		name: assertName(v),
		description: _.description,
		type: _.type,
		defaultValue: _.defaultValue,
		deprecationReason: _.deprecationReason,
		extensions: toObjMap(_.extensions),
		astNode: _.astNode
	}));
}
function isRequiredInputField(e) {
	return isNonNullType(e.type) && e.defaultValue === void 0;
}
function isEqualType(e, _) {
	return e === _ ? !0 : isNonNullType(e) && isNonNullType(_) || isListType(e) && isListType(_) ? isEqualType(e.ofType, _.ofType) : !1;
}
function isTypeSubTypeOf(e, _, v) {
	return _ === v ? !0 : isNonNullType(v) ? isNonNullType(_) ? isTypeSubTypeOf(e, _.ofType, v.ofType) : !1 : isNonNullType(_) ? isTypeSubTypeOf(e, _.ofType, v) : isListType(v) ? isListType(_) ? isTypeSubTypeOf(e, _.ofType, v.ofType) : !1 : isListType(_) ? !1 : isAbstractType(v) && (isInterfaceType(_) || isObjectType(_)) && e.isSubType(v, _);
}
function doTypesOverlap(e, _, v) {
	return _ === v ? !0 : isAbstractType(_) ? isAbstractType(v) ? e.getPossibleTypes(_).some((_) => e.isSubType(v, _)) : e.isSubType(_, v) : isAbstractType(v) ? e.isSubType(v, _) : !1;
}
const GraphQLInt = new GraphQLScalarType({
	name: "Int",
	description: "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",
	serialize(e) {
		let _ = serializeObject(e);
		if (typeof _ == "boolean") return _ ? 1 : 0;
		let v = _;
		if (typeof _ == "string" && _ !== "" && (v = Number(_)), typeof v != "number" || !Number.isInteger(v)) throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(_)}`);
		if (v > 2147483647 || v < -2147483648) throw new GraphQLError("Int cannot represent non 32-bit signed integer value: " + inspect(_));
		return v;
	},
	parseValue(e) {
		if (typeof e != "number" || !Number.isInteger(e)) throw new GraphQLError(`Int cannot represent non-integer value: ${inspect(e)}`);
		if (e > 2147483647 || e < -2147483648) throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${e}`);
		return e;
	},
	parseLiteral(e) {
		if (e.kind !== Kind.INT) throw new GraphQLError(`Int cannot represent non-integer value: ${print(e)}`, { nodes: e });
		let _ = parseInt(e.value, 10);
		if (_ > 2147483647 || _ < -2147483648) throw new GraphQLError(`Int cannot represent non 32-bit signed integer value: ${e.value}`, { nodes: e });
		return _;
	}
}), GraphQLFloat = new GraphQLScalarType({
	name: "Float",
	description: "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",
	serialize(e) {
		let _ = serializeObject(e);
		if (typeof _ == "boolean") return _ ? 1 : 0;
		let v = _;
		if (typeof _ == "string" && _ !== "" && (v = Number(_)), typeof v != "number" || !Number.isFinite(v)) throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(_)}`);
		return v;
	},
	parseValue(e) {
		if (typeof e != "number" || !Number.isFinite(e)) throw new GraphQLError(`Float cannot represent non numeric value: ${inspect(e)}`);
		return e;
	},
	parseLiteral(e) {
		if (e.kind !== Kind.FLOAT && e.kind !== Kind.INT) throw new GraphQLError(`Float cannot represent non numeric value: ${print(e)}`, e);
		return parseFloat(e.value);
	}
}), GraphQLString = new GraphQLScalarType({
	name: "String",
	description: "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",
	serialize(e) {
		let _ = serializeObject(e);
		if (typeof _ == "string") return _;
		if (typeof _ == "boolean") return _ ? "true" : "false";
		if (typeof _ == "number" && Number.isFinite(_)) return _.toString();
		throw new GraphQLError(`String cannot represent value: ${inspect(e)}`);
	},
	parseValue(e) {
		if (typeof e != "string") throw new GraphQLError(`String cannot represent a non string value: ${inspect(e)}`);
		return e;
	},
	parseLiteral(e) {
		if (e.kind !== Kind.STRING) throw new GraphQLError(`String cannot represent a non string value: ${print(e)}`, { nodes: e });
		return e.value;
	}
}), GraphQLBoolean = new GraphQLScalarType({
	name: "Boolean",
	description: "The `Boolean` scalar type represents `true` or `false`.",
	serialize(e) {
		let _ = serializeObject(e);
		if (typeof _ == "boolean") return _;
		if (Number.isFinite(_)) return _ !== 0;
		throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(_)}`);
	},
	parseValue(e) {
		if (typeof e != "boolean") throw new GraphQLError(`Boolean cannot represent a non boolean value: ${inspect(e)}`);
		return e;
	},
	parseLiteral(e) {
		if (e.kind !== Kind.BOOLEAN) throw new GraphQLError(`Boolean cannot represent a non boolean value: ${print(e)}`, { nodes: e });
		return e.value;
	}
}), GraphQLID = new GraphQLScalarType({
	name: "ID",
	description: "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.",
	serialize(e) {
		let _ = serializeObject(e);
		if (typeof _ == "string") return _;
		if (Number.isInteger(_)) return String(_);
		throw new GraphQLError(`ID cannot represent value: ${inspect(e)}`);
	},
	parseValue(e) {
		if (typeof e == "string") return e;
		if (typeof e == "number" && Number.isInteger(e)) return e.toString();
		throw new GraphQLError(`ID cannot represent value: ${inspect(e)}`);
	},
	parseLiteral(e) {
		if (e.kind !== Kind.STRING && e.kind !== Kind.INT) throw new GraphQLError("ID cannot represent a non-string and non-integer value: " + print(e), { nodes: e });
		return e.value;
	}
}), specifiedScalarTypes = Object.freeze([
	GraphQLString,
	GraphQLInt,
	GraphQLFloat,
	GraphQLBoolean,
	GraphQLID
]);
function isSpecifiedScalarType(e) {
	return specifiedScalarTypes.some(({ name: _ }) => e.name === _);
}
function serializeObject(e) {
	if (isObjectLike(e)) {
		if (typeof e.valueOf == "function") {
			let _ = e.valueOf();
			if (!isObjectLike(_)) return _;
		}
		if (typeof e.toJSON == "function") return e.toJSON();
	}
	return e;
}
function isDirective(e) {
	return instanceOf(e, GraphQLDirective);
}
var GraphQLDirective = class {
	constructor(e) {
		this.name = assertName(e.name), this.description = e.description, this.locations = e.locations, this.isRepeatable = e.isRepeatable ?? !1, this.deprecationReason = e.deprecationReason, this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], Array.isArray(e.locations) || devAssert(!1, `@${e.name} locations must be an Array.`);
		let _ = e.args ?? {};
		isObjectLike(_) && !Array.isArray(_) || devAssert(!1, `@${e.name} args must be an object with argument names as keys.`), this.args = defineArguments(_);
	}
	get [Symbol.toStringTag]() {
		return "GraphQLDirective";
	}
	toConfig() {
		return {
			name: this.name,
			description: this.description,
			locations: this.locations,
			args: argsToArgsConfig(this.args),
			isRepeatable: this.isRepeatable,
			deprecationReason: this.deprecationReason,
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes
		};
	}
	toString() {
		return "@" + this.name;
	}
	toJSON() {
		return this.toString();
	}
};
const GraphQLIncludeDirective = new GraphQLDirective({
	name: "include",
	description: "Directs the executor to include this field or fragment only when the `if` argument is true.",
	locations: [
		DirectiveLocation.FIELD,
		DirectiveLocation.FRAGMENT_SPREAD,
		DirectiveLocation.INLINE_FRAGMENT
	],
	args: { if: {
		type: new GraphQLNonNull(GraphQLBoolean),
		description: "Included when true."
	} }
}), GraphQLSkipDirective = new GraphQLDirective({
	name: "skip",
	description: "Directs the executor to skip this field or fragment when the `if` argument is true.",
	locations: [
		DirectiveLocation.FIELD,
		DirectiveLocation.FRAGMENT_SPREAD,
		DirectiveLocation.INLINE_FRAGMENT
	],
	args: { if: {
		type: new GraphQLNonNull(GraphQLBoolean),
		description: "Skipped when true."
	} }
}), DEFAULT_DEPRECATION_REASON = "No longer supported", GraphQLDeprecatedDirective = new GraphQLDirective({
	name: "deprecated",
	description: "Marks an element of a GraphQL schema as no longer supported.",
	locations: [
		DirectiveLocation.FIELD_DEFINITION,
		DirectiveLocation.ARGUMENT_DEFINITION,
		DirectiveLocation.INPUT_FIELD_DEFINITION,
		DirectiveLocation.ENUM_VALUE,
		DirectiveLocation.DIRECTIVE_DEFINITION
	],
	args: { reason: {
		type: GraphQLString,
		description: "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",
		defaultValue: DEFAULT_DEPRECATION_REASON
	} }
}), GraphQLSpecifiedByDirective = new GraphQLDirective({
	name: "specifiedBy",
	description: "Exposes a URL that specifies the behavior of this scalar.",
	locations: [DirectiveLocation.SCALAR],
	args: { url: {
		type: new GraphQLNonNull(GraphQLString),
		description: "The URL that specifies the behavior of this scalar."
	} }
}), GraphQLOneOfDirective = new GraphQLDirective({
	name: "oneOf",
	description: "Indicates exactly one field must be supplied and this field must not be `null`.",
	locations: [DirectiveLocation.INPUT_OBJECT],
	args: {}
}), specifiedDirectives = Object.freeze([
	GraphQLIncludeDirective,
	GraphQLSkipDirective,
	GraphQLDeprecatedDirective,
	GraphQLSpecifiedByDirective,
	GraphQLOneOfDirective
]);
function isSpecifiedDirective(e) {
	return specifiedDirectives.some(({ name: _ }) => _ === e.name);
}
function isIterableObject(e) {
	return typeof e == "object" && typeof e?.[Symbol.iterator] == "function";
}
function astFromValue(e, _) {
	if (isNonNullType(_)) {
		let v = astFromValue(e, _.ofType);
		return v?.kind === Kind.NULL ? null : v;
	}
	if (e === null) return { kind: Kind.NULL };
	if (e === void 0) return null;
	if (isListType(_)) {
		let v = _.ofType;
		if (isIterableObject(e)) {
			let _ = [];
			for (let y of e) {
				let e = astFromValue(y, v);
				e != null && _.push(e);
			}
			return {
				kind: Kind.LIST,
				values: _
			};
		}
		return astFromValue(e, v);
	}
	if (isInputObjectType(_)) {
		if (!isObjectLike(e)) return null;
		let v = [];
		for (let y of Object.values(_.getFields())) {
			let _ = astFromValue(e[y.name], y.type);
			_ && v.push({
				kind: Kind.OBJECT_FIELD,
				name: {
					kind: Kind.NAME,
					value: y.name
				},
				value: _
			});
		}
		return {
			kind: Kind.OBJECT,
			fields: v
		};
	}
	if (isLeafType(_)) {
		let v = _.serialize(e);
		if (v == null) return null;
		if (typeof v == "boolean") return {
			kind: Kind.BOOLEAN,
			value: v
		};
		if (typeof v == "number" && Number.isFinite(v)) {
			let e = String(v);
			return integerStringRegExp.test(e) ? {
				kind: Kind.INT,
				value: e
			} : {
				kind: Kind.FLOAT,
				value: e
			};
		}
		if (typeof v == "string") return isEnumType(_) ? {
			kind: Kind.ENUM,
			value: v
		} : _ === GraphQLID && integerStringRegExp.test(v) ? {
			kind: Kind.INT,
			value: v
		} : {
			kind: Kind.STRING,
			value: v
		};
		throw TypeError(`Cannot convert value to AST: ${inspect(v)}.`);
	}
	/* c8 ignore next 3 */
	invariant(!1, "Unexpected input type: " + inspect(_));
}
var integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;
const __Schema = new GraphQLObjectType({
	name: "__Schema",
	description: "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",
	fields: () => ({
		description: {
			type: GraphQLString,
			resolve: (e) => e.description
		},
		types: {
			description: "A list of all types supported by this server.",
			type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Type))),
			resolve(e) {
				return Object.values(e.getTypeMap());
			}
		},
		queryType: {
			description: "The type that query operations will be rooted at.",
			type: new GraphQLNonNull(__Type),
			resolve: (e) => e.getQueryType()
		},
		mutationType: {
			description: "If this server supports mutation, the type that mutation operations will be rooted at.",
			type: __Type,
			resolve: (e) => e.getMutationType()
		},
		subscriptionType: {
			description: "If this server support subscription, the type that subscription operations will be rooted at.",
			type: __Type,
			resolve: (e) => e.getSubscriptionType()
		},
		directives: {
			description: "A list of all directives supported by this server.",
			type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__Directive))),
			args: { includeDeprecated: {
				type: new GraphQLNonNull(GraphQLBoolean),
				defaultValue: !1
			} },
			resolve: (e, { includeDeprecated: _ }) => _ ? e.getDirectives() : e.getDirectives().filter((e) => e.deprecationReason == null)
		}
	})
}), __Directive = new GraphQLObjectType({
	name: "__Directive",
	description: "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",
	fields: () => ({
		name: {
			type: new GraphQLNonNull(GraphQLString),
			resolve: (e) => e.name
		},
		description: {
			type: GraphQLString,
			resolve: (e) => e.description
		},
		isRepeatable: {
			type: new GraphQLNonNull(GraphQLBoolean),
			resolve: (e) => e.isRepeatable
		},
		locations: {
			type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__DirectiveLocation))),
			resolve: (e) => e.locations
		},
		args: {
			type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))),
			args: { includeDeprecated: {
				type: GraphQLBoolean,
				defaultValue: !1
			} },
			resolve(e, { includeDeprecated: _ }) {
				return _ ? e.args : e.args.filter((e) => e.deprecationReason == null);
			}
		},
		isDeprecated: {
			type: new GraphQLNonNull(GraphQLBoolean),
			resolve: (e) => e.deprecationReason != null
		},
		deprecationReason: {
			type: GraphQLString,
			resolve: (e) => e.deprecationReason
		}
	})
}), __DirectiveLocation = new GraphQLEnumType({
	name: "__DirectiveLocation",
	description: "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",
	values: {
		QUERY: {
			value: DirectiveLocation.QUERY,
			description: "Location adjacent to a query operation."
		},
		MUTATION: {
			value: DirectiveLocation.MUTATION,
			description: "Location adjacent to a mutation operation."
		},
		SUBSCRIPTION: {
			value: DirectiveLocation.SUBSCRIPTION,
			description: "Location adjacent to a subscription operation."
		},
		FIELD: {
			value: DirectiveLocation.FIELD,
			description: "Location adjacent to a field."
		},
		FRAGMENT_DEFINITION: {
			value: DirectiveLocation.FRAGMENT_DEFINITION,
			description: "Location adjacent to a fragment definition."
		},
		FRAGMENT_SPREAD: {
			value: DirectiveLocation.FRAGMENT_SPREAD,
			description: "Location adjacent to a fragment spread."
		},
		INLINE_FRAGMENT: {
			value: DirectiveLocation.INLINE_FRAGMENT,
			description: "Location adjacent to an inline fragment."
		},
		VARIABLE_DEFINITION: {
			value: DirectiveLocation.VARIABLE_DEFINITION,
			description: "Location adjacent to a variable definition."
		},
		SCHEMA: {
			value: DirectiveLocation.SCHEMA,
			description: "Location adjacent to a schema definition."
		},
		SCALAR: {
			value: DirectiveLocation.SCALAR,
			description: "Location adjacent to a scalar definition."
		},
		OBJECT: {
			value: DirectiveLocation.OBJECT,
			description: "Location adjacent to an object type definition."
		},
		FIELD_DEFINITION: {
			value: DirectiveLocation.FIELD_DEFINITION,
			description: "Location adjacent to a field definition."
		},
		ARGUMENT_DEFINITION: {
			value: DirectiveLocation.ARGUMENT_DEFINITION,
			description: "Location adjacent to an argument definition."
		},
		INTERFACE: {
			value: DirectiveLocation.INTERFACE,
			description: "Location adjacent to an interface definition."
		},
		UNION: {
			value: DirectiveLocation.UNION,
			description: "Location adjacent to a union definition."
		},
		ENUM: {
			value: DirectiveLocation.ENUM,
			description: "Location adjacent to an enum definition."
		},
		ENUM_VALUE: {
			value: DirectiveLocation.ENUM_VALUE,
			description: "Location adjacent to an enum value definition."
		},
		INPUT_OBJECT: {
			value: DirectiveLocation.INPUT_OBJECT,
			description: "Location adjacent to an input object type definition."
		},
		INPUT_FIELD_DEFINITION: {
			value: DirectiveLocation.INPUT_FIELD_DEFINITION,
			description: "Location adjacent to an input object field definition."
		},
		DIRECTIVE_DEFINITION: {
			value: DirectiveLocation.DIRECTIVE_DEFINITION,
			description: "Location adjacent to a directive definition."
		}
	}
}), __Type = new GraphQLObjectType({
	name: "__Type",
	description: "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",
	fields: () => ({
		kind: {
			type: new GraphQLNonNull(__TypeKind),
			resolve(e) {
				if (isScalarType(e)) return TypeKind.SCALAR;
				if (isObjectType(e)) return TypeKind.OBJECT;
				if (isInterfaceType(e)) return TypeKind.INTERFACE;
				if (isUnionType(e)) return TypeKind.UNION;
				if (isEnumType(e)) return TypeKind.ENUM;
				if (isInputObjectType(e)) return TypeKind.INPUT_OBJECT;
				if (isListType(e)) return TypeKind.LIST;
				if (isNonNullType(e)) return TypeKind.NON_NULL;
				/* c8 ignore next 3 */
				invariant(!1, `Unexpected type: "${inspect(e)}".`);
			}
		},
		name: {
			type: GraphQLString,
			resolve: (e) => "name" in e ? e.name : void 0
		},
		description: {
			type: GraphQLString,
			resolve: (e) => "description" in e ? e.description : void 0
		},
		specifiedByURL: {
			type: GraphQLString,
			resolve: (e) => "specifiedByURL" in e ? e.specifiedByURL : void 0
		},
		fields: {
			type: new GraphQLList(new GraphQLNonNull(__Field)),
			args: { includeDeprecated: {
				type: GraphQLBoolean,
				defaultValue: !1
			} },
			resolve(e, { includeDeprecated: _ }) {
				if (isObjectType(e) || isInterfaceType(e)) {
					let v = Object.values(e.getFields());
					return _ ? v : v.filter((e) => e.deprecationReason == null);
				}
			}
		},
		interfaces: {
			type: new GraphQLList(new GraphQLNonNull(__Type)),
			resolve(e) {
				if (isObjectType(e) || isInterfaceType(e)) return e.getInterfaces();
			}
		},
		possibleTypes: {
			type: new GraphQLList(new GraphQLNonNull(__Type)),
			resolve(e, _, v, { schema: y }) {
				if (isAbstractType(e)) return y.getPossibleTypes(e);
			}
		},
		enumValues: {
			type: new GraphQLList(new GraphQLNonNull(__EnumValue)),
			args: { includeDeprecated: {
				type: GraphQLBoolean,
				defaultValue: !1
			} },
			resolve(e, { includeDeprecated: _ }) {
				if (isEnumType(e)) {
					let v = e.getValues();
					return _ ? v : v.filter((e) => e.deprecationReason == null);
				}
			}
		},
		inputFields: {
			type: new GraphQLList(new GraphQLNonNull(__InputValue)),
			args: { includeDeprecated: {
				type: GraphQLBoolean,
				defaultValue: !1
			} },
			resolve(e, { includeDeprecated: _ }) {
				if (isInputObjectType(e)) {
					let v = Object.values(e.getFields());
					return _ ? v : v.filter((e) => e.deprecationReason == null);
				}
			}
		},
		ofType: {
			type: __Type,
			resolve: (e) => "ofType" in e ? e.ofType : void 0
		},
		isOneOf: {
			type: GraphQLBoolean,
			resolve: (e) => {
				if (isInputObjectType(e)) return e.isOneOf;
			}
		}
	})
}), __Field = new GraphQLObjectType({
	name: "__Field",
	description: "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",
	fields: () => ({
		name: {
			type: new GraphQLNonNull(GraphQLString),
			resolve: (e) => e.name
		},
		description: {
			type: GraphQLString,
			resolve: (e) => e.description
		},
		args: {
			type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(__InputValue))),
			args: { includeDeprecated: {
				type: GraphQLBoolean,
				defaultValue: !1
			} },
			resolve(e, { includeDeprecated: _ }) {
				return _ ? e.args : e.args.filter((e) => e.deprecationReason == null);
			}
		},
		type: {
			type: new GraphQLNonNull(__Type),
			resolve: (e) => e.type
		},
		isDeprecated: {
			type: new GraphQLNonNull(GraphQLBoolean),
			resolve: (e) => e.deprecationReason != null
		},
		deprecationReason: {
			type: GraphQLString,
			resolve: (e) => e.deprecationReason
		}
	})
}), __InputValue = new GraphQLObjectType({
	name: "__InputValue",
	description: "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",
	fields: () => ({
		name: {
			type: new GraphQLNonNull(GraphQLString),
			resolve: (e) => e.name
		},
		description: {
			type: GraphQLString,
			resolve: (e) => e.description
		},
		type: {
			type: new GraphQLNonNull(__Type),
			resolve: (e) => e.type
		},
		defaultValue: {
			type: GraphQLString,
			description: "A GraphQL-formatted string representing the default value for this input value.",
			resolve(e) {
				let { type: _, defaultValue: v } = e, y = astFromValue(v, _);
				return y ? print(y) : null;
			}
		},
		isDeprecated: {
			type: new GraphQLNonNull(GraphQLBoolean),
			resolve: (e) => e.deprecationReason != null
		},
		deprecationReason: {
			type: GraphQLString,
			resolve: (e) => e.deprecationReason
		}
	})
}), __EnumValue = new GraphQLObjectType({
	name: "__EnumValue",
	description: "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",
	fields: () => ({
		name: {
			type: new GraphQLNonNull(GraphQLString),
			resolve: (e) => e.name
		},
		description: {
			type: GraphQLString,
			resolve: (e) => e.description
		},
		isDeprecated: {
			type: new GraphQLNonNull(GraphQLBoolean),
			resolve: (e) => e.deprecationReason != null
		},
		deprecationReason: {
			type: GraphQLString,
			resolve: (e) => e.deprecationReason
		}
	})
});
var TypeKind;
(function(e) {
	e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.INPUT_OBJECT = "INPUT_OBJECT", e.LIST = "LIST", e.NON_NULL = "NON_NULL";
})(TypeKind ||= {});
const __TypeKind = new GraphQLEnumType({
	name: "__TypeKind",
	description: "An enum describing what kind of type a given `__Type` is.",
	values: {
		SCALAR: {
			value: TypeKind.SCALAR,
			description: "Indicates this type is a scalar."
		},
		OBJECT: {
			value: TypeKind.OBJECT,
			description: "Indicates this type is an object. `fields` and `interfaces` are valid fields."
		},
		INTERFACE: {
			value: TypeKind.INTERFACE,
			description: "Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."
		},
		UNION: {
			value: TypeKind.UNION,
			description: "Indicates this type is a union. `possibleTypes` is a valid field."
		},
		ENUM: {
			value: TypeKind.ENUM,
			description: "Indicates this type is an enum. `enumValues` is a valid field."
		},
		INPUT_OBJECT: {
			value: TypeKind.INPUT_OBJECT,
			description: "Indicates this type is an input object. `inputFields` is a valid field."
		},
		LIST: {
			value: TypeKind.LIST,
			description: "Indicates this type is a list. `ofType` is a valid field."
		},
		NON_NULL: {
			value: TypeKind.NON_NULL,
			description: "Indicates this type is a non-null. `ofType` is a valid field."
		}
	}
}), SchemaMetaFieldDef = {
	name: "__schema",
	type: new GraphQLNonNull(__Schema),
	description: "Access the current type schema of this server.",
	args: [],
	resolve: (e, _, v, { schema: y }) => y,
	deprecationReason: void 0,
	extensions: Object.create(null),
	astNode: void 0
}, TypeMetaFieldDef = {
	name: "__type",
	type: __Type,
	description: "Request the type information of a single type.",
	args: [{
		name: "name",
		description: void 0,
		type: new GraphQLNonNull(GraphQLString),
		defaultValue: void 0,
		deprecationReason: void 0,
		extensions: Object.create(null),
		astNode: void 0
	}],
	resolve: (e, { name: _ }, v, { schema: y }) => y.getType(_),
	deprecationReason: void 0,
	extensions: Object.create(null),
	astNode: void 0
}, TypeNameMetaFieldDef = {
	name: "__typename",
	type: new GraphQLNonNull(GraphQLString),
	description: "The name of the current Object type at runtime.",
	args: [],
	resolve: (e, _, v, { parentType: y }) => y.name,
	deprecationReason: void 0,
	extensions: Object.create(null),
	astNode: void 0
}, introspectionTypes = Object.freeze([
	__Schema,
	__Directive,
	__DirectiveLocation,
	__Type,
	__Field,
	__InputValue,
	__EnumValue,
	__TypeKind
]);
function isIntrospectionType(e) {
	return introspectionTypes.some(({ name: _ }) => e.name === _);
}
function isSchema(e) {
	return instanceOf(e, GraphQLSchema);
}
function assertSchema(e) {
	if (!isSchema(e)) throw Error(`Expected ${inspect(e)} to be a GraphQL schema.`);
	return e;
}
var GraphQLSchema = class {
	constructor(e) {
		this.__validationErrors = e.assumeValid === !0 ? [] : void 0, isObjectLike(e) || devAssert(!1, "Must provide configuration object."), !e.types || Array.isArray(e.types) || devAssert(!1, `"types" must be Array if provided but got: ${inspect(e.types)}.`), !e.directives || Array.isArray(e.directives) || devAssert(!1, `"directives" must be Array if provided but got: ${inspect(e.directives)}.`), this.description = e.description, this.extensions = toObjMap(e.extensions), this.astNode = e.astNode, this.extensionASTNodes = e.extensionASTNodes ?? [], this._queryType = e.query, this._mutationType = e.mutation, this._subscriptionType = e.subscription, this._directives = e.directives ?? specifiedDirectives;
		let _ = new Set(e.types);
		if (e.types != null) for (let v of e.types) _.delete(v), collectReferencedTypes(v, _);
		this._queryType != null && collectReferencedTypes(this._queryType, _), this._mutationType != null && collectReferencedTypes(this._mutationType, _), this._subscriptionType != null && collectReferencedTypes(this._subscriptionType, _);
		for (let e of this._directives) if (isDirective(e)) for (let v of e.args) collectReferencedTypes(v.type, _);
		collectReferencedTypes(__Schema, _), this._typeMap = Object.create(null), this._subTypeMap = Object.create(null), this._implementationsMap = Object.create(null);
		for (let e of _) {
			if (e == null) continue;
			let _ = e.name;
			if (_ || devAssert(!1, "One of the provided types for building the Schema is missing a name."), this._typeMap[_] !== void 0) throw Error(`Schema must contain uniquely named types but contains multiple types named "${_}".`);
			if (this._typeMap[_] = e, isInterfaceType(e)) {
				for (let _ of e.getInterfaces()) if (isInterfaceType(_)) {
					let v = this._implementationsMap[_.name];
					v === void 0 && (v = this._implementationsMap[_.name] = {
						objects: [],
						interfaces: []
					}), v.interfaces.push(e);
				}
			} else if (isObjectType(e)) {
				for (let _ of e.getInterfaces()) if (isInterfaceType(_)) {
					let v = this._implementationsMap[_.name];
					v === void 0 && (v = this._implementationsMap[_.name] = {
						objects: [],
						interfaces: []
					}), v.objects.push(e);
				}
			}
		}
	}
	get [Symbol.toStringTag]() {
		return "GraphQLSchema";
	}
	getQueryType() {
		return this._queryType;
	}
	getMutationType() {
		return this._mutationType;
	}
	getSubscriptionType() {
		return this._subscriptionType;
	}
	getRootType(e) {
		switch (e) {
			case OperationTypeNode.QUERY: return this.getQueryType();
			case OperationTypeNode.MUTATION: return this.getMutationType();
			case OperationTypeNode.SUBSCRIPTION: return this.getSubscriptionType();
		}
	}
	getTypeMap() {
		return this._typeMap;
	}
	getType(e) {
		return this.getTypeMap()[e];
	}
	getPossibleTypes(e) {
		return isUnionType(e) ? e.getTypes() : this.getImplementations(e).objects;
	}
	getImplementations(e) {
		return this._implementationsMap[e.name] ?? {
			objects: [],
			interfaces: []
		};
	}
	isSubType(e, _) {
		let v = this._subTypeMap[e.name];
		if (v === void 0) {
			if (v = Object.create(null), isUnionType(e)) for (let _ of e.getTypes()) v[_.name] = !0;
			else {
				let _ = this.getImplementations(e);
				for (let e of _.objects) v[e.name] = !0;
				for (let e of _.interfaces) v[e.name] = !0;
			}
			this._subTypeMap[e.name] = v;
		}
		return v[_.name] !== void 0;
	}
	getDirectives() {
		return this._directives;
	}
	getDirective(e) {
		return this.getDirectives().find((_) => _.name === e);
	}
	toConfig() {
		return {
			description: this.description,
			query: this.getQueryType(),
			mutation: this.getMutationType(),
			subscription: this.getSubscriptionType(),
			types: Object.values(this.getTypeMap()),
			directives: this.getDirectives(),
			extensions: this.extensions,
			astNode: this.astNode,
			extensionASTNodes: this.extensionASTNodes,
			assumeValid: this.__validationErrors !== void 0
		};
	}
};
function collectReferencedTypes(e, _) {
	let v = getNamedType(e);
	if (!_.has(v)) {
		if (_.add(v), isUnionType(v)) for (let e of v.getTypes()) collectReferencedTypes(e, _);
		else if (isObjectType(v) || isInterfaceType(v)) {
			for (let e of v.getInterfaces()) collectReferencedTypes(e, _);
			for (let e of Object.values(v.getFields())) {
				collectReferencedTypes(e.type, _);
				for (let v of e.args) collectReferencedTypes(v.type, _);
			}
		} else if (isInputObjectType(v)) for (let e of Object.values(v.getFields())) collectReferencedTypes(e.type, _);
	}
	return _;
}
function validateSchema(e) {
	if (assertSchema(e), e.__validationErrors) return e.__validationErrors;
	let _ = new SchemaValidationContext(e);
	validateRootTypes(_), validateDirectives(_), validateTypes(_);
	let v = _.getErrors();
	return e.__validationErrors = v, v;
}
function assertValidSchema(e) {
	let _ = validateSchema(e);
	if (_.length !== 0) throw Error(_.map((e) => e.message).join("\n\n"));
}
var SchemaValidationContext = class {
	constructor(e) {
		this._errors = [], this.schema = e;
	}
	reportError(e, _) {
		let v = Array.isArray(_) ? _.filter(Boolean) : _;
		this._errors.push(new GraphQLError(e, { nodes: v }));
	}
	getErrors() {
		return this._errors;
	}
};
function validateRootTypes(e) {
	let _ = e.schema, v = _.getQueryType();
	v ? isObjectType(v) || e.reportError(`Query root type must be Object type, it cannot be ${inspect(v)}.`, getOperationTypeNode(_, OperationTypeNode.QUERY) ?? v.astNode) : e.reportError("Query root type must be provided.", _.astNode);
	let y = _.getMutationType();
	y && !isObjectType(y) && e.reportError(`Mutation root type must be Object type if provided, it cannot be ${inspect(y)}.`, getOperationTypeNode(_, OperationTypeNode.MUTATION) ?? y.astNode);
	let b = _.getSubscriptionType();
	b && !isObjectType(b) && e.reportError(`Subscription root type must be Object type if provided, it cannot be ${inspect(b)}.`, getOperationTypeNode(_, OperationTypeNode.SUBSCRIPTION) ?? b.astNode);
}
function getOperationTypeNode(e, _) {
	return [e.astNode, ...e.extensionASTNodes].flatMap((e) => e?.operationTypes ?? []).find((e) => e.operation === _)?.type;
}
function validateDirectives(e) {
	for (let _ of e.schema.getDirectives()) {
		if (!isDirective(_)) {
			e.reportError(`Expected directive but got: ${inspect(_)}.`, _?.astNode);
			continue;
		}
		validateName(e, _), _.locations.length === 0 && e.reportError(`Directive @${_.name} must include 1 or more locations.`, _.astNode);
		for (let v of _.args) validateName(e, v), isInputType(v.type) || e.reportError(`The type of @${_.name}(${v.name}:) must be Input Type but got: ${inspect(v.type)}.`, v.astNode), isRequiredArgument(v) && v.deprecationReason != null && e.reportError(`Required argument @${_.name}(${v.name}:) cannot be deprecated.`, [getDeprecatedDirectiveNode(v.astNode), v.astNode?.type]);
	}
}
function validateName(e, _) {
	_.name.startsWith("__") && e.reportError(`Name "${_.name}" must not begin with "__", which is reserved by GraphQL introspection.`, _.astNode);
}
function validateTypes(e) {
	let _ = createInputObjectCircularRefsValidator(e), v = e.schema.getTypeMap();
	for (let y of Object.values(v)) {
		if (!isNamedType(y)) {
			e.reportError(`Expected GraphQL named type but got: ${inspect(y)}.`, y.astNode);
			continue;
		}
		isIntrospectionType(y) || validateName(e, y), isObjectType(y) || isInterfaceType(y) ? (validateFields(e, y), validateInterfaces(e, y)) : isUnionType(y) ? validateUnionMembers(e, y) : isEnumType(y) ? validateEnumValues(e, y) : isInputObjectType(y) && (validateInputFields(e, y), _(y));
	}
}
function validateFields(e, _) {
	let v = Object.values(_.getFields());
	v.length === 0 && e.reportError(`Type ${_.name} must define one or more fields.`, [_.astNode, ..._.extensionASTNodes]);
	for (let y of v) {
		validateName(e, y), !isOutputType(y.type) && e.reportError(`The type of ${_.name}.${y.name} must be Output Type but got: ${inspect(y.type)}.`, y.astNode?.type);
		for (let v of y.args) {
			let b = v.name;
			validateName(e, v), !isInputType(v.type) && e.reportError(`The type of ${_.name}.${y.name}(${b}:) must be Input Type but got: ${inspect(v.type)}.`, v.astNode?.type), isRequiredArgument(v) && v.deprecationReason != null && e.reportError(`Required argument ${_.name}.${y.name}(${b}:) cannot be deprecated.`, [getDeprecatedDirectiveNode(v.astNode), v.astNode?.type]);
		}
	}
}
function validateInterfaces(e, _) {
	let v = Object.create(null);
	for (let y of _.getInterfaces()) {
		if (!isInterfaceType(y)) {
			e.reportError(`Type ${inspect(_)} must only implement Interface types, it cannot implement ${inspect(y)}.`, getAllImplementsInterfaceNodes(_, y));
			continue;
		}
		if (_ === y) {
			e.reportError(`Type ${_.name} cannot implement itself because it would create a circular reference.`, getAllImplementsInterfaceNodes(_, y));
			continue;
		}
		if (v[y.name]) {
			e.reportError(`Type ${_.name} can only implement ${y.name} once.`, getAllImplementsInterfaceNodes(_, y));
			continue;
		}
		v[y.name] = !0, validateTypeImplementsAncestors(e, _, y), validateTypeImplementsInterface(e, _, y);
	}
}
function validateTypeImplementsInterface(e, _, v) {
	let y = _.getFields();
	for (let b of Object.values(v.getFields())) {
		let x = b.name, S = y[x];
		if (!S) {
			e.reportError(`Interface field ${v.name}.${x} expected but ${_.name} does not provide it.`, [
				b.astNode,
				_.astNode,
				..._.extensionASTNodes
			]);
			continue;
		}
		isTypeSubTypeOf(e.schema, S.type, b.type) || e.reportError(`Interface field ${v.name}.${x} expects type ${inspect(b.type)} but ${_.name}.${x} is type ${inspect(S.type)}.`, [b.astNode?.type, S.astNode?.type]);
		for (let y of b.args) {
			let b = y.name, C = S.args.find((e) => e.name === b);
			if (!C) {
				e.reportError(`Interface field argument ${v.name}.${x}(${b}:) expected but ${_.name}.${x} does not provide it.`, [y.astNode, S.astNode]);
				continue;
			}
			isEqualType(y.type, C.type) || e.reportError(`Interface field argument ${v.name}.${x}(${b}:) expects type ${inspect(y.type)} but ${_.name}.${x}(${b}:) is type ${inspect(C.type)}.`, [y.astNode?.type, C.astNode?.type]);
		}
		for (let y of S.args) {
			let S = y.name;
			!b.args.find((e) => e.name === S) && isRequiredArgument(y) && e.reportError(`Object field ${_.name}.${x} includes required argument ${S} that is missing from the Interface field ${v.name}.${x}.`, [y.astNode, b.astNode]);
		}
	}
}
function validateTypeImplementsAncestors(e, _, v) {
	let y = _.getInterfaces();
	for (let b of v.getInterfaces()) y.includes(b) || e.reportError(b === _ ? `Type ${_.name} cannot implement ${v.name} because it would create a circular reference.` : `Type ${_.name} must implement ${b.name} because it is implemented by ${v.name}.`, [...getAllImplementsInterfaceNodes(v, b), ...getAllImplementsInterfaceNodes(_, v)]);
}
function validateUnionMembers(e, _) {
	let v = _.getTypes();
	v.length === 0 && e.reportError(`Union type ${_.name} must define one or more member types.`, [_.astNode, ..._.extensionASTNodes]);
	let y = Object.create(null);
	for (let b of v) {
		if (y[b.name]) {
			e.reportError(`Union type ${_.name} can only include type ${b.name} once.`, getUnionMemberTypeNodes(_, b.name));
			continue;
		}
		y[b.name] = !0, isObjectType(b) || e.reportError(`Union type ${_.name} can only include Object types, it cannot include ${inspect(b)}.`, getUnionMemberTypeNodes(_, String(b)));
	}
}
function validateEnumValues(e, _) {
	let v = _.getValues();
	v.length === 0 && e.reportError(`Enum type ${_.name} must define one or more values.`, [_.astNode, ..._.extensionASTNodes]);
	for (let _ of v) validateName(e, _);
}
function validateInputFields(e, _) {
	let v = Object.values(_.getFields());
	v.length === 0 && e.reportError(`Input Object type ${_.name} must define one or more fields.`, [_.astNode, ..._.extensionASTNodes]);
	for (let y of v) validateName(e, y), !isInputType(y.type) && e.reportError(`The type of ${_.name}.${y.name} must be Input Type but got: ${inspect(y.type)}.`, y.astNode?.type), isRequiredInputField(y) && y.deprecationReason != null && e.reportError(`Required input field ${_.name}.${y.name} cannot be deprecated.`, [getDeprecatedDirectiveNode(y.astNode), y.astNode?.type]), _.isOneOf && validateOneOfInputObjectField(_, y, e);
}
function validateOneOfInputObjectField(e, _, v) {
	isNonNullType(_.type) && v.reportError(`OneOf input field ${e.name}.${_.name} must be nullable.`, _.astNode?.type), _.defaultValue !== void 0 && v.reportError(`OneOf input field ${e.name}.${_.name} cannot have a default value.`, _.astNode);
}
function createInputObjectCircularRefsValidator(e) {
	let _ = Object.create(null), v = [], y = Object.create(null);
	return b;
	function b(x) {
		if (_[x.name]) return;
		_[x.name] = !0, y[x.name] = v.length;
		let S = Object.values(x.getFields());
		for (let _ of S) if (isNonNullType(_.type) && isInputObjectType(_.type.ofType)) {
			let x = _.type.ofType, S = y[x.name];
			if (v.push(_), S === void 0) b(x);
			else {
				let _ = v.slice(S), y = _.map((e) => e.name).join(".");
				e.reportError(`Cannot reference Input Object "${x.name}" within itself through a series of non-null fields: "${y}".`, _.map((e) => e.astNode));
			}
			v.pop();
		}
		y[x.name] = void 0;
	}
}
function getAllImplementsInterfaceNodes(e, _) {
	let { astNode: v, extensionASTNodes: y } = e;
	return (v == null ? y : [v, ...y]).flatMap((e) => e.interfaces ?? []).filter((e) => e.name.value === _.name);
}
function getUnionMemberTypeNodes(e, _) {
	let { astNode: v, extensionASTNodes: y } = e;
	return (v == null ? y : [v, ...y]).flatMap((e) => e.types ?? []).filter((e) => e.name.value === _);
}
function getDeprecatedDirectiveNode(e) {
	return e?.directives?.find((e) => e.name.value === GraphQLDeprecatedDirective.name);
}
function typeFromAST(e, _) {
	switch (_.kind) {
		case Kind.LIST_TYPE: {
			let v = typeFromAST(e, _.type);
			return v && new GraphQLList(v);
		}
		case Kind.NON_NULL_TYPE: {
			let v = typeFromAST(e, _.type);
			return v && new GraphQLNonNull(v);
		}
		case Kind.NAMED_TYPE: return e.getType(_.name.value);
	}
}
var TypeInfo = class {
	constructor(e, _, v) {
		this._schema = e, this._typeStack = [], this._parentTypeStack = [], this._inputTypeStack = [], this._fieldDefStack = [], this._defaultValueStack = [], this._directive = null, this._argument = null, this._enumValue = null, this._getFieldDef = v ?? getFieldDef$1, _ && (isInputType(_) && this._inputTypeStack.push(_), isCompositeType(_) && this._parentTypeStack.push(_), isOutputType(_) && this._typeStack.push(_));
	}
	get [Symbol.toStringTag]() {
		return "TypeInfo";
	}
	getType() {
		if (this._typeStack.length > 0) return this._typeStack[this._typeStack.length - 1];
	}
	getParentType() {
		if (this._parentTypeStack.length > 0) return this._parentTypeStack[this._parentTypeStack.length - 1];
	}
	getInputType() {
		if (this._inputTypeStack.length > 0) return this._inputTypeStack[this._inputTypeStack.length - 1];
	}
	getParentInputType() {
		if (this._inputTypeStack.length > 1) return this._inputTypeStack[this._inputTypeStack.length - 2];
	}
	getFieldDef() {
		if (this._fieldDefStack.length > 0) return this._fieldDefStack[this._fieldDefStack.length - 1];
	}
	getDefaultValue() {
		if (this._defaultValueStack.length > 0) return this._defaultValueStack[this._defaultValueStack.length - 1];
	}
	getDirective() {
		return this._directive;
	}
	getArgument() {
		return this._argument;
	}
	getEnumValue() {
		return this._enumValue;
	}
	enter(e) {
		let _ = this._schema;
		switch (e.kind) {
			case Kind.SELECTION_SET: {
				let e = getNamedType(this.getType());
				this._parentTypeStack.push(isCompositeType(e) ? e : void 0);
				break;
			}
			case Kind.FIELD: {
				let v = this.getParentType(), y, b;
				v && (y = this._getFieldDef(_, v, e), y && (b = y.type)), this._fieldDefStack.push(y), this._typeStack.push(isOutputType(b) ? b : void 0);
				break;
			}
			case Kind.DIRECTIVE:
				this._directive = _.getDirective(e.name.value);
				break;
			case Kind.OPERATION_DEFINITION: {
				let v = _.getRootType(e.operation);
				this._typeStack.push(isObjectType(v) ? v : void 0);
				break;
			}
			case Kind.INLINE_FRAGMENT:
			case Kind.FRAGMENT_DEFINITION: {
				let v = e.typeCondition, y = v ? typeFromAST(_, v) : getNamedType(this.getType());
				this._typeStack.push(isOutputType(y) ? y : void 0);
				break;
			}
			case Kind.VARIABLE_DEFINITION: {
				let v = typeFromAST(_, e.type);
				this._inputTypeStack.push(isInputType(v) ? v : void 0);
				break;
			}
			case Kind.ARGUMENT: {
				let _, v, y = this.getDirective() ?? this.getFieldDef();
				y && (_ = y.args.find((_) => _.name === e.name.value), _ && (v = _.type)), this._argument = _, this._defaultValueStack.push(_ ? _.defaultValue : void 0), this._inputTypeStack.push(isInputType(v) ? v : void 0);
				break;
			}
			case Kind.LIST: {
				let e = getNullableType(this.getInputType()), _ = isListType(e) ? e.ofType : e;
				this._defaultValueStack.push(void 0), this._inputTypeStack.push(isInputType(_) ? _ : void 0);
				break;
			}
			case Kind.OBJECT_FIELD: {
				let _ = getNamedType(this.getInputType()), v, y;
				isInputObjectType(_) && (y = _.getFields()[e.name.value], y && (v = y.type)), this._defaultValueStack.push(y ? y.defaultValue : void 0), this._inputTypeStack.push(isInputType(v) ? v : void 0);
				break;
			}
			case Kind.ENUM: {
				let _ = getNamedType(this.getInputType()), v;
				isEnumType(_) && (v = _.getValue(e.value)), this._enumValue = v;
				break;
			}
			default:
		}
	}
	leave(e) {
		switch (e.kind) {
			case Kind.SELECTION_SET:
				this._parentTypeStack.pop();
				break;
			case Kind.FIELD:
				this._fieldDefStack.pop(), this._typeStack.pop();
				break;
			case Kind.DIRECTIVE:
				this._directive = null;
				break;
			case Kind.OPERATION_DEFINITION:
			case Kind.INLINE_FRAGMENT:
			case Kind.FRAGMENT_DEFINITION:
				this._typeStack.pop();
				break;
			case Kind.VARIABLE_DEFINITION:
				this._inputTypeStack.pop();
				break;
			case Kind.ARGUMENT:
				this._argument = null, this._defaultValueStack.pop(), this._inputTypeStack.pop();
				break;
			case Kind.LIST:
			case Kind.OBJECT_FIELD:
				this._defaultValueStack.pop(), this._inputTypeStack.pop();
				break;
			case Kind.ENUM:
				this._enumValue = null;
				break;
			default:
		}
	}
};
function getFieldDef$1(e, _, v) {
	let y = v.name.value;
	if (y === SchemaMetaFieldDef.name && e.getQueryType() === _) return SchemaMetaFieldDef;
	if (y === TypeMetaFieldDef.name && e.getQueryType() === _) return TypeMetaFieldDef;
	if (y === TypeNameMetaFieldDef.name && isCompositeType(_)) return TypeNameMetaFieldDef;
	if (isObjectType(_) || isInterfaceType(_)) return _.getFields()[y];
}
function visitWithTypeInfo(e, _) {
	return {
		enter(...v) {
			let y = v[0];
			e.enter(y);
			let b = getEnterLeaveForKind(_, y.kind).enter;
			if (b) {
				let x = b.apply(_, v);
				return x !== void 0 && (e.leave(y), isNode(x) && e.enter(x)), x;
			}
		},
		leave(...v) {
			let y = v[0], b = getEnterLeaveForKind(_, y.kind).leave, x;
			return b && (x = b.apply(_, v)), e.leave(y), x;
		}
	};
}
function isExecutableDefinitionNode(e) {
	return e.kind === Kind.OPERATION_DEFINITION || e.kind === Kind.FRAGMENT_DEFINITION;
}
function isTypeSystemDefinitionNode(e) {
	return e.kind === Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(e) || e.kind === Kind.DIRECTIVE_DEFINITION;
}
function isTypeDefinitionNode(e) {
	return e.kind === Kind.SCALAR_TYPE_DEFINITION || e.kind === Kind.OBJECT_TYPE_DEFINITION || e.kind === Kind.INTERFACE_TYPE_DEFINITION || e.kind === Kind.UNION_TYPE_DEFINITION || e.kind === Kind.ENUM_TYPE_DEFINITION || e.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;
}
function isTypeSystemExtensionNode(e) {
	return e.kind === Kind.SCHEMA_EXTENSION || e.kind === Kind.DIRECTIVE_EXTENSION || isTypeExtensionNode(e);
}
function isTypeExtensionNode(e) {
	return e.kind === Kind.SCALAR_TYPE_EXTENSION || e.kind === Kind.OBJECT_TYPE_EXTENSION || e.kind === Kind.INTERFACE_TYPE_EXTENSION || e.kind === Kind.UNION_TYPE_EXTENSION || e.kind === Kind.ENUM_TYPE_EXTENSION || e.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;
}
function ExecutableDefinitionsRule(e) {
	return { Document(_) {
		for (let v of _.definitions) if (!isExecutableDefinitionNode(v)) {
			let _ = v.kind === Kind.SCHEMA_DEFINITION || v.kind === Kind.SCHEMA_EXTENSION ? "schema" : "\"" + v.name.value + "\"";
			e.reportError(new GraphQLError(`The ${_} definition is not executable.`, { nodes: v }));
		}
		return !1;
	} };
}
function FieldsOnCorrectTypeRule(e) {
	return { Field(_) {
		let v = e.getParentType();
		if (v && !e.getFieldDef()) {
			let y = e.getSchema(), b = _.name.value, x = didYouMean("to use an inline fragment on", getSuggestedTypeNames(y, v, b));
			x === "" && (x = didYouMean(getSuggestedFieldNames(v, b))), e.reportError(new GraphQLError(`Cannot query field "${b}" on type "${v.name}".` + x, { nodes: _ }));
		}
	} };
}
function getSuggestedTypeNames(e, _, v) {
	if (!isAbstractType(_)) return [];
	let y = /* @__PURE__ */ new Set(), b = Object.create(null);
	for (let x of e.getPossibleTypes(_)) if (x.getFields()[v]) {
		y.add(x), b[x.name] = 1;
		for (let e of x.getInterfaces()) e.getFields()[v] && (y.add(e), b[e.name] = (b[e.name] ?? 0) + 1);
	}
	return [...y].sort((_, v) => {
		let y = b[v.name] - b[_.name];
		return y === 0 ? isInterfaceType(_) && e.isSubType(_, v) ? -1 : isInterfaceType(v) && e.isSubType(v, _) ? 1 : naturalCompare(_.name, v.name) : y;
	}).map((e) => e.name);
}
function getSuggestedFieldNames(e, _) {
	if (isObjectType(e) || isInterfaceType(e)) {
		let v = Object.keys(e.getFields());
		return suggestionList(_, v);
	}
	return [];
}
function FragmentsOnCompositeTypesRule(e) {
	return {
		InlineFragment(_) {
			let v = _.typeCondition;
			if (v) {
				let _ = typeFromAST(e.getSchema(), v);
				if (_ && !isCompositeType(_)) {
					let _ = print(v);
					e.reportError(new GraphQLError(`Fragment cannot condition on non composite type "${_}".`, { nodes: v }));
				}
			}
		},
		FragmentDefinition(_) {
			let v = typeFromAST(e.getSchema(), _.typeCondition);
			if (v && !isCompositeType(v)) {
				let v = print(_.typeCondition);
				e.reportError(new GraphQLError(`Fragment "${_.name.value}" cannot condition on non composite type "${v}".`, { nodes: _.typeCondition }));
			}
		}
	};
}
function KnownArgumentNamesRule(e) {
	return {
		...KnownArgumentNamesOnDirectivesRule(e),
		Argument(_) {
			let v = e.getArgument(), y = e.getFieldDef(), b = e.getParentType();
			if (!v && y && b) {
				let v = _.name.value, x = y.args.map((e) => e.name), S = suggestionList(v, x);
				e.reportError(new GraphQLError(`Unknown argument "${v}" on field "${b.name}.${y.name}".` + didYouMean(S), { nodes: _ }));
			}
		}
	};
}
function KnownArgumentNamesOnDirectivesRule(e) {
	let _ = Object.create(null), v = e.getSchema(), y = v ? v.getDirectives() : specifiedDirectives;
	for (let e of y) _[e.name] = e.args.map((e) => e.name);
	let b = e.getDocument().definitions;
	for (let e of b) if (e.kind === Kind.DIRECTIVE_DEFINITION) {
		/* c8 ignore next */
		let v = e.arguments ?? [];
		_[e.name.value] = v.map((e) => e.name.value);
	}
	return { Directive(v) {
		let y = v.name.value, b = _[y];
		if (v.arguments && b) for (let _ of v.arguments) {
			let v = _.name.value;
			if (!b.includes(v)) {
				let x = suggestionList(v, b);
				e.reportError(new GraphQLError(`Unknown argument "${v}" on directive "@${y}".` + didYouMean(x), { nodes: _ }));
			}
		}
		return !1;
	} };
}
function KnownDirectivesRule(e) {
	let _ = Object.create(null), v = e.getSchema(), y = v ? v.getDirectives() : specifiedDirectives;
	for (let e of y) _[e.name] = e.locations;
	let b = e.getDocument().definitions;
	for (let e of b) e.kind === Kind.DIRECTIVE_DEFINITION && (_[e.name.value] = e.locations.map((e) => e.value));
	return { Directive(v, y, b, x, S) {
		let C = v.name.value, w = _[C];
		if (!w) {
			e.reportError(new GraphQLError(`Unknown directive "@${C}".`, { nodes: v }));
			return;
		}
		let T = getDirectiveLocationForASTPath(S);
		T && !w.includes(T) && e.reportError(new GraphQLError(`Directive "@${C}" may not be used on ${T}.`, { nodes: v }));
	} };
}
function getDirectiveLocationForASTPath(e) {
	let _ = e[e.length - 1];
	switch ("kind" in _ || invariant(!1), _.kind) {
		case Kind.OPERATION_DEFINITION: return getDirectiveLocationForOperation(_.operation);
		case Kind.FIELD: return DirectiveLocation.FIELD;
		case Kind.FRAGMENT_SPREAD: return DirectiveLocation.FRAGMENT_SPREAD;
		case Kind.INLINE_FRAGMENT: return DirectiveLocation.INLINE_FRAGMENT;
		case Kind.FRAGMENT_DEFINITION: return DirectiveLocation.FRAGMENT_DEFINITION;
		case Kind.VARIABLE_DEFINITION: return DirectiveLocation.VARIABLE_DEFINITION;
		case Kind.SCHEMA_DEFINITION:
		case Kind.SCHEMA_EXTENSION: return DirectiveLocation.SCHEMA;
		case Kind.SCALAR_TYPE_DEFINITION:
		case Kind.SCALAR_TYPE_EXTENSION: return DirectiveLocation.SCALAR;
		case Kind.OBJECT_TYPE_DEFINITION:
		case Kind.OBJECT_TYPE_EXTENSION: return DirectiveLocation.OBJECT;
		case Kind.FIELD_DEFINITION: return DirectiveLocation.FIELD_DEFINITION;
		case Kind.INTERFACE_TYPE_DEFINITION:
		case Kind.INTERFACE_TYPE_EXTENSION: return DirectiveLocation.INTERFACE;
		case Kind.UNION_TYPE_DEFINITION:
		case Kind.UNION_TYPE_EXTENSION: return DirectiveLocation.UNION;
		case Kind.ENUM_TYPE_DEFINITION:
		case Kind.ENUM_TYPE_EXTENSION: return DirectiveLocation.ENUM;
		case Kind.ENUM_VALUE_DEFINITION: return DirectiveLocation.ENUM_VALUE;
		case Kind.INPUT_OBJECT_TYPE_DEFINITION:
		case Kind.INPUT_OBJECT_TYPE_EXTENSION: return DirectiveLocation.INPUT_OBJECT;
		case Kind.INPUT_VALUE_DEFINITION: {
			let _ = e[e.length - 3];
			return "kind" in _ || invariant(!1), _.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? DirectiveLocation.INPUT_FIELD_DEFINITION : DirectiveLocation.ARGUMENT_DEFINITION;
		}
		case Kind.DIRECTIVE_DEFINITION:
		case Kind.DIRECTIVE_EXTENSION: return DirectiveLocation.DIRECTIVE_DEFINITION;
		default: invariant(!1, "Unexpected kind: " + inspect(_.kind));
	}
}
function getDirectiveLocationForOperation(e) {
	switch (e) {
		case OperationTypeNode.QUERY: return DirectiveLocation.QUERY;
		case OperationTypeNode.MUTATION: return DirectiveLocation.MUTATION;
		case OperationTypeNode.SUBSCRIPTION: return DirectiveLocation.SUBSCRIPTION;
	}
}
function KnownFragmentNamesRule(e) {
	return { FragmentSpread(_) {
		let v = _.name.value;
		e.getFragment(v) || e.reportError(new GraphQLError(`Unknown fragment "${v}".`, { nodes: _.name }));
	} };
}
function KnownTypeNamesRule(e) {
	let _ = e.getSchema(), v = _ ? _.getTypeMap() : Object.create(null), y = Object.create(null);
	for (let _ of e.getDocument().definitions) isTypeDefinitionNode(_) && (y[_.name.value] = !0);
	let b = [...Object.keys(v), ...Object.keys(y)];
	return { NamedType(_, x, S, C, w) {
		let T = _.name.value;
		if (!v[T] && !y[T]) {
			let v = w[2] ?? S, y = v != null && isSDLNode(v);
			if (y && standardTypeNames.includes(T)) return;
			let x = suggestionList(T, y ? standardTypeNames.concat(b) : b);
			e.reportError(new GraphQLError(`Unknown type "${T}".` + didYouMean(x), { nodes: _ }));
		}
	} };
}
var standardTypeNames = [...specifiedScalarTypes, ...introspectionTypes].map((e) => e.name);
function isSDLNode(e) {
	return "kind" in e && (isTypeSystemDefinitionNode(e) || isTypeSystemExtensionNode(e));
}
function LoneAnonymousOperationRule(e) {
	let _ = 0;
	return {
		Document(e) {
			_ = e.definitions.filter((e) => e.kind === Kind.OPERATION_DEFINITION).length;
		},
		OperationDefinition(v) {
			!v.name && _ > 1 && e.reportError(new GraphQLError("This anonymous operation must be the only defined operation.", { nodes: v }));
		}
	};
}
function LoneSchemaDefinitionRule(e) {
	let _ = e.getSchema(), v = _?.astNode ?? _?.getQueryType() ?? _?.getMutationType() ?? _?.getSubscriptionType(), y = 0;
	return { SchemaDefinition(_) {
		if (v) {
			e.reportError(new GraphQLError("Cannot define a new schema within a schema extension.", { nodes: _ }));
			return;
		}
		y > 0 && e.reportError(new GraphQLError("Must provide only one schema definition.", { nodes: _ })), ++y;
	} };
}
var MAX_LISTS_DEPTH = 3;
function MaxIntrospectionDepthRule(e) {
	function _(v, y = Object.create(null), b = 0) {
		if (v.kind === Kind.FRAGMENT_SPREAD) {
			let x = v.name.value;
			if (y[x] === !0) return !1;
			let S = e.getFragment(x);
			if (!S) return !1;
			try {
				return y[x] = !0, _(S, y, b);
			} finally {
				y[x] = void 0;
			}
		}
		if (v.kind === Kind.FIELD && (v.name.value === "fields" || v.name.value === "interfaces" || v.name.value === "possibleTypes" || v.name.value === "inputFields") && (b++, b >= MAX_LISTS_DEPTH)) return !0;
		if ("selectionSet" in v && v.selectionSet) {
			for (let e of v.selectionSet.selections) if (_(e, y, b)) return !0;
		}
		return !1;
	}
	return { Field(v) {
		if ((v.name.value === "__schema" || v.name.value === "__type") && _(v)) return e.reportError(new GraphQLError("Maximum introspection depth exceeded", { nodes: [v] })), !1;
	} };
}
function NoFragmentCyclesRule(e) {
	let _ = Object.create(null), v = [], y = Object.create(null);
	return {
		OperationDefinition: () => !1,
		FragmentDefinition(e) {
			return b(e), !1;
		}
	};
	function b(x) {
		if (_[x.name.value]) return;
		let S = x.name.value;
		_[S] = !0;
		let C = e.getFragmentSpreads(x.selectionSet);
		if (C.length !== 0) {
			y[S] = v.length;
			for (let _ of C) {
				let x = _.name.value, S = y[x];
				if (v.push(_), S === void 0) {
					let _ = e.getFragment(x);
					_ && b(_);
				} else {
					let _ = v.slice(S), y = _.slice(0, -1).map((e) => "\"" + e.name.value + "\"").join(", ");
					e.reportError(new GraphQLError(`Cannot spread fragment "${x}" within itself` + (y === "" ? "." : ` via ${y}.`), { nodes: _ }));
				}
				v.pop();
			}
			y[S] = void 0;
		}
	}
}
function NoUndefinedVariablesRule(e) {
	let _ = Object.create(null);
	return {
		OperationDefinition: {
			enter() {
				_ = Object.create(null);
			},
			leave(v) {
				let y = e.getRecursiveVariableUsages(v);
				for (let { node: b } of y) {
					let y = b.name.value;
					_[y] !== !0 && e.reportError(new GraphQLError(v.name ? `Variable "$${y}" is not defined by operation "${v.name.value}".` : `Variable "$${y}" is not defined.`, { nodes: [b, v] }));
				}
			}
		},
		VariableDefinition(e) {
			_[e.variable.name.value] = !0;
		}
	};
}
function NoUnusedFragmentsRule(e) {
	let _ = [], v = [];
	return {
		OperationDefinition(e) {
			return _.push(e), !1;
		},
		FragmentDefinition(e) {
			return v.push(e), !1;
		},
		Document: { leave() {
			let y = Object.create(null);
			for (let v of _) for (let _ of e.getRecursivelyReferencedFragments(v)) y[_.name.value] = !0;
			for (let _ of v) {
				let v = _.name.value;
				y[v] !== !0 && e.reportError(new GraphQLError(`Fragment "${v}" is never used.`, { nodes: _ }));
			}
		} }
	};
}
function NoUnusedVariablesRule(e) {
	let _ = [];
	return {
		OperationDefinition: {
			enter() {
				_ = [];
			},
			leave(v) {
				let y = Object.create(null), b = e.getRecursiveVariableUsages(v);
				for (let { node: e } of b) y[e.name.value] = !0;
				for (let b of _) {
					let _ = b.variable.name.value;
					y[_] !== !0 && e.reportError(new GraphQLError(v.name ? `Variable "$${_}" is never used in operation "${v.name.value}".` : `Variable "$${_}" is never used.`, { nodes: b }));
				}
			}
		},
		VariableDefinition(e) {
			_.push(e);
		}
	};
}
function sortValueNode(e) {
	switch (e.kind) {
		case Kind.OBJECT: return {
			...e,
			fields: sortFields(e.fields)
		};
		case Kind.LIST: return {
			...e,
			values: e.values.map(sortValueNode)
		};
		case Kind.INT:
		case Kind.FLOAT:
		case Kind.STRING:
		case Kind.BOOLEAN:
		case Kind.NULL:
		case Kind.ENUM:
		case Kind.VARIABLE: return e;
	}
}
function sortFields(e) {
	return e.map((e) => ({
		...e,
		value: sortValueNode(e.value)
	})).sort((e, _) => naturalCompare(e.name.value, _.name.value));
}
function reasonMessage(e) {
	return Array.isArray(e) ? e.map(([e, _]) => `subfields "${e}" conflict because ` + reasonMessage(_)).join(" and ") : e;
}
function OverlappingFieldsCanBeMergedRule(e) {
	let _ = new OrderedPairSet(), v = new PairSet(), y = /* @__PURE__ */ new Map();
	return { SelectionSet(b) {
		let x = findConflictsWithinSelectionSet(e, y, _, v, e.getParentType(), b);
		for (let [[_, v], y, b] of x) {
			let x = reasonMessage(v);
			e.reportError(new GraphQLError(`Fields "${_}" conflict because ${x}. Use different aliases on the fields to fetch both if this was intentional.`, { nodes: y.concat(b) }));
		}
	} };
}
function findConflictsWithinSelectionSet(e, _, v, y, b, x) {
	let S = [], [C, w] = getFieldsAndFragmentNames(e, _, b, x);
	if (collectConflictsWithin(e, S, _, v, y, C), w.length !== 0) for (let b = 0; b < w.length; b++) {
		collectConflictsBetweenFieldsAndFragment(e, S, _, v, y, !1, C, w[b]);
		for (let x = b + 1; x < w.length; x++) collectConflictsBetweenFragments(e, S, _, v, y, !1, w[b], w[x]);
	}
	return S;
}
function collectConflictsBetweenFieldsAndFragment(e, _, v, y, b, x, S, C) {
	if (y.has(S, C, x)) return;
	y.add(S, C, x);
	let w = e.getFragment(C);
	if (!w) return;
	let [T, E] = getReferencedFieldsAndFragmentNames(e, v, w);
	if (S !== T) {
		collectConflictsBetween(e, _, v, y, b, x, S, T);
		for (let C of E) collectConflictsBetweenFieldsAndFragment(e, _, v, y, b, x, S, C);
	}
}
function collectConflictsBetweenFragments(e, _, v, y, b, x, S, C) {
	if (S === C || b.has(S, C, x)) return;
	b.add(S, C, x);
	let w = e.getFragment(S), T = e.getFragment(C);
	if (!w || !T) return;
	let [E, D] = getReferencedFieldsAndFragmentNames(e, v, w), [O, k] = getReferencedFieldsAndFragmentNames(e, v, T);
	collectConflictsBetween(e, _, v, y, b, x, E, O);
	for (let C of k) collectConflictsBetweenFragments(e, _, v, y, b, x, S, C);
	for (let S of D) collectConflictsBetweenFragments(e, _, v, y, b, x, S, C);
}
function findConflictsBetweenSubSelectionSets(e, _, v, y, b, x, S, C, w) {
	let T = [], [E, D] = getFieldsAndFragmentNames(e, _, x, S), [O, k] = getFieldsAndFragmentNames(e, _, C, w);
	collectConflictsBetween(e, T, _, v, y, b, E, O);
	for (let x of k) collectConflictsBetweenFieldsAndFragment(e, T, _, v, y, b, E, x);
	for (let x of D) collectConflictsBetweenFieldsAndFragment(e, T, _, v, y, b, O, x);
	for (let x of D) for (let S of k) collectConflictsBetweenFragments(e, T, _, v, y, b, x, S);
	return T;
}
function collectConflictsWithin(e, _, v, y, b, x) {
	for (let [S, C] of Object.entries(x)) if (C.length > 1) for (let x = 0; x < C.length; x++) for (let w = x + 1; w < C.length; w++) {
		let T = findConflict(e, v, y, b, !1, S, C[x], C[w]);
		T && _.push(T);
	}
}
function collectConflictsBetween(e, _, v, y, b, x, S, C) {
	for (let [w, T] of Object.entries(S)) {
		let S = C[w];
		if (S) for (let C of T) for (let T of S) {
			let S = findConflict(e, v, y, b, x, w, C, T);
			S && _.push(S);
		}
	}
}
function findConflict(e, _, v, y, b, x, S, C) {
	let [w, T, E] = S, [D, O, k] = C, A = b || w !== D && isObjectType(w) && isObjectType(D);
	if (!A) {
		let e = T.name.value, _ = O.name.value;
		if (e !== _) return [
			[x, `"${e}" and "${_}" are different fields`],
			[T],
			[O]
		];
		if (!sameArguments(T, O)) return [
			[x, "they have differing arguments"],
			[T],
			[O]
		];
	}
	let j = E?.type, M = k?.type;
	if (j && M && doTypesConflict(j, M)) return [
		[x, `they return conflicting types "${inspect(j)}" and "${inspect(M)}"`],
		[T],
		[O]
	];
	let N = T.selectionSet, P = O.selectionSet;
	if (N && P) {
		let b = findConflictsBetweenSubSelectionSets(e, _, v, y, A, getNamedType(j), N, getNamedType(M), P);
		return subfieldConflicts(b, x, T, O);
	}
}
function sameArguments(e, _) {
	let v = e.arguments, y = _.arguments;
	if (v === void 0 || v.length === 0) return y === void 0 || y.length === 0;
	/* c8 ignore next */
	if (y === void 0 || y.length === 0 || v.length !== y.length)
 /* c8 ignore next */
	return !1;
	let b = new Map(y.map(({ name: e, value: _ }) => [e.value, _]));
	return v.every((e) => {
		let _ = e.value, v = b.get(e.name.value);
		return v === void 0 ? !1 : stringifyValue(_) === stringifyValue(v);
	});
}
function stringifyValue(e) {
	return print(sortValueNode(e));
}
function doTypesConflict(e, _) {
	return isListType(e) ? isListType(_) ? doTypesConflict(e.ofType, _.ofType) : !0 : isListType(_) ? !0 : isNonNullType(e) ? isNonNullType(_) ? doTypesConflict(e.ofType, _.ofType) : !0 : isNonNullType(_) ? !0 : isLeafType(e) || isLeafType(_) ? e !== _ : !1;
}
function getFieldsAndFragmentNames(e, _, v, y) {
	let b = _.get(y);
	if (b) return b;
	let x = Object.create(null), S = Object.create(null);
	_collectFieldsAndFragmentNames(e, v, y, x, S);
	let C = [x, Object.keys(S)];
	return _.set(y, C), C;
}
function getReferencedFieldsAndFragmentNames(e, _, v) {
	let y = _.get(v.selectionSet);
	if (y) return y;
	let b = typeFromAST(e.getSchema(), v.typeCondition);
	return getFieldsAndFragmentNames(e, _, b, v.selectionSet);
}
function _collectFieldsAndFragmentNames(e, _, v, y, b) {
	for (let x of v.selections) switch (x.kind) {
		case Kind.FIELD: {
			let e = x.name.value, v;
			(isObjectType(_) || isInterfaceType(_)) && (v = _.getFields()[e]);
			let b = x.alias ? x.alias.value : e;
			y[b] || (y[b] = []), y[b].push([
				_,
				x,
				v
			]);
			break;
		}
		case Kind.FRAGMENT_SPREAD:
			b[x.name.value] = !0;
			break;
		case Kind.INLINE_FRAGMENT: {
			let v = x.typeCondition, S = v ? typeFromAST(e.getSchema(), v) : _;
			_collectFieldsAndFragmentNames(e, S, x.selectionSet, y, b);
			break;
		}
	}
}
function subfieldConflicts(e, _, v, y) {
	if (e.length > 0) return [
		[_, e.map(([e]) => e)],
		[v, ...e.map(([, e]) => e).flat()],
		[y, ...e.map(([, , e]) => e).flat()]
	];
}
var OrderedPairSet = class {
	constructor() {
		this._data = /* @__PURE__ */ new Map();
	}
	has(e, _, v) {
		let y = this._data.get(e)?.get(_);
		return y === void 0 ? !1 : v ? !0 : v === y;
	}
	add(e, _, v) {
		let y = this._data.get(e);
		y === void 0 ? this._data.set(e, new Map([[_, v]])) : y.set(_, v);
	}
}, PairSet = class {
	constructor() {
		this._orderedPairSet = new OrderedPairSet();
	}
	has(e, _, v) {
		return e < _ ? this._orderedPairSet.has(e, _, v) : this._orderedPairSet.has(_, e, v);
	}
	add(e, _, v) {
		e < _ ? this._orderedPairSet.add(e, _, v) : this._orderedPairSet.add(_, e, v);
	}
};
function PossibleFragmentSpreadsRule(e) {
	return {
		InlineFragment(_) {
			let v = e.getType(), y = e.getParentType();
			if (isCompositeType(v) && isCompositeType(y) && !doTypesOverlap(e.getSchema(), v, y)) {
				let b = inspect(y), x = inspect(v);
				e.reportError(new GraphQLError(`Fragment cannot be spread here as objects of type "${b}" can never be of type "${x}".`, { nodes: _ }));
			}
		},
		FragmentSpread(_) {
			let v = _.name.value, y = getFragmentType(e, v), b = e.getParentType();
			if (y && b && !doTypesOverlap(e.getSchema(), y, b)) {
				let x = inspect(b), S = inspect(y);
				e.reportError(new GraphQLError(`Fragment "${v}" cannot be spread here as objects of type "${x}" can never be of type "${S}".`, { nodes: _ }));
			}
		}
	};
}
function getFragmentType(e, _) {
	let v = e.getFragment(_);
	if (v) {
		let _ = typeFromAST(e.getSchema(), v.typeCondition);
		if (isCompositeType(_)) return _;
	}
}
function PossibleTypeExtensionsRule(e) {
	let _ = e.getSchema(), v = Object.create(null);
	for (let _ of e.getDocument().definitions) isTypeDefinitionNode(_) && (v[_.name.value] = _);
	return {
		ScalarTypeExtension: y,
		ObjectTypeExtension: y,
		InterfaceTypeExtension: y,
		UnionTypeExtension: y,
		EnumTypeExtension: y,
		InputObjectTypeExtension: y
	};
	function y(y) {
		let b = y.name.value, x = v[b], S = _?.getType(b), C;
		if (x ? C = defKindToExtKind[x.kind] : S && (C = typeToExtKind(S)), C) {
			if (C !== y.kind) {
				let _ = extensionKindToTypeName(y.kind);
				e.reportError(new GraphQLError(`Cannot extend non-${_} type "${b}".`, { nodes: x ? [x, y] : y }));
			}
		} else {
			let x = Object.keys({
				...v,
				..._?.getTypeMap()
			}), S = suggestionList(b, x);
			e.reportError(new GraphQLError(`Cannot extend type "${b}" because it is not defined.` + didYouMean(S), { nodes: y.name }));
		}
	}
}
var defKindToExtKind = {
	[Kind.SCALAR_TYPE_DEFINITION]: Kind.SCALAR_TYPE_EXTENSION,
	[Kind.OBJECT_TYPE_DEFINITION]: Kind.OBJECT_TYPE_EXTENSION,
	[Kind.INTERFACE_TYPE_DEFINITION]: Kind.INTERFACE_TYPE_EXTENSION,
	[Kind.UNION_TYPE_DEFINITION]: Kind.UNION_TYPE_EXTENSION,
	[Kind.ENUM_TYPE_DEFINITION]: Kind.ENUM_TYPE_EXTENSION,
	[Kind.INPUT_OBJECT_TYPE_DEFINITION]: Kind.INPUT_OBJECT_TYPE_EXTENSION
};
function typeToExtKind(e) {
	if (isScalarType(e)) return Kind.SCALAR_TYPE_EXTENSION;
	if (isObjectType(e)) return Kind.OBJECT_TYPE_EXTENSION;
	if (isInterfaceType(e)) return Kind.INTERFACE_TYPE_EXTENSION;
	if (isUnionType(e)) return Kind.UNION_TYPE_EXTENSION;
	if (isEnumType(e)) return Kind.ENUM_TYPE_EXTENSION;
	if (isInputObjectType(e)) return Kind.INPUT_OBJECT_TYPE_EXTENSION;
	/* c8 ignore next 3 */
	invariant(!1, "Unexpected type: " + inspect(e));
}
function extensionKindToTypeName(e) {
	switch (e) {
		case Kind.SCALAR_TYPE_EXTENSION: return "scalar";
		case Kind.OBJECT_TYPE_EXTENSION: return "object";
		case Kind.INTERFACE_TYPE_EXTENSION: return "interface";
		case Kind.UNION_TYPE_EXTENSION: return "union";
		case Kind.ENUM_TYPE_EXTENSION: return "enum";
		case Kind.INPUT_OBJECT_TYPE_EXTENSION: return "input object";
		default: invariant(!1, "Unexpected kind: " + inspect(e));
	}
}
function ProvidedRequiredArgumentsRule(e) {
	return {
		...ProvidedRequiredArgumentsOnDirectivesRule(e),
		Field: { leave(_) {
			let v = e.getFieldDef();
			if (!v) return !1;
			let y = new Set(_.arguments?.map((e) => e.name.value));
			for (let b of v.args) if (!y.has(b.name) && isRequiredArgument(b)) {
				let y = inspect(b.type);
				e.reportError(new GraphQLError(`Field "${v.name}" argument "${b.name}" of type "${y}" is required, but it was not provided.`, { nodes: _ }));
			}
		} }
	};
}
function ProvidedRequiredArgumentsOnDirectivesRule(e) {
	let _ = Object.create(null), v = e.getSchema()?.getDirectives() ?? specifiedDirectives;
	for (let e of v) _[e.name] = keyMap(e.args.filter(isRequiredArgument), (e) => e.name);
	let y = e.getDocument().definitions;
	for (let e of y) if (e.kind === Kind.DIRECTIVE_DEFINITION) {
		/* c8 ignore next */
		let v = e.arguments ?? [];
		_[e.name.value] = keyMap(v.filter(isRequiredArgumentNode), (e) => e.name.value);
	}
	return { Directive: { leave(v) {
		let y = v.name.value, b = _[y];
		if (b) {
			/* c8 ignore next */
			let _ = v.arguments ?? [], x = new Set(_.map((e) => e.name.value));
			for (let [_, S] of Object.entries(b)) if (!x.has(_)) {
				let b = isType(S.type) ? inspect(S.type) : print(S.type);
				e.reportError(new GraphQLError(`Directive "@${y}" argument "${_}" of type "${b}" is required, but it was not provided.`, { nodes: v }));
			}
		}
	} } };
}
function isRequiredArgumentNode(e) {
	return e.type.kind === Kind.NON_NULL_TYPE && e.defaultValue == null;
}
function ScalarLeafsRule(e) {
	return { Field(_) {
		let v = e.getType(), y = _.selectionSet;
		if (v) if (isLeafType(getNamedType(v))) {
			if (y) {
				let b = _.name.value, x = inspect(v);
				e.reportError(new GraphQLError(`Field "${b}" must not have a selection since type "${x}" has no subfields.`, { nodes: y }));
			}
		} else if (y) {
			if (y.selections.length === 0) {
				let y = _.name.value, b = inspect(v);
				e.reportError(new GraphQLError(`Field "${y}" of type "${b}" must have at least one field selected.`, { nodes: _ }));
			}
		} else {
			let y = _.name.value, b = inspect(v);
			e.reportError(new GraphQLError(`Field "${y}" of type "${b}" must have a selection of subfields. Did you mean "${y} { ... }"?`, { nodes: _ }));
		}
	} };
}
function printPathArray(e) {
	return e.map((e) => typeof e == "number" ? "[" + e.toString() + "]" : "." + e).join("");
}
function addPath(e, _, v) {
	return {
		prev: e,
		key: _,
		typename: v
	};
}
function pathToArray(e) {
	let _ = [], v = e;
	for (; v;) _.push(v.key), v = v.prev;
	return _.reverse();
}
function coerceInputValue(e, _, v = defaultOnError) {
	return coerceInputValueImpl(e, _, v, void 0);
}
function defaultOnError(e, _, v) {
	let y = "Invalid value " + inspect(_);
	throw e.length > 0 && (y += ` at "value${printPathArray(e)}"`), v.message = y + ": " + v.message, v;
}
function coerceInputValueImpl(e, _, v, y) {
	if (isNonNullType(_)) {
		if (e != null) return coerceInputValueImpl(e, _.ofType, v, y);
		v(pathToArray(y), e, new GraphQLError(`Expected non-nullable type "${inspect(_)}" not to be null.`));
		return;
	}
	if (e == null) return null;
	if (isListType(_)) {
		let b = _.ofType;
		return isIterableObject(e) ? Array.from(e, (e, _) => {
			let x = addPath(y, _, void 0);
			return coerceInputValueImpl(e, b, v, x);
		}) : [coerceInputValueImpl(e, b, v, y)];
	}
	if (isInputObjectType(_)) {
		if (!isObjectLike(e) || Array.isArray(e)) {
			v(pathToArray(y), e, new GraphQLError(`Expected type "${_.name}" to be an object.`));
			return;
		}
		let b = Object.create(null), x = _.getFields();
		for (let S of Object.values(x)) {
			let x = e[S.name];
			if (x === void 0) {
				if (S.defaultValue !== void 0) b[S.name] = S.defaultValue;
				else if (isNonNullType(S.type)) {
					let _ = inspect(S.type);
					v(pathToArray(y), e, new GraphQLError(`Field "${S.name}" of required type "${_}" was not provided.`));
				}
				continue;
			}
			b[S.name] = coerceInputValueImpl(x, S.type, v, addPath(y, S.name, _.name));
		}
		for (let b of Object.keys(e)) if (!x[b]) {
			let x = suggestionList(b, Object.keys(_.getFields()));
			v(pathToArray(y), e, new GraphQLError(`Field "${b}" is not defined by type "${_.name}".` + didYouMean(x)));
		}
		if (_.isOneOf) {
			let x = Object.keys(b);
			x.length !== 1 && v(pathToArray(y), e, new GraphQLError(`Exactly one key must be specified for OneOf type "${_.name}".`));
			let S = x[0], C = b[S];
			C === null && v(pathToArray(y).concat(S), C, new GraphQLError(`Field "${S}" must be non-null.`));
		}
		return { ...b };
	}
	if (isLeafType(_)) {
		let b;
		try {
			b = _.parseValue(e);
		} catch (b) {
			b instanceof GraphQLError ? v(pathToArray(y), e, b) : v(pathToArray(y), e, new GraphQLError(`Expected type "${_.name}". ` + b.message, { originalError: b }));
			return;
		}
		return b === void 0 && v(pathToArray(y), e, new GraphQLError(`Expected type "${_.name}".`)), b;
	}
	/* c8 ignore next 3 */
	invariant(!1, "Unexpected input type: " + inspect(_));
}
function valueFromAST(e, _, v) {
	if (e) {
		if (e.kind === Kind.VARIABLE) {
			let y = e.name.value;
			if (v == null || v[y] === void 0 || !hasOwnProperty$1(v, y)) return;
			let b = v[y];
			return b === null && isNonNullType(_) ? void 0 : b;
		}
		if (isNonNullType(_)) return e.kind === Kind.NULL ? void 0 : valueFromAST(e, _.ofType, v);
		if (e.kind === Kind.NULL) return null;
		if (isListType(_)) {
			let y = _.ofType;
			if (e.kind === Kind.LIST) {
				let _ = [];
				for (let b of e.values) if (isMissingVariable(b, v)) {
					if (isNonNullType(y)) return;
					_.push(null);
				} else {
					let e = valueFromAST(b, y, v);
					if (e === void 0) return;
					_.push(e);
				}
				return _;
			}
			let b = valueFromAST(e, y, v);
			return b === void 0 ? void 0 : [b];
		}
		if (isInputObjectType(_)) {
			if (e.kind !== Kind.OBJECT) return;
			let y = Object.create(null), b = keyMap(e.fields, (e) => e.name.value);
			for (let e of Object.values(_.getFields())) {
				let _ = b[e.name];
				if (!_ || isMissingVariable(_.value, v)) {
					if (e.defaultValue !== void 0) y[e.name] = e.defaultValue;
					else if (isNonNullType(e.type)) return;
					continue;
				}
				let x = valueFromAST(_.value, e.type, v);
				if (x === void 0) return;
				y[e.name] = x;
			}
			if (_.isOneOf) {
				let e = Object.keys(y);
				if (e.length !== 1 || y[e[0]] === null) return;
			}
			return y;
		}
		if (isLeafType(_)) {
			let y;
			try {
				y = _.parseLiteral(e, v);
			} catch {
				return;
			}
			return y === void 0 ? void 0 : y;
		}
		/* c8 ignore next 3 */
		invariant(!1, "Unexpected input type: " + inspect(_));
	}
}
function isMissingVariable(e, _) {
	return e.kind === Kind.VARIABLE && (_ == null || _[e.name.value] === void 0 || !hasOwnProperty$1(_, e.name.value));
}
function hasOwnProperty$1(e, _) {
	return Object.prototype.hasOwnProperty.call(e, _);
}
function getVariableValues(e, _, v, y) {
	let b = [], x = y?.maxErrors;
	try {
		let y = coerceVariableValues(e, _, v, (e) => {
			if (x != null && b.length >= x) throw new GraphQLError("Too many errors processing variables, error limit reached. Execution aborted.");
			b.push(e);
		});
		if (b.length === 0) return { coerced: y };
	} catch (e) {
		b.push(e);
	}
	return { errors: b };
}
function coerceVariableValues(e, _, v, y) {
	let b = Object.create(null);
	for (let x of _) {
		let _ = x.variable.name.value, S = typeFromAST(e, x.type);
		if (!isInputType(S)) {
			let e = print(x.type);
			y(new GraphQLError(`Variable "$${_}" expected value of type "${e}" which cannot be used as an input type.`, { nodes: x.type }));
			continue;
		}
		if (!hasOwnProperty(v, _)) {
			if (x.defaultValue) b[_] = valueFromAST(x.defaultValue, S);
			else if (isNonNullType(S)) {
				let e = inspect(S);
				y(new GraphQLError(`Variable "$${_}" of required type "${e}" was not provided.`, { nodes: x }));
			}
			continue;
		}
		let C = v[_];
		if (C === null && isNonNullType(S)) {
			let e = inspect(S);
			y(new GraphQLError(`Variable "$${_}" of non-null type "${e}" must not be null.`, { nodes: x }));
			continue;
		}
		b[_] = coerceInputValue(C, S, (e, v, b) => {
			let S = `Variable "$${_}" got invalid value ` + inspect(v);
			e.length > 0 && (S += ` at "${_}${printPathArray(e)}"`), y(new GraphQLError(S + "; " + b.message, {
				nodes: x,
				originalError: b
			}));
		});
	}
	return { ...b };
}
function getArgumentValues(e, _, v) {
	let y = Object.create(null), b = _.arguments ?? [], x = keyMap(b, (e) => e.name.value);
	for (let b of e.args) {
		let e = b.name, S = b.type, C = x[e];
		if (!C) {
			if (b.defaultValue !== void 0) y[e] = b.defaultValue;
			else if (isNonNullType(S)) throw new GraphQLError(`Argument "${e}" of required type "${inspect(S)}" was not provided.`, { nodes: _ });
			continue;
		}
		let w = C.value, T = w.kind === Kind.NULL;
		if (w.kind === Kind.VARIABLE) {
			let _ = w.name.value;
			if (v == null || !hasOwnProperty(v, _)) {
				if (b.defaultValue !== void 0) y[e] = b.defaultValue;
				else if (isNonNullType(S)) throw new GraphQLError(`Argument "${e}" of required type "${inspect(S)}" was provided the variable "$${_}" which was not provided a runtime value.`, { nodes: w });
				continue;
			}
			T = v[_] == null;
		}
		if (T && isNonNullType(S)) throw new GraphQLError(`Argument "${e}" of non-null type "${inspect(S)}" must not be null.`, { nodes: w });
		let E = valueFromAST(w, S, v);
		if (E === void 0) throw new GraphQLError(`Argument "${e}" has invalid value ${print(w)}.`, { nodes: w });
		y[e] = E;
	}
	return { ...y };
}
function getDirectiveValues(e, _, v) {
	let y = _.directives?.find((_) => _.name.value === e.name);
	if (y) return getArgumentValues(e, y, v);
}
function hasOwnProperty(e, _) {
	return Object.prototype.hasOwnProperty.call(e, _);
}
function collectFields(e, _, v, y, b) {
	let x = /* @__PURE__ */ new Map();
	return collectFieldsImpl(e, _, v, y, b, x, /* @__PURE__ */ new Set()), x;
}
function collectSubfields(e, _, v, y, b) {
	let x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set();
	for (let C of b) C.selectionSet && collectFieldsImpl(e, _, v, y, C.selectionSet, x, S);
	return x;
}
function collectFieldsImpl(e, _, v, y, b, x, S) {
	for (let C of b.selections) switch (C.kind) {
		case Kind.FIELD: {
			if (!shouldIncludeNode(v, C)) continue;
			let e = getFieldEntryKey(C), _ = x.get(e);
			_ === void 0 ? x.set(e, [C]) : _.push(C);
			break;
		}
		case Kind.INLINE_FRAGMENT:
			if (!shouldIncludeNode(v, C) || !doesFragmentConditionMatch(e, C, y)) continue;
			collectFieldsImpl(e, _, v, y, C.selectionSet, x, S);
			break;
		case Kind.FRAGMENT_SPREAD: {
			let b = C.name.value;
			if (S.has(b) || !shouldIncludeNode(v, C)) continue;
			S.add(b);
			let w = _[b];
			if (!w || !doesFragmentConditionMatch(e, w, y)) continue;
			collectFieldsImpl(e, _, v, y, w.selectionSet, x, S);
			break;
		}
	}
}
function shouldIncludeNode(e, _) {
	return getDirectiveValues(GraphQLSkipDirective, _, e)?.if === !0 ? !1 : getDirectiveValues(GraphQLIncludeDirective, _, e)?.if !== !1;
}
function doesFragmentConditionMatch(e, _, v) {
	let y = _.typeCondition;
	if (!y) return !0;
	let b = typeFromAST(e, y);
	return b === v ? !0 : isAbstractType(b) ? e.isSubType(b, v) : !1;
}
function getFieldEntryKey(e) {
	return e.alias ? e.alias.value : e.name.value;
}
function SingleFieldSubscriptionsRule(e) {
	return { OperationDefinition(_) {
		if (_.operation === "subscription") {
			let v = e.getSchema(), y = v.getSubscriptionType();
			if (y) {
				let b = _.name ? _.name.value : null, x = Object.create(null), S = e.getDocument(), C = Object.create(null);
				for (let e of S.definitions) e.kind === Kind.FRAGMENT_DEFINITION && (C[e.name.value] = e);
				let w = collectFields(v, C, x, y, _.selectionSet);
				if (w.size > 1) {
					let _ = [...w.values()].slice(1).flat();
					e.reportError(new GraphQLError(b == null ? "Anonymous Subscription must select only one top level field." : `Subscription "${b}" must select only one top level field.`, { nodes: _ }));
				}
				for (let _ of w.values()) _[0].name.value.startsWith("__") && e.reportError(new GraphQLError(b == null ? "Anonymous Subscription must not select an introspection top level field." : `Subscription "${b}" must not select an introspection top level field.`, { nodes: _ }));
			}
		}
	} };
}
function groupBy$1(e, _) {
	let v = /* @__PURE__ */ new Map();
	for (let y of e) {
		let e = _(y), b = v.get(e);
		b === void 0 ? v.set(e, [y]) : b.push(y);
	}
	return v;
}
function UniqueArgumentDefinitionNamesRule(e) {
	return {
		DirectiveDefinition(e) {
			/* c8 ignore next */
			let _ = e.arguments ?? [];
			return v(`@${e.name.value}`, _);
		},
		InterfaceTypeDefinition: _,
		InterfaceTypeExtension: _,
		ObjectTypeDefinition: _,
		ObjectTypeExtension: _
	};
	function _(e) {
		let _ = e.name.value, y = e.fields ?? [];
		for (let e of y) {
			let y = e.name.value, b = e.arguments ?? [];
			v(`${_}.${y}`, b);
		}
		return !1;
	}
	function v(_, v) {
		let y = groupBy$1(v, (e) => e.name.value);
		for (let [v, b] of y) b.length > 1 && e.reportError(new GraphQLError(`Argument "${_}(${v}:)" can only be defined once.`, { nodes: b.map((e) => e.name) }));
		return !1;
	}
}
function UniqueArgumentNamesRule(e) {
	return {
		Field: _,
		Directive: _
	};
	function _(_) {
		/* c8 ignore next */
		let v = _.arguments ?? [], y = groupBy$1(v, (e) => e.name.value);
		for (let [_, v] of y) v.length > 1 && e.reportError(new GraphQLError(`There can be only one argument named "${_}".`, { nodes: v.map((e) => e.name) }));
	}
}
function UniqueDirectiveNamesRule(e) {
	let _ = Object.create(null), v = e.getSchema();
	return { DirectiveDefinition(y) {
		let b = y.name.value;
		if (v != null && v.getDirective(b)) {
			e.reportError(new GraphQLError(`Directive "@${b}" already exists in the schema. It cannot be redefined.`, { nodes: y.name }));
			return;
		}
		return _[b] ? e.reportError(new GraphQLError(`There can be only one directive named "@${b}".`, { nodes: [_[b], y.name] })) : _[b] = y.name, !1;
	} };
}
function UniqueDirectivesPerLocationRule(e) {
	let _ = Object.create(null), v = e.getSchema(), y = v ? v.getDirectives() : specifiedDirectives;
	for (let e of y) _[e.name] = !e.isRepeatable;
	let b = e.getDocument().definitions;
	for (let e of b) e.kind === Kind.DIRECTIVE_DEFINITION && (_[e.name.value] = !e.repeatable);
	let x = Object.create(null), S = Object.create(null), C = Object.create(null);
	return { enter(v) {
		if (!("directives" in v) || !v.directives) return;
		let y;
		if (v.kind === Kind.SCHEMA_DEFINITION || v.kind === Kind.SCHEMA_EXTENSION) y = x;
		else if (isTypeDefinitionNode(v) || isTypeExtensionNode(v)) {
			let e = v.name.value;
			y = S[e], y === void 0 && (S[e] = y = Object.create(null));
		} else if (v.kind === Kind.DIRECTIVE_DEFINITION || v.kind === Kind.DIRECTIVE_EXTENSION) {
			let e = v.name.value;
			y = C[e], y === void 0 && (C[e] = y = Object.create(null));
		} else y = Object.create(null);
		for (let b of v.directives) {
			let v = b.name.value;
			_[v] && (y[v] ? e.reportError(new GraphQLError(`The directive "@${v}" can only be used once at this location.`, { nodes: [y[v], b] })) : y[v] = b);
		}
	} };
}
function UniqueEnumValueNamesRule(e) {
	let _ = e.getSchema(), v = _ ? _.getTypeMap() : Object.create(null), y = Object.create(null);
	return {
		EnumTypeDefinition: b,
		EnumTypeExtension: b
	};
	function b(_) {
		let b = _.name.value;
		y[b] || (y[b] = Object.create(null));
		/* c8 ignore next */
		let x = _.values ?? [], S = y[b];
		for (let _ of x) {
			let y = _.name.value, x = v[b];
			isEnumType(x) && x.getValue(y) ? e.reportError(new GraphQLError(`Enum value "${b}.${y}" already exists in the schema. It cannot also be defined in this type extension.`, { nodes: _.name })) : S[y] ? e.reportError(new GraphQLError(`Enum value "${b}.${y}" can only be defined once.`, { nodes: [S[y], _.name] })) : S[y] = _.name;
		}
		return !1;
	}
}
function UniqueFieldDefinitionNamesRule(e) {
	let _ = e.getSchema(), v = _ ? _.getTypeMap() : Object.create(null), y = Object.create(null);
	return {
		InputObjectTypeDefinition: b,
		InputObjectTypeExtension: b,
		InterfaceTypeDefinition: b,
		InterfaceTypeExtension: b,
		ObjectTypeDefinition: b,
		ObjectTypeExtension: b
	};
	function b(_) {
		let b = _.name.value;
		y[b] || (y[b] = Object.create(null));
		/* c8 ignore next */
		let x = _.fields ?? [], S = y[b];
		for (let _ of x) {
			let y = _.name.value;
			hasField(v[b], y) ? e.reportError(new GraphQLError(`Field "${b}.${y}" already exists in the schema. It cannot also be defined in this type extension.`, { nodes: _.name })) : S[y] ? e.reportError(new GraphQLError(`Field "${b}.${y}" can only be defined once.`, { nodes: [S[y], _.name] })) : S[y] = _.name;
		}
		return !1;
	}
}
function hasField(e, _) {
	return isObjectType(e) || isInterfaceType(e) || isInputObjectType(e) ? e.getFields()[_] != null : !1;
}
function UniqueFragmentNamesRule(e) {
	let _ = Object.create(null);
	return {
		OperationDefinition: () => !1,
		FragmentDefinition(v) {
			let y = v.name.value;
			return _[y] ? e.reportError(new GraphQLError(`There can be only one fragment named "${y}".`, { nodes: [_[y], v.name] })) : _[y] = v.name, !1;
		}
	};
}
function UniqueInputFieldNamesRule(e) {
	let _ = [], v = Object.create(null);
	return {
		ObjectValue: {
			enter() {
				_.push(v), v = Object.create(null);
			},
			leave() {
				let e = _.pop();
				e || invariant(!1), v = e;
			}
		},
		ObjectField(_) {
			let y = _.name.value;
			v[y] ? e.reportError(new GraphQLError(`There can be only one input field named "${y}".`, { nodes: [v[y], _.name] })) : v[y] = _.name;
		}
	};
}
function UniqueOperationNamesRule(e) {
	let _ = Object.create(null);
	return {
		OperationDefinition(v) {
			let y = v.name;
			return y && (_[y.value] ? e.reportError(new GraphQLError(`There can be only one operation named "${y.value}".`, { nodes: [_[y.value], y] })) : _[y.value] = y), !1;
		},
		FragmentDefinition: () => !1
	};
}
function UniqueOperationTypesRule(e) {
	let _ = e.getSchema(), v = Object.create(null), y = _ ? {
		query: _.getQueryType(),
		mutation: _.getMutationType(),
		subscription: _.getSubscriptionType()
	} : {};
	return {
		SchemaDefinition: b,
		SchemaExtension: b
	};
	function b(_) {
		/* c8 ignore next */
		let b = _.operationTypes ?? [];
		for (let _ of b) {
			let b = _.operation, x = v[b];
			y[b] ? e.reportError(new GraphQLError(`Type for ${b} already defined in the schema. It cannot be redefined.`, { nodes: _ })) : x ? e.reportError(new GraphQLError(`There can be only one ${b} type in schema.`, { nodes: [x, _] })) : v[b] = _;
		}
		return !1;
	}
}
function UniqueTypeNamesRule(e) {
	let _ = Object.create(null), v = e.getSchema();
	return {
		ScalarTypeDefinition: y,
		ObjectTypeDefinition: y,
		InterfaceTypeDefinition: y,
		UnionTypeDefinition: y,
		EnumTypeDefinition: y,
		InputObjectTypeDefinition: y
	};
	function y(y) {
		let b = y.name.value;
		if (v != null && v.getType(b)) {
			e.reportError(new GraphQLError(`Type "${b}" already exists in the schema. It cannot also be defined in this type definition.`, { nodes: y.name }));
			return;
		}
		return _[b] ? e.reportError(new GraphQLError(`There can be only one type named "${b}".`, { nodes: [_[b], y.name] })) : _[b] = y.name, !1;
	}
}
function UniqueVariableNamesRule(e) {
	return { OperationDefinition(_) {
		/* c8 ignore next */
		let v = _.variableDefinitions ?? [], y = groupBy$1(v, (e) => e.variable.name.value);
		for (let [_, v] of y) v.length > 1 && e.reportError(new GraphQLError(`There can be only one variable named "$${_}".`, { nodes: v.map((e) => e.variable.name) }));
	} };
}
function ValuesOfCorrectTypeRule(e) {
	return {
		ListValue(_) {
			let v = getNullableType(e.getParentInputType());
			if (!isListType(v)) return isValidValueNode(e, _), !1;
		},
		ObjectValue(_) {
			let v = getNamedType(e.getInputType());
			if (!isInputObjectType(v)) return isValidValueNode(e, _), !1;
			let y = keyMap(_.fields, (e) => e.name.value);
			for (let b of Object.values(v.getFields())) if (!y[b.name] && isRequiredInputField(b)) {
				let y = inspect(b.type);
				e.reportError(new GraphQLError(`Field "${v.name}.${b.name}" of required type "${y}" was not provided.`, { nodes: _ }));
			}
			v.isOneOf && validateOneOfInputObject(e, _, v, y);
		},
		ObjectField(_) {
			let v = getNamedType(e.getParentInputType());
			if (!e.getInputType() && isInputObjectType(v)) {
				let y = suggestionList(_.name.value, Object.keys(v.getFields()));
				e.reportError(new GraphQLError(`Field "${_.name.value}" is not defined by type "${v.name}".` + didYouMean(y), { nodes: _ }));
			}
		},
		NullValue(_) {
			let v = e.getInputType();
			isNonNullType(v) && e.reportError(new GraphQLError(`Expected value of type "${inspect(v)}", found ${print(_)}.`, { nodes: _ }));
		},
		EnumValue: (_) => isValidValueNode(e, _),
		IntValue: (_) => isValidValueNode(e, _),
		FloatValue: (_) => isValidValueNode(e, _),
		StringValue: (_) => isValidValueNode(e, _),
		BooleanValue: (_) => isValidValueNode(e, _)
	};
}
function isValidValueNode(e, _) {
	let v = e.getInputType();
	if (!v) return;
	let y = getNamedType(v);
	if (!isLeafType(y)) {
		let y = inspect(v);
		e.reportError(new GraphQLError(`Expected value of type "${y}", found ${print(_)}.`, { nodes: _ }));
		return;
	}
	try {
		if (y.parseLiteral(_, void 0) === void 0) {
			let y = inspect(v);
			e.reportError(new GraphQLError(`Expected value of type "${y}", found ${print(_)}.`, { nodes: _ }));
		}
	} catch (y) {
		let b = inspect(v);
		y instanceof GraphQLError ? e.reportError(y) : e.reportError(new GraphQLError(`Expected value of type "${b}", found ${print(_)}; ` + y.message, {
			nodes: _,
			originalError: y
		}));
	}
}
function validateOneOfInputObject(e, _, v, y) {
	let b = Object.keys(y);
	if (b.length !== 1) {
		e.reportError(new GraphQLError(`OneOf Input Object "${v.name}" must specify exactly one key.`, { nodes: [_] }));
		return;
	}
	let x = y[b[0]]?.value;
	(!x || x.kind === Kind.NULL) && e.reportError(new GraphQLError(`Field "${v.name}.${b[0]}" must be non-null.`, { nodes: [_] }));
}
function VariablesAreInputTypesRule(e) {
	return { VariableDefinition(_) {
		let v = typeFromAST(e.getSchema(), _.type);
		if (v !== void 0 && !isInputType(v)) {
			let v = _.variable.name.value, y = print(_.type);
			e.reportError(new GraphQLError(`Variable "$${v}" cannot be non-input type "${y}".`, { nodes: _.type }));
		}
	} };
}
function VariablesInAllowedPositionRule(e) {
	let _ = Object.create(null);
	return {
		OperationDefinition: {
			enter() {
				_ = Object.create(null);
			},
			leave(v) {
				let y = e.getRecursiveVariableUsages(v);
				for (let { node: v, type: b, defaultValue: x, parentType: S } of y) {
					let y = v.name.value, C = _[y];
					if (C && b) {
						let _ = e.getSchema(), w = typeFromAST(_, C.type);
						if (w && !allowedVariableUsage(_, w, C.defaultValue, b, x)) {
							let _ = inspect(w), x = inspect(b);
							e.reportError(new GraphQLError(`Variable "$${y}" of type "${_}" used in position expecting type "${x}".`, { nodes: [C, v] }));
						}
						isInputObjectType(S) && S.isOneOf && isNullableType(w) && e.reportError(new GraphQLError(`Variable "$${y}" is of type "${w}" but must be non-nullable to be used for OneOf Input Object "${S}".`, { nodes: [C, v] }));
					}
				}
			}
		},
		VariableDefinition(e) {
			_[e.variable.name.value] = e;
		}
	};
}
function allowedVariableUsage(e, _, v, y, b) {
	if (isNonNullType(y) && !isNonNullType(_)) {
		if (!(v != null && v.kind !== Kind.NULL) && b === void 0) return !1;
		let x = y.ofType;
		return isTypeSubTypeOf(e, _, x);
	}
	return isTypeSubTypeOf(e, _, y);
}
const recommendedRules = Object.freeze([MaxIntrospectionDepthRule]), specifiedRules = Object.freeze([
	ExecutableDefinitionsRule,
	UniqueOperationNamesRule,
	LoneAnonymousOperationRule,
	SingleFieldSubscriptionsRule,
	KnownTypeNamesRule,
	FragmentsOnCompositeTypesRule,
	VariablesAreInputTypesRule,
	ScalarLeafsRule,
	FieldsOnCorrectTypeRule,
	UniqueFragmentNamesRule,
	KnownFragmentNamesRule,
	NoUnusedFragmentsRule,
	PossibleFragmentSpreadsRule,
	NoFragmentCyclesRule,
	UniqueVariableNamesRule,
	NoUndefinedVariablesRule,
	NoUnusedVariablesRule,
	KnownDirectivesRule,
	UniqueDirectivesPerLocationRule,
	KnownArgumentNamesRule,
	UniqueArgumentNamesRule,
	ValuesOfCorrectTypeRule,
	ProvidedRequiredArgumentsRule,
	VariablesInAllowedPositionRule,
	OverlappingFieldsCanBeMergedRule,
	UniqueInputFieldNamesRule,
	...recommendedRules
]), specifiedSDLRules = Object.freeze([
	LoneSchemaDefinitionRule,
	UniqueOperationTypesRule,
	UniqueTypeNamesRule,
	UniqueEnumValueNamesRule,
	UniqueFieldDefinitionNamesRule,
	UniqueArgumentDefinitionNamesRule,
	UniqueDirectiveNamesRule,
	KnownTypeNamesRule,
	KnownDirectivesRule,
	UniqueDirectivesPerLocationRule,
	PossibleTypeExtensionsRule,
	KnownArgumentNamesOnDirectivesRule,
	UniqueArgumentNamesRule,
	UniqueInputFieldNamesRule,
	ProvidedRequiredArgumentsOnDirectivesRule
]);
var ASTValidationContext = class {
	constructor(e, _) {
		this._ast = e, this._fragments = void 0, this._fragmentSpreads = /* @__PURE__ */ new Map(), this._recursivelyReferencedFragments = /* @__PURE__ */ new Map(), this._onError = _;
	}
	get [Symbol.toStringTag]() {
		return "ASTValidationContext";
	}
	reportError(e) {
		this._onError(e);
	}
	getDocument() {
		return this._ast;
	}
	getFragment(e) {
		let _;
		if (this._fragments) _ = this._fragments;
		else {
			_ = Object.create(null);
			for (let e of this.getDocument().definitions) e.kind === Kind.FRAGMENT_DEFINITION && (_[e.name.value] = e);
			this._fragments = _;
		}
		return _[e];
	}
	getFragmentSpreads(e) {
		let _ = this._fragmentSpreads.get(e);
		if (!_) {
			_ = [];
			let v = [e], y;
			for (; y = v.pop();) for (let e of y.selections) e.kind === Kind.FRAGMENT_SPREAD ? _.push(e) : e.selectionSet && v.push(e.selectionSet);
			this._fragmentSpreads.set(e, _);
		}
		return _;
	}
	getRecursivelyReferencedFragments(e) {
		let _ = this._recursivelyReferencedFragments.get(e);
		if (!_) {
			_ = [];
			let v = Object.create(null), y = [e.selectionSet], b;
			for (; b = y.pop();) for (let e of this.getFragmentSpreads(b)) {
				let b = e.name.value;
				if (v[b] !== !0) {
					v[b] = !0;
					let e = this.getFragment(b);
					e && (_.push(e), y.push(e.selectionSet));
				}
			}
			this._recursivelyReferencedFragments.set(e, _);
		}
		return _;
	}
}, SDLValidationContext = class extends ASTValidationContext {
	constructor(e, _, v) {
		super(e, v), this._schema = _;
	}
	get [Symbol.toStringTag]() {
		return "SDLValidationContext";
	}
	getSchema() {
		return this._schema;
	}
}, ValidationContext = class extends ASTValidationContext {
	constructor(e, _, v, y) {
		super(_, y), this._schema = e, this._typeInfo = v, this._variableUsages = /* @__PURE__ */ new Map(), this._recursiveVariableUsages = /* @__PURE__ */ new Map();
	}
	get [Symbol.toStringTag]() {
		return "ValidationContext";
	}
	getSchema() {
		return this._schema;
	}
	getVariableUsages(e) {
		let _ = this._variableUsages.get(e);
		if (!_) {
			let v = [], y = new TypeInfo(this._schema);
			visit(e, visitWithTypeInfo(y, {
				VariableDefinition: () => !1,
				Variable(e) {
					v.push({
						node: e,
						type: y.getInputType(),
						defaultValue: y.getDefaultValue(),
						parentType: y.getParentInputType()
					});
				}
			})), _ = v, this._variableUsages.set(e, _);
		}
		return _;
	}
	getRecursiveVariableUsages(e) {
		let _ = this._recursiveVariableUsages.get(e);
		if (!_) {
			_ = this.getVariableUsages(e);
			for (let v of this.getRecursivelyReferencedFragments(e)) _ = _.concat(this.getVariableUsages(v));
			this._recursiveVariableUsages.set(e, _);
		}
		return _;
	}
	getType() {
		return this._typeInfo.getType();
	}
	getParentType() {
		return this._typeInfo.getParentType();
	}
	getInputType() {
		return this._typeInfo.getInputType();
	}
	getParentInputType() {
		return this._typeInfo.getParentInputType();
	}
	getFieldDef() {
		return this._typeInfo.getFieldDef();
	}
	getDirective() {
		return this._typeInfo.getDirective();
	}
	getArgument() {
		return this._typeInfo.getArgument();
	}
	getEnumValue() {
		return this._typeInfo.getEnumValue();
	}
}, QueryDocumentKeysToValidate = mapValue(QueryDocumentKeys, (e) => e.filter((e) => e !== "description"));
function validate(e, _, v = specifiedRules, y, b = new TypeInfo(e)) {
	let x = y?.maxErrors ?? 100;
	_ || devAssert(!1, "Must provide document."), assertValidSchema(e);
	let S = Object.freeze({}), C = [], w = new ValidationContext(e, _, b, (e) => {
		if (C.length >= x) throw C.push(new GraphQLError("Too many validation errors, error limit reached. Validation aborted.")), S;
		C.push(e);
	}), T = visitInParallel(v.map((e) => e(w)));
	try {
		visit(_, visitWithTypeInfo(b, T), QueryDocumentKeysToValidate);
	} catch (e) {
		if (e !== S) throw e;
	}
	return C;
}
function validateSDL(e, _, v = specifiedSDLRules) {
	let y = [], b = new SDLValidationContext(e, _, (e) => {
		y.push(e);
	}), x = v.map((e) => e(b));
	return visit(e, visitInParallel(x)), y;
}
function assertValidSDL(e) {
	let _ = validateSDL(e);
	if (_.length !== 0) throw Error(_.map((e) => e.message).join("\n\n"));
}
function extendSchemaImpl(e, _, v) {
	let y = [], b = Object.create(null), x = Object.create(null), S = [], C, w = [];
	for (let e of _.definitions) if (e.kind === Kind.SCHEMA_DEFINITION) C = e;
	else if (e.kind === Kind.SCHEMA_EXTENSION) w.push(e);
	else if (isTypeDefinitionNode(e)) y.push(e);
	else if (isTypeExtensionNode(e)) {
		let _ = e.name.value, v = b[_];
		b[_] = v ? v.concat([e]) : [e];
	} else if (e.kind === Kind.DIRECTIVE_DEFINITION) S.push(e);
	else if (e.kind === Kind.DIRECTIVE_EXTENSION) {
		let _ = e.name.value, v = x[_];
		x[_] = v ? v.concat([e]) : [e];
	}
	if (Object.keys(b).length === 0 && y.length === 0 && Object.keys(x).length === 0 && S.length === 0 && w.length === 0 && C == null) return e;
	let T = Object.create(null);
	for (let _ of e.types) T[_.name] = M(_);
	for (let e of y) {
		let _ = e.name.value;
		T[_] = stdTypeMap[_] ?? Q(e);
	}
	let E = Object.create(null);
	for (let _ of e.directives) E[_.name] = H(_);
	let D = {
		query: e.query && A(e.query),
		mutation: e.mutation && A(e.mutation),
		subscription: e.subscription && A(e.subscription),
		...C && V([C]),
		...V(w)
	}, O = Object.values(E);
	return {
		description: C?.description?.value,
		...D,
		types: Object.values(T),
		directives: [...O.map(j), ...S.map(G)],
		extensions: Object.create(null),
		astNode: C ?? e.astNode,
		extensionASTNodes: e.extensionASTNodes.concat(w),
		assumeValid: v?.assumeValid ?? !1
	};
	function k(e) {
		return isListType(e) ? new GraphQLList(k(e.ofType)) : isNonNullType(e) ? new GraphQLNonNull(k(e.ofType)) : A(e);
	}
	function A(e) {
		return T[e.name];
	}
	function j(e) {
		let _ = e.toConfig();
		return new GraphQLDirective({
			..._,
			args: mapValue(_.args, B)
		});
	}
	function M(e) {
		if (isIntrospectionType(e) || isSpecifiedScalarType(e)) return e;
		if (isScalarType(e)) return F(e);
		if (isObjectType(e)) return I(e);
		if (isInterfaceType(e)) return L(e);
		if (isUnionType(e)) return R(e);
		if (isEnumType(e)) return P(e);
		if (isInputObjectType(e)) return N(e);
		/* c8 ignore next 3 */
		invariant(!1, "Unexpected type: " + inspect(e));
	}
	function N(e) {
		let _ = e.toConfig(), v = b[_.name] ?? [];
		return new GraphQLInputObjectType({
			..._,
			fields: () => ({
				...mapValue(_.fields, (e) => ({
					...e,
					type: k(e.type)
				})),
				...J(v)
			}),
			extensionASTNodes: _.extensionASTNodes.concat(v)
		});
	}
	function P(e) {
		let _ = e.toConfig(), v = b[e.name] ?? [];
		return new GraphQLEnumType({
			..._,
			values: {
				..._.values,
				...Y(v)
			},
			extensionASTNodes: _.extensionASTNodes.concat(v)
		});
	}
	function F(e) {
		let _ = e.toConfig(), v = b[_.name] ?? [], y = _.specifiedByURL;
		for (let e of v) y = getSpecifiedByURL(e) ?? y;
		return new GraphQLScalarType({
			..._,
			specifiedByURL: y,
			extensionASTNodes: _.extensionASTNodes.concat(v)
		});
	}
	function I(e) {
		let _ = e.toConfig(), v = b[_.name] ?? [];
		return new GraphQLObjectType({
			..._,
			interfaces: () => [...e.getInterfaces().map(A), ...X(v)],
			fields: () => ({
				...mapValue(_.fields, z),
				...K(v)
			}),
			extensionASTNodes: _.extensionASTNodes.concat(v)
		});
	}
	function L(e) {
		let _ = e.toConfig(), v = b[_.name] ?? [];
		return new GraphQLInterfaceType({
			..._,
			interfaces: () => [...e.getInterfaces().map(A), ...X(v)],
			fields: () => ({
				...mapValue(_.fields, z),
				...K(v)
			}),
			extensionASTNodes: _.extensionASTNodes.concat(v)
		});
	}
	function R(e) {
		let _ = e.toConfig(), v = b[_.name] ?? [];
		return new GraphQLUnionType({
			..._,
			types: () => [...e.getTypes().map(A), ...Z(v)],
			extensionASTNodes: _.extensionASTNodes.concat(v)
		});
	}
	function z(e) {
		return {
			...e,
			type: k(e.type),
			args: e.args && mapValue(e.args, B)
		};
	}
	function B(e) {
		return {
			...e,
			type: k(e.type)
		};
	}
	function V(e) {
		let _ = {};
		for (let v of e) {
			let e = v.operationTypes ?? [];
			for (let v of e) _[v.operation] = U(v.type);
		}
		return _;
	}
	function H(e) {
		let _ = e.toConfig(), v = x[_.name] ?? [], y = _.deprecationReason ?? v.map((e) => getDeprecationReason(e)).find((e) => e != null);
		return new GraphQLDirective({
			..._,
			deprecationReason: y,
			extensionASTNodes: _.extensionASTNodes.concat(v)
		});
	}
	function U(e) {
		let _ = e.name.value, v = stdTypeMap[_] ?? T[_];
		if (v === void 0) throw Error(`Unknown type: "${_}".`);
		return v;
	}
	function W(e) {
		return e.kind === Kind.LIST_TYPE ? new GraphQLList(W(e.type)) : e.kind === Kind.NON_NULL_TYPE ? new GraphQLNonNull(W(e.type)) : U(e);
	}
	function G(e) {
		let _ = x[e.name.value] ?? [], v = getDeprecationReason(e) ?? _.map((e) => getDeprecationReason(e)).find((e) => e != null);
		return new GraphQLDirective({
			name: e.name.value,
			description: e.description?.value,
			locations: e.locations.map(({ value: e }) => e),
			isRepeatable: e.repeatable,
			args: q(e.arguments),
			deprecationReason: v,
			astNode: e,
			extensionASTNodes: _
		});
	}
	function K(e) {
		let _ = Object.create(null);
		for (let v of e) {
			let e = v.fields ?? [];
			for (let v of e) _[v.name.value] = {
				type: W(v.type),
				description: v.description?.value,
				args: q(v.arguments),
				deprecationReason: getDeprecationReason(v),
				astNode: v
			};
		}
		return _;
	}
	function q(e) {
		let _ = e ?? [], v = Object.create(null);
		for (let e of _) {
			let _ = W(e.type);
			v[e.name.value] = {
				type: _,
				description: e.description?.value,
				defaultValue: valueFromAST(e.defaultValue, _),
				deprecationReason: getDeprecationReason(e),
				astNode: e
			};
		}
		return v;
	}
	function J(e) {
		let _ = Object.create(null);
		for (let v of e) {
			let e = v.fields ?? [];
			for (let v of e) {
				let e = W(v.type);
				_[v.name.value] = {
					type: e,
					description: v.description?.value,
					defaultValue: valueFromAST(v.defaultValue, e),
					deprecationReason: getDeprecationReason(v),
					astNode: v
				};
			}
		}
		return _;
	}
	function Y(e) {
		let _ = Object.create(null);
		for (let v of e) {
			let e = v.values ?? [];
			for (let v of e) _[v.name.value] = {
				description: v.description?.value,
				deprecationReason: getDeprecationReason(v),
				astNode: v
			};
		}
		return _;
	}
	function X(e) {
		return e.flatMap((e) => e.interfaces?.map(U) ?? []);
	}
	function Z(e) {
		return e.flatMap((e) => e.types?.map(U) ?? []);
	}
	function Q(e) {
		let _ = e.name.value, v = b[_] ?? [];
		switch (e.kind) {
			case Kind.OBJECT_TYPE_DEFINITION: {
				let y = [e, ...v];
				return new GraphQLObjectType({
					name: _,
					description: e.description?.value,
					interfaces: () => X(y),
					fields: () => K(y),
					astNode: e,
					extensionASTNodes: v
				});
			}
			case Kind.INTERFACE_TYPE_DEFINITION: {
				let y = [e, ...v];
				return new GraphQLInterfaceType({
					name: _,
					description: e.description?.value,
					interfaces: () => X(y),
					fields: () => K(y),
					astNode: e,
					extensionASTNodes: v
				});
			}
			case Kind.ENUM_TYPE_DEFINITION: {
				let y = [e, ...v];
				return new GraphQLEnumType({
					name: _,
					description: e.description?.value,
					values: Y(y),
					astNode: e,
					extensionASTNodes: v
				});
			}
			case Kind.UNION_TYPE_DEFINITION: {
				let y = [e, ...v];
				return new GraphQLUnionType({
					name: _,
					description: e.description?.value,
					types: () => Z(y),
					astNode: e,
					extensionASTNodes: v
				});
			}
			case Kind.SCALAR_TYPE_DEFINITION: return new GraphQLScalarType({
				name: _,
				description: e.description?.value,
				specifiedByURL: getSpecifiedByURL(e),
				astNode: e,
				extensionASTNodes: v
			});
			case Kind.INPUT_OBJECT_TYPE_DEFINITION: {
				let y = [e, ...v];
				return new GraphQLInputObjectType({
					name: _,
					description: e.description?.value,
					fields: () => J(y),
					astNode: e,
					extensionASTNodes: v,
					isOneOf: isOneOf(e)
				});
			}
		}
	}
}
var stdTypeMap = keyMap([...specifiedScalarTypes, ...introspectionTypes], (e) => e.name);
function getDeprecationReason(e) {
	return getDirectiveValues(GraphQLDeprecatedDirective, e)?.reason;
}
function getSpecifiedByURL(e) {
	return getDirectiveValues(GraphQLSpecifiedByDirective, e)?.url;
}
function isOneOf(e) {
	return !!getDirectiveValues(GraphQLOneOfDirective, e);
}
function buildASTSchema(e, _) {
	e != null && e.kind === Kind.DOCUMENT || devAssert(!1, "Must provide valid Document AST."), _?.assumeValid !== !0 && _?.assumeValidSDL !== !0 && assertValidSDL(e);
	let v = extendSchemaImpl({
		description: void 0,
		types: [],
		directives: [],
		extensions: Object.create(null),
		extensionASTNodes: [],
		assumeValid: !1
	}, e, _);
	if (v.astNode == null) for (let e of v.types) switch (e.name) {
		case "Query":
			v.query = e;
			break;
		case "Mutation":
			v.mutation = e;
			break;
		case "Subscription":
			v.subscription = e;
			break;
	}
	let y = [...v.directives, ...specifiedDirectives.filter((e) => v.directives.every((_) => _.name !== e.name))];
	return new GraphQLSchema({
		...v,
		directives: y
	});
}
function buildSchema(e, _) {
	let v = parse(e, {
		noLocation: _?.noLocation,
		allowLegacyFragmentVariables: _?.allowLegacyFragmentVariables,
		experimentalDirectivesOnDirectiveDefinitions: _?.experimentalDirectivesOnDirectiveDefinitions
	});
	return buildASTSchema(v, {
		assumeValidSDL: _?.assumeValidSDL,
		assumeValid: _?.assumeValid
	});
}
var DocumentUri;
(function(e) {
	function _(e) {
		return typeof e == "string";
	}
	e.is = _;
})(DocumentUri ||= {});
var URI$1;
(function(e) {
	function _(e) {
		return typeof e == "string";
	}
	e.is = _;
})(URI$1 ||= {});
var integer;
(function(e) {
	e.MIN_VALUE = -2147483648, e.MAX_VALUE = 2147483647;
	function _(_) {
		return typeof _ == "number" && e.MIN_VALUE <= _ && _ <= e.MAX_VALUE;
	}
	e.is = _;
})(integer ||= {});
var uinteger;
(function(e) {
	e.MIN_VALUE = 0, e.MAX_VALUE = 2147483647;
	function _(_) {
		return typeof _ == "number" && e.MIN_VALUE <= _ && _ <= e.MAX_VALUE;
	}
	e.is = _;
})(uinteger ||= {});
var Position$2;
(function(e) {
	function _(e, _) {
		return e === Number.MAX_VALUE && (e = uinteger.MAX_VALUE), _ === Number.MAX_VALUE && (_ = uinteger.MAX_VALUE), {
			line: e,
			character: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Is.uinteger(_.line) && Is.uinteger(_.character);
	}
	e.is = v;
})(Position$2 ||= {});
var Range$2;
(function(e) {
	function _(e, _, v, y) {
		if (Is.uinteger(e) && Is.uinteger(_) && Is.uinteger(v) && Is.uinteger(y)) return {
			start: Position$2.create(e, _),
			end: Position$2.create(v, y)
		};
		if (Position$2.is(e) && Position$2.is(_)) return {
			start: e,
			end: _
		};
		throw Error(`Range#create called with invalid arguments[${e}, ${_}, ${v}, ${y}]`);
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Position$2.is(_.start) && Position$2.is(_.end);
	}
	e.is = v;
})(Range$2 ||= {});
var Location;
(function(e) {
	function _(e, _) {
		return {
			uri: e,
			range: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Range$2.is(_.range) && (Is.string(_.uri) || Is.undefined(_.uri));
	}
	e.is = v;
})(Location ||= {});
var LocationLink;
(function(e) {
	function _(e, _, v, y) {
		return {
			targetUri: e,
			targetRange: _,
			targetSelectionRange: v,
			originSelectionRange: y
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Range$2.is(_.targetRange) && Is.string(_.targetUri) && Range$2.is(_.targetSelectionRange) && (Range$2.is(_.originSelectionRange) || Is.undefined(_.originSelectionRange));
	}
	e.is = v;
})(LocationLink ||= {});
var Color$1;
(function(e) {
	function _(e, _, v, y) {
		return {
			red: e,
			green: _,
			blue: v,
			alpha: y
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Is.numberRange(_.red, 0, 1) && Is.numberRange(_.green, 0, 1) && Is.numberRange(_.blue, 0, 1) && Is.numberRange(_.alpha, 0, 1);
	}
	e.is = v;
})(Color$1 ||= {});
var ColorInformation;
(function(e) {
	function _(e, _) {
		return {
			range: e,
			color: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Range$2.is(_.range) && Color$1.is(_.color);
	}
	e.is = v;
})(ColorInformation ||= {});
var ColorPresentation;
(function(e) {
	function _(e, _, v) {
		return {
			label: e,
			textEdit: _,
			additionalTextEdits: v
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Is.string(_.label) && (Is.undefined(_.textEdit) || TextEdit$1.is(_)) && (Is.undefined(_.additionalTextEdits) || Is.typedArray(_.additionalTextEdits, TextEdit$1.is));
	}
	e.is = v;
})(ColorPresentation ||= {});
var FoldingRangeKind$1;
(function(e) {
	e.Comment = "comment", e.Imports = "imports", e.Region = "region";
})(FoldingRangeKind$1 ||= {});
var FoldingRange;
(function(e) {
	function _(e, _, v, y, b, x) {
		let S = {
			startLine: e,
			endLine: _
		};
		return Is.defined(v) && (S.startCharacter = v), Is.defined(y) && (S.endCharacter = y), Is.defined(b) && (S.kind = b), Is.defined(x) && (S.collapsedText = x), S;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Is.uinteger(_.startLine) && Is.uinteger(_.startLine) && (Is.undefined(_.startCharacter) || Is.uinteger(_.startCharacter)) && (Is.undefined(_.endCharacter) || Is.uinteger(_.endCharacter)) && (Is.undefined(_.kind) || Is.string(_.kind));
	}
	e.is = v;
})(FoldingRange ||= {});
var DiagnosticRelatedInformation;
(function(e) {
	function _(e, _) {
		return {
			location: e,
			message: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Location.is(_.location) && Is.string(_.message);
	}
	e.is = v;
})(DiagnosticRelatedInformation ||= {});
var DiagnosticSeverity;
(function(e) {
	e.Error = 1, e.Warning = 2, e.Information = 3, e.Hint = 4;
})(DiagnosticSeverity ||= {});
var DiagnosticTag;
(function(e) {
	e.Unnecessary = 1, e.Deprecated = 2;
})(DiagnosticTag ||= {});
var CodeDescription;
(function(e) {
	function _(e) {
		let _ = e;
		return Is.objectLiteral(_) && Is.string(_.href);
	}
	e.is = _;
})(CodeDescription ||= {});
var Diagnostic;
(function(e) {
	function _(e, _, v, y, b, x) {
		let S = {
			range: e,
			message: _
		};
		return Is.defined(v) && (S.severity = v), Is.defined(y) && (S.code = y), Is.defined(b) && (S.source = b), Is.defined(x) && (S.relatedInformation = x), S;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Range$2.is(_.range) && Is.string(_.message) && (Is.number(_.severity) || Is.undefined(_.severity)) && (Is.integer(_.code) || Is.string(_.code) || Is.undefined(_.code)) && (Is.undefined(_.codeDescription) || Is.string(_.codeDescription?.href)) && (Is.string(_.source) || Is.undefined(_.source)) && (Is.undefined(_.relatedInformation) || Is.typedArray(_.relatedInformation, DiagnosticRelatedInformation.is));
	}
	e.is = v;
})(Diagnostic ||= {});
var Command;
(function(e) {
	function _(e, _, ...v) {
		let y = {
			title: e,
			command: _
		};
		return Is.defined(v) && v.length > 0 && (y.arguments = v), y;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Is.string(_.title) && Is.string(_.command);
	}
	e.is = v;
})(Command ||= {});
var TextEdit$1;
(function(e) {
	function _(e, _) {
		return {
			range: e,
			newText: _
		};
	}
	e.replace = _;
	function v(e, _) {
		return {
			range: {
				start: e,
				end: e
			},
			newText: _
		};
	}
	e.insert = v;
	function y(e) {
		return {
			range: e,
			newText: ""
		};
	}
	e.del = y;
	function b(e) {
		let _ = e;
		return Is.objectLiteral(_) && Is.string(_.newText) && Range$2.is(_.range);
	}
	e.is = b;
})(TextEdit$1 ||= {});
var ChangeAnnotation;
(function(e) {
	function _(e, _, v) {
		let y = { label: e };
		return _ !== void 0 && (y.needsConfirmation = _), v !== void 0 && (y.description = v), y;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Is.string(_.label) && (Is.boolean(_.needsConfirmation) || _.needsConfirmation === void 0) && (Is.string(_.description) || _.description === void 0);
	}
	e.is = v;
})(ChangeAnnotation ||= {});
var ChangeAnnotationIdentifier;
(function(e) {
	function _(e) {
		let _ = e;
		return Is.string(_);
	}
	e.is = _;
})(ChangeAnnotationIdentifier ||= {});
var AnnotatedTextEdit;
(function(e) {
	function _(e, _, v) {
		return {
			range: e,
			newText: _,
			annotationId: v
		};
	}
	e.replace = _;
	function v(e, _, v) {
		return {
			range: {
				start: e,
				end: e
			},
			newText: _,
			annotationId: v
		};
	}
	e.insert = v;
	function y(e, _) {
		return {
			range: e,
			newText: "",
			annotationId: _
		};
	}
	e.del = y;
	function b(e) {
		let _ = e;
		return TextEdit$1.is(_) && (ChangeAnnotation.is(_.annotationId) || ChangeAnnotationIdentifier.is(_.annotationId));
	}
	e.is = b;
})(AnnotatedTextEdit ||= {});
var TextDocumentEdit;
(function(e) {
	function _(e, _) {
		return {
			textDocument: e,
			edits: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && OptionalVersionedTextDocumentIdentifier.is(_.textDocument) && Array.isArray(_.edits);
	}
	e.is = v;
})(TextDocumentEdit ||= {});
var CreateFile;
(function(e) {
	function _(e, _, v) {
		let y = {
			kind: "create",
			uri: e
		};
		return _ !== void 0 && (_.overwrite !== void 0 || _.ignoreIfExists !== void 0) && (y.options = _), v !== void 0 && (y.annotationId = v), y;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ && _.kind === "create" && Is.string(_.uri) && (_.options === void 0 || (_.options.overwrite === void 0 || Is.boolean(_.options.overwrite)) && (_.options.ignoreIfExists === void 0 || Is.boolean(_.options.ignoreIfExists))) && (_.annotationId === void 0 || ChangeAnnotationIdentifier.is(_.annotationId));
	}
	e.is = v;
})(CreateFile ||= {});
var RenameFile;
(function(e) {
	function _(e, _, v, y) {
		let b = {
			kind: "rename",
			oldUri: e,
			newUri: _
		};
		return v !== void 0 && (v.overwrite !== void 0 || v.ignoreIfExists !== void 0) && (b.options = v), y !== void 0 && (b.annotationId = y), b;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ && _.kind === "rename" && Is.string(_.oldUri) && Is.string(_.newUri) && (_.options === void 0 || (_.options.overwrite === void 0 || Is.boolean(_.options.overwrite)) && (_.options.ignoreIfExists === void 0 || Is.boolean(_.options.ignoreIfExists))) && (_.annotationId === void 0 || ChangeAnnotationIdentifier.is(_.annotationId));
	}
	e.is = v;
})(RenameFile ||= {});
var DeleteFile;
(function(e) {
	function _(e, _, v) {
		let y = {
			kind: "delete",
			uri: e
		};
		return _ !== void 0 && (_.recursive !== void 0 || _.ignoreIfNotExists !== void 0) && (y.options = _), v !== void 0 && (y.annotationId = v), y;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ && _.kind === "delete" && Is.string(_.uri) && (_.options === void 0 || (_.options.recursive === void 0 || Is.boolean(_.options.recursive)) && (_.options.ignoreIfNotExists === void 0 || Is.boolean(_.options.ignoreIfNotExists))) && (_.annotationId === void 0 || ChangeAnnotationIdentifier.is(_.annotationId));
	}
	e.is = v;
})(DeleteFile ||= {});
var WorkspaceEdit;
(function(e) {
	function _(e) {
		let _ = e;
		return _ && (_.changes !== void 0 || _.documentChanges !== void 0) && (_.documentChanges === void 0 || _.documentChanges.every((e) => Is.string(e.kind) ? CreateFile.is(e) || RenameFile.is(e) || DeleteFile.is(e) : TextDocumentEdit.is(e)));
	}
	e.is = _;
})(WorkspaceEdit ||= {});
var TextDocumentIdentifier;
(function(e) {
	function _(e) {
		return { uri: e };
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Is.string(_.uri);
	}
	e.is = v;
})(TextDocumentIdentifier ||= {});
var VersionedTextDocumentIdentifier;
(function(e) {
	function _(e, _) {
		return {
			uri: e,
			version: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Is.string(_.uri) && Is.integer(_.version);
	}
	e.is = v;
})(VersionedTextDocumentIdentifier ||= {});
var OptionalVersionedTextDocumentIdentifier;
(function(e) {
	function _(e, _) {
		return {
			uri: e,
			version: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Is.string(_.uri) && (_.version === null || Is.integer(_.version));
	}
	e.is = v;
})(OptionalVersionedTextDocumentIdentifier ||= {});
var TextDocumentItem;
(function(e) {
	function _(e, _, v, y) {
		return {
			uri: e,
			languageId: _,
			version: v,
			text: y
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Is.string(_.uri) && Is.string(_.languageId) && Is.integer(_.version) && Is.string(_.text);
	}
	e.is = v;
})(TextDocumentItem ||= {});
var MarkupKind;
(function(e) {
	e.PlainText = "plaintext", e.Markdown = "markdown";
	function _(_) {
		let v = _;
		return v === e.PlainText || v === e.Markdown;
	}
	e.is = _;
})(MarkupKind ||= {});
var MarkupContent;
(function(e) {
	function _(e) {
		let _ = e;
		return Is.objectLiteral(e) && MarkupKind.is(_.kind) && Is.string(_.value);
	}
	e.is = _;
})(MarkupContent ||= {});
var CompletionItemKind$1;
(function(e) {
	e.Text = 1, e.Method = 2, e.Function = 3, e.Constructor = 4, e.Field = 5, e.Variable = 6, e.Class = 7, e.Interface = 8, e.Module = 9, e.Property = 10, e.Unit = 11, e.Value = 12, e.Enum = 13, e.Keyword = 14, e.Snippet = 15, e.Color = 16, e.File = 17, e.Reference = 18, e.Folder = 19, e.EnumMember = 20, e.Constant = 21, e.Struct = 22, e.Event = 23, e.Operator = 24, e.TypeParameter = 25;
})(CompletionItemKind$1 ||= {});
var InsertTextFormat;
(function(e) {
	e.PlainText = 1, e.Snippet = 2;
})(InsertTextFormat ||= {});
var CompletionItemTag;
(function(e) {
	e.Deprecated = 1;
})(CompletionItemTag ||= {});
var InsertReplaceEdit;
(function(e) {
	function _(e, _, v) {
		return {
			newText: e,
			insert: _,
			replace: v
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ && Is.string(_.newText) && Range$2.is(_.insert) && Range$2.is(_.replace);
	}
	e.is = v;
})(InsertReplaceEdit ||= {});
var InsertTextMode;
(function(e) {
	e.asIs = 1, e.adjustIndentation = 2;
})(InsertTextMode ||= {});
var CompletionItemLabelDetails;
(function(e) {
	function _(e) {
		let _ = e;
		return _ && (Is.string(_.detail) || _.detail === void 0) && (Is.string(_.description) || _.description === void 0);
	}
	e.is = _;
})(CompletionItemLabelDetails ||= {});
var CompletionItem$1;
(function(e) {
	function _(e) {
		return { label: e };
	}
	e.create = _;
})(CompletionItem$1 ||= {});
var CompletionList;
(function(e) {
	function _(e, _) {
		return {
			items: e || [],
			isIncomplete: !!_
		};
	}
	e.create = _;
})(CompletionList ||= {});
var MarkedString;
(function(e) {
	function _(e) {
		return e.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
	}
	e.fromPlainText = _;
	function v(e) {
		let _ = e;
		return Is.string(_) || Is.objectLiteral(_) && Is.string(_.language) && Is.string(_.value);
	}
	e.is = v;
})(MarkedString ||= {});
var Hover;
(function(e) {
	function _(e) {
		let _ = e;
		return !!_ && Is.objectLiteral(_) && (MarkupContent.is(_.contents) || MarkedString.is(_.contents) || Is.typedArray(_.contents, MarkedString.is)) && (e.range === void 0 || Range$2.is(e.range));
	}
	e.is = _;
})(Hover ||= {});
var ParameterInformation;
(function(e) {
	function _(e, _) {
		return _ ? {
			label: e,
			documentation: _
		} : { label: e };
	}
	e.create = _;
})(ParameterInformation ||= {});
var SignatureInformation;
(function(e) {
	function _(e, _, ...v) {
		let y = { label: e };
		return Is.defined(_) && (y.documentation = _), Is.defined(v) ? y.parameters = v : y.parameters = [], y;
	}
	e.create = _;
})(SignatureInformation ||= {});
var DocumentHighlightKind$1;
(function(e) {
	e.Text = 1, e.Read = 2, e.Write = 3;
})(DocumentHighlightKind$1 ||= {});
var DocumentHighlight;
(function(e) {
	function _(e, _) {
		let v = { range: e };
		return Is.number(_) && (v.kind = _), v;
	}
	e.create = _;
})(DocumentHighlight ||= {});
var SymbolKind;
(function(e) {
	e.File = 1, e.Module = 2, e.Namespace = 3, e.Package = 4, e.Class = 5, e.Method = 6, e.Property = 7, e.Field = 8, e.Constructor = 9, e.Enum = 10, e.Interface = 11, e.Function = 12, e.Variable = 13, e.Constant = 14, e.String = 15, e.Number = 16, e.Boolean = 17, e.Array = 18, e.Object = 19, e.Key = 20, e.Null = 21, e.EnumMember = 22, e.Struct = 23, e.Event = 24, e.Operator = 25, e.TypeParameter = 26;
})(SymbolKind ||= {});
var SymbolTag;
(function(e) {
	e.Deprecated = 1;
})(SymbolTag ||= {});
var SymbolInformation;
(function(e) {
	function _(e, _, v, y, b) {
		let x = {
			name: e,
			kind: _,
			location: {
				uri: y,
				range: v
			}
		};
		return b && (x.containerName = b), x;
	}
	e.create = _;
})(SymbolInformation ||= {});
var WorkspaceSymbol;
(function(e) {
	function _(e, _, v, y) {
		return y === void 0 ? {
			name: e,
			kind: _,
			location: { uri: v }
		} : {
			name: e,
			kind: _,
			location: {
				uri: v,
				range: y
			}
		};
	}
	e.create = _;
})(WorkspaceSymbol ||= {});
var DocumentSymbol;
(function(e) {
	function _(e, _, v, y, b, x) {
		let S = {
			name: e,
			detail: _,
			kind: v,
			range: y,
			selectionRange: b
		};
		return x !== void 0 && (S.children = x), S;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ && Is.string(_.name) && Is.number(_.kind) && Range$2.is(_.range) && Range$2.is(_.selectionRange) && (_.detail === void 0 || Is.string(_.detail)) && (_.deprecated === void 0 || Is.boolean(_.deprecated)) && (_.children === void 0 || Array.isArray(_.children)) && (_.tags === void 0 || Array.isArray(_.tags));
	}
	e.is = v;
})(DocumentSymbol ||= {});
var CodeActionKind$1;
(function(e) {
	e.Empty = "", e.QuickFix = "quickfix", e.Refactor = "refactor", e.RefactorExtract = "refactor.extract", e.RefactorInline = "refactor.inline", e.RefactorRewrite = "refactor.rewrite", e.Source = "source", e.SourceOrganizeImports = "source.organizeImports", e.SourceFixAll = "source.fixAll";
})(CodeActionKind$1 ||= {});
var CodeActionTriggerKind;
(function(e) {
	e.Invoked = 1, e.Automatic = 2;
})(CodeActionTriggerKind ||= {});
var CodeActionContext;
(function(e) {
	function _(e, _, v) {
		let y = { diagnostics: e };
		return _ != null && (y.only = _), v != null && (y.triggerKind = v), y;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Is.typedArray(_.diagnostics, Diagnostic.is) && (_.only === void 0 || Is.typedArray(_.only, Is.string)) && (_.triggerKind === void 0 || _.triggerKind === CodeActionTriggerKind.Invoked || _.triggerKind === CodeActionTriggerKind.Automatic);
	}
	e.is = v;
})(CodeActionContext ||= {});
var CodeAction;
(function(e) {
	function _(e, _, v) {
		let y = { title: e }, b = !0;
		return typeof _ == "string" ? (b = !1, y.kind = _) : Command.is(_) ? y.command = _ : y.edit = _, b && v !== void 0 && (y.kind = v), y;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ && Is.string(_.title) && (_.diagnostics === void 0 || Is.typedArray(_.diagnostics, Diagnostic.is)) && (_.kind === void 0 || Is.string(_.kind)) && (_.edit !== void 0 || _.command !== void 0) && (_.command === void 0 || Command.is(_.command)) && (_.isPreferred === void 0 || Is.boolean(_.isPreferred)) && (_.edit === void 0 || WorkspaceEdit.is(_.edit));
	}
	e.is = v;
})(CodeAction ||= {});
var CodeLens;
(function(e) {
	function _(e, _) {
		let v = { range: e };
		return Is.defined(_) && (v.data = _), v;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Range$2.is(_.range) && (Is.undefined(_.command) || Command.is(_.command));
	}
	e.is = v;
})(CodeLens ||= {});
var FormattingOptions;
(function(e) {
	function _(e, _) {
		return {
			tabSize: e,
			insertSpaces: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Is.uinteger(_.tabSize) && Is.boolean(_.insertSpaces);
	}
	e.is = v;
})(FormattingOptions ||= {});
var DocumentLink;
(function(e) {
	function _(e, _, v) {
		return {
			range: e,
			target: _,
			data: v
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Range$2.is(_.range) && (Is.undefined(_.target) || Is.string(_.target));
	}
	e.is = v;
})(DocumentLink ||= {});
var SelectionRange;
(function(e) {
	function _(e, _) {
		return {
			range: e,
			parent: _
		};
	}
	e.create = _;
	function v(_) {
		let v = _;
		return Is.objectLiteral(v) && Range$2.is(v.range) && (v.parent === void 0 || e.is(v.parent));
	}
	e.is = v;
})(SelectionRange ||= {});
var SemanticTokenTypes;
(function(e) {
	e.namespace = "namespace", e.type = "type", e.class = "class", e.enum = "enum", e.interface = "interface", e.struct = "struct", e.typeParameter = "typeParameter", e.parameter = "parameter", e.variable = "variable", e.property = "property", e.enumMember = "enumMember", e.event = "event", e.function = "function", e.method = "method", e.macro = "macro", e.keyword = "keyword", e.modifier = "modifier", e.comment = "comment", e.string = "string", e.number = "number", e.regexp = "regexp", e.operator = "operator", e.decorator = "decorator";
})(SemanticTokenTypes ||= {});
var SemanticTokenModifiers;
(function(e) {
	e.declaration = "declaration", e.definition = "definition", e.readonly = "readonly", e.static = "static", e.deprecated = "deprecated", e.abstract = "abstract", e.async = "async", e.modification = "modification", e.documentation = "documentation", e.defaultLibrary = "defaultLibrary";
})(SemanticTokenModifiers ||= {});
var SemanticTokens;
(function(e) {
	function _(e) {
		let _ = e;
		return Is.objectLiteral(_) && (_.resultId === void 0 || typeof _.resultId == "string") && Array.isArray(_.data) && (_.data.length === 0 || typeof _.data[0] == "number");
	}
	e.is = _;
})(SemanticTokens ||= {});
var InlineValueText;
(function(e) {
	function _(e, _) {
		return {
			range: e,
			text: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ != null && Range$2.is(_.range) && Is.string(_.text);
	}
	e.is = v;
})(InlineValueText ||= {});
var InlineValueVariableLookup;
(function(e) {
	function _(e, _, v) {
		return {
			range: e,
			variableName: _,
			caseSensitiveLookup: v
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ != null && Range$2.is(_.range) && Is.boolean(_.caseSensitiveLookup) && (Is.string(_.variableName) || _.variableName === void 0);
	}
	e.is = v;
})(InlineValueVariableLookup ||= {});
var InlineValueEvaluatableExpression;
(function(e) {
	function _(e, _) {
		return {
			range: e,
			expression: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return _ != null && Range$2.is(_.range) && (Is.string(_.expression) || _.expression === void 0);
	}
	e.is = v;
})(InlineValueEvaluatableExpression ||= {});
var InlineValueContext;
(function(e) {
	function _(e, _) {
		return {
			frameId: e,
			stoppedLocation: _
		};
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.defined(_) && Range$2.is(e.stoppedLocation);
	}
	e.is = v;
})(InlineValueContext ||= {});
var InlayHintKind;
(function(e) {
	e.Type = 1, e.Parameter = 2;
	function _(e) {
		return e === 1 || e === 2;
	}
	e.is = _;
})(InlayHintKind ||= {});
var InlayHintLabelPart;
(function(e) {
	function _(e) {
		return { value: e };
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && (_.tooltip === void 0 || Is.string(_.tooltip) || MarkupContent.is(_.tooltip)) && (_.location === void 0 || Location.is(_.location)) && (_.command === void 0 || Command.is(_.command));
	}
	e.is = v;
})(InlayHintLabelPart ||= {});
var InlayHint;
(function(e) {
	function _(e, _, v) {
		let y = {
			position: e,
			label: _
		};
		return v !== void 0 && (y.kind = v), y;
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return Is.objectLiteral(_) && Position$2.is(_.position) && (Is.string(_.label) || Is.typedArray(_.label, InlayHintLabelPart.is)) && (_.kind === void 0 || InlayHintKind.is(_.kind)) && _.textEdits === void 0 || Is.typedArray(_.textEdits, TextEdit$1.is) && (_.tooltip === void 0 || Is.string(_.tooltip) || MarkupContent.is(_.tooltip)) && (_.paddingLeft === void 0 || Is.boolean(_.paddingLeft)) && (_.paddingRight === void 0 || Is.boolean(_.paddingRight));
	}
	e.is = v;
})(InlayHint ||= {});
var StringValue;
(function(e) {
	function _(e) {
		return {
			kind: "snippet",
			value: e
		};
	}
	e.createSnippet = _;
})(StringValue ||= {});
var InlineCompletionItem$1;
(function(e) {
	function _(e, _, v, y) {
		return {
			insertText: e,
			filterText: _,
			range: v,
			command: y
		};
	}
	e.create = _;
})(InlineCompletionItem$1 ||= {});
var InlineCompletionList$1;
(function(e) {
	function _(e) {
		return { items: e };
	}
	e.create = _;
})(InlineCompletionList$1 ||= {});
var InlineCompletionTriggerKind$1;
(function(e) {
	e.Invoked = 0, e.Automatic = 1;
})(InlineCompletionTriggerKind$1 ||= {});
var SelectedCompletionInfo;
(function(e) {
	function _(e, _) {
		return {
			range: e,
			text: _
		};
	}
	e.create = _;
})(SelectedCompletionInfo ||= {});
var InlineCompletionContext;
(function(e) {
	function _(e, _) {
		return {
			triggerKind: e,
			selectedCompletionInfo: _
		};
	}
	e.create = _;
})(InlineCompletionContext ||= {});
var WorkspaceFolder;
(function(e) {
	function _(e) {
		let _ = e;
		return Is.objectLiteral(_) && URI$1.is(_.uri) && Is.string(_.name);
	}
	e.is = _;
})(WorkspaceFolder ||= {});
var TextDocument;
(function(e) {
	function _(e, _, v, y) {
		return new FullTextDocument(e, _, v, y);
	}
	e.create = _;
	function v(e) {
		let _ = e;
		return !!(Is.defined(_) && Is.string(_.uri) && (Is.undefined(_.languageId) || Is.string(_.languageId)) && Is.uinteger(_.lineCount) && Is.func(_.getText) && Is.func(_.positionAt) && Is.func(_.offsetAt));
	}
	e.is = v;
	function y(e, _) {
		let v = e.getText(), y = b(_, (e, _) => {
			let v = e.range.start.line - _.range.start.line;
			return v === 0 ? e.range.start.character - _.range.start.character : v;
		}), x = v.length;
		for (let _ = y.length - 1; _ >= 0; _--) {
			let b = y[_], S = e.offsetAt(b.range.start), C = e.offsetAt(b.range.end);
			if (C <= x) v = v.substring(0, S) + b.newText + v.substring(C, v.length);
			else throw Error("Overlapping edit");
			x = S;
		}
		return v;
	}
	e.applyEdits = y;
	function b(e, _) {
		if (e.length <= 1) return e;
		let v = e.length / 2 | 0, y = e.slice(0, v), x = e.slice(v);
		b(y, _), b(x, _);
		let S = 0, C = 0, w = 0;
		for (; S < y.length && C < x.length;) _(y[S], x[C]) <= 0 ? e[w++] = y[S++] : e[w++] = x[C++];
		for (; S < y.length;) e[w++] = y[S++];
		for (; C < x.length;) e[w++] = x[C++];
		return e;
	}
})(TextDocument ||= {});
var FullTextDocument = class {
	constructor(e, _, v, y) {
		this._uri = e, this._languageId = _, this._version = v, this._content = y, this._lineOffsets = void 0;
	}
	get uri() {
		return this._uri;
	}
	get languageId() {
		return this._languageId;
	}
	get version() {
		return this._version;
	}
	getText(e) {
		if (e) {
			let _ = this.offsetAt(e.start), v = this.offsetAt(e.end);
			return this._content.substring(_, v);
		}
		return this._content;
	}
	update(e, _) {
		this._content = e.text, this._version = _, this._lineOffsets = void 0;
	}
	getLineOffsets() {
		if (this._lineOffsets === void 0) {
			let e = [], _ = this._content, v = !0;
			for (let y = 0; y < _.length; y++) {
				v &&= (e.push(y), !1);
				let b = _.charAt(y);
				v = b === "\r" || b === "\n", b === "\r" && y + 1 < _.length && _.charAt(y + 1) === "\n" && y++;
			}
			v && _.length > 0 && e.push(_.length), this._lineOffsets = e;
		}
		return this._lineOffsets;
	}
	positionAt(e) {
		e = Math.max(Math.min(e, this._content.length), 0);
		let _ = this.getLineOffsets(), v = 0, y = _.length;
		if (y === 0) return Position$2.create(0, e);
		for (; v < y;) {
			let b = Math.floor((v + y) / 2);
			_[b] > e ? y = b : v = b + 1;
		}
		let b = v - 1;
		return Position$2.create(b, e - _[b]);
	}
	offsetAt(e) {
		let _ = this.getLineOffsets();
		if (e.line >= _.length) return this._content.length;
		if (e.line < 0) return 0;
		let v = _[e.line], y = e.line + 1 < _.length ? _[e.line + 1] : this._content.length;
		return Math.max(Math.min(v + e.character, y), v);
	}
	get lineCount() {
		return this.getLineOffsets().length;
	}
}, Is;
(function(e) {
	let _ = Object.prototype.toString;
	function v(e) {
		return e !== void 0;
	}
	e.defined = v;
	function y(e) {
		return e === void 0;
	}
	e.undefined = y;
	function b(e) {
		return e === !0 || e === !1;
	}
	e.boolean = b;
	function x(e) {
		return _.call(e) === "[object String]";
	}
	e.string = x;
	function S(e) {
		return _.call(e) === "[object Number]";
	}
	e.number = S;
	function C(e, v, y) {
		return _.call(e) === "[object Number]" && v <= e && e <= y;
	}
	e.numberRange = C;
	function w(e) {
		return _.call(e) === "[object Number]" && -2147483648 <= e && e <= 2147483647;
	}
	e.integer = w;
	function T(e) {
		return _.call(e) === "[object Number]" && 0 <= e && e <= 2147483647;
	}
	e.uinteger = T;
	function E(e) {
		return _.call(e) === "[object Function]";
	}
	e.func = E;
	function D(e) {
		return typeof e == "object" && !!e;
	}
	e.objectLiteral = D;
	function O(e, _) {
		return Array.isArray(e) && e.every(_);
	}
	e.typedArray = O;
})(Is ||= {});
var CharacterStream = class {
	constructor(e) {
		this._start = 0, this._pos = 0, this.getStartOfToken = () => this._start, this.getCurrentPosition = () => this._pos, this.eol = () => this._sourceText.length === this._pos, this.sol = () => this._pos === 0, this.peek = () => this._sourceText.charAt(this._pos) || null, this.next = () => {
			let e = this._sourceText.charAt(this._pos);
			return this._pos++, e;
		}, this.eat = (e) => {
			if (this._testNextCharacter(e)) return this._start = this._pos, this._pos++, this._sourceText.charAt(this._pos - 1);
		}, this.eatWhile = (e) => {
			let _ = this._testNextCharacter(e), v = !1;
			for (_ && (v = _, this._start = this._pos); _;) this._pos++, _ = this._testNextCharacter(e), v = !0;
			return v;
		}, this.eatSpace = () => this.eatWhile(/[\s\u00a0]/), this.skipToEnd = () => {
			this._pos = this._sourceText.length;
		}, this.skipTo = (e) => {
			this._pos = e;
		}, this.match = (e, _ = !0, v = !1) => {
			let y = null, b = null;
			return typeof e == "string" ? (b = new RegExp(e, v ? "i" : "g").test(this._sourceText.slice(this._pos, this._pos + e.length)), y = e) : e instanceof RegExp && (b = this._sourceText.slice(this._pos).match(e), y = b?.[0]), b != null && (typeof e == "string" || b instanceof Array && this._sourceText.startsWith(b[0], this._pos)) ? (_ && (this._start = this._pos, y && y.length && (this._pos += y.length)), b) : !1;
		}, this.backUp = (e) => {
			this._pos -= e;
		}, this.column = () => this._pos, this.indentation = () => {
			let e = this._sourceText.match(/\s*/), _ = 0;
			if (e && e.length !== 0) {
				let v = e[0], y = 0;
				for (; v.length > y;) v.charCodeAt(y) === 9 ? _ += 2 : _++, y++;
			}
			return _;
		}, this.current = () => this._sourceText.slice(this._start, this._pos), this._sourceText = e;
	}
	_testNextCharacter(e) {
		let _ = this._sourceText.charAt(this._pos), v = !1;
		return v = typeof e == "string" ? _ === e : e instanceof RegExp ? e.test(_) : e(_), v;
	}
};
function opt(e) {
	return { ofRule: e };
}
function list(e, _) {
	return {
		ofRule: e,
		isList: !0,
		separator: _
	};
}
function butNot(e, _) {
	let v = e.match;
	return e.match = (e) => {
		let y = !1;
		return v && (y = v(e)), y && _.every((_) => _.match && !_.match(e));
	}, e;
}
function t(e, _) {
	return {
		style: _,
		match: (_) => _.kind === e
	};
}
function p(e, _) {
	return {
		style: _ || "punctuation",
		match: (_) => _.kind === "Punctuation" && _.value === e
	};
}
const isIgnored = (e) => e === " " || e === "	" || e === "," || e === "\n" || e === "\r" || e === "" || e === "\xA0", LexRules = {
	Name: /^[_A-Za-z][_0-9A-Za-z]*/,
	Punctuation: /^(?:!|\$|\(|\)|\.\.\.|:|=|&|@|\[|]|\{|\||\})/,
	Number: /^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,
	String: /^(?:"""(?:\\"""|[^"]|"[^"]|""[^"])*(?:""")?|"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?)/,
	Comment: /^#.*/
}, ParseRules = {
	Document: [list("Definition")],
	Definition(e) {
		switch (e.value) {
			case "{": return "ShortQuery";
			case "query": return "Query";
			case "mutation": return "Mutation";
			case "subscription": return "Subscription";
			case "fragment": return Kind.FRAGMENT_DEFINITION;
			case "schema": return "SchemaDef";
			case "scalar": return "ScalarDef";
			case "type": return "ObjectTypeDef";
			case "interface": return "InterfaceDef";
			case "union": return "UnionDef";
			case "enum": return "EnumDef";
			case "input": return "InputDef";
			case "extend": return "ExtendDef";
			case "directive": return "DirectiveDef";
		}
	},
	ShortQuery: ["SelectionSet"],
	Query: [
		word("query"),
		opt(name("def")),
		opt("VariableDefinitions"),
		list("Directive"),
		"SelectionSet"
	],
	Mutation: [
		word("mutation"),
		opt(name("def")),
		opt("VariableDefinitions"),
		list("Directive"),
		"SelectionSet"
	],
	Subscription: [
		word("subscription"),
		opt(name("def")),
		opt("VariableDefinitions"),
		list("Directive"),
		"SelectionSet"
	],
	VariableDefinitions: [
		p("("),
		list("VariableDefinition"),
		p(")")
	],
	VariableDefinition: [
		"Variable",
		p(":"),
		"Type",
		opt("DefaultValue")
	],
	Variable: [p("$", "variable"), name("variable")],
	DefaultValue: [p("="), "Value"],
	SelectionSet: [
		p("{"),
		list("Selection"),
		p("}")
	],
	Selection(e, _) {
		return e.value === "..." ? _.match(/[\s\u00a0,]*(on\b|@|{)/, !1) ? "InlineFragment" : "FragmentSpread" : _.match(/[\s\u00a0,]*:/, !1) ? "AliasedField" : "Field";
	},
	AliasedField: [
		name("property"),
		p(":"),
		name("qualifier"),
		opt("Arguments"),
		list("Directive"),
		opt("SelectionSet")
	],
	Field: [
		name("property"),
		opt("Arguments"),
		list("Directive"),
		opt("SelectionSet")
	],
	Arguments: [
		p("("),
		list("Argument"),
		p(")")
	],
	Argument: [
		name("attribute"),
		p(":"),
		"Value"
	],
	FragmentSpread: [
		p("..."),
		name("def"),
		list("Directive")
	],
	InlineFragment: [
		p("..."),
		opt("TypeCondition"),
		list("Directive"),
		"SelectionSet"
	],
	FragmentDefinition: [
		word("fragment"),
		opt(butNot(name("def"), [word("on")])),
		"TypeCondition",
		list("Directive"),
		"SelectionSet"
	],
	TypeCondition: [word("on"), "NamedType"],
	Value(e) {
		switch (e.kind) {
			case "Number": return "NumberValue";
			case "String": return "StringValue";
			case "Punctuation":
				switch (e.value) {
					case "[": return "ListValue";
					case "{": return "ObjectValue";
					case "$": return "Variable";
					case "&": return "NamedType";
				}
				return null;
			case "Name":
				switch (e.value) {
					case "true":
					case "false": return "BooleanValue";
				}
				return e.value === "null" ? "NullValue" : "EnumValue";
		}
	},
	NumberValue: [t("Number", "number")],
	StringValue: [{
		style: "string",
		match: (e) => e.kind === "String",
		update(e, _) {
			_.value.startsWith("\"\"\"") && (e.inBlockstring = !_.value.slice(3).endsWith("\"\"\""));
		}
	}],
	BooleanValue: [t("Name", "builtin")],
	NullValue: [t("Name", "keyword")],
	EnumValue: [name("string-2")],
	ListValue: [
		p("["),
		list("Value"),
		p("]")
	],
	ObjectValue: [
		p("{"),
		list("ObjectField"),
		p("}")
	],
	ObjectField: [
		name("attribute"),
		p(":"),
		"Value"
	],
	Type(e) {
		return e.value === "[" ? "ListType" : "NonNullType";
	},
	ListType: [
		p("["),
		"Type",
		p("]"),
		opt(p("!"))
	],
	NonNullType: ["NamedType", opt(p("!"))],
	NamedType: [type("atom")],
	Directive: [
		p("@", "meta"),
		name("meta"),
		opt("Arguments")
	],
	DirectiveDef: [
		word("directive"),
		p("@", "meta"),
		name("meta"),
		opt("ArgumentsDef"),
		word("on"),
		list("DirectiveLocation", p("|"))
	],
	InterfaceDef: [
		word("interface"),
		name("atom"),
		opt("Implements"),
		list("Directive"),
		p("{"),
		list("FieldDef"),
		p("}")
	],
	Implements: [word("implements"), list("NamedType", p("&"))],
	DirectiveLocation: [name("string-2")],
	SchemaDef: [
		word("schema"),
		list("Directive"),
		p("{"),
		list("OperationTypeDef"),
		p("}")
	],
	OperationTypeDef: [
		name("keyword"),
		p(":"),
		name("atom")
	],
	ScalarDef: [
		word("scalar"),
		name("atom"),
		list("Directive")
	],
	ObjectTypeDef: [
		word("type"),
		name("atom"),
		opt("Implements"),
		list("Directive"),
		p("{"),
		list("FieldDef"),
		p("}")
	],
	FieldDef: [
		name("property"),
		opt("ArgumentsDef"),
		p(":"),
		"Type",
		list("Directive")
	],
	ArgumentsDef: [
		p("("),
		list("InputValueDef"),
		p(")")
	],
	InputValueDef: [
		name("attribute"),
		p(":"),
		"Type",
		opt("DefaultValue"),
		list("Directive")
	],
	UnionDef: [
		word("union"),
		name("atom"),
		list("Directive"),
		p("="),
		list("UnionMember", p("|"))
	],
	UnionMember: ["NamedType"],
	EnumDef: [
		word("enum"),
		name("atom"),
		list("Directive"),
		p("{"),
		list("EnumValueDef"),
		p("}")
	],
	EnumValueDef: [name("string-2"), list("Directive")],
	InputDef: [
		word("input"),
		name("atom"),
		list("Directive"),
		p("{"),
		list("InputValueDef"),
		p("}")
	],
	ExtendDef: [word("extend"), "ExtensionDefinition"],
	ExtensionDefinition(e) {
		switch (e.value) {
			case "schema": return Kind.SCHEMA_EXTENSION;
			case "scalar": return Kind.SCALAR_TYPE_EXTENSION;
			case "type": return Kind.OBJECT_TYPE_EXTENSION;
			case "interface": return Kind.INTERFACE_TYPE_EXTENSION;
			case "union": return Kind.UNION_TYPE_EXTENSION;
			case "enum": return Kind.ENUM_TYPE_EXTENSION;
			case "input": return Kind.INPUT_OBJECT_TYPE_EXTENSION;
		}
	},
	[Kind.SCHEMA_EXTENSION]: ["SchemaDef"],
	[Kind.SCALAR_TYPE_EXTENSION]: ["ScalarDef"],
	[Kind.OBJECT_TYPE_EXTENSION]: ["ObjectTypeDef"],
	[Kind.INTERFACE_TYPE_EXTENSION]: ["InterfaceDef"],
	[Kind.UNION_TYPE_EXTENSION]: ["UnionDef"],
	[Kind.ENUM_TYPE_EXTENSION]: ["EnumDef"],
	[Kind.INPUT_OBJECT_TYPE_EXTENSION]: ["InputDef"]
};
function word(e) {
	return {
		style: "keyword",
		match: (_) => _.kind === "Name" && _.value === e
	};
}
function name(e) {
	return {
		style: e,
		match: (e) => e.kind === "Name",
		update(e, _) {
			e.name = _.value;
		}
	};
}
function type(e) {
	return {
		style: e,
		match: (e) => e.kind === "Name",
		update(e, _) {
			e.prevState?.prevState && (e.name = _.value, e.prevState.prevState.type = _.value);
		}
	};
}
function onlineParser(e = {
	eatWhitespace: (e) => e.eatWhile(isIgnored),
	lexRules: LexRules,
	parseRules: ParseRules,
	editorConfig: {}
}) {
	return {
		startState() {
			let _ = {
				level: 0,
				step: 0,
				name: null,
				kind: null,
				type: null,
				rule: null,
				needsSeparator: !1,
				prevState: null
			};
			return pushRule(e.parseRules, _, Kind.DOCUMENT), _;
		},
		token(_, v) {
			return getToken(_, v, e);
		}
	};
}
function getToken(e, _, v) {
	if (_.inBlockstring) return e.match(/.*"""/) ? (_.inBlockstring = !1, "string") : (e.skipToEnd(), "string");
	let { lexRules: y, parseRules: b, eatWhitespace: x, editorConfig: S } = v;
	if (_.rule && _.rule.length === 0 ? popRule(_) : _.needsAdvance && (_.needsAdvance = !1, advanceRule(_, !0)), e.sol()) {
		let v = S?.tabSize || 2;
		_.indentLevel = Math.floor(e.indentation() / v);
	}
	if (x(e)) return "ws";
	let C = lex(y, e);
	if (!C) return e.match(/\S+/) || e.match(/\s/), pushRule(SpecialParseRules, _, "Invalid"), "invalidchar";
	if (C.kind === "Comment") return pushRule(SpecialParseRules, _, "Comment"), "comment";
	let w = assign({}, _);
	if (C.kind === "Punctuation") {
		if (/^[{([]/.test(C.value)) _.indentLevel !== void 0 && (_.levels = (_.levels || []).concat(_.indentLevel + 1));
		else if (/^[})\]]/.test(C.value)) {
			let e = _.levels = (_.levels || []).slice(0, -1);
			_.indentLevel && e.length > 0 && e.at(-1) < _.indentLevel && (_.indentLevel = e.at(-1));
		}
	}
	for (; _.rule;) {
		let v = typeof _.rule == "function" ? _.step === 0 ? _.rule(C, e) : null : _.rule[_.step];
		if (_.needsSeparator && (v = v?.separator), v) {
			if (v.ofRule && (v = v.ofRule), typeof v == "string") {
				pushRule(b, _, v);
				continue;
			}
			if (v.match?.call(v, C)) return v.update && v.update(_, C), C.kind === "Punctuation" ? advanceRule(_, !0) : _.needsAdvance = !0, v.style;
		}
		unsuccessful(_);
	}
	return assign(_, w), pushRule(SpecialParseRules, _, "Invalid"), "invalidchar";
}
function assign(e, _) {
	let v = Object.keys(_);
	for (let y = 0; y < v.length; y++) e[v[y]] = _[v[y]];
	return e;
}
var SpecialParseRules = {
	Invalid: [],
	Comment: []
};
function pushRule(e, _, v) {
	if (!e[v]) throw TypeError("Unknown rule: " + v);
	_.prevState = Object.assign({}, _), _.kind = v, _.name = null, _.type = null, _.rule = e[v], _.step = 0, _.needsSeparator = !1;
}
function popRule(e) {
	e.prevState &&= (e.kind = e.prevState.kind, e.name = e.prevState.name, e.type = e.prevState.type, e.rule = e.prevState.rule, e.step = e.prevState.step, e.needsSeparator = e.prevState.needsSeparator, e.prevState.prevState);
}
function advanceRule(e, _) {
	if (isList(e) && e.rule) {
		let v = e.rule[e.step];
		if (v.separator) {
			let { separator: _ } = v;
			if (e.needsSeparator = !e.needsSeparator, !e.needsSeparator && _.ofRule) return;
		}
		if (_) return;
	}
	for (e.needsSeparator = !1, e.step++; e.rule && !(Array.isArray(e.rule) && e.step < e.rule.length);) popRule(e), e.rule && (isList(e) ? e.rule?.[e.step].separator && (e.needsSeparator = !e.needsSeparator) : (e.needsSeparator = !1, e.step++));
}
function isList(e) {
	let _ = Array.isArray(e.rule) && typeof e.rule[e.step] != "string" && e.rule[e.step];
	return _ && _.isList;
}
function unsuccessful(e) {
	for (; e.rule && !(Array.isArray(e.rule) && e.rule[e.step].ofRule);) popRule(e);
	e.rule && advanceRule(e, !1);
}
function lex(e, _) {
	let v = Object.keys(e);
	for (let y = 0; y < v.length; y++) {
		let b = _.match(e[v[y]]);
		if (b && b instanceof Array) return {
			kind: v[y],
			value: b[0]
		};
	}
}
function runOnlineParser(e, _) {
	let v = e.split("\n"), y = onlineParser(), b = y.startState(), x = "", S = new CharacterStream("");
	for (let e = 0; e < v.length; e++) {
		for (S = new CharacterStream(v[e]); !S.eol() && (x = y.token(S, b), _(S, b, x, e) !== "BREAK"););
		_(S, b, x, e), b.kind || (b = y.startState());
	}
	return {
		start: S.getStartOfToken(),
		end: S.getCurrentPosition(),
		string: S.current(),
		state: b,
		style: x
	};
}
var GraphQLDocumentMode;
(function(e) {
	e.TYPE_SYSTEM = "TYPE_SYSTEM", e.EXECUTABLE = "EXECUTABLE", e.UNKNOWN = "UNKNOWN";
})(GraphQLDocumentMode ||= {});
const TYPE_SYSTEM_KINDS = [
	Kind.SCHEMA_DEFINITION,
	Kind.OPERATION_TYPE_DEFINITION,
	Kind.SCALAR_TYPE_DEFINITION,
	Kind.OBJECT_TYPE_DEFINITION,
	Kind.INTERFACE_TYPE_DEFINITION,
	Kind.UNION_TYPE_DEFINITION,
	Kind.ENUM_TYPE_DEFINITION,
	Kind.INPUT_OBJECT_TYPE_DEFINITION,
	Kind.DIRECTIVE_DEFINITION,
	Kind.SCHEMA_EXTENSION,
	Kind.SCALAR_TYPE_EXTENSION,
	Kind.OBJECT_TYPE_EXTENSION,
	Kind.INTERFACE_TYPE_EXTENSION,
	Kind.UNION_TYPE_EXTENSION,
	Kind.ENUM_TYPE_EXTENSION,
	Kind.INPUT_OBJECT_TYPE_EXTENSION
];
var getParsedMode = (e) => {
	let _ = GraphQLDocumentMode.UNKNOWN;
	if (e) try {
		visit(parse(e), { enter(e) {
			if (e.kind === "Document") {
				_ = GraphQLDocumentMode.EXECUTABLE;
				return;
			}
			return TYPE_SYSTEM_KINDS.includes(e.kind) ? (_ = GraphQLDocumentMode.TYPE_SYSTEM, BREAK) : !1;
		} });
	} catch {
		return _;
	}
	return _;
};
function getDocumentMode(e, _) {
	return _?.endsWith(".graphqls") ? GraphQLDocumentMode.TYPE_SYSTEM : getParsedMode(e);
}
function getTokenAtPosition(e, _, v = 0) {
	let y = null, b = null, x = null, S = runOnlineParser(e, (e, S, C, w) => {
		if (!(w !== _.line || e.getCurrentPosition() + v < _.character + 1)) return y = C, b = Object.assign({}, S), x = e.current(), "BREAK";
	});
	return {
		start: S.start,
		end: S.end,
		string: x || S.string,
		state: b || S.state,
		style: y || S.style
	};
}
function getContextAtPosition(e, _, v, y, b) {
	let x = y || getTokenAtPosition(e, _, 1);
	if (!x) return null;
	let S = x.state.kind === "Invalid" ? x.state.prevState : x.state;
	if (!S) return null;
	let C = getTypeInfo(v, x.state), w = b?.mode || getDocumentMode(e, b?.uri);
	return {
		token: x,
		state: S,
		typeInfo: C,
		mode: w
	};
}
function getFieldDef(e, _, v) {
	return v === SchemaMetaFieldDef.name && e.getQueryType() === _ ? SchemaMetaFieldDef : v === TypeMetaFieldDef.name && e.getQueryType() === _ ? TypeMetaFieldDef : v === TypeNameMetaFieldDef.name && isCompositeType(_) ? TypeNameMetaFieldDef : "getFields" in _ ? _.getFields()[v] : null;
}
function forEachState(e, _) {
	let v = [], y = e;
	for (; y?.kind;) v.push(y), y = y.prevState;
	for (let e = v.length - 1; e >= 0; e--) _(v[e]);
}
function getTypeInfo(e, _) {
	let v, y, b, x, S, C, w, T, E, D, O;
	return forEachState(_, (_) => {
		switch (_.kind) {
			case RuleKinds.QUERY:
			case "ShortQuery":
				D = e.getQueryType();
				break;
			case RuleKinds.MUTATION:
				D = e.getMutationType();
				break;
			case RuleKinds.SUBSCRIPTION:
				D = e.getSubscriptionType();
				break;
			case RuleKinds.INLINE_FRAGMENT:
			case RuleKinds.FRAGMENT_DEFINITION:
				_.type && (D = e.getType(_.type));
				break;
			case RuleKinds.FIELD:
			case RuleKinds.ALIASED_FIELD:
				!D || !_.name ? S = null : (S = E ? getFieldDef(e, E, _.name) : null, D = S ? S.type : null);
				break;
			case RuleKinds.SELECTION_SET:
				E = getNamedType(D);
				break;
			case RuleKinds.DIRECTIVE:
				b = _.name ? e.getDirective(_.name) : null;
				break;
			case RuleKinds.INTERFACE_DEF:
				_.name && (w = null, O = new GraphQLInterfaceType({
					name: _.name,
					interfaces: [],
					fields: {}
				}));
				break;
			case RuleKinds.OBJECT_TYPE_DEF:
				_.name && (O = null, w = new GraphQLObjectType({
					name: _.name,
					interfaces: [],
					fields: {}
				}));
				break;
			case RuleKinds.ARGUMENTS:
				if (_.prevState) switch (_.prevState.kind) {
					case RuleKinds.FIELD:
						y = S && S.args;
						break;
					case RuleKinds.DIRECTIVE:
						y = b && b.args;
						break;
					case RuleKinds.ALIASED_FIELD: {
						let v = _.prevState?.name;
						if (!v) {
							y = null;
							break;
						}
						let b = E ? getFieldDef(e, E, v) : null;
						if (!b) {
							y = null;
							break;
						}
						y = b.args;
						break;
					}
					default:
						y = null;
						break;
				}
				else y = null;
				break;
			case RuleKinds.ARGUMENT:
				if (y) {
					for (let e = 0; e < y.length; e++) if (y[e].name === _.name) {
						v = y[e];
						break;
					}
				}
				C = v?.type;
				break;
			case RuleKinds.VARIABLE_DEFINITION:
			case RuleKinds.VARIABLE:
				D = C;
				break;
			case RuleKinds.ENUM_VALUE:
				let k = getNamedType(C);
				x = k instanceof GraphQLEnumType ? k.getValues().find((e) => e.value === _.name) : null;
				break;
			case RuleKinds.LIST_VALUE:
				let A = getNullableType(C);
				C = A instanceof GraphQLList ? A.ofType : null;
				break;
			case RuleKinds.OBJECT_VALUE:
				let j = getNamedType(C);
				T = j instanceof GraphQLInputObjectType ? j.getFields() : null;
				break;
			case RuleKinds.OBJECT_FIELD:
				let M = _.name && T ? T[_.name] : null;
				C = M?.type, S = M, D = S ? S.type : null;
				break;
			case RuleKinds.NAMED_TYPE:
				_.name && (D = e.getType(_.name));
				break;
		}
	}), {
		argDef: v,
		argDefs: y,
		directiveDef: b,
		enumValue: x,
		fieldDef: S,
		inputType: C,
		objectFieldDefs: T,
		parentType: E,
		type: D,
		interfaceDef: O,
		objectTypeDef: w
	};
}
const RuleKinds = Object.assign(Object.assign({}, Kind), {
	ALIASED_FIELD: "AliasedField",
	ARGUMENTS: "Arguments",
	SHORT_QUERY: "ShortQuery",
	QUERY: "Query",
	MUTATION: "Mutation",
	SUBSCRIPTION: "Subscription",
	TYPE_CONDITION: "TypeCondition",
	INVALID: "Invalid",
	COMMENT: "Comment",
	SCHEMA_DEF: "SchemaDef",
	SCALAR_DEF: "ScalarDef",
	OBJECT_TYPE_DEF: "ObjectTypeDef",
	OBJECT_VALUE: "ObjectValue",
	LIST_VALUE: "ListValue",
	INTERFACE_DEF: "InterfaceDef",
	UNION_DEF: "UnionDef",
	ENUM_DEF: "EnumDef",
	ENUM_VALUE: "EnumValue",
	FIELD_DEF: "FieldDef",
	INPUT_DEF: "InputDef",
	INPUT_VALUE_DEF: "InputValueDef",
	ARGUMENTS_DEF: "ArgumentsDef",
	EXTEND_DEF: "ExtendDef",
	EXTENSION_DEFINITION: "ExtensionDefinition",
	DIRECTIVE_DEF: "DirectiveDef",
	IMPLEMENTS: "Implements",
	VARIABLE_DEFINITIONS: "VariableDefinitions",
	TYPE: "Type",
	VARIABLE: "Variable"
});
var CompletionItemKind;
(function(e) {
	e.Text = 1, e.Method = 2, e.Function = 3, e.Constructor = 4, e.Field = 5, e.Variable = 6, e.Class = 7, e.Interface = 8, e.Module = 9, e.Property = 10, e.Unit = 11, e.Value = 12, e.Enum = 13, e.Keyword = 14, e.Snippet = 15, e.Color = 16, e.File = 17, e.Reference = 18, e.Folder = 19, e.EnumMember = 20, e.Constant = 21, e.Struct = 22, e.Event = 23, e.Operator = 24, e.TypeParameter = 25;
})(CompletionItemKind ||= {}), CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Function, CompletionItemKind.Constructor, (/* @__PURE__ */ __commonJSMin(((e, _) => {
	function v(e, _) {
		if (e != null) return e;
		var v = Error(_ === void 0 ? "Got unexpected " + e : _);
		throw v.framesToPop = 1, v;
	}
	_.exports = v, _.exports.default = v, Object.defineProperty(_.exports, "__esModule", { value: !0 });
})))();
var Position$1 = class {
	constructor(e, _) {
		this.lessThanOrEqualTo = (e) => this.line < e.line || this.line === e.line && this.character <= e.character, this.line = e, this.character = _;
	}
	setLine(e) {
		this.line = e;
	}
	setCharacter(e) {
		this.character = e;
	}
};
const SEVERITY = {
	Error: "Error",
	Warning: "Warning",
	Information: "Information",
	Hint: "Hint"
};
SEVERITY.Error, SEVERITY.Warning, SEVERITY.Information, SEVERITY.Hint;
function getHoverInformation(e, _, v, y, b) {
	let x = Object.assign(Object.assign({}, b), { schema: e }), S = getContextAtPosition(_, v, e, y);
	if (!S) return "";
	let { typeInfo: C, token: w } = S, { kind: T, step: E } = w.state;
	if (T === "Field" && E === 0 && C.fieldDef || T === "AliasedField" && E === 2 && C.fieldDef || T === "ObjectField" && E === 0 && C.fieldDef) {
		let e = [];
		return renderMdCodeStart(e, x), renderField(e, C, x), renderMdCodeEnd(e, x), renderDescription(e, x, C.fieldDef), e.join("").trim();
	}
	if (T === "Directive" && E === 1 && C.directiveDef) {
		let e = [];
		return renderMdCodeStart(e, x), renderDirective(e, C, x), renderMdCodeEnd(e, x), renderDescription(e, x, C.directiveDef), e.join("").trim();
	}
	if (T === "Variable" && C.type) {
		let e = [];
		return renderMdCodeStart(e, x), renderType(e, C, x, C.type), renderMdCodeEnd(e, x), renderDescription(e, x, C.type), e.join("").trim();
	}
	if (T === "Argument" && E === 0 && C.argDef) {
		let e = [];
		return renderMdCodeStart(e, x), renderArg(e, C, x), renderMdCodeEnd(e, x), renderDescription(e, x, C.argDef), e.join("").trim();
	}
	if (T === "EnumValue" && C.enumValue && "description" in C.enumValue) {
		let e = [];
		return renderMdCodeStart(e, x), renderEnumValue(e, C, x), renderMdCodeEnd(e, x), renderDescription(e, x, C.enumValue), e.join("").trim();
	}
	if (T === "NamedType" && C.type && "description" in C.type) {
		let e = [];
		return renderMdCodeStart(e, x), renderType(e, C, x, C.type), renderMdCodeEnd(e, x), renderDescription(e, x, C.type), e.join("").trim();
	}
	return "";
}
function renderMdCodeStart(e, _) {
	_.useMarkdown && text(e, "```graphql\n");
}
function renderMdCodeEnd(e, _) {
	_.useMarkdown && text(e, "\n```");
}
function renderField(e, _, v) {
	renderQualifiedField(e, _, v), renderTypeAnnotation(e, _, v, _.type);
}
function renderQualifiedField(e, _, v) {
	if (!_.fieldDef) return;
	let y = _.fieldDef.name;
	y.slice(0, 2) !== "__" && (renderType(e, _, v, _.parentType), text(e, ".")), text(e, y);
}
function renderDirective(e, _, v) {
	if (!_.directiveDef) return;
	let y = "@" + _.directiveDef.name;
	text(e, y);
}
function renderArg(e, _, v) {
	if (_.directiveDef ? renderDirective(e, _, v) : _.fieldDef && renderQualifiedField(e, _, v), !_.argDef) return;
	let { name: y } = _.argDef;
	text(e, "("), text(e, y), renderTypeAnnotation(e, _, v, _.inputType), text(e, ")");
}
function renderTypeAnnotation(e, _, v, y) {
	text(e, ": "), renderType(e, _, v, y);
}
function renderEnumValue(e, _, v) {
	if (!_.enumValue) return;
	let { name: y } = _.enumValue;
	renderType(e, _, v, _.inputType), text(e, "."), text(e, y);
}
function renderType(e, _, v, y) {
	y && (y instanceof GraphQLNonNull ? (renderType(e, _, v, y.ofType), text(e, "!")) : y instanceof GraphQLList ? (text(e, "["), renderType(e, _, v, y.ofType), text(e, "]")) : text(e, y.name));
}
function renderDescription(e, _, v) {
	if (!v) return;
	let y = typeof v.description == "string" ? v.description : null;
	y && (text(e, "\n\n"), text(e, y)), renderDeprecation(e, _, v);
}
function renderDeprecation(e, _, v) {
	if (!v) return;
	let y = v.deprecationReason;
	y && (text(e, "\n\n"), text(e, "Deprecated: "), text(e, y));
}
function text(e, _) {
	e.push(_);
}
/*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
* Released under the MIT license
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
*-----------------------------------------------------------------------------*/
var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __hasOwnProp = Object.prototype.hasOwnProperty, __copyProps = (e, _, v, y) => {
	if (_ && typeof _ == "object" || typeof _ == "function") for (let b of __getOwnPropNames(_)) !__hasOwnProp.call(e, b) && b !== v && __defProp(e, b, {
		get: () => _[b],
		enumerable: !(y = __getOwnPropDesc(_, b)) || y.enumerable
	});
	return e;
}, __reExport = (e, _, v) => (__copyProps(e, _, "default"), v && __copyProps(v, _, "default")), monaco_editor_core_exports = {};
__reExport(monaco_editor_core_exports, editor_api_exports);
var languageDefinitions = {}, lazyLanguageLoaders = {}, LazyLanguageLoader = class e {
	static getOrCreate(_) {
		return lazyLanguageLoaders[_] || (lazyLanguageLoaders[_] = new e(_)), lazyLanguageLoaders[_];
	}
	constructor(e) {
		this._languageId = e, this._loadingTriggered = !1, this._lazyLoadPromise = new Promise((e, _) => {
			this._lazyLoadPromiseResolve = e, this._lazyLoadPromiseReject = _;
		});
	}
	load() {
		return this._loadingTriggered || (this._loadingTriggered = !0, languageDefinitions[this._languageId].loader().then((e) => this._lazyLoadPromiseResolve(e), (e) => this._lazyLoadPromiseReject(e))), this._lazyLoadPromise;
	}
};
function registerLanguage(e) {
	let _ = e.id;
	languageDefinitions[_] = e, monaco_editor_core_exports.languages.register(e);
	let v = LazyLanguageLoader.getOrCreate(_);
	monaco_editor_core_exports.languages.registerTokensProviderFactory(_, { create: async () => (await v.load()).language }), monaco_editor_core_exports.languages.onLanguageEncountered(_, async () => {
		let e = await v.load();
		monaco_editor_core_exports.languages.setLanguageConfiguration(_, e.conf);
	});
}
registerLanguage({
	id: "graphql",
	extensions: [".graphql", ".gql"],
	aliases: [
		"GraphQL",
		"graphql",
		"gql"
	],
	mimetypes: ["application/graphql"],
	loader: () => import("./graphql-CFvHDT0S.js")
});
var ToggleCollapseUnchangedRegions = class extends Action2 {
	constructor() {
		super({
			id: "diffEditor.toggleCollapseUnchangedRegions",
			title: localize2("toggleCollapseUnchangedRegions", "Toggle Collapse Unchanged Regions"),
			icon: Codicon.map,
			toggled: ContextKeyExpr.has("config.diffEditor.hideUnchangedRegions.enabled"),
			precondition: ContextKeyExpr.has("isInDiffEditor"),
			menu: {
				when: ContextKeyExpr.has("isInDiffEditor"),
				id: MenuId.EditorTitle,
				order: 22,
				group: "navigation"
			}
		});
	}
	run(e, ..._) {
		let v = e.get(IConfigurationService), y = !v.getValue("diffEditor.hideUnchangedRegions.enabled");
		v.updateValue("diffEditor.hideUnchangedRegions.enabled", y);
	}
}, ToggleShowMovedCodeBlocks = class extends Action2 {
	constructor() {
		super({
			id: "diffEditor.toggleShowMovedCodeBlocks",
			title: localize2("toggleShowMovedCodeBlocks", "Toggle Show Moved Code Blocks"),
			precondition: ContextKeyExpr.has("isInDiffEditor")
		});
	}
	run(e, ..._) {
		let v = e.get(IConfigurationService), y = !v.getValue("diffEditor.experimental.showMoves");
		v.updateValue("diffEditor.experimental.showMoves", y);
	}
}, ToggleUseInlineViewWhenSpaceIsLimited = class extends Action2 {
	constructor() {
		super({
			id: "diffEditor.toggleUseInlineViewWhenSpaceIsLimited",
			title: localize2("toggleUseInlineViewWhenSpaceIsLimited", "Toggle Use Inline View When Space Is Limited"),
			precondition: ContextKeyExpr.has("isInDiffEditor")
		});
	}
	run(e, ..._) {
		let v = e.get(IConfigurationService), y = !v.getValue("diffEditor.useInlineViewWhenSpaceIsLimited");
		v.updateValue("diffEditor.useInlineViewWhenSpaceIsLimited", y);
	}
}, diffEditorCategory = localize2("diffEditor", "Diff Editor"), SwitchSide = class extends EditorAction2 {
	constructor() {
		super({
			id: "diffEditor.switchSide",
			title: localize2("switchSide", "Switch Side"),
			icon: Codicon.arrowSwap,
			precondition: ContextKeyExpr.has("isInDiffEditor"),
			f1: !0,
			category: diffEditorCategory
		});
	}
	runEditorCommand(e, _, v) {
		let y = findFocusedDiffEditor(e);
		if (y instanceof DiffEditorWidget) {
			if (v && v.dryRun) return { destinationSelection: y.mapToOtherSide().destinationSelection };
			y.switchSide();
		}
	}
}, ExitCompareMove = class extends EditorAction2 {
	constructor() {
		super({
			id: "diffEditor.exitCompareMove",
			title: localize2("exitCompareMove", "Exit Compare Move"),
			icon: Codicon.close,
			precondition: EditorContextKeys.comparingMovedCode,
			f1: !1,
			category: diffEditorCategory,
			keybinding: {
				weight: 1e4,
				primary: 9
			}
		});
	}
	runEditorCommand(e, _, ...v) {
		let y = findFocusedDiffEditor(e);
		y instanceof DiffEditorWidget && y.exitCompareMove();
	}
}, CollapseAllUnchangedRegions = class extends EditorAction2 {
	constructor() {
		super({
			id: "diffEditor.collapseAllUnchangedRegions",
			title: localize2("collapseAllUnchangedRegions", "Collapse All Unchanged Regions"),
			icon: Codicon.fold,
			precondition: ContextKeyExpr.has("isInDiffEditor"),
			f1: !0,
			category: diffEditorCategory
		});
	}
	runEditorCommand(e, _, ...v) {
		let y = findFocusedDiffEditor(e);
		y instanceof DiffEditorWidget && y.collapseAllUnchangedRegions();
	}
}, ShowAllUnchangedRegions = class extends EditorAction2 {
	constructor() {
		super({
			id: "diffEditor.showAllUnchangedRegions",
			title: localize2("showAllUnchangedRegions", "Show All Unchanged Regions"),
			icon: Codicon.unfold,
			precondition: ContextKeyExpr.has("isInDiffEditor"),
			f1: !0,
			category: diffEditorCategory
		});
	}
	runEditorCommand(e, _, ...v) {
		let y = findFocusedDiffEditor(e);
		y instanceof DiffEditorWidget && y.showAllUnchangedRegions();
	}
}, RevertHunkOrSelection = class extends Action2 {
	constructor() {
		super({
			id: "diffEditor.revert",
			title: localize2("revert", "Revert"),
			f1: !1,
			category: diffEditorCategory
		});
	}
	run(e, _) {
		let v = findDiffEditor(e, _.originalUri, _.modifiedUri);
		v instanceof DiffEditorWidget && v.revertRangeMappings(_.mapping.innerChanges ?? []);
	}
}, accessibleDiffViewerCategory = localize2("accessibleDiffViewer", "Accessible Diff Viewer"), AccessibleDiffViewerNext = class e extends Action2 {
	static {
		this.id = "editor.action.accessibleDiffViewer.next";
	}
	constructor() {
		super({
			id: e.id,
			title: localize2("editor.action.accessibleDiffViewer.next", "Go to Next Difference"),
			category: accessibleDiffViewerCategory,
			precondition: ContextKeyExpr.has("isInDiffEditor"),
			keybinding: {
				primary: 65,
				weight: 100
			},
			f1: !0
		});
	}
	run(e) {
		findFocusedDiffEditor(e)?.accessibleDiffViewerNext();
	}
}, AccessibleDiffViewerPrev = class e extends Action2 {
	static {
		this.id = "editor.action.accessibleDiffViewer.prev";
	}
	constructor() {
		super({
			id: e.id,
			title: localize2("editor.action.accessibleDiffViewer.prev", "Go to Previous Difference"),
			category: accessibleDiffViewerCategory,
			precondition: ContextKeyExpr.has("isInDiffEditor"),
			keybinding: {
				primary: 1089,
				weight: 100
			},
			f1: !0
		});
	}
	run(e) {
		findFocusedDiffEditor(e)?.accessibleDiffViewerPrev();
	}
};
function findDiffEditor(e, _, v) {
	return e.get(ICodeEditorService).listDiffEditors().find((e) => {
		let y = e.getModifiedEditor(), b = e.getOriginalEditor();
		return y && y.getModel()?.uri.toString() === v.toString() && b && b.getModel()?.uri.toString() === _.toString();
	}) || null;
}
function findFocusedDiffEditor(e) {
	let _ = e.get(ICodeEditorService).listDiffEditors(), v = getActiveElement();
	if (v) for (let e of _) {
		let _ = e.getContainerDomNode();
		if (isElementOrParentOf(_, v)) return e;
	}
	return null;
}
function isElementOrParentOf(e, _) {
	let v = _;
	for (; v;) {
		if (v === e) return !0;
		v = v.parentElement;
	}
	return !1;
}
registerAction2(ToggleCollapseUnchangedRegions), registerAction2(ToggleShowMovedCodeBlocks), registerAction2(ToggleUseInlineViewWhenSpaceIsLimited), MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
	command: {
		id: new ToggleUseInlineViewWhenSpaceIsLimited().desc.id,
		title: localize("useInlineViewWhenSpaceIsLimited", "Use Inline View When Space Is Limited"),
		toggled: ContextKeyExpr.has("config.diffEditor.useInlineViewWhenSpaceIsLimited"),
		precondition: ContextKeyExpr.has("isInDiffEditor")
	},
	order: 11,
	group: "1_diff",
	when: ContextKeyExpr.and(EditorContextKeys.diffEditorRenderSideBySideInlineBreakpointReached, ContextKeyExpr.has("isInDiffEditor"))
}), MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
	command: {
		id: new ToggleShowMovedCodeBlocks().desc.id,
		title: localize("showMoves", "Show Moved Code Blocks"),
		icon: Codicon.move,
		toggled: ContextKeyEqualsExpr.create("config.diffEditor.experimental.showMoves", !0),
		precondition: ContextKeyExpr.has("isInDiffEditor")
	},
	order: 10,
	group: "1_diff",
	when: ContextKeyExpr.has("isInDiffEditor")
}), registerAction2(RevertHunkOrSelection);
for (let e of [{
	icon: Codicon.arrowRight,
	key: EditorContextKeys.diffEditorInlineMode.toNegated()
}, {
	icon: Codicon.discard,
	key: EditorContextKeys.diffEditorInlineMode
}]) MenuRegistry.appendMenuItem(MenuId.DiffEditorHunkToolbar, {
	command: {
		id: new RevertHunkOrSelection().desc.id,
		title: localize("revertHunk", "Revert Block"),
		icon: e.icon
	},
	when: ContextKeyExpr.and(EditorContextKeys.diffEditorModifiedWritable, e.key),
	order: 5,
	group: "primary"
}), MenuRegistry.appendMenuItem(MenuId.DiffEditorSelectionToolbar, {
	command: {
		id: new RevertHunkOrSelection().desc.id,
		title: localize("revertSelection", "Revert Selection"),
		icon: e.icon
	},
	when: ContextKeyExpr.and(EditorContextKeys.diffEditorModifiedWritable, e.key),
	order: 5,
	group: "primary"
});
registerAction2(SwitchSide), registerAction2(ExitCompareMove), registerAction2(CollapseAllUnchangedRegions), registerAction2(ShowAllUnchangedRegions), MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
	command: {
		id: AccessibleDiffViewerNext.id,
		title: localize("Open Accessible Diff Viewer", "Open Accessible Diff Viewer"),
		precondition: ContextKeyExpr.has("isInDiffEditor")
	},
	order: 10,
	group: "2_diff",
	when: ContextKeyExpr.and(EditorContextKeys.accessibleDiffViewerVisible.negate(), ContextKeyExpr.has("isInDiffEditor"))
}), CommandsRegistry.registerCommandAlias("editor.action.diffReview.next", AccessibleDiffViewerNext.id), registerAction2(AccessibleDiffViewerNext), CommandsRegistry.registerCommandAlias("editor.action.diffReview.prev", AccessibleDiffViewerPrev.id), registerAction2(AccessibleDiffViewerPrev);
var __decorate$102 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$102 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SelectionAnchorController_1;
const SelectionAnchorSet = new RawContextKey("selectionAnchorSet", !1);
var SelectionAnchorController = class {
	static {
		SelectionAnchorController_1 = this;
	}
	static {
		this.ID = "editor.contrib.selectionAnchorController";
	}
	static get(e) {
		return e.getContribution(SelectionAnchorController_1.ID);
	}
	constructor(e, _) {
		this.editor = e, this.selectionAnchorSetContextKey = SelectionAnchorSet.bindTo(_), this.modelChangeListener = e.onDidChangeModel(() => this.selectionAnchorSetContextKey.reset());
	}
	setSelectionAnchor() {
		if (this.editor.hasModel()) {
			let e = this.editor.getPosition();
			this.editor.changeDecorations((_) => {
				this.decorationId && _.removeDecoration(this.decorationId), this.decorationId = _.addDecoration(Selection.fromPositions(e, e), {
					description: "selection-anchor",
					stickiness: 1,
					hoverMessage: new MarkdownString().appendText(localize("selectionAnchor", "Selection Anchor")),
					className: "selection-anchor"
				});
			}), this.selectionAnchorSetContextKey.set(!!this.decorationId), alert(localize("anchorSet", "Anchor set at {0}:{1}", e.lineNumber, e.column));
		}
	}
	goToSelectionAnchor() {
		if (this.editor.hasModel() && this.decorationId) {
			let e = this.editor.getModel().getDecorationRange(this.decorationId);
			e && this.editor.setPosition(e.getStartPosition());
		}
	}
	selectFromAnchorToCursor() {
		if (this.editor.hasModel() && this.decorationId) {
			let e = this.editor.getModel().getDecorationRange(this.decorationId);
			if (e) {
				let _ = this.editor.getPosition();
				this.editor.setSelection(Selection.fromPositions(e.getStartPosition(), _)), this.cancelSelectionAnchor();
			}
		}
	}
	cancelSelectionAnchor() {
		if (this.decorationId) {
			let e = this.decorationId;
			this.editor.changeDecorations((_) => {
				_.removeDecoration(e), this.decorationId = void 0;
			}), this.selectionAnchorSetContextKey.set(!1);
		}
	}
	dispose() {
		this.cancelSelectionAnchor(), this.modelChangeListener.dispose();
	}
};
SelectionAnchorController = SelectionAnchorController_1 = __decorate$102([__param$102(1, IContextKeyService)], SelectionAnchorController);
var SetSelectionAnchor = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.setSelectionAnchor",
			label: localize("setSelectionAnchor", "Set Selection Anchor"),
			alias: "Set Selection Anchor",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2080),
				weight: 100
			}
		});
	}
	async run(e, _) {
		SelectionAnchorController.get(_)?.setSelectionAnchor();
	}
}, GoToSelectionAnchor = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.goToSelectionAnchor",
			label: localize("goToSelectionAnchor", "Go to Selection Anchor"),
			alias: "Go to Selection Anchor",
			precondition: SelectionAnchorSet
		});
	}
	async run(e, _) {
		SelectionAnchorController.get(_)?.goToSelectionAnchor();
	}
}, SelectFromAnchorToCursor = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.selectFromAnchorToCursor",
			label: localize("selectFromAnchorToCursor", "Select from Anchor to Cursor"),
			alias: "Select from Anchor to Cursor",
			precondition: SelectionAnchorSet,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2089),
				weight: 100
			}
		});
	}
	async run(e, _) {
		SelectionAnchorController.get(_)?.selectFromAnchorToCursor();
	}
}, CancelSelectionAnchor = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.cancelSelectionAnchor",
			label: localize("cancelSelectionAnchor", "Cancel Selection Anchor"),
			alias: "Cancel Selection Anchor",
			precondition: SelectionAnchorSet,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 9,
				weight: 100
			}
		});
	}
	async run(e, _) {
		SelectionAnchorController.get(_)?.cancelSelectionAnchor();
	}
};
registerEditorContribution(SelectionAnchorController.ID, SelectionAnchorController, 4), registerEditorAction(SetSelectionAnchor), registerEditorAction(GoToSelectionAnchor), registerEditorAction(SelectFromAnchorToCursor), registerEditorAction(CancelSelectionAnchor);
var overviewRulerBracketMatchForeground = registerColor("editorOverviewRuler.bracketMatchForeground", "#A0A0A0", localize("overviewRulerBracketMatchForeground", "Overview ruler marker color for matching brackets.")), JumpToBracketAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.jumpToBracket",
			label: localize("smartSelect.jumpBracket", "Go to Bracket"),
			alias: "Go to Bracket",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3165,
				weight: 100
			}
		});
	}
	run(e, _) {
		BracketMatchingController.get(_)?.jumpToBracket();
	}
}, SelectToBracketAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.selectToBracket",
			label: localize("smartSelect.selectToBracket", "Select to Bracket"),
			alias: "Select to Bracket",
			precondition: void 0,
			metadata: {
				description: localize2("smartSelect.selectToBracketDescription", "Select the text inside and including the brackets or curly braces"),
				args: [{
					name: "args",
					schema: {
						type: "object",
						properties: { selectBrackets: {
							type: "boolean",
							default: !0
						} }
					}
				}]
			}
		});
	}
	run(e, _, v) {
		let y = !0;
		v && v.selectBrackets === !1 && (y = !1), BracketMatchingController.get(_)?.selectToBracket(y);
	}
}, RemoveBracketsAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.removeBrackets",
			label: localize("smartSelect.removeBrackets", "Remove Brackets"),
			alias: "Remove Brackets",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2561,
				weight: 100
			}
		});
	}
	run(e, _) {
		BracketMatchingController.get(_)?.removeBrackets(this.id);
	}
}, BracketsData = class {
	constructor(e, _, v) {
		this.position = e, this.brackets = _, this.options = v;
	}
}, BracketMatchingController = class e extends Disposable {
	static {
		this.ID = "editor.contrib.bracketMatchingController";
	}
	static get(_) {
		return _.getContribution(e.ID);
	}
	constructor(e) {
		super(), this._editor = e, this._lastBracketsData = [], this._lastVersionId = 0, this._decorations = this._editor.createDecorationsCollection(), this._updateBracketsSoon = this._register(new RunOnceScheduler(() => this._updateBrackets(), 50)), this._matchBrackets = this._editor.getOption(72), this._updateBracketsSoon.schedule(), this._register(e.onDidChangeCursorPosition((e) => {
			this._matchBrackets !== "never" && this._updateBracketsSoon.schedule();
		})), this._register(e.onDidChangeModelContent((e) => {
			this._updateBracketsSoon.schedule();
		})), this._register(e.onDidChangeModel((e) => {
			this._lastBracketsData = [], this._updateBracketsSoon.schedule();
		})), this._register(e.onDidChangeModelLanguageConfiguration((e) => {
			this._lastBracketsData = [], this._updateBracketsSoon.schedule();
		})), this._register(e.onDidChangeConfiguration((e) => {
			e.hasChanged(72) && (this._matchBrackets = this._editor.getOption(72), this._decorations.clear(), this._lastBracketsData = [], this._lastVersionId = 0, this._updateBracketsSoon.schedule());
		})), this._register(e.onDidBlurEditorWidget(() => {
			this._updateBracketsSoon.schedule();
		})), this._register(e.onDidFocusEditorWidget(() => {
			this._updateBracketsSoon.schedule();
		}));
	}
	jumpToBracket() {
		if (!this._editor.hasModel()) return;
		let e = this._editor.getModel(), _ = this._editor.getSelections().map((_) => {
			let v = _.getStartPosition(), y = e.bracketPairs.matchBracket(v), b = null;
			if (y) y[0].containsPosition(v) && !y[1].containsPosition(v) ? b = y[1].getStartPosition() : y[1].containsPosition(v) && (b = y[0].getStartPosition());
			else {
				let _ = e.bracketPairs.findEnclosingBrackets(v);
				if (_) b = _[1].getStartPosition();
				else {
					let _ = e.bracketPairs.findNextBracket(v);
					_ && _.range && (b = _.range.getStartPosition());
				}
			}
			return b ? new Selection(b.lineNumber, b.column, b.lineNumber, b.column) : new Selection(v.lineNumber, v.column, v.lineNumber, v.column);
		});
		this._editor.setSelections(_), this._editor.revealRange(_[0]);
	}
	selectToBracket(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._editor.getModel(), v = [];
		this._editor.getSelections().forEach((y) => {
			let b = y.getStartPosition(), x = _.bracketPairs.matchBracket(b);
			if (!x && (x = _.bracketPairs.findEnclosingBrackets(b), !x)) {
				let e = _.bracketPairs.findNextBracket(b);
				e && e.range && (x = _.bracketPairs.matchBracket(e.range.getStartPosition()));
			}
			let S = null, C = null;
			if (x) {
				x.sort(Range.compareRangesUsingStarts);
				let [_, v] = x;
				if (S = e ? _.getStartPosition() : _.getEndPosition(), C = e ? v.getEndPosition() : v.getStartPosition(), v.containsPosition(b)) {
					let e = S;
					S = C, C = e;
				}
			}
			S && C && v.push(new Selection(S.lineNumber, S.column, C.lineNumber, C.column));
		}), v.length > 0 && (this._editor.setSelections(v), this._editor.revealRange(v[0]));
	}
	removeBrackets(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._editor.getModel();
		this._editor.getSelections().forEach((v) => {
			let y = v.getPosition(), b = _.bracketPairs.matchBracket(y);
			b ||= _.bracketPairs.findEnclosingBrackets(y), b && (this._editor.pushUndoStop(), this._editor.executeEdits(e, [{
				range: b[0],
				text: ""
			}, {
				range: b[1],
				text: ""
			}]), this._editor.pushUndoStop());
		});
	}
	static {
		this._DECORATION_OPTIONS_WITH_OVERVIEW_RULER = ModelDecorationOptions.register({
			description: "bracket-match-overview",
			stickiness: 1,
			className: "bracket-match",
			overviewRuler: {
				color: themeColorFromId(overviewRulerBracketMatchForeground),
				position: OverviewRulerLane.Center
			}
		});
	}
	static {
		this._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER = ModelDecorationOptions.register({
			description: "bracket-match-no-overview",
			stickiness: 1,
			className: "bracket-match"
		});
	}
	_updateBrackets() {
		if (this._matchBrackets === "never") return;
		this._recomputeBrackets();
		let e = [], _ = 0;
		for (let v of this._lastBracketsData) {
			let y = v.brackets;
			y && (e[_++] = {
				range: y[0],
				options: v.options
			}, e[_++] = {
				range: y[1],
				options: v.options
			});
		}
		this._decorations.set(e);
	}
	_recomputeBrackets() {
		if (!this._editor.hasModel() || !this._editor.hasWidgetFocus()) {
			this._lastBracketsData = [], this._lastVersionId = 0;
			return;
		}
		let _ = this._editor.getSelections();
		if (_.length > 100) {
			this._lastBracketsData = [], this._lastVersionId = 0;
			return;
		}
		let v = this._editor.getModel(), y = v.getVersionId(), b = [];
		this._lastVersionId === y && (b = this._lastBracketsData);
		let x = [], S = 0;
		for (let e = 0, v = _.length; e < v; e++) {
			let v = _[e];
			v.isEmpty() && (x[S++] = v.getStartPosition());
		}
		x.length > 1 && x.sort(Position.compare);
		let C = [], w = 0, T = 0, E = b.length;
		for (let _ = 0, y = x.length; _ < y; _++) {
			let y = x[_];
			for (; T < E && b[T].position.isBefore(y);) T++;
			if (T < E && b[T].position.equals(y)) C[w++] = b[T];
			else {
				let _ = v.bracketPairs.matchBracket(y, 20), b = e._DECORATION_OPTIONS_WITH_OVERVIEW_RULER;
				!_ && this._matchBrackets === "always" && (_ = v.bracketPairs.findEnclosingBrackets(y, 20), b = e._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER), C[w++] = new BracketsData(y, _, b);
			}
		}
		this._lastBracketsData = C, this._lastVersionId = y;
	}
};
registerEditorContribution(BracketMatchingController.ID, BracketMatchingController, 1), registerEditorAction(SelectToBracketAction), registerEditorAction(JumpToBracketAction), registerEditorAction(RemoveBracketsAction), MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
	group: "5_infile_nav",
	command: {
		id: "editor.action.jumpToBracket",
		title: localize({
			key: "miGoToBracket",
			comment: ["&& denotes a mnemonic"]
		}, "Go to &&Bracket")
	},
	order: 2
});
var MoveCaretCommand = class {
	constructor(e, _) {
		this._selection = e, this._isMovingLeft = _;
	}
	getEditOperations(e, _) {
		if (this._selection.startLineNumber !== this._selection.endLineNumber || this._selection.isEmpty()) return;
		let v = this._selection.startLineNumber, y = this._selection.startColumn, b = this._selection.endColumn;
		if (!(this._isMovingLeft && y === 1) && !(!this._isMovingLeft && b === e.getLineMaxColumn(v))) if (this._isMovingLeft) {
			let x = new Range(v, y - 1, v, y), S = e.getValueInRange(x);
			_.addEditOperation(x, null), _.addEditOperation(new Range(v, b, v, b), S);
		} else {
			let x = new Range(v, b, v, b + 1), S = e.getValueInRange(x);
			_.addEditOperation(x, null), _.addEditOperation(new Range(v, y, v, y), S);
		}
	}
	computeCursorState(e, _) {
		return this._isMovingLeft ? new Selection(this._selection.startLineNumber, this._selection.startColumn - 1, this._selection.endLineNumber, this._selection.endColumn - 1) : new Selection(this._selection.startLineNumber, this._selection.startColumn + 1, this._selection.endLineNumber, this._selection.endColumn + 1);
	}
}, MoveCaretAction = class extends EditorAction {
	constructor(e, _) {
		super(_), this.left = e;
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = [], y = _.getSelections();
		for (let e of y) v.push(new MoveCaretCommand(e, this.left));
		_.pushUndoStop(), _.executeCommands(this.id, v), _.pushUndoStop();
	}
}, MoveCaretLeftAction = class extends MoveCaretAction {
	constructor() {
		super(!0, {
			id: "editor.action.moveCarretLeftAction",
			label: localize("caret.moveLeft", "Move Selected Text Left"),
			alias: "Move Selected Text Left",
			precondition: EditorContextKeys.writable
		});
	}
}, MoveCaretRightAction = class extends MoveCaretAction {
	constructor() {
		super(!1, {
			id: "editor.action.moveCarretRightAction",
			label: localize("caret.moveRight", "Move Selected Text Right"),
			alias: "Move Selected Text Right",
			precondition: EditorContextKeys.writable
		});
	}
};
registerEditorAction(MoveCaretLeftAction), registerEditorAction(MoveCaretRightAction), registerEditorAction(class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.transposeLetters",
			label: localize("transposeLetters.label", "Transpose Letters"),
			alias: "Transpose Letters",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 306 },
				weight: 100
			}
		});
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getModel(), y = [], b = _.getSelections();
		for (let e of b) {
			if (!e.isEmpty()) continue;
			let _ = e.startLineNumber, b = e.startColumn, x = v.getLineMaxColumn(_);
			if (_ === 1 && (b === 1 || b === 2 && x === 2)) continue;
			let S = b === x ? e.getPosition() : MoveOperations.rightPosition(v, e.getPosition().lineNumber, e.getPosition().column), C = MoveOperations.leftPosition(v, S), w = MoveOperations.leftPosition(v, C), T = v.getValueInRange(Range.fromPositions(w, C)), E = v.getValueInRange(Range.fromPositions(C, S)), D = Range.fromPositions(w, S);
			y.push(new ReplaceCommand(D, E + T));
		}
		y.length > 0 && (_.pushUndoStop(), _.executeCommands(this.id, y), _.pushUndoStop());
	}
});
const generateUuid = (function() {
	if (typeof crypto == "object" && typeof crypto.randomUUID == "function") return crypto.randomUUID.bind(crypto);
	let e;
	e = typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? crypto.getRandomValues.bind(crypto) : function(e) {
		for (let _ = 0; _ < e.length; _++) e[_] = Math.floor(Math.random() * 256);
		return e;
	};
	let _ = new Uint8Array(16), v = [];
	for (let e = 0; e < 256; e++) v.push(e.toString(16).padStart(2, "0"));
	return function() {
		e(_), _[6] = _[6] & 15 | 64, _[8] = _[8] & 63 | 128;
		let y = 0, b = "";
		return b += v[_[y++]], b += v[_[y++]], b += v[_[y++]], b += v[_[y++]], b += "-", b += v[_[y++]], b += v[_[y++]], b += "-", b += v[_[y++]], b += v[_[y++]], b += "-", b += v[_[y++]], b += v[_[y++]], b += "-", b += v[_[y++]], b += v[_[y++]], b += v[_[y++]], b += v[_[y++]], b += v[_[y++]], b += v[_[y++]], b;
	};
})();
function createStringDataTransferItem(e) {
	return {
		asString: async () => e,
		asFile: () => void 0,
		value: typeof e == "string" ? e : void 0
	};
}
function createFileDataTransferItem(e, _, v) {
	let y = {
		id: generateUuid(),
		name: e,
		uri: _,
		data: v
	};
	return {
		asString: async () => "",
		asFile: () => y,
		value: void 0
	};
}
var VSDataTransfer = class {
	constructor() {
		this._entries = /* @__PURE__ */ new Map();
	}
	get size() {
		let e = 0;
		for (let _ of this._entries) e++;
		return e;
	}
	has(e) {
		return this._entries.has(this.toKey(e));
	}
	matches(e) {
		let _ = [...this._entries.keys()];
		return Iterable.some(this, ([e, _]) => _.asFile()) && _.push("files"), matchesMimeType_normalized(normalizeMimeType(e), _);
	}
	get(e) {
		return this._entries.get(this.toKey(e))?.[0];
	}
	append(e, _) {
		let v = this._entries.get(e);
		v ? v.push(_) : this._entries.set(this.toKey(e), [_]);
	}
	replace(e, _) {
		this._entries.set(this.toKey(e), [_]);
	}
	delete(e) {
		this._entries.delete(this.toKey(e));
	}
	*[Symbol.iterator]() {
		for (let [e, _] of this._entries) for (let v of _) yield [e, v];
	}
	toKey(e) {
		return normalizeMimeType(e);
	}
};
function normalizeMimeType(e) {
	return e.toLowerCase();
}
function matchesMimeType(e, _) {
	return matchesMimeType_normalized(normalizeMimeType(e), _.map(normalizeMimeType));
}
function matchesMimeType_normalized(e, _) {
	if (e === "*/*") return _.length > 0;
	if (_.includes(e)) return !0;
	let v = e.match(/^([a-z]+)\/([a-z]+|\*)$/i);
	if (!v) return !1;
	let [y, b, x] = v;
	return x === "*" ? _.some((e) => e.startsWith(b + "/")) : !1;
}
const UriList = Object.freeze({
	create: (e) => distinct(e.map((e) => e.toString())).join("\r\n"),
	split: (e) => e.split("\r\n"),
	parse: (e) => UriList.split(e).filter((e) => !e.startsWith("#"))
});
var HierarchicalKind = class e {
	static {
		this.sep = ".";
	}
	static {
		this.None = new e("@@none@@");
	}
	static {
		this.Empty = new e("");
	}
	constructor(e) {
		this.value = e;
	}
	equals(e) {
		return this.value === e.value;
	}
	contains(_) {
		return this.equals(_) || this.value === "" || _.value.startsWith(this.value + e.sep);
	}
	intersects(e) {
		return this.contains(e) || e.contains(this);
	}
	append(..._) {
		return new e((this.value ? [this.value, ..._] : _).join(e.sep));
	}
};
const CodeDataTransfers = {
	EDITORS: "CodeEditors",
	FILES: "CodeFiles"
};
var DragAndDropContributionRegistry = class {};
Registry.add({ DragAndDropContribution: "workbench.contributions.dragAndDrop" }.DragAndDropContribution, new DragAndDropContributionRegistry());
var LocalSelectionTransfer = class e {
	static {
		this.INSTANCE = new e();
	}
	constructor() {}
	static getInstance() {
		return e.INSTANCE;
	}
	hasData(e) {
		return e && e === this.proto;
	}
	getData(e) {
		if (this.hasData(e)) return this.data;
	}
};
function toVSDataTransfer(e) {
	let _ = new VSDataTransfer();
	for (let v of e.items) {
		let e = v.type;
		if (v.kind === "string") {
			let y = new Promise((e) => v.getAsString(e));
			_.append(e, createStringDataTransferItem(y));
		} else if (v.kind === "file") {
			let y = v.getAsFile();
			y && _.append(e, createFileDataTransferItemFromFile(y));
		}
	}
	return _;
}
function createFileDataTransferItemFromFile(e) {
	let _ = e.path ? URI.parse(e.path) : void 0;
	return createFileDataTransferItem(e.name, _, async () => new Uint8Array(await e.arrayBuffer()));
}
var INTERNAL_DND_MIME_TYPES = Object.freeze([
	CodeDataTransfers.EDITORS,
	CodeDataTransfers.FILES,
	DataTransfers.RESOURCES,
	DataTransfers.INTERNAL_URI_LIST
]);
function toExternalVSDataTransfer(e, _ = !1) {
	let v = toVSDataTransfer(e), y = v.get(DataTransfers.INTERNAL_URI_LIST);
	if (y) v.replace(Mimes.uriList, y);
	else if (_ || !v.has(Mimes.uriList)) {
		let _ = [];
		for (let v of e.items) {
			let e = v.getAsFile();
			if (e) {
				let v = e.path;
				try {
					v ? _.push(URI.file(v).toString()) : _.push(URI.parse(e.name, !0).toString());
				} catch {}
			}
		}
		_.length && v.replace(Mimes.uriList, createStringDataTransferItem(UriList.create(_)));
	}
	for (let e of INTERNAL_DND_MIME_TYPES) v.delete(e);
	return v;
}
var __decorate$101 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$101 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SimplePasteAndDropProvider = class {
	async provideDocumentPasteEdits(e, _, v, y, b) {
		let x = await this.getEdit(v, b);
		if (x) return {
			edits: [{
				insertText: x.insertText,
				title: x.title,
				kind: x.kind,
				handledMimeType: x.handledMimeType,
				yieldTo: x.yieldTo
			}],
			dispose() {}
		};
	}
	async provideDocumentDropEdits(e, _, v, y) {
		let b = await this.getEdit(v, y);
		if (b) return {
			edits: [{
				insertText: b.insertText,
				title: b.title,
				kind: b.kind,
				handledMimeType: b.handledMimeType,
				yieldTo: b.yieldTo
			}],
			dispose() {}
		};
	}
}, DefaultTextPasteOrDropEditProvider = class e extends SimplePasteAndDropProvider {
	constructor() {
		super(...arguments), this.kind = e.kind, this.dropMimeTypes = [Mimes.text], this.pasteMimeTypes = [Mimes.text];
	}
	static {
		this.id = "text";
	}
	static {
		this.kind = new HierarchicalKind("text.plain");
	}
	async getEdit(e, _) {
		let v = e.get(Mimes.text);
		if (!v || e.has(Mimes.uriList)) return;
		let y = await v.asString();
		return {
			handledMimeType: Mimes.text,
			title: localize("text.label", "Insert Plain Text"),
			insertText: y,
			kind: this.kind
		};
	}
}, PathProvider = class extends SimplePasteAndDropProvider {
	constructor() {
		super(...arguments), this.kind = new HierarchicalKind("uri.absolute"), this.dropMimeTypes = [Mimes.uriList], this.pasteMimeTypes = [Mimes.uriList];
	}
	async getEdit(e, _) {
		let v = await extractUriList(e);
		if (!v.length || _.isCancellationRequested) return;
		let y = 0, b = v.map(({ uri: e, originalText: _ }) => e.scheme === Schemas.file ? e.fsPath : (y++, _)).join(" "), x;
		return x = y > 0 ? v.length > 1 ? localize("defaultDropProvider.uriList.uris", "Insert Uris") : localize("defaultDropProvider.uriList.uri", "Insert Uri") : v.length > 1 ? localize("defaultDropProvider.uriList.paths", "Insert Paths") : localize("defaultDropProvider.uriList.path", "Insert Path"), {
			handledMimeType: Mimes.uriList,
			insertText: b,
			title: x,
			kind: this.kind
		};
	}
}, RelativePathProvider = class extends SimplePasteAndDropProvider {
	constructor(e) {
		super(), this._workspaceContextService = e, this.kind = new HierarchicalKind("uri.relative"), this.dropMimeTypes = [Mimes.uriList], this.pasteMimeTypes = [Mimes.uriList];
	}
	async getEdit(e, _) {
		let v = await extractUriList(e);
		if (!v.length || _.isCancellationRequested) return;
		let y = coalesce(v.map(({ uri: e }) => {
			let _ = this._workspaceContextService.getWorkspaceFolder(e);
			return _ ? relativePath(_.uri, e) : void 0;
		}));
		if (y.length) return {
			handledMimeType: Mimes.uriList,
			insertText: y.join(" "),
			title: v.length > 1 ? localize("defaultDropProvider.uriList.relativePaths", "Insert Relative Paths") : localize("defaultDropProvider.uriList.relativePath", "Insert Relative Path"),
			kind: this.kind
		};
	}
};
RelativePathProvider = __decorate$101([__param$101(0, IWorkspaceContextService)], RelativePathProvider);
var PasteHtmlProvider = class {
	constructor() {
		this.kind = new HierarchicalKind("html"), this.pasteMimeTypes = ["text/html"], this._yieldTo = [{ mimeType: Mimes.text }];
	}
	async provideDocumentPasteEdits(e, _, v, y, b) {
		if (y.triggerKind !== DocumentPasteTriggerKind.PasteAs && !y.only?.contains(this.kind)) return;
		let x = await v.get("text/html")?.asString();
		if (!(!x || b.isCancellationRequested)) return {
			dispose() {},
			edits: [{
				insertText: x,
				yieldTo: this._yieldTo,
				title: localize("pasteHtmlLabel", "Insert HTML"),
				kind: this.kind
			}]
		};
	}
};
async function extractUriList(e) {
	let _ = e.get(Mimes.uriList);
	if (!_) return [];
	let v = await _.asString(), y = [];
	for (let e of UriList.parse(v)) try {
		y.push({
			uri: URI.parse(e),
			originalText: e
		});
	} catch {}
	return y;
}
var DefaultDropProvidersFeature = class extends Disposable {
	constructor(e, _) {
		super(), this._register(e.documentDropEditProvider.register("*", new DefaultTextPasteOrDropEditProvider())), this._register(e.documentDropEditProvider.register("*", new PathProvider())), this._register(e.documentDropEditProvider.register("*", new RelativePathProvider(_)));
	}
};
DefaultDropProvidersFeature = __decorate$101([__param$101(0, ILanguageFeaturesService), __param$101(1, IWorkspaceContextService)], DefaultDropProvidersFeature);
var DefaultPasteProvidersFeature = class extends Disposable {
	constructor(e, _) {
		super(), this._register(e.documentPasteEditProvider.register("*", new DefaultTextPasteOrDropEditProvider())), this._register(e.documentPasteEditProvider.register("*", new PathProvider())), this._register(e.documentPasteEditProvider.register("*", new RelativePathProvider(_))), this._register(e.documentPasteEditProvider.register("*", new PasteHtmlProvider()));
	}
};
DefaultPasteProvidersFeature = __decorate$101([__param$101(0, ILanguageFeaturesService), __param$101(1, IWorkspaceContextService)], DefaultPasteProvidersFeature);
var Scanner = class e {
	constructor() {
		this.value = "", this.pos = 0;
	}
	static {
		this._table = {
			36: 0,
			58: 1,
			44: 2,
			123: 3,
			125: 4,
			92: 5,
			47: 6,
			124: 7,
			43: 11,
			45: 12,
			63: 13
		};
	}
	static isDigitCharacter(e) {
		return e >= 48 && e <= 57;
	}
	static isVariableCharacter(e) {
		return e === 95 || e >= 97 && e <= 122 || e >= 65 && e <= 90;
	}
	text(e) {
		this.value = e, this.pos = 0;
	}
	tokenText(e) {
		return this.value.substr(e.pos, e.len);
	}
	next() {
		if (this.pos >= this.value.length) return {
			type: 14,
			pos: this.pos,
			len: 0
		};
		let _ = this.pos, v = 0, y = this.value.charCodeAt(_), b;
		if (b = e._table[y], typeof b == "number") return this.pos += 1, {
			type: b,
			pos: _,
			len: 1
		};
		if (e.isDigitCharacter(y)) {
			b = 8;
			do
				v += 1, y = this.value.charCodeAt(_ + v);
			while (e.isDigitCharacter(y));
			return this.pos += v, {
				type: b,
				pos: _,
				len: v
			};
		}
		if (e.isVariableCharacter(y)) {
			b = 9;
			do
				y = this.value.charCodeAt(_ + ++v);
			while (e.isVariableCharacter(y) || e.isDigitCharacter(y));
			return this.pos += v, {
				type: b,
				pos: _,
				len: v
			};
		}
		b = 10;
		do
			v += 1, y = this.value.charCodeAt(_ + v);
		while (!isNaN(y) && e._table[y] === void 0 && !e.isDigitCharacter(y) && !e.isVariableCharacter(y));
		return this.pos += v, {
			type: b,
			pos: _,
			len: v
		};
	}
}, Marker = class {
	constructor() {
		this._children = [];
	}
	appendChild(e) {
		return e instanceof Text && this._children[this._children.length - 1] instanceof Text ? this._children[this._children.length - 1].value += e.value : (e.parent = this, this._children.push(e)), this;
	}
	replace(e, _) {
		let { parent: v } = e, y = v.children.indexOf(e), b = v.children.slice(0);
		b.splice(y, 1, ..._), v._children = b, (function e(_, v) {
			for (let y of _) y.parent = v, e(y.children, y);
		})(_, v);
	}
	get children() {
		return this._children;
	}
	get rightMostDescendant() {
		return this._children.length > 0 ? this._children[this._children.length - 1].rightMostDescendant : this;
	}
	get snippet() {
		let e = this;
		for (;;) {
			if (!e) return;
			if (e instanceof TextmateSnippet) return e;
			e = e.parent;
		}
	}
	toString() {
		return this.children.reduce((e, _) => e + _.toString(), "");
	}
	len() {
		return 0;
	}
}, Text = class e extends Marker {
	constructor(e) {
		super(), this.value = e;
	}
	toString() {
		return this.value;
	}
	len() {
		return this.value.length;
	}
	clone() {
		return new e(this.value);
	}
}, TransformableMarker = class extends Marker {}, Placeholder = class e extends TransformableMarker {
	static compareByIndex(e, _) {
		return e.index === _.index ? 0 : e.isFinalTabstop ? 1 : _.isFinalTabstop || e.index < _.index ? -1 : e.index > _.index ? 1 : 0;
	}
	constructor(e) {
		super(), this.index = e;
	}
	get isFinalTabstop() {
		return this.index === 0;
	}
	get choice() {
		return this._children.length === 1 && this._children[0] instanceof Choice ? this._children[0] : void 0;
	}
	clone() {
		let _ = new e(this.index);
		return this.transform && (_.transform = this.transform.clone()), _._children = this.children.map((e) => e.clone()), _;
	}
}, Choice = class e extends Marker {
	constructor() {
		super(...arguments), this.options = [];
	}
	appendChild(e) {
		return e instanceof Text && (e.parent = this, this.options.push(e)), this;
	}
	toString() {
		return this.options[0].value;
	}
	len() {
		return this.options[0].len();
	}
	clone() {
		let _ = new e();
		return this.options.forEach(_.appendChild, _), _;
	}
}, Transform = class e extends Marker {
	constructor() {
		super(...arguments), this.regexp = /* @__PURE__ */ RegExp("");
	}
	resolve(e) {
		let _ = this, v = !1, y = e.replace(this.regexp, function() {
			return v = !0, _._replace(Array.prototype.slice.call(arguments, 0, -2));
		});
		return !v && this._children.some((e) => e instanceof FormatString && !!e.elseValue) && (y = this._replace([])), y;
	}
	_replace(e) {
		let _ = "";
		for (let v of this._children) if (v instanceof FormatString) {
			let y = e[v.index] || "";
			y = v.resolve(y), _ += y;
		} else _ += v.toString();
		return _;
	}
	toString() {
		return "";
	}
	clone() {
		let _ = new e();
		return _.regexp = new RegExp(this.regexp.source, (this.regexp.ignoreCase ? "i" : "") + (this.regexp.global ? "g" : "")), _._children = this.children.map((e) => e.clone()), _;
	}
}, FormatString = class e extends Marker {
	constructor(e, _, v, y) {
		super(), this.index = e, this.shorthandName = _, this.ifValue = v, this.elseValue = y;
	}
	resolve(e) {
		return this.shorthandName === "upcase" ? e ? e.toLocaleUpperCase() : "" : this.shorthandName === "downcase" ? e ? e.toLocaleLowerCase() : "" : this.shorthandName === "capitalize" ? e ? e[0].toLocaleUpperCase() + e.substr(1) : "" : this.shorthandName === "pascalcase" ? e ? this._toPascalCase(e) : "" : this.shorthandName === "camelcase" ? e ? this._toCamelCase(e) : "" : e && typeof this.ifValue == "string" ? this.ifValue : !e && typeof this.elseValue == "string" ? this.elseValue : e || "";
	}
	_toPascalCase(e) {
		let _ = e.match(/[a-z0-9]+/gi);
		return _ ? _.map((e) => e.charAt(0).toUpperCase() + e.substr(1)).join("") : e;
	}
	_toCamelCase(e) {
		let _ = e.match(/[a-z0-9]+/gi);
		return _ ? _.map((e, _) => _ === 0 ? e.charAt(0).toLowerCase() + e.substr(1) : e.charAt(0).toUpperCase() + e.substr(1)).join("") : e;
	}
	clone() {
		return new e(this.index, this.shorthandName, this.ifValue, this.elseValue);
	}
}, Variable = class e extends TransformableMarker {
	constructor(e) {
		super(), this.name = e;
	}
	resolve(e) {
		let _ = e.resolve(this);
		return this.transform && (_ = this.transform.resolve(_ || "")), _ === void 0 ? !1 : (this._children = [new Text(_)], !0);
	}
	clone() {
		let _ = new e(this.name);
		return this.transform && (_.transform = this.transform.clone()), _._children = this.children.map((e) => e.clone()), _;
	}
};
function walk(e, _) {
	let v = [...e];
	for (; v.length > 0;) {
		let e = v.shift();
		if (!_(e)) break;
		v.unshift(...e.children);
	}
}
var TextmateSnippet = class e extends Marker {
	get placeholderInfo() {
		if (!this._placeholders) {
			let e = [], _;
			this.walk(function(v) {
				return v instanceof Placeholder && (e.push(v), _ = !_ || _.index < v.index ? v : _), !0;
			}), this._placeholders = {
				all: e,
				last: _
			};
		}
		return this._placeholders;
	}
	get placeholders() {
		let { all: e } = this.placeholderInfo;
		return e;
	}
	offset(e) {
		let _ = 0, v = !1;
		return this.walk((y) => y === e ? (v = !0, !1) : (_ += y.len(), !0)), v ? _ : -1;
	}
	fullLen(e) {
		let _ = 0;
		return walk([e], (e) => (_ += e.len(), !0)), _;
	}
	enclosingPlaceholders(e) {
		let _ = [], { parent: v } = e;
		for (; v;) v instanceof Placeholder && _.push(v), v = v.parent;
		return _;
	}
	resolveVariables(e) {
		return this.walk((_) => (_ instanceof Variable && _.resolve(e) && (this._placeholders = void 0), !0)), this;
	}
	appendChild(e) {
		return this._placeholders = void 0, super.appendChild(e);
	}
	replace(e, _) {
		return this._placeholders = void 0, super.replace(e, _);
	}
	clone() {
		let _ = new e();
		return this._children = this.children.map((e) => e.clone()), _;
	}
	walk(e) {
		walk(this.children, e);
	}
}, SnippetParser = class {
	constructor() {
		this._scanner = new Scanner(), this._token = {
			type: 14,
			pos: 0,
			len: 0
		};
	}
	static escape(e) {
		return e.replace(/\$|}|\\/g, "\\$&");
	}
	static guessNeedsClipboard(e) {
		return /\${?CLIPBOARD/.test(e);
	}
	parse(e, _, v) {
		let y = new TextmateSnippet();
		return this.parseFragment(e, y), this.ensureFinalTabstop(y, v ?? !1, _ ?? !1), y;
	}
	parseFragment(e, _) {
		let v = _.children.length;
		for (this._scanner.text(e), this._token = this._scanner.next(); this._parse(_););
		let y = /* @__PURE__ */ new Map(), b = [];
		_.walk((e) => (e instanceof Placeholder && (e.isFinalTabstop ? y.set(0, void 0) : !y.has(e.index) && e.children.length > 0 ? y.set(e.index, e.children) : b.push(e)), !0));
		let x = (e, v) => {
			let b = y.get(e.index);
			if (!b) return;
			let S = new Placeholder(e.index);
			S.transform = e.transform;
			for (let e of b) {
				let _ = e.clone();
				S.appendChild(_), _ instanceof Placeholder && y.has(_.index) && !v.has(_.index) && (v.add(_.index), x(_, v), v.delete(_.index));
			}
			_.replace(e, [S]);
		}, S = /* @__PURE__ */ new Set();
		for (let e of b) x(e, S);
		return _.children.slice(v);
	}
	ensureFinalTabstop(e, _, v) {
		(_ || v && e.placeholders.length > 0) && (e.placeholders.find((e) => e.index === 0) || e.appendChild(new Placeholder(0)));
	}
	_accept(e, _) {
		if (e === void 0 || this._token.type === e) {
			let e = _ ? this._scanner.tokenText(this._token) : !0;
			return this._token = this._scanner.next(), e;
		}
		return !1;
	}
	_backTo(e) {
		return this._scanner.pos = e.pos + e.len, this._token = e, !1;
	}
	_until(e) {
		let _ = this._token;
		for (; this._token.type !== e;) {
			if (this._token.type === 14) return !1;
			if (this._token.type === 5) {
				let e = this._scanner.next();
				if (e.type !== 0 && e.type !== 4 && e.type !== 5) return !1;
			}
			this._token = this._scanner.next();
		}
		let v = this._scanner.value.substring(_.pos, this._token.pos).replace(/\\(\$|}|\\)/g, "$1");
		return this._token = this._scanner.next(), v;
	}
	_parse(e) {
		return this._parseEscaped(e) || this._parseTabstopOrVariableName(e) || this._parseComplexPlaceholder(e) || this._parseComplexVariable(e) || this._parseAnything(e);
	}
	_parseEscaped(e) {
		let _;
		return (_ = this._accept(5, !0)) ? (_ = this._accept(0, !0) || this._accept(4, !0) || this._accept(5, !0) || _, e.appendChild(new Text(_)), !0) : !1;
	}
	_parseTabstopOrVariableName(e) {
		let _, v = this._token;
		return this._accept(0) && (_ = this._accept(9, !0) || this._accept(8, !0)) ? (e.appendChild(/^\d+$/.test(_) ? new Placeholder(Number(_)) : new Variable(_)), !0) : this._backTo(v);
	}
	_parseComplexPlaceholder(e) {
		let _, v = this._token;
		if (!(this._accept(0) && this._accept(3) && (_ = this._accept(8, !0)))) return this._backTo(v);
		let y = new Placeholder(Number(_));
		if (this._accept(1)) for (;;) {
			if (this._accept(4)) return e.appendChild(y), !0;
			if (!this._parse(y)) return e.appendChild(new Text("${" + _ + ":")), y.children.forEach(e.appendChild, e), !0;
		}
		else if (y.index > 0 && this._accept(7)) {
			let _ = new Choice();
			for (;;) {
				if (this._parseChoiceElement(_)) {
					if (this._accept(2)) continue;
					if (this._accept(7) && (y.appendChild(_), this._accept(4))) return e.appendChild(y), !0;
				}
				return this._backTo(v), !1;
			}
		} else if (this._accept(6)) return this._parseTransform(y) ? (e.appendChild(y), !0) : (this._backTo(v), !1);
		else if (this._accept(4)) return e.appendChild(y), !0;
		else return this._backTo(v);
	}
	_parseChoiceElement(e) {
		let _ = this._token, v = [];
		for (; !(this._token.type === 2 || this._token.type === 7);) {
			let e;
			if (e = (e = this._accept(5, !0)) ? this._accept(2, !0) || this._accept(7, !0) || this._accept(5, !0) || e : this._accept(void 0, !0), !e) return this._backTo(_), !1;
			v.push(e);
		}
		return v.length === 0 ? (this._backTo(_), !1) : (e.appendChild(new Text(v.join(""))), !0);
	}
	_parseComplexVariable(e) {
		let _, v = this._token;
		if (!(this._accept(0) && this._accept(3) && (_ = this._accept(9, !0)))) return this._backTo(v);
		let y = new Variable(_);
		if (this._accept(1)) for (;;) {
			if (this._accept(4)) return e.appendChild(y), !0;
			if (!this._parse(y)) return e.appendChild(new Text("${" + _ + ":")), y.children.forEach(e.appendChild, e), !0;
		}
		else if (this._accept(6)) return this._parseTransform(y) ? (e.appendChild(y), !0) : (this._backTo(v), !1);
		else if (this._accept(4)) return e.appendChild(y), !0;
		else return this._backTo(v);
	}
	_parseTransform(e) {
		let _ = new Transform(), v = "", y = "";
		for (; !this._accept(6);) {
			let e;
			if (e = this._accept(5, !0)) {
				e = this._accept(6, !0) || e, v += e;
				continue;
			}
			if (this._token.type !== 14) {
				v += this._accept(void 0, !0);
				continue;
			}
			return !1;
		}
		for (; !this._accept(6);) {
			let e;
			if (e = this._accept(5, !0)) {
				e = this._accept(5, !0) || this._accept(6, !0) || e, _.appendChild(new Text(e));
				continue;
			}
			if (!(this._parseFormatString(_) || this._parseAnything(_))) return !1;
		}
		for (; !this._accept(4);) {
			if (this._token.type !== 14) {
				y += this._accept(void 0, !0);
				continue;
			}
			return !1;
		}
		try {
			_.regexp = new RegExp(v, y);
		} catch {
			return !1;
		}
		return e.transform = _, !0;
	}
	_parseFormatString(e) {
		let _ = this._token;
		if (!this._accept(0)) return !1;
		let v = !1;
		this._accept(3) && (v = !0);
		let y = this._accept(8, !0);
		if (y) if (v) {
			if (this._accept(4)) return e.appendChild(new FormatString(Number(y))), !0;
			if (!this._accept(1)) return this._backTo(_), !1;
		} else return e.appendChild(new FormatString(Number(y))), !0;
		else return this._backTo(_), !1;
		if (this._accept(6)) {
			let v = this._accept(9, !0);
			return !v || !this._accept(4) ? (this._backTo(_), !1) : (e.appendChild(new FormatString(Number(y), v)), !0);
		} else if (this._accept(11)) {
			let _ = this._until(4);
			if (_) return e.appendChild(new FormatString(Number(y), void 0, _, void 0)), !0;
		} else if (this._accept(12)) {
			let _ = this._until(4);
			if (_) return e.appendChild(new FormatString(Number(y), void 0, void 0, _)), !0;
		} else if (this._accept(13)) {
			let _ = this._until(1);
			if (_) {
				let v = this._until(4);
				if (v) return e.appendChild(new FormatString(Number(y), void 0, _, v)), !0;
			}
		} else {
			let _ = this._until(4);
			if (_) return e.appendChild(new FormatString(Number(y), void 0, void 0, _)), !0;
		}
		return this._backTo(_), !1;
	}
	_parseAnything(e) {
		return this._token.type === 14 ? !1 : (e.appendChild(new Text(this._scanner.tokenText(this._token))), this._accept(void 0), !0);
	}
};
function createCombinedWorkspaceEdit(e, _, v) {
	return (typeof v.insertText == "string" ? v.insertText === "" : v.insertText.snippet === "") ? { edits: v.additionalEdit?.edits ?? [] } : { edits: [..._.map((_) => new ResourceTextEdit(e, {
		range: _,
		text: typeof v.insertText == "string" ? SnippetParser.escape(v.insertText) + "$0" : v.insertText.snippet,
		insertAsSnippet: !0
	})), ...v.additionalEdit?.edits ?? []] };
}
function sortEditsByYieldTo(e) {
	function _(e, _) {
		return "mimeType" in e ? e.mimeType === _.handledMimeType : !!_.kind && e.kind.contains(_.kind);
	}
	let v = /* @__PURE__ */ new Map();
	for (let y of e) for (let b of y.yieldTo ?? []) for (let x of e) if (x !== y && _(b, x)) {
		let e = v.get(y);
		e || (e = [], v.set(y, e)), e.push(x);
	}
	if (!v.size) return Array.from(e);
	let y = /* @__PURE__ */ new Set(), b = [];
	function x(e) {
		if (!e.length) return [];
		let _ = e[0];
		if (b.includes(_)) return console.warn("Yield to cycle detected", _), e;
		if (y.has(_)) return x(e.slice(1));
		let S = [], C = v.get(_);
		return C && (b.push(_), S = x(C), b.pop()), y.add(_), [
			...S,
			_,
			...x(e.slice(1))
		];
	}
	return x(Array.from(e));
}
var __decorate$100 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$100 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, inlineProgressDecoration = ModelDecorationOptions.register({
	description: "inline-progress-widget",
	stickiness: 1,
	showIfCollapsed: !0,
	after: {
		content: "\xA0",
		inlineClassName: "inline-editor-progress-decoration",
		inlineClassNameAffectsLetterSpacing: !0
	}
}), InlineProgressWidget = class e extends Disposable {
	static {
		this.baseId = "editor.widget.inlineProgressWidget";
	}
	constructor(e, _, v, y, b) {
		super(), this.typeId = e, this.editor = _, this.range = v, this.delegate = b, this.allowEditorOverflow = !1, this.suppressMouseDown = !0, this.create(y), this.editor.addContentWidget(this), this.editor.layoutContentWidget(this);
	}
	create(e) {
		this.domNode = $(".inline-progress-widget"), this.domNode.role = "button", this.domNode.title = e;
		let _ = $("span.icon");
		this.domNode.append(_), _.classList.add(...ThemeIcon.asClassNameArray(Codicon.loading), "codicon-modifier-spin");
		let v = () => {
			let e = this.editor.getOption(67);
			this.domNode.style.height = `${e}px`, this.domNode.style.width = `${Math.ceil(.8 * e)}px`;
		};
		v(), this._register(this.editor.onDidChangeConfiguration((e) => {
			(e.hasChanged(52) || e.hasChanged(67)) && v();
		})), this._register(addDisposableListener(this.domNode, EventType$1.CLICK, (e) => {
			this.delegate.cancel();
		}));
	}
	getId() {
		return e.baseId + "." + this.typeId;
	}
	getDomNode() {
		return this.domNode;
	}
	getPosition() {
		return {
			position: {
				lineNumber: this.range.startLineNumber,
				column: this.range.startColumn
			},
			preference: [0]
		};
	}
	dispose() {
		super.dispose(), this.editor.removeContentWidget(this);
	}
}, InlineProgressManager = class extends Disposable {
	constructor(e, _, v) {
		super(), this.id = e, this._editor = _, this._instantiationService = v, this._showDelay = 500, this._showPromise = this._register(new MutableDisposable()), this._currentWidget = this._register(new MutableDisposable()), this._operationIdPool = 0, this._currentDecorations = _.createDecorationsCollection();
	}
	dispose() {
		super.dispose(), this._currentDecorations.clear();
	}
	async showWhile(e, _, v, y, b) {
		let x = this._operationIdPool++;
		this._currentOperation = x, this.clear(), this._showPromise.value = disposableTimeout(() => {
			let v = Range.fromPositions(e);
			this._currentDecorations.set([{
				range: v,
				options: inlineProgressDecoration
			}]).length > 0 && (this._currentWidget.value = this._instantiationService.createInstance(InlineProgressWidget, this.id, this._editor, v, _, y));
		}, b ?? this._showDelay);
		try {
			return await v;
		} finally {
			this._currentOperation === x && (this.clear(), this._currentOperation = void 0);
		}
	}
	clear() {
		this._showPromise.clear(), this._currentDecorations.clear(), this._currentWidget.clear();
	}
};
InlineProgressManager = __decorate$100([__param$100(2, IInstantiationService)], InlineProgressManager);
var __decorate$99 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$99 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, MessageController_1, MessageController = class {
	static {
		MessageController_1 = this;
	}
	static {
		this.ID = "editor.contrib.messageController";
	}
	static {
		this.MESSAGE_VISIBLE = new RawContextKey("messageVisible", !1, localize("messageVisible", "Whether the editor is currently showing an inline message"));
	}
	static get(e) {
		return e.getContribution(MessageController_1.ID);
	}
	constructor(e, _, v) {
		this._openerService = v, this._messageWidget = new MutableDisposable(), this._messageListeners = new DisposableStore(), this._mouseOverMessage = !1, this._editor = e, this._visible = MessageController_1.MESSAGE_VISIBLE.bindTo(_);
	}
	dispose() {
		this._message?.dispose(), this._messageListeners.dispose(), this._messageWidget.dispose(), this._visible.reset();
	}
	showMessage(e, _) {
		alert(isMarkdownString(e) ? e.value : e), this._visible.set(!0), this._messageWidget.clear(), this._messageListeners.clear(), this._message = isMarkdownString(e) ? renderMarkdown(e, { actionHandler: {
			callback: (_) => {
				this.closeMessage(), openLinkFromMarkdown(this._openerService, _, isMarkdownString(e) ? e.isTrusted : void 0);
			},
			disposables: this._messageListeners
		} }) : void 0, this._messageWidget.value = new MessageWidget$1(this._editor, _, typeof e == "string" ? e : this._message.element), this._messageListeners.add(Event.debounce(this._editor.onDidBlurEditorText, (e, _) => _, 0)(() => {
			this._mouseOverMessage || this._messageWidget.value && isAncestor(getActiveElement(), this._messageWidget.value.getDomNode()) || this.closeMessage();
		})), this._messageListeners.add(this._editor.onDidChangeCursorPosition(() => this.closeMessage())), this._messageListeners.add(this._editor.onDidDispose(() => this.closeMessage())), this._messageListeners.add(this._editor.onDidChangeModel(() => this.closeMessage())), this._messageListeners.add(addDisposableListener(this._messageWidget.value.getDomNode(), EventType$1.MOUSE_ENTER, () => this._mouseOverMessage = !0, !0)), this._messageListeners.add(addDisposableListener(this._messageWidget.value.getDomNode(), EventType$1.MOUSE_LEAVE, () => this._mouseOverMessage = !1, !0));
		let v;
		this._messageListeners.add(this._editor.onMouseMove((e) => {
			e.target.position && (v ? v.containsPosition(e.target.position) || this.closeMessage() : v = new Range(_.lineNumber - 3, 1, e.target.position.lineNumber + 3, 1));
		}));
	}
	closeMessage() {
		this._visible.reset(), this._messageListeners.clear(), this._messageWidget.value && this._messageListeners.add(MessageWidget$1.fadeOut(this._messageWidget.value));
	}
};
MessageController = MessageController_1 = __decorate$99([__param$99(1, IContextKeyService), __param$99(2, IOpenerService)], MessageController);
var MessageCommand = EditorCommand.bindToContribution(MessageController.get);
registerEditorCommand(new MessageCommand({
	id: "leaveEditorMessage",
	precondition: MessageController.MESSAGE_VISIBLE,
	handler: (e) => e.closeMessage(),
	kbOpts: {
		weight: 130,
		primary: 9
	}
}));
var MessageWidget$1 = class {
	static fadeOut(e) {
		let _ = () => {
			e.dispose(), clearTimeout(v), e.getDomNode().removeEventListener("animationend", _);
		}, v = setTimeout(_, 110);
		return e.getDomNode().addEventListener("animationend", _), e.getDomNode().classList.add("fadeOut"), { dispose: _ };
	}
	constructor(e, { lineNumber: _, column: v }, y) {
		this.allowEditorOverflow = !0, this.suppressMouseDown = !1, this._editor = e, this._editor.revealLinesInCenterIfOutsideViewport(_, _, 0), this._position = {
			lineNumber: _,
			column: v
		}, this._domNode = document.createElement("div"), this._domNode.classList.add("monaco-editor-overlaymessage"), this._domNode.style.marginLeft = "-6px";
		let b = document.createElement("div");
		b.classList.add("anchor", "top"), this._domNode.appendChild(b);
		let x = document.createElement("div");
		typeof y == "string" ? (x.classList.add("message"), x.textContent = y) : (y.classList.add("message"), x.appendChild(y)), this._domNode.appendChild(x);
		let S = document.createElement("div");
		S.classList.add("anchor", "below"), this._domNode.appendChild(S), this._editor.addContentWidget(this), this._domNode.classList.add("fadeIn");
	}
	dispose() {
		this._editor.removeContentWidget(this);
	}
	getId() {
		return "messageoverlay";
	}
	getDomNode() {
		return this._domNode;
	}
	getPosition() {
		return {
			position: this._position,
			preference: [1, 2],
			positionAffinity: 1
		};
	}
	afterRender(e) {
		this._domNode.classList.toggle("below", e === 2);
	}
};
registerEditorContribution(MessageController.ID, MessageController, 4);
function exceptionToErrorMessage(e, _) {
	return _ && (e.stack || e.stacktrace) ? localize("stackTrace.format", "{0}: {1}", detectSystemErrorMessage(e), stackToString(e.stack) || stackToString(e.stacktrace)) : detectSystemErrorMessage(e);
}
function stackToString(e) {
	return Array.isArray(e) ? e.join("\n") : e;
}
function detectSystemErrorMessage(e) {
	return e.code === "ERR_UNC_HOST_NOT_ALLOWED" ? `${e.message}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.` : typeof e.code == "string" && typeof e.errno == "number" && typeof e.syscall == "string" ? localize("nodeExceptionMessage", "A system error occurred ({0})", e.message) : e.message || localize("error.defaultMessage", "An unknown error occurred. Please consult the log for more details.");
}
function toErrorMessage(e = null, _ = !1) {
	if (!e) return localize("error.defaultMessage", "An unknown error occurred. Please consult the log for more details.");
	if (Array.isArray(e)) {
		let v = coalesce(e), y = toErrorMessage(v[0], _);
		return v.length > 1 ? localize("error.moreErrors", "{0} ({1} errors in total)", y, v.length) : y;
	}
	if (isString(e)) return e;
	if (e.detail) {
		let v = e.detail;
		if (v.error) return exceptionToErrorMessage(v.error, _);
		if (v.exception) return exceptionToErrorMessage(v.exception, _);
	}
	return e.stack ? exceptionToErrorMessage(e, _) : e.message ? e.message : localize("error.defaultMessage", "An unknown error occurred. Please consult the log for more details.");
}
var __decorate$98 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$98 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, PostEditWidget_1, PostEditWidget = class extends Disposable {
	static {
		PostEditWidget_1 = this;
	}
	static {
		this.baseId = "editor.widget.postEditWidget";
	}
	constructor(e, _, v, y, b, x, S, C, w, T) {
		super(), this.typeId = e, this.editor = _, this.showCommand = y, this.range = b, this.edits = x, this.onSelectNewEdit = S, this._contextMenuService = C, this._keybindingService = T, this.allowEditorOverflow = !0, this.suppressMouseDown = !0, this.create(), this.visibleContext = v.bindTo(w), this.visibleContext.set(!0), this._register(toDisposable(() => this.visibleContext.reset())), this.editor.addContentWidget(this), this.editor.layoutContentWidget(this), this._register(toDisposable((() => this.editor.removeContentWidget(this)))), this._register(this.editor.onDidChangeCursorPosition((e) => {
			b.containsPosition(e.position) || this.dispose();
		})), this._register(Event.runAndSubscribe(T.onDidUpdateKeybindings, () => {
			this._updateButtonTitle();
		}));
	}
	_updateButtonTitle() {
		let e = this._keybindingService.lookupKeybinding(this.showCommand.id)?.getLabel();
		this.button.element.title = this.showCommand.label + (e ? ` (${e})` : "");
	}
	create() {
		this.domNode = $(".post-edit-widget"), this.button = this._register(new Button(this.domNode, { supportIcons: !0 })), this.button.label = "$(insert)", this._register(addDisposableListener(this.domNode, EventType$1.CLICK, () => this.showSelector()));
	}
	getId() {
		return PostEditWidget_1.baseId + "." + this.typeId;
	}
	getDomNode() {
		return this.domNode;
	}
	getPosition() {
		return {
			position: this.range.getEndPosition(),
			preference: [2]
		};
	}
	showSelector() {
		this._contextMenuService.showContextMenu({
			getAnchor: () => {
				let e = getDomNodePagePosition(this.button.element);
				return {
					x: e.left + e.width,
					y: e.top + e.height
				};
			},
			getActions: () => this.edits.allEdits.map((e, _) => toAction({
				id: "",
				label: e.title,
				checked: _ === this.edits.activeEditIndex,
				run: () => {
					if (_ !== this.edits.activeEditIndex) return this.onSelectNewEdit(_);
				}
			}))
		});
	}
};
PostEditWidget = PostEditWidget_1 = __decorate$98([
	__param$98(7, IContextMenuService),
	__param$98(8, IContextKeyService),
	__param$98(9, IKeybindingService)
], PostEditWidget);
var PostEditWidgetManager = class extends Disposable {
	constructor(e, _, v, y, b, x, S) {
		super(), this._id = e, this._editor = _, this._visibleContext = v, this._showCommand = y, this._instantiationService = b, this._bulkEditService = x, this._notificationService = S, this._currentWidget = this._register(new MutableDisposable()), this._register(Event.any(_.onDidChangeModel, _.onDidChangeModelContent)(() => this.clear()));
	}
	async applyEditAndShowIfNeeded(e, _, v, y, b) {
		let x = this._editor.getModel();
		if (!x || !e.length) return;
		let S = _.allEdits.at(_.activeEditIndex);
		if (!S) return;
		let C = async (x) => {
			let S = this._editor.getModel();
			S && (await S.undo(), this.applyEditAndShowIfNeeded(e, {
				activeEditIndex: x,
				allEdits: _.allEdits
			}, v, y, b));
		}, w = (y, b) => {
			isCancellationError(y) || (this._notificationService.error(b), v && this.show(e[0], _, C));
		}, T;
		try {
			T = await y(S, b);
		} catch (e) {
			return w(e, localize("resolveError", "Error resolving edit '{0}':\n{1}", S.title, toErrorMessage(e)));
		}
		if (b.isCancellationRequested) return;
		let E = createCombinedWorkspaceEdit(x.uri, e, T), D = e[0], O = x.deltaDecorations([], [{
			range: D,
			options: {
				description: "paste-line-suffix",
				stickiness: 0
			}
		}]);
		this._editor.focus();
		let k, A;
		try {
			k = await this._bulkEditService.apply(E, {
				editor: this._editor,
				token: b
			}), A = x.getDecorationRange(O[0]);
		} catch (e) {
			return w(e, localize("applyError", "Error applying edit '{0}':\n{1}", S.title, toErrorMessage(e)));
		} finally {
			x.deltaDecorations(O, []);
		}
		b.isCancellationRequested || v && k.isApplied && _.allEdits.length > 1 && this.show(A ?? D, _, C);
	}
	show(e, _, v) {
		this.clear(), this._editor.hasModel() && (this._currentWidget.value = this._instantiationService.createInstance(PostEditWidget, this._id, this._editor, this._visibleContext, this._showCommand, e, _, v));
	}
	clear() {
		this._currentWidget.clear();
	}
	tryShowSelector() {
		this._currentWidget.value?.showSelector();
	}
};
PostEditWidgetManager = __decorate$98([
	__param$98(4, IInstantiationService),
	__param$98(5, IBulkEditService),
	__param$98(6, INotificationService)
], PostEditWidgetManager);
var __decorate$97 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$97 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, CopyPasteController_1;
const changePasteTypeCommandId = "editor.changePasteType", pasteWidgetVisibleCtx = new RawContextKey("pasteWidgetVisible", !1, localize("pasteWidgetVisible", "Whether the paste widget is showing"));
var vscodeClipboardMime = "application/vnd.code.copyMetadata", CopyPasteController = class extends Disposable {
	static {
		CopyPasteController_1 = this;
	}
	static {
		this.ID = "editor.contrib.copyPasteActionController";
	}
	static get(e) {
		return e.getContribution(CopyPasteController_1.ID);
	}
	constructor(e, _, v, y, b, x, S) {
		super(), this._bulkEditService = v, this._clipboardService = y, this._languageFeaturesService = b, this._quickInputService = x, this._progressService = S, this._editor = e;
		let C = e.getContainerDomNode();
		this._register(addDisposableListener(C, "copy", (e) => this.handleCopy(e))), this._register(addDisposableListener(C, "cut", (e) => this.handleCopy(e))), this._register(addDisposableListener(C, "paste", (e) => this.handlePaste(e), !0)), this._pasteProgressManager = this._register(new InlineProgressManager("pasteIntoEditor", e, _)), this._postPasteWidgetManager = this._register(_.createInstance(PostEditWidgetManager, "pasteIntoEditor", e, pasteWidgetVisibleCtx, {
			id: changePasteTypeCommandId,
			label: localize("postPasteWidgetTitle", "Show paste options...")
		}));
	}
	changePasteType() {
		this._postPasteWidgetManager.tryShowSelector();
	}
	pasteAs(e) {
		this._editor.focus();
		try {
			this._pasteAsActionContext = { preferred: e }, getActiveDocument().execCommand("paste");
		} finally {
			this._pasteAsActionContext = void 0;
		}
	}
	clearWidgets() {
		this._postPasteWidgetManager.clear();
	}
	isPasteAsEnabled() {
		return this._editor.getOption(85).enabled;
	}
	async finishedPaste() {
		await this._currentPasteOperation;
	}
	handleCopy(e) {
		if (!this._editor.hasTextFocus() || (this._clipboardService.clearInternalState?.(), !e.clipboardData || !this.isPasteAsEnabled())) return;
		let _ = this._editor.getModel(), v = this._editor.getSelections();
		if (!_ || !v?.length) return;
		let y = this._editor.getOption(37), b = v, x = v.length === 1 && v[0].isEmpty();
		if (x) {
			if (!y) return;
			b = [new Range(b[0].startLineNumber, 1, b[0].startLineNumber, 1 + _.getLineLength(b[0].startLineNumber))];
		}
		let S = this._editor._getViewModel()?.getPlainTextToCopy(v, y, isWindows), C = {
			multicursorText: Array.isArray(S) ? S : null,
			pasteOnNewLine: x,
			mode: null
		}, w = this._languageFeaturesService.documentPasteEditProvider.ordered(_).filter((e) => !!e.prepareDocumentPaste);
		if (!w.length) {
			this.setCopyMetadata(e.clipboardData, { defaultPastePayload: C });
			return;
		}
		let T = toVSDataTransfer(e.clipboardData), E = w.flatMap((e) => e.copyMimeTypes ?? []), D = generateUuid();
		this.setCopyMetadata(e.clipboardData, {
			id: D,
			providerCopyMimeTypes: E,
			defaultPastePayload: C
		});
		let O = createCancelablePromise(async (e) => {
			let v = coalesce(await Promise.all(w.map(async (v) => {
				try {
					return await v.prepareDocumentPaste(_, b, T, e);
				} catch (e) {
					console.error(e);
					return;
				}
			})));
			v.reverse();
			for (let e of v) for (let [_, v] of e) T.replace(_, v);
			return T;
		});
		CopyPasteController_1._currentCopyOperation?.dataTransferPromise.cancel(), CopyPasteController_1._currentCopyOperation = {
			handle: D,
			dataTransferPromise: O
		};
	}
	async handlePaste(e) {
		if (!e.clipboardData || !this._editor.hasTextFocus()) return;
		MessageController.get(this._editor)?.closeMessage(), this._currentPasteOperation?.cancel(), this._currentPasteOperation = void 0;
		let _ = this._editor.getModel(), v = this._editor.getSelections();
		if (!v?.length || !_ || this._editor.getOption(92) || !this.isPasteAsEnabled() && !this._pasteAsActionContext) return;
		let y = this.fetchCopyMetadata(e), b = toExternalVSDataTransfer(e.clipboardData);
		b.delete(vscodeClipboardMime);
		let x = [
			...e.clipboardData.types,
			...y?.providerCopyMimeTypes ?? [],
			Mimes.uriList
		], S = this._languageFeaturesService.documentPasteEditProvider.ordered(_).filter((e) => {
			let _ = this._pasteAsActionContext?.preferred;
			return _ && e.providedPasteEditKinds && !this.providerMatchesPreference(e, _) ? !1 : e.pasteMimeTypes?.some((e) => matchesMimeType(e, x));
		});
		if (!S.length) {
			this._pasteAsActionContext?.preferred && this.showPasteAsNoEditMessage(v, this._pasteAsActionContext.preferred);
			return;
		}
		e.preventDefault(), e.stopImmediatePropagation(), this._pasteAsActionContext ? this.showPasteAsPick(this._pasteAsActionContext.preferred, S, v, b, y) : this.doPasteInline(S, v, b, y, e);
	}
	showPasteAsNoEditMessage(e, _) {
		MessageController.get(this._editor)?.showMessage(localize("pasteAsError", "No paste edits for '{0}' found", _ instanceof HierarchicalKind ? _.value : _.providerId), e[0].getStartPosition());
	}
	doPasteInline(e, _, v, y, b) {
		let x = this._editor;
		if (!x.hasModel()) return;
		let S = new EditorStateCancellationTokenSource(x, 3, void 0), C = createCancelablePromise(async (x) => {
			let w = this._editor;
			if (!w.hasModel()) return;
			let T = w.getModel(), E = new DisposableStore(), D = E.add(new CancellationTokenSource(x));
			E.add(S.token.onCancellationRequested(() => D.cancel()));
			let O = D.token;
			try {
				if (await this.mergeInDataFromCopy(v, y, O), O.isCancellationRequested) return;
				let x = e.filter((e) => this.isSupportedPasteProvider(e, v));
				if (!x.length || x.length === 1 && x[0] instanceof DefaultTextPasteOrDropEditProvider) return this.applyDefaultPasteHandler(v, y, O, b);
				let S = { triggerKind: DocumentPasteTriggerKind.Automatic }, C = await this.getPasteEdits(x, v, T, _, S, O);
				if (E.add(C), O.isCancellationRequested) return;
				if (C.edits.length === 1 && C.edits[0].provider instanceof DefaultTextPasteOrDropEditProvider) return this.applyDefaultPasteHandler(v, y, O, b);
				if (C.edits.length) {
					let e = w.getOption(85).showPasteSelector === "afterPaste";
					return this._postPasteWidgetManager.applyEditAndShowIfNeeded(_, {
						activeEditIndex: 0,
						allEdits: C.edits
					}, e, (e, v) => new Promise((y, b) => {
						(async () => {
							try {
								let x = e.provider.resolveDocumentPasteEdit?.(e, v), S = new DeferredPromise(), C = x && await this._pasteProgressManager.showWhile(_[0].getEndPosition(), localize("resolveProcess", "Resolving paste edit. Click to cancel"), Promise.race([S.p, x]), { cancel: () => (S.cancel(), b(new CancellationError())) }, 0);
								return C && (e.additionalEdit = C.additionalEdit), y(e);
							} catch (e) {
								return b(e);
							}
						})();
					}), O);
				}
				await this.applyDefaultPasteHandler(v, y, O, b);
			} finally {
				E.dispose(), this._currentPasteOperation === C && (this._currentPasteOperation = void 0);
			}
		});
		this._pasteProgressManager.showWhile(_[0].getEndPosition(), localize("pasteIntoEditorProgress", "Running paste handlers. Click to cancel and do basic paste"), C, { cancel: async () => {
			try {
				if (C.cancel(), S.token.isCancellationRequested) return;
				await this.applyDefaultPasteHandler(v, y, S.token, b);
			} finally {
				S.dispose();
			}
		} }).then(() => {
			S.dispose();
		}), this._currentPasteOperation = C;
	}
	showPasteAsPick(e, _, v, y, b) {
		let x = createCancelablePromise(async (S) => {
			let C = this._editor;
			if (!C.hasModel()) return;
			let w = C.getModel(), T = new DisposableStore(), E = T.add(new EditorStateCancellationTokenSource(C, 3, void 0, S));
			try {
				if (await this.mergeInDataFromCopy(y, b, E.token), E.token.isCancellationRequested) return;
				let x = _.filter((_) => this.isSupportedPasteProvider(_, y, e));
				e && (x = x.filter((_) => this.providerMatchesPreference(_, e)));
				let S = {
					triggerKind: DocumentPasteTriggerKind.PasteAs,
					only: e && e instanceof HierarchicalKind ? e : void 0
				}, C = T.add(await this.getPasteEdits(x, y, w, v, S, E.token));
				if (E.token.isCancellationRequested) return;
				if (e && (C = {
					edits: C.edits.filter((_) => e instanceof HierarchicalKind ? e.contains(_.kind) : e.providerId === _.provider.id),
					dispose: C.dispose
				}), !C.edits.length) {
					S.only && this.showPasteAsNoEditMessage(v, S.only);
					return;
				}
				let D;
				if (D = e ? C.edits.at(0) : (await this._quickInputService.pick(C.edits.map((e) => ({
					label: e.title,
					description: e.kind?.value,
					edit: e
				})), { placeHolder: localize("pasteAsPickerPlaceholder", "Select Paste Action") }))?.edit, !D) return;
				let O = createCombinedWorkspaceEdit(w.uri, v, D);
				await this._bulkEditService.apply(O, { editor: this._editor });
			} finally {
				T.dispose(), this._currentPasteOperation === x && (this._currentPasteOperation = void 0);
			}
		});
		this._progressService.withProgress({
			location: 10,
			title: localize("pasteAsProgress", "Running paste handlers")
		}, () => x);
	}
	setCopyMetadata(e, _) {
		e.setData(vscodeClipboardMime, JSON.stringify(_));
	}
	fetchCopyMetadata(e) {
		if (!e.clipboardData) return;
		let _ = e.clipboardData.getData(vscodeClipboardMime);
		if (_) try {
			return JSON.parse(_);
		} catch {
			return;
		}
		let [v, y] = ClipboardEventUtils.getTextData(e.clipboardData);
		if (y) return { defaultPastePayload: {
			mode: y.mode,
			multicursorText: y.multicursorText ?? null,
			pasteOnNewLine: !!y.isFromEmptySelection
		} };
	}
	async mergeInDataFromCopy(e, _, v) {
		if (_?.id && CopyPasteController_1._currentCopyOperation?.handle === _.id) {
			let _ = await CopyPasteController_1._currentCopyOperation.dataTransferPromise;
			if (v.isCancellationRequested) return;
			for (let [v, y] of _) e.replace(v, y);
		}
		if (!e.has(Mimes.uriList)) {
			let _ = await this._clipboardService.readResources();
			if (v.isCancellationRequested) return;
			_.length && e.append(Mimes.uriList, createStringDataTransferItem(UriList.create(_)));
		}
	}
	async getPasteEdits(e, _, v, y, b, x) {
		let S = new DisposableStore(), C = await raceCancellation(Promise.all(e.map(async (e) => {
			try {
				let C = await e.provideDocumentPasteEdits?.(v, y, _, b, x);
				return C && S.add(C), C?.edits?.map((_) => ({
					..._,
					provider: e
				}));
			} catch (e) {
				isCancellationError(e) || console.error(e);
				return;
			}
		})), x), w = coalesce(C ?? []).flat().filter((e) => !b.only || b.only.contains(e.kind));
		return {
			edits: sortEditsByYieldTo(w),
			dispose: () => S.dispose()
		};
	}
	async applyDefaultPasteHandler(e, _, v, y) {
		let b = await (e.get(Mimes.text) ?? e.get("text"))?.asString() ?? "";
		if (v.isCancellationRequested) return;
		let x = {
			clipboardEvent: y,
			text: b,
			pasteOnNewLine: _?.defaultPastePayload.pasteOnNewLine ?? !1,
			multicursorText: _?.defaultPastePayload.multicursorText ?? null,
			mode: null
		};
		this._editor.trigger("keyboard", "paste", x);
	}
	isSupportedPasteProvider(e, _, v) {
		return e.pasteMimeTypes?.some((e) => _.matches(e)) ? !v || this.providerMatchesPreference(e, v) : !1;
	}
	providerMatchesPreference(e, _) {
		return _ instanceof HierarchicalKind ? e.providedPasteEditKinds ? e.providedPasteEditKinds.some((e) => _.contains(e)) : !0 : e.id === _.providerId;
	}
};
CopyPasteController = CopyPasteController_1 = __decorate$97([
	__param$97(1, IInstantiationService),
	__param$97(2, IBulkEditService),
	__param$97(3, IClipboardService),
	__param$97(4, ILanguageFeaturesService),
	__param$97(5, IQuickInputService),
	__param$97(6, IProgressService)
], CopyPasteController);
var CLIPBOARD_CONTEXT_MENU_GROUP = "9_cutcopypaste", supportsCut = isNative || document.queryCommandSupported("cut"), supportsCopy = isNative || document.queryCommandSupported("copy"), supportsPaste = navigator.clipboard === void 0 || isFirefox ? document.queryCommandSupported("paste") : !0;
function registerCommand(e) {
	return e.register(), e;
}
const CutAction = supportsCut ? registerCommand(new MultiCommand({
	id: "editor.action.clipboardCutAction",
	precondition: void 0,
	kbOpts: isNative ? {
		primary: 2102,
		win: {
			primary: 2102,
			secondary: [1044]
		},
		weight: 100
	} : void 0,
	menuOpts: [
		{
			menuId: MenuId.MenubarEditMenu,
			group: "2_ccp",
			title: localize({
				key: "miCut",
				comment: ["&& denotes a mnemonic"]
			}, "Cu&&t"),
			order: 1
		},
		{
			menuId: MenuId.EditorContext,
			group: CLIPBOARD_CONTEXT_MENU_GROUP,
			title: localize("actions.clipboard.cutLabel", "Cut"),
			when: EditorContextKeys.writable,
			order: 1
		},
		{
			menuId: MenuId.CommandPalette,
			group: "",
			title: localize("actions.clipboard.cutLabel", "Cut"),
			order: 1
		},
		{
			menuId: MenuId.SimpleEditorContext,
			group: CLIPBOARD_CONTEXT_MENU_GROUP,
			title: localize("actions.clipboard.cutLabel", "Cut"),
			when: EditorContextKeys.writable,
			order: 1
		}
	]
})) : void 0, CopyAction = supportsCopy ? registerCommand(new MultiCommand({
	id: "editor.action.clipboardCopyAction",
	precondition: void 0,
	kbOpts: isNative ? {
		primary: 2081,
		win: {
			primary: 2081,
			secondary: [2067]
		},
		weight: 100
	} : void 0,
	menuOpts: [
		{
			menuId: MenuId.MenubarEditMenu,
			group: "2_ccp",
			title: localize({
				key: "miCopy",
				comment: ["&& denotes a mnemonic"]
			}, "&&Copy"),
			order: 2
		},
		{
			menuId: MenuId.EditorContext,
			group: CLIPBOARD_CONTEXT_MENU_GROUP,
			title: localize("actions.clipboard.copyLabel", "Copy"),
			order: 2
		},
		{
			menuId: MenuId.CommandPalette,
			group: "",
			title: localize("actions.clipboard.copyLabel", "Copy"),
			order: 1
		},
		{
			menuId: MenuId.SimpleEditorContext,
			group: CLIPBOARD_CONTEXT_MENU_GROUP,
			title: localize("actions.clipboard.copyLabel", "Copy"),
			order: 2
		}
	]
})) : void 0;
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
	submenu: MenuId.MenubarCopy,
	title: localize2("copy as", "Copy As"),
	group: "2_ccp",
	order: 3
}), MenuRegistry.appendMenuItem(MenuId.EditorContext, {
	submenu: MenuId.EditorContextCopy,
	title: localize2("copy as", "Copy As"),
	group: CLIPBOARD_CONTEXT_MENU_GROUP,
	order: 3
}), MenuRegistry.appendMenuItem(MenuId.EditorContext, {
	submenu: MenuId.EditorContextShare,
	title: localize2("share", "Share"),
	group: "11_share",
	order: -1,
	when: ContextKeyExpr.and(ContextKeyExpr.notEquals("resourceScheme", "output"), EditorContextKeys.editorTextFocus)
}), MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
	submenu: MenuId.ExplorerContextShare,
	title: localize2("share", "Share"),
	group: "11_share",
	order: -1
});
const PasteAction = supportsPaste ? registerCommand(new MultiCommand({
	id: "editor.action.clipboardPasteAction",
	precondition: void 0,
	kbOpts: isNative ? {
		primary: 2100,
		win: {
			primary: 2100,
			secondary: [1043]
		},
		linux: {
			primary: 2100,
			secondary: [1043]
		},
		weight: 100
	} : void 0,
	menuOpts: [
		{
			menuId: MenuId.MenubarEditMenu,
			group: "2_ccp",
			title: localize({
				key: "miPaste",
				comment: ["&& denotes a mnemonic"]
			}, "&&Paste"),
			order: 4
		},
		{
			menuId: MenuId.EditorContext,
			group: CLIPBOARD_CONTEXT_MENU_GROUP,
			title: localize("actions.clipboard.pasteLabel", "Paste"),
			when: EditorContextKeys.writable,
			order: 4
		},
		{
			menuId: MenuId.CommandPalette,
			group: "",
			title: localize("actions.clipboard.pasteLabel", "Paste"),
			order: 1
		},
		{
			menuId: MenuId.SimpleEditorContext,
			group: CLIPBOARD_CONTEXT_MENU_GROUP,
			title: localize("actions.clipboard.pasteLabel", "Paste"),
			when: EditorContextKeys.writable,
			order: 4
		}
	]
})) : void 0;
var ExecCommandCopyWithSyntaxHighlightingAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.clipboardCopyWithSyntaxHighlightingAction",
			label: localize("actions.clipboard.copyWithSyntaxHighlightingLabel", "Copy With Syntax Highlighting"),
			alias: "Copy With Syntax Highlighting",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				weight: 100
			}
		});
	}
	run(e, _) {
		_.hasModel() && (!_.getOption(37) && _.getSelection().isEmpty() || (CopyOptions.forceCopyWithSyntaxHighlighting = !0, _.focus(), _.getContainerDomNode().ownerDocument.execCommand("copy"), CopyOptions.forceCopyWithSyntaxHighlighting = !1));
	}
};
function registerExecCommandImpl(e, _) {
	e && (e.addImplementation(1e4, "code-editor", (e, v) => {
		let y = e.get(ICodeEditorService).getFocusedCodeEditor();
		if (y && y.hasTextFocus()) {
			let e = y.getOption(37), v = y.getSelection();
			return v && v.isEmpty() && !e || y.getContainerDomNode().ownerDocument.execCommand(_), !0;
		}
		return !1;
	}), e.addImplementation(0, "generic-dom", (e, v) => (getActiveDocument().execCommand(_), !0)));
}
registerExecCommandImpl(CutAction, "cut"), registerExecCommandImpl(CopyAction, "copy"), PasteAction && (PasteAction.addImplementation(1e4, "code-editor", (e, _) => {
	let v = e.get(ICodeEditorService), y = e.get(IClipboardService), b = v.getFocusedCodeEditor();
	return b && b.hasTextFocus() ? b.getContainerDomNode().ownerDocument.execCommand("paste") ? CopyPasteController.get(b)?.finishedPaste() ?? Promise.resolve() : isWeb ? (async () => {
		let e = await y.readText();
		if (e !== "") {
			let _ = InMemoryClipboardMetadataManager.INSTANCE.get(e), v = !1, y = null, x = null;
			_ && (v = b.getOption(37) && !!_.isFromEmptySelection, y = _.multicursorText === void 0 ? null : _.multicursorText, x = _.mode), b.trigger("keyboard", "paste", {
				text: e,
				pasteOnNewLine: v,
				multicursorText: y,
				mode: x
			});
		}
	})() : !0 : !1;
}), PasteAction.addImplementation(0, "generic-dom", (e, _) => (getActiveDocument().execCommand("paste"), !0))), supportsCopy && registerEditorAction(ExecCommandCopyWithSyntaxHighlightingAction);
const CodeActionKind = new class {
	constructor() {
		this.QuickFix = new HierarchicalKind("quickfix"), this.Refactor = new HierarchicalKind("refactor"), this.RefactorExtract = this.Refactor.append("extract"), this.RefactorInline = this.Refactor.append("inline"), this.RefactorMove = this.Refactor.append("move"), this.RefactorRewrite = this.Refactor.append("rewrite"), this.Notebook = new HierarchicalKind("notebook"), this.Source = new HierarchicalKind("source"), this.SourceOrganizeImports = this.Source.append("organizeImports"), this.SourceFixAll = this.Source.append("fixAll"), this.SurroundWith = this.Refactor.append("surround");
	}
}();
var CodeActionTriggerSource;
(function(e) {
	e.Refactor = "refactor", e.RefactorPreview = "refactor preview", e.Lightbulb = "lightbulb", e.Default = "other (default)", e.SourceAction = "source action", e.QuickFix = "quick fix action", e.FixAll = "fix all", e.OrganizeImports = "organize imports", e.AutoFix = "auto fix", e.QuickFixHover = "quick fix hover window", e.OnSave = "save participants", e.ProblemsView = "problems view";
})(CodeActionTriggerSource ||= {});
function mayIncludeActionsOfKind(e, _) {
	return !(e.include && !e.include.intersects(_) || e.excludes && e.excludes.some((v) => excludesAction(_, v, e.include)) || !e.includeSourceActions && CodeActionKind.Source.contains(_));
}
function filtersAction(e, _) {
	let v = _.kind ? new HierarchicalKind(_.kind) : void 0;
	return !(e.include && (!v || !e.include.contains(v)) || e.excludes && v && e.excludes.some((_) => excludesAction(v, _, e.include)) || !e.includeSourceActions && v && CodeActionKind.Source.contains(v) || e.onlyIncludePreferredActions && !_.isPreferred);
}
function excludesAction(e, _, v) {
	return !(!_.contains(e) || v && _.contains(v));
}
var CodeActionCommandArgs = class e {
	static fromUser(_, v) {
		return !_ || typeof _ != "object" ? new e(v.kind, v.apply, !1) : new e(e.getKindFromUser(_, v.kind), e.getApplyFromUser(_, v.apply), e.getPreferredUser(_));
	}
	static getApplyFromUser(e, _) {
		switch (typeof e.apply == "string" ? e.apply.toLowerCase() : "") {
			case "first": return "first";
			case "never": return "never";
			case "ifsingle": return "ifSingle";
			default: return _;
		}
	}
	static getKindFromUser(e, _) {
		return typeof e.kind == "string" ? new HierarchicalKind(e.kind) : _;
	}
	static getPreferredUser(e) {
		return typeof e.preferred == "boolean" ? e.preferred : !1;
	}
	constructor(e, _, v) {
		this.kind = e, this.apply = _, this.preferred = v;
	}
}, CodeActionItem = class {
	constructor(e, _, v) {
		this.action = e, this.provider = _, this.highlightRange = v;
	}
	async resolve(e) {
		if (this.provider?.resolveCodeAction && !this.action.edit) {
			let _;
			try {
				_ = await this.provider.resolveCodeAction(this.action, e);
			} catch (e) {
				onUnexpectedExternalError(e);
			}
			_ && (this.action.edit = _.edit);
		}
		return this;
	}
};
const codeActionCommandId = "editor.action.codeAction", quickFixCommandId = "editor.action.quickFix", refactorCommandId = "editor.action.refactor", sourceActionCommandId = "editor.action.sourceAction", organizeImportsCommandId = "editor.action.organizeImports", fixAllCommandId = "editor.action.fixAll";
var ManagedCodeActionSet = class e extends Disposable {
	static codeActionsPreferredComparator(e, _) {
		return e.isPreferred && !_.isPreferred ? -1 : !e.isPreferred && _.isPreferred ? 1 : 0;
	}
	static codeActionsComparator({ action: _ }, { action: v }) {
		return _.isAI && !v.isAI ? 1 : !_.isAI && v.isAI ? -1 : isNonEmptyArray(_.diagnostics) ? isNonEmptyArray(v.diagnostics) ? e.codeActionsPreferredComparator(_, v) : -1 : isNonEmptyArray(v.diagnostics) ? 1 : e.codeActionsPreferredComparator(_, v);
	}
	constructor(_, v, y) {
		super(), this.documentation = v, this._register(y), this.allActions = [..._].sort(e.codeActionsComparator), this.validActions = this.allActions.filter(({ action: e }) => !e.disabled);
	}
	get hasAutoFix() {
		return this.validActions.some(({ action: e }) => !!e.kind && CodeActionKind.QuickFix.contains(new HierarchicalKind(e.kind)) && !!e.isPreferred);
	}
	get hasAIFix() {
		return this.validActions.some(({ action: e }) => !!e.isAI);
	}
	get allAIFixes() {
		return this.validActions.every(({ action: e }) => !!e.isAI);
	}
}, emptyCodeActionsResponse = {
	actions: [],
	documentation: void 0
};
async function getCodeActions(e, _, v, y, b, x) {
	let S = y.filter || {}, C = {
		...S,
		excludes: [...S.excludes || [], CodeActionKind.Notebook]
	}, w = {
		only: S.include?.value,
		trigger: y.type
	}, T = new TextModelCancellationTokenSource(_, x), E = y.type === 2, D = getCodeActionProviders(e, _, E ? C : S), O = new DisposableStore(), k = D.map(async (e) => {
		try {
			b.report(e);
			let y = await e.provideCodeActions(_, v, w, T.token);
			if (y && O.add(y), T.token.isCancellationRequested) return emptyCodeActionsResponse;
			let x = (y?.actions || []).filter((e) => e && filtersAction(S, e)), C = getDocumentationFromProvider(e, x, S.include);
			return {
				actions: x.map((_) => new CodeActionItem(_, e)),
				documentation: C
			};
		} catch (e) {
			if (isCancellationError(e)) throw e;
			return onUnexpectedExternalError(e), emptyCodeActionsResponse;
		}
	}), A = e.onDidChange(() => {
		let v = e.all(_);
		equals(v, D) || T.cancel();
	});
	try {
		let v = await Promise.all(k), b = v.map((e) => e.actions).flat(), x = [...coalesce(v.map((e) => e.documentation)), ...getAdditionalDocumentationForShowingActions(e, _, y, b)];
		return new ManagedCodeActionSet(b, x, O);
	} finally {
		A.dispose(), T.dispose();
	}
}
function getCodeActionProviders(e, _, v) {
	return e.all(_).filter((e) => e.providedCodeActionKinds ? e.providedCodeActionKinds.some((e) => mayIncludeActionsOfKind(v, new HierarchicalKind(e))) : !0);
}
function* getAdditionalDocumentationForShowingActions(e, _, v, y) {
	if (_ && y.length) for (let b of e.all(_)) b._getAdditionalMenuItems && (yield* b._getAdditionalMenuItems?.({
		trigger: v.type,
		only: v.filter?.include?.value
	}, y.map((e) => e.action)));
}
function getDocumentationFromProvider(e, _, v) {
	if (!e.documentation) return;
	let y = e.documentation.map((e) => ({
		kind: new HierarchicalKind(e.kind),
		command: e.command
	}));
	if (v) {
		let e;
		for (let _ of y) _.kind.contains(v) && (e ? e.kind.contains(_.kind) && (e = _) : e = _);
		if (e) return e?.command;
	}
	for (let e of _) if (e.kind) {
		for (let _ of y) if (_.kind.contains(new HierarchicalKind(e.kind))) return _.command;
	}
}
var ApplyCodeActionReason;
(function(e) {
	e.OnSave = "onSave", e.FromProblemsView = "fromProblemsView", e.FromCodeActions = "fromCodeActions", e.FromAILightbulb = "fromAILightbulb";
})(ApplyCodeActionReason ||= {});
async function applyCodeAction(e, _, v, y, b = CancellationToken.None) {
	let x = e.get(IBulkEditService), S = e.get(ICommandService), C = e.get(ITelemetryService), w = e.get(INotificationService);
	if (C.publicLog2("codeAction.applyCodeAction", {
		codeActionTitle: _.action.title,
		codeActionKind: _.action.kind,
		codeActionIsPreferred: !!_.action.isPreferred,
		reason: v
	}), await _.resolve(b), !b.isCancellationRequested && !(_.action.edit?.edits.length && !(await x.apply(_.action.edit, {
		editor: y?.editor,
		label: _.action.title,
		quotableLabel: _.action.title,
		code: "undoredo.codeAction",
		respectAutoSaveConfig: v !== ApplyCodeActionReason.OnSave,
		showPreview: y?.preview
	})).isApplied) && _.action.command) try {
		await S.executeCommand(_.action.command.id, ..._.action.command.arguments || []);
	} catch (e) {
		let _ = asMessage(e);
		w.error(typeof _ == "string" ? _ : localize("applyCodeActionFailed", "An unknown error occurred while applying the code action"));
	}
}
function asMessage(e) {
	if (typeof e == "string") return e;
	if (e instanceof Error && typeof e.message == "string") return e.message;
}
CommandsRegistry.registerCommand("_executeCodeActionProvider", async function(e, _, v, y, x) {
	if (!(_ instanceof URI)) throw illegalArgument();
	let { codeActionProvider: S } = e.get(ILanguageFeaturesService), C = e.get(IModelService).getModel(_);
	if (!C) throw illegalArgument();
	let w = Selection.isISelection(v) ? Selection.liftSelection(v) : Range.isIRange(v) ? C.validateRange(v) : void 0;
	if (!w) throw illegalArgument();
	let T = typeof y == "string" ? new HierarchicalKind(y) : void 0, E = await getCodeActions(S, C, w, {
		type: 1,
		triggerAction: CodeActionTriggerSource.Default,
		filter: {
			includeSourceActions: !0,
			include: T
		}
	}, Progress.None, CancellationToken.None), D = [], O = Math.min(E.validActions.length, typeof x == "number" ? x : 0);
	for (let e = 0; e < O; e++) D.push(E.validActions[e].resolve(CancellationToken.None));
	try {
		return await Promise.all(D), E.validActions.map((e) => e.action);
	} finally {
		setTimeout(() => E.dispose(), 100);
	}
});
var __decorate$96 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$96 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, CodeActionKeybindingResolver_1, CodeActionKeybindingResolver = class {
	static {
		CodeActionKeybindingResolver_1 = this;
	}
	static {
		this.codeActionCommands = [
			refactorCommandId,
			codeActionCommandId,
			sourceActionCommandId,
			organizeImportsCommandId,
			fixAllCommandId
		];
	}
	constructor(e) {
		this.keybindingService = e;
	}
	getResolver() {
		let e = new Lazy(() => this.keybindingService.getKeybindings().filter((e) => CodeActionKeybindingResolver_1.codeActionCommands.indexOf(e.command) >= 0).filter((e) => e.resolvedKeybinding).map((e) => {
			let _ = e.commandArgs;
			return e.command === "editor.action.organizeImports" ? _ = { kind: CodeActionKind.SourceOrganizeImports.value } : e.command === "editor.action.fixAll" && (_ = { kind: CodeActionKind.SourceFixAll.value }), {
				resolvedKeybinding: e.resolvedKeybinding,
				...CodeActionCommandArgs.fromUser(_, {
					kind: HierarchicalKind.None,
					apply: "never"
				})
			};
		}));
		return (_) => {
			if (_.kind) return this.bestKeybindingForCodeAction(_, e.value)?.resolvedKeybinding;
		};
	}
	bestKeybindingForCodeAction(e, _) {
		if (!e.kind) return;
		let v = new HierarchicalKind(e.kind);
		return _.filter((e) => e.kind.contains(v)).filter((_) => _.preferred ? e.isPreferred : !0).reduceRight((e, _) => e ? e.kind.contains(_.kind) ? _ : e : _, void 0);
	}
};
CodeActionKeybindingResolver = CodeActionKeybindingResolver_1 = __decorate$96([__param$96(0, IKeybindingService)], CodeActionKeybindingResolver), registerColor("symbolIcon.arrayForeground", foreground, localize("symbolIcon.arrayForeground", "The foreground color for array symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.booleanForeground", foreground, localize("symbolIcon.booleanForeground", "The foreground color for boolean symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.classForeground", {
	dark: "#EE9D28",
	light: "#D67E00",
	hcDark: "#EE9D28",
	hcLight: "#D67E00"
}, localize("symbolIcon.classForeground", "The foreground color for class symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.colorForeground", foreground, localize("symbolIcon.colorForeground", "The foreground color for color symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.constantForeground", foreground, localize("symbolIcon.constantForeground", "The foreground color for constant symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.constructorForeground", {
	dark: "#B180D7",
	light: "#652D90",
	hcDark: "#B180D7",
	hcLight: "#652D90"
}, localize("symbolIcon.constructorForeground", "The foreground color for constructor symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.enumeratorForeground", {
	dark: "#EE9D28",
	light: "#D67E00",
	hcDark: "#EE9D28",
	hcLight: "#D67E00"
}, localize("symbolIcon.enumeratorForeground", "The foreground color for enumerator symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.enumeratorMemberForeground", {
	dark: "#75BEFF",
	light: "#007ACC",
	hcDark: "#75BEFF",
	hcLight: "#007ACC"
}, localize("symbolIcon.enumeratorMemberForeground", "The foreground color for enumerator member symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.eventForeground", {
	dark: "#EE9D28",
	light: "#D67E00",
	hcDark: "#EE9D28",
	hcLight: "#D67E00"
}, localize("symbolIcon.eventForeground", "The foreground color for event symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.fieldForeground", {
	dark: "#75BEFF",
	light: "#007ACC",
	hcDark: "#75BEFF",
	hcLight: "#007ACC"
}, localize("symbolIcon.fieldForeground", "The foreground color for field symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.fileForeground", foreground, localize("symbolIcon.fileForeground", "The foreground color for file symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.folderForeground", foreground, localize("symbolIcon.folderForeground", "The foreground color for folder symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.functionForeground", {
	dark: "#B180D7",
	light: "#652D90",
	hcDark: "#B180D7",
	hcLight: "#652D90"
}, localize("symbolIcon.functionForeground", "The foreground color for function symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.interfaceForeground", {
	dark: "#75BEFF",
	light: "#007ACC",
	hcDark: "#75BEFF",
	hcLight: "#007ACC"
}, localize("symbolIcon.interfaceForeground", "The foreground color for interface symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.keyForeground", foreground, localize("symbolIcon.keyForeground", "The foreground color for key symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.keywordForeground", foreground, localize("symbolIcon.keywordForeground", "The foreground color for keyword symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.methodForeground", {
	dark: "#B180D7",
	light: "#652D90",
	hcDark: "#B180D7",
	hcLight: "#652D90"
}, localize("symbolIcon.methodForeground", "The foreground color for method symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.moduleForeground", foreground, localize("symbolIcon.moduleForeground", "The foreground color for module symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.namespaceForeground", foreground, localize("symbolIcon.namespaceForeground", "The foreground color for namespace symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.nullForeground", foreground, localize("symbolIcon.nullForeground", "The foreground color for null symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.numberForeground", foreground, localize("symbolIcon.numberForeground", "The foreground color for number symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.objectForeground", foreground, localize("symbolIcon.objectForeground", "The foreground color for object symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.operatorForeground", foreground, localize("symbolIcon.operatorForeground", "The foreground color for operator symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.packageForeground", foreground, localize("symbolIcon.packageForeground", "The foreground color for package symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.propertyForeground", foreground, localize("symbolIcon.propertyForeground", "The foreground color for property symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.referenceForeground", foreground, localize("symbolIcon.referenceForeground", "The foreground color for reference symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.snippetForeground", foreground, localize("symbolIcon.snippetForeground", "The foreground color for snippet symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.stringForeground", foreground, localize("symbolIcon.stringForeground", "The foreground color for string symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.structForeground", foreground, localize("symbolIcon.structForeground", "The foreground color for struct symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.textForeground", foreground, localize("symbolIcon.textForeground", "The foreground color for text symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.typeParameterForeground", foreground, localize("symbolIcon.typeParameterForeground", "The foreground color for type parameter symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.unitForeground", foreground, localize("symbolIcon.unitForeground", "The foreground color for unit symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")), registerColor("symbolIcon.variableForeground", {
	dark: "#75BEFF",
	light: "#007ACC",
	hcDark: "#75BEFF",
	hcLight: "#007ACC"
}, localize("symbolIcon.variableForeground", "The foreground color for variable symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));
var uncategorizedCodeActionGroup = Object.freeze({
	kind: HierarchicalKind.Empty,
	title: localize("codeAction.widget.id.more", "More Actions...")
}), codeActionGroups = Object.freeze([
	{
		kind: CodeActionKind.QuickFix,
		title: localize("codeAction.widget.id.quickfix", "Quick Fix")
	},
	{
		kind: CodeActionKind.RefactorExtract,
		title: localize("codeAction.widget.id.extract", "Extract"),
		icon: Codicon.wrench
	},
	{
		kind: CodeActionKind.RefactorInline,
		title: localize("codeAction.widget.id.inline", "Inline"),
		icon: Codicon.wrench
	},
	{
		kind: CodeActionKind.RefactorRewrite,
		title: localize("codeAction.widget.id.convert", "Rewrite"),
		icon: Codicon.wrench
	},
	{
		kind: CodeActionKind.RefactorMove,
		title: localize("codeAction.widget.id.move", "Move"),
		icon: Codicon.wrench
	},
	{
		kind: CodeActionKind.SurroundWith,
		title: localize("codeAction.widget.id.surround", "Surround With"),
		icon: Codicon.surroundWith
	},
	{
		kind: CodeActionKind.Source,
		title: localize("codeAction.widget.id.source", "Source Action"),
		icon: Codicon.symbolFile
	},
	uncategorizedCodeActionGroup
]);
function toMenuItems(e, _, v) {
	if (!_) return e.map((e) => ({
		kind: "action",
		item: e,
		group: uncategorizedCodeActionGroup,
		disabled: !!e.action.disabled,
		label: e.action.disabled || e.action.title,
		canPreview: !!e.action.edit?.edits.length
	}));
	let y = codeActionGroups.map((e) => ({
		group: e,
		actions: []
	}));
	for (let _ of e) {
		let e = _.action.kind ? new HierarchicalKind(_.action.kind) : HierarchicalKind.None;
		for (let v of y) if (v.group.kind.contains(e)) {
			v.actions.push(_);
			break;
		}
	}
	let b = [];
	for (let e of y) if (e.actions.length) {
		b.push({
			kind: "header",
			group: e.group
		});
		for (let _ of e.actions) {
			let y = e.group;
			b.push({
				kind: "action",
				item: _,
				group: _.action.isAI ? {
					title: y.title,
					kind: y.kind,
					icon: Codicon.sparkle
				} : y,
				label: _.action.title,
				disabled: !!_.action.disabled,
				keybinding: v(_.action)
			});
		}
	}
	return b;
}
var __decorate$95 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$95 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, LightBulbWidget_1, GUTTER_LIGHTBULB_ICON = registerIcon("gutter-lightbulb", Codicon.lightBulb, localize("gutterLightbulbWidget", "Icon which spawns code actions menu from the gutter when there is no space in the editor.")), GUTTER_LIGHTBULB_AUTO_FIX_ICON = registerIcon("gutter-lightbulb-auto-fix", Codicon.lightbulbAutofix, localize("gutterLightbulbAutoFixWidget", "Icon which spawns code actions menu from the gutter when there is no space in the editor and a quick fix is available.")), GUTTER_LIGHTBULB_AIFIX_ICON = registerIcon("gutter-lightbulb-sparkle", Codicon.lightbulbSparkle, localize("gutterLightbulbAIFixWidget", "Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix is available.")), GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON = registerIcon("gutter-lightbulb-aifix-auto-fix", Codicon.lightbulbSparkleAutofix, localize("gutterLightbulbAIFixAutoFixWidget", "Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix and a quick fix is available.")), GUTTER_SPARKLE_FILLED_ICON = registerIcon("gutter-lightbulb-sparkle-filled", Codicon.sparkleFilled, localize("gutterLightbulbSparkleFilledWidget", "Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix and a quick fix is available.")), LightBulbState;
(function(e) {
	e.Hidden = { type: 0 };
	class _ {
		constructor(e, _, v, y) {
			this.actions = e, this.trigger = _, this.editorPosition = v, this.widgetPosition = y, this.type = 1;
		}
	}
	e.Showing = _;
})(LightBulbState ||= {});
var LightBulbWidget = class extends Disposable {
	static {
		LightBulbWidget_1 = this;
	}
	static {
		this.GUTTER_DECORATION = ModelDecorationOptions.register({
			description: "codicon-gutter-lightbulb-decoration",
			glyphMarginClassName: ThemeIcon.asClassName(Codicon.lightBulb),
			glyphMargin: { position: GlyphMarginLane.Left },
			stickiness: 1
		});
	}
	static {
		this.ID = "editor.contrib.lightbulbWidget";
	}
	static {
		this._posPref = [0];
	}
	constructor(e, _) {
		super(), this._editor = e, this._keybindingService = _, this._onClick = this._register(new Emitter()), this.onClick = this._onClick.event, this._state = LightBulbState.Hidden, this._gutterState = LightBulbState.Hidden, this._iconClasses = [], this.lightbulbClasses = [
			"codicon-" + GUTTER_LIGHTBULB_ICON.id,
			"codicon-" + GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON.id,
			"codicon-" + GUTTER_LIGHTBULB_AUTO_FIX_ICON.id,
			"codicon-" + GUTTER_LIGHTBULB_AIFIX_ICON.id,
			"codicon-" + GUTTER_SPARKLE_FILLED_ICON.id
		], this.gutterDecoration = LightBulbWidget_1.GUTTER_DECORATION, this._domNode = $("div.lightBulbWidget"), this._domNode.role = "listbox", this._register(Gesture.ignoreTarget(this._domNode)), this._editor.addContentWidget(this), this._register(this._editor.onDidChangeModelContent((e) => {
			let _ = this._editor.getModel();
			(this.state.type !== 1 || !_ || this.state.editorPosition.lineNumber >= _.getLineCount()) && this.hide(), (this.gutterState.type !== 1 || !_ || this.gutterState.editorPosition.lineNumber >= _.getLineCount()) && this.gutterHide();
		})), this._register(addStandardDisposableGenericMouseDownListener(this._domNode, (e) => {
			if (this.state.type !== 1) return;
			this._editor.focus(), e.preventDefault();
			let { top: _, height: v } = getDomNodePagePosition(this._domNode), y = this._editor.getOption(67), b = Math.floor(y / 3);
			this.state.widgetPosition.position !== null && this.state.widgetPosition.position.lineNumber < this.state.editorPosition.lineNumber && (b += y), this._onClick.fire({
				x: e.posx,
				y: _ + v + b,
				actions: this.state.actions,
				trigger: this.state.trigger
			});
		})), this._register(addDisposableListener(this._domNode, "mouseenter", (e) => {
			(e.buttons & 1) == 1 && this.hide();
		})), this._register(Event.runAndSubscribe(this._keybindingService.onDidUpdateKeybindings, () => {
			this._preferredKbLabel = this._keybindingService.lookupKeybinding("editor.action.autoFix")?.getLabel() ?? void 0, this._quickFixKbLabel = this._keybindingService.lookupKeybinding("editor.action.quickFix")?.getLabel() ?? void 0, this._updateLightBulbTitleAndIcon();
		})), this._register(this._editor.onMouseDown(async (e) => {
			if (!e.target.element || !this.lightbulbClasses.some((_) => e.target.element && e.target.element.classList.contains(_)) || this.gutterState.type !== 1) return;
			this._editor.focus();
			let { top: _, height: v } = getDomNodePagePosition(e.target.element), y = this._editor.getOption(67), b = Math.floor(y / 3);
			this.gutterState.widgetPosition.position !== null && this.gutterState.widgetPosition.position.lineNumber < this.gutterState.editorPosition.lineNumber && (b += y), this._onClick.fire({
				x: e.event.posx,
				y: _ + v + b,
				actions: this.gutterState.actions,
				trigger: this.gutterState.trigger
			});
		}));
	}
	dispose() {
		super.dispose(), this._editor.removeContentWidget(this), this._gutterDecorationID && this._removeGutterDecoration(this._gutterDecorationID);
	}
	getId() {
		return "LightBulbWidget";
	}
	getDomNode() {
		return this._domNode;
	}
	getPosition() {
		return this._state.type === 1 ? this._state.widgetPosition : null;
	}
	update(e, _, v) {
		if (e.validActions.length <= 0 || !this._editor.hasTextFocus() || !this._editor.getOptions().get(65).enabled) return this.gutterHide(), this.hide();
		let y = this._editor.getModel();
		if (!y) return this.gutterHide(), this.hide();
		let { lineNumber: b, column: x } = y.validatePosition(v), S = y.getOptions().tabSize, C = this._editor.getOptions().get(50), w = y.getLineContent(b), T = computeIndentLevel(w, S), E = C.spaceWidth * T > 22, D = (e) => e > 2 && this._editor.getTopForLineNumber(e) === this._editor.getTopForLineNumber(e - 1), O = this._editor.getLineDecorations(b), k = !1;
		if (O) for (let e of O) {
			let _ = e.options.glyphMarginClassName;
			if (_ && !this.lightbulbClasses.some((e) => _.includes(e))) {
				k = !0;
				break;
			}
		}
		let A = b, j = 1;
		if (!E) {
			let S = (e) => {
				let _ = y.getLineContent(e);
				return /^\s*$|^\s+/.test(_) || _.length <= j;
			};
			if (b > 1 && !D(b - 1)) {
				let x = y.getLineCount(), C = b === x, w = b > 1 && S(b - 1), T = !C && S(b + 1), E = S(b), D = !T && !w;
				if (!T && !w && !k) return this.gutterState = new LightBulbState.Showing(e, _, v, {
					position: {
						lineNumber: A,
						column: j
					},
					preference: LightBulbWidget_1._posPref
				}), this.renderGutterLightbub(), this.hide();
				w || C || w && !E ? --A : (T || D && E) && (A += 1);
			} else if (b === 1 && (b === y.getLineCount() || !S(b + 1) && !S(b))) if (this.gutterState = new LightBulbState.Showing(e, _, v, {
				position: {
					lineNumber: A,
					column: j
				},
				preference: LightBulbWidget_1._posPref
			}), k) this.gutterHide();
			else return this.renderGutterLightbub(), this.hide();
			else if (b < y.getLineCount() && !D(b + 1)) A += 1;
			else if (x * C.spaceWidth < 22) return this.hide();
			j = /^\S\s*$/.test(y.getLineContent(A)) ? 2 : 1;
		}
		this.state = new LightBulbState.Showing(e, _, v, {
			position: {
				lineNumber: A,
				column: j
			},
			preference: LightBulbWidget_1._posPref
		}), this._gutterDecorationID && (this._removeGutterDecoration(this._gutterDecorationID), this.gutterHide());
		let M = e.validActions, N = e.validActions[0].action.kind;
		if (M.length !== 1 || !N) {
			this._editor.layoutContentWidget(this);
			return;
		}
		this._editor.layoutContentWidget(this);
	}
	hide() {
		this.state !== LightBulbState.Hidden && (this.state = LightBulbState.Hidden, this._editor.layoutContentWidget(this));
	}
	gutterHide() {
		this.gutterState !== LightBulbState.Hidden && (this._gutterDecorationID && this._removeGutterDecoration(this._gutterDecorationID), this.gutterState = LightBulbState.Hidden);
	}
	get state() {
		return this._state;
	}
	set state(e) {
		this._state = e, this._updateLightBulbTitleAndIcon();
	}
	get gutterState() {
		return this._gutterState;
	}
	set gutterState(e) {
		this._gutterState = e, this._updateGutterLightBulbTitleAndIcon();
	}
	_updateLightBulbTitleAndIcon() {
		if (this._domNode.classList.remove(...this._iconClasses), this._iconClasses = [], this.state.type !== 1) return;
		let e, _ = !1;
		this.state.actions.allAIFixes ? (e = Codicon.sparkleFilled, this.state.actions.validActions.length === 1 && (_ = !0)) : e = this.state.actions.hasAutoFix ? this.state.actions.hasAIFix ? Codicon.lightbulbSparkleAutofix : Codicon.lightbulbAutofix : this.state.actions.hasAIFix ? Codicon.lightbulbSparkle : Codicon.lightBulb, this._updateLightbulbTitle(this.state.actions.hasAutoFix, _), this._iconClasses = ThemeIcon.asClassNameArray(e), this._domNode.classList.add(...this._iconClasses);
	}
	_updateGutterLightBulbTitleAndIcon() {
		if (this.gutterState.type !== 1) return;
		let e, _ = !1;
		this.gutterState.actions.allAIFixes ? (e = GUTTER_SPARKLE_FILLED_ICON, this.gutterState.actions.validActions.length === 1 && (_ = !0)) : e = this.gutterState.actions.hasAutoFix ? this.gutterState.actions.hasAIFix ? GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON : GUTTER_LIGHTBULB_AUTO_FIX_ICON : this.gutterState.actions.hasAIFix ? GUTTER_LIGHTBULB_AIFIX_ICON : GUTTER_LIGHTBULB_ICON, this._updateLightbulbTitle(this.gutterState.actions.hasAutoFix, _), this.gutterDecoration = ModelDecorationOptions.register({
			description: "codicon-gutter-lightbulb-decoration",
			glyphMarginClassName: ThemeIcon.asClassName(e),
			glyphMargin: { position: GlyphMarginLane.Left },
			stickiness: 1
		});
	}
	renderGutterLightbub() {
		let e = this._editor.getSelection();
		e && (this._gutterDecorationID === void 0 ? this._addGutterDecoration(e.startLineNumber) : this._updateGutterDecoration(this._gutterDecorationID, e.startLineNumber));
	}
	_addGutterDecoration(e) {
		this._editor.changeDecorations((_) => {
			this._gutterDecorationID = _.addDecoration(new Range(e, 0, e, 0), this.gutterDecoration);
		});
	}
	_removeGutterDecoration(e) {
		this._editor.changeDecorations((_) => {
			_.removeDecoration(e), this._gutterDecorationID = void 0;
		});
	}
	_updateGutterDecoration(e, _) {
		this._editor.changeDecorations((v) => {
			v.changeDecoration(e, new Range(_, 0, _, 0)), v.changeDecorationOptions(e, this.gutterDecoration);
		});
	}
	_updateLightbulbTitle(e, _) {
		this.state.type === 1 && (_ ? this.title = localize("codeActionAutoRun", "Run: {0}", this.state.actions.validActions[0].action.title) : e && this._preferredKbLabel ? this.title = localize("preferredcodeActionWithKb", "Show Code Actions. Preferred Quick Fix Available ({0})", this._preferredKbLabel) : !e && this._quickFixKbLabel ? this.title = localize("codeActionWithKb", "Show Code Actions ({0})", this._quickFixKbLabel) : e || (this.title = localize("codeAction", "Show Code Actions")));
	}
	set title(e) {
		this._domNode.title = e;
	}
};
LightBulbWidget = LightBulbWidget_1 = __decorate$95([__param$95(1, IKeybindingService)], LightBulbWidget);
var __decorate$94 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$94 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const acceptSelectedActionCommand = "acceptSelectedCodeAction", previewSelectedActionCommand = "previewSelectedCodeAction";
var HeaderRenderer = class {
	get templateId() {
		return "header";
	}
	renderTemplate(e) {
		e.classList.add("group-header");
		let _ = document.createElement("span");
		return e.append(_), {
			container: e,
			text: _
		};
	}
	renderElement(e, _, v) {
		v.text.textContent = e.group?.title ?? "";
	}
	disposeTemplate(e) {}
}, ActionItemRenderer = class {
	get templateId() {
		return "action";
	}
	constructor(e, _) {
		this._supportsPreview = e, this._keybindingService = _;
	}
	renderTemplate(e) {
		e.classList.add(this.templateId);
		let _ = document.createElement("div");
		_.className = "icon", e.append(_);
		let v = document.createElement("span");
		v.className = "title", e.append(v);
		let y = new KeybindingLabel(e, OS);
		return {
			container: e,
			icon: _,
			text: v,
			keybinding: y
		};
	}
	renderElement(e, _, v) {
		if (e.group?.icon ? (v.icon.className = ThemeIcon.asClassName(e.group.icon), e.group.icon.color && (v.icon.style.color = asCssVariable(e.group.icon.color.id))) : (v.icon.className = ThemeIcon.asClassName(Codicon.lightBulb), v.icon.style.color = "var(--vscode-editorLightBulb-foreground)"), !e.item || !e.label) return;
		v.text.textContent = stripNewlines(e.label), v.keybinding.set(e.keybinding), setVisibility(!!e.keybinding, v.keybinding.element);
		let y = this._keybindingService.lookupKeybinding(acceptSelectedActionCommand)?.getLabel(), b = this._keybindingService.lookupKeybinding(previewSelectedActionCommand)?.getLabel();
		v.container.classList.toggle("option-disabled", e.disabled), e.disabled ? v.container.title = e.label : y && b ? this._supportsPreview && e.canPreview ? v.container.title = localize({
			key: "label-preview",
			comment: ["placeholders are keybindings, e.g \"F2 to Apply, Shift+F2 to Preview\""]
		}, "{0} to Apply, {1} to Preview", y, b) : v.container.title = localize({
			key: "label",
			comment: ["placeholder is a keybinding, e.g \"F2 to Apply\""]
		}, "{0} to Apply", y) : v.container.title = "";
	}
	disposeTemplate(e) {
		e.keybinding.dispose();
	}
};
ActionItemRenderer = __decorate$94([__param$94(1, IKeybindingService)], ActionItemRenderer);
var AcceptSelectedEvent = class extends UIEvent {
	constructor() {
		super("acceptSelectedAction");
	}
}, PreviewSelectedEvent = class extends UIEvent {
	constructor() {
		super("previewSelectedAction");
	}
};
function getKeyboardNavigationLabel(e) {
	if (e.kind === "action") return e.label;
}
var ActionList = class extends Disposable {
	constructor(e, _, v, y, b, x) {
		super(), this._delegate = y, this._contextViewService = b, this._keybindingService = x, this._actionLineHeight = 24, this._headerLineHeight = 26, this.cts = this._register(new CancellationTokenSource()), this.domNode = document.createElement("div"), this.domNode.classList.add("actionList"), this._list = this._register(new List(e, this.domNode, {
			getHeight: (e) => e.kind === "header" ? this._headerLineHeight : this._actionLineHeight,
			getTemplateId: (e) => e.kind
		}, [new ActionItemRenderer(_, this._keybindingService), new HeaderRenderer()], {
			keyboardSupport: !1,
			typeNavigationEnabled: !0,
			keyboardNavigationLabelProvider: { getKeyboardNavigationLabel },
			accessibilityProvider: {
				getAriaLabel: (e) => {
					if (e.kind === "action") {
						let _ = e.label ? stripNewlines(e?.label) : "";
						return e.disabled && (_ = localize({
							key: "customQuickFixWidget.labels",
							comment: ["Action widget labels for accessibility."]
						}, "{0}, Disabled Reason: {1}", _, e.disabled)), _;
					}
					return null;
				},
				getWidgetAriaLabel: () => localize({
					key: "customQuickFixWidget",
					comment: ["An action widget option"]
				}, "Action Widget"),
				getRole: (e) => e.kind === "action" ? "option" : "separator",
				getWidgetRole: () => "listbox"
			}
		})), this._list.style(defaultListStyles), this._register(this._list.onMouseClick((e) => this.onListClick(e))), this._register(this._list.onMouseOver((e) => this.onListHover(e))), this._register(this._list.onDidChangeFocus(() => this.onFocus())), this._register(this._list.onDidChangeSelection((e) => this.onListSelection(e))), this._allMenuItems = v, this._list.splice(0, this._list.length, this._allMenuItems), this._list.length && this.focusNext();
	}
	focusCondition(e) {
		return !e.disabled && e.kind === "action";
	}
	hide(e) {
		this._delegate.onHide(e), this.cts.cancel(), this._contextViewService.hideContextView();
	}
	layout(e) {
		let _ = this._allMenuItems.filter((e) => e.kind === "header").length, v = this._allMenuItems.length * this._actionLineHeight + _ * this._headerLineHeight - _ * this._actionLineHeight;
		this._list.layout(v);
		let y = e;
		if (this._allMenuItems.length >= 50) y = 380;
		else {
			let _ = this._allMenuItems.map((e, _) => {
				let v = this.domNode.ownerDocument.getElementById(this._list.getElementID(_));
				if (v) {
					v.style.width = "auto";
					let e = v.getBoundingClientRect().width;
					return v.style.width = "", e;
				}
				return 0;
			});
			y = Math.max(..._, e);
		}
		let b = Math.min(v, this.domNode.ownerDocument.body.clientHeight * .7);
		return this._list.layout(b, y), this.domNode.style.height = `${b}px`, this._list.domFocus(), y;
	}
	focusPrevious() {
		this._list.focusPrevious(1, !0, void 0, this.focusCondition);
	}
	focusNext() {
		this._list.focusNext(1, !0, void 0, this.focusCondition);
	}
	acceptSelected(e) {
		let _ = this._list.getFocus();
		if (_.length === 0) return;
		let v = _[0], y = this._list.element(v);
		if (!this.focusCondition(y)) return;
		let b = e ? new PreviewSelectedEvent() : new AcceptSelectedEvent();
		this._list.setSelection([v], b);
	}
	onListSelection(e) {
		if (!e.elements.length) return;
		let _ = e.elements[0];
		_.item && this.focusCondition(_) ? this._delegate.onSelect(_.item, e.browserEvent instanceof PreviewSelectedEvent) : this._list.setSelection([]);
	}
	onFocus() {
		let e = this._list.getFocus();
		if (e.length === 0) return;
		let _ = e[0], v = this._list.element(_);
		this._delegate.onFocus?.(v.item);
	}
	async onListHover(e) {
		let _ = e.element;
		if (_ && _.item && this.focusCondition(_)) {
			if (this._delegate.onHover && !_.disabled && _.kind === "action") {
				let e = await this._delegate.onHover(_.item, this.cts.token);
				_.canPreview = e ? e.canPreview : void 0;
			}
			e.index && this._list.splice(e.index, 1, [_]);
		}
		this._list.setFocus(typeof e.index == "number" ? [e.index] : []);
	}
	onListClick(e) {
		e.element && this.focusCondition(e.element) && this._list.setFocus([]);
	}
};
ActionList = __decorate$94([__param$94(4, IContextViewService), __param$94(5, IKeybindingService)], ActionList);
function stripNewlines(e) {
	return e.replace(/\r\n|\r|\n/g, " ");
}
var __decorate$93 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$93 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
registerColor("actionBar.toggledBackground", inputActiveOptionBackground, localize("actionBar.toggledBackground", "Background color for toggled action items in action bar."));
var ActionWidgetContextKeys = { Visible: new RawContextKey("codeActionMenuVisible", !1, localize("codeActionMenuVisible", "Whether the action widget list is visible")) };
const IActionWidgetService = createDecorator("actionWidgetService");
var ActionWidgetService = class extends Disposable {
	get isVisible() {
		return ActionWidgetContextKeys.Visible.getValue(this._contextKeyService) || !1;
	}
	constructor(e, _, v) {
		super(), this._contextViewService = e, this._contextKeyService = _, this._instantiationService = v, this._list = this._register(new MutableDisposable());
	}
	show(e, _, v, y, b, x, S) {
		let C = ActionWidgetContextKeys.Visible.bindTo(this._contextKeyService), w = this._instantiationService.createInstance(ActionList, e, _, v, y);
		this._contextViewService.showContextView({
			getAnchor: () => b,
			render: (e) => (C.set(!0), this._renderWidget(e, w, S ?? [])),
			onHide: (e) => {
				C.reset(), this._onWidgetClosed(e);
			}
		}, x, !1);
	}
	acceptSelected(e) {
		this._list.value?.acceptSelected(e);
	}
	focusPrevious() {
		this._list?.value?.focusPrevious();
	}
	focusNext() {
		this._list?.value?.focusNext();
	}
	hide(e) {
		this._list.value?.hide(e), this._list.clear();
	}
	_renderWidget(e, _, v) {
		let y = document.createElement("div");
		if (y.classList.add("action-widget"), e.appendChild(y), this._list.value = _, this._list.value) y.appendChild(this._list.value.domNode);
		else throw Error("List has no value");
		let b = new DisposableStore(), x = document.createElement("div"), S = e.appendChild(x);
		S.classList.add("context-view-block"), b.add(addDisposableListener(S, EventType$1.MOUSE_DOWN, (e) => e.stopPropagation()));
		let C = document.createElement("div"), w = e.appendChild(C);
		w.classList.add("context-view-pointerBlock"), b.add(addDisposableListener(w, EventType$1.POINTER_MOVE, () => w.remove())), b.add(addDisposableListener(w, EventType$1.MOUSE_DOWN, () => w.remove()));
		let T = 0;
		if (v.length) {
			let e = this._createActionBar(".action-widget-action-bar", v);
			e && (y.appendChild(e.getContainer().parentElement), b.add(e), T = e.getContainer().offsetWidth);
		}
		let E = this._list.value?.layout(T);
		y.style.width = `${E}px`;
		let D = b.add(trackFocus(e));
		return b.add(D.onDidBlur(() => this.hide(!0))), b;
	}
	_createActionBar(e, _) {
		if (!_.length) return;
		let v = $(e), y = new ActionBar(v);
		return y.push(_, {
			icon: !1,
			label: !0
		}), y;
	}
	_onWidgetClosed(e) {
		this._list.value?.hide(e);
	}
};
ActionWidgetService = __decorate$93([
	__param$93(0, IContextViewService),
	__param$93(1, IContextKeyService),
	__param$93(2, IInstantiationService)
], ActionWidgetService), registerSingleton(IActionWidgetService, ActionWidgetService, 1);
var weight$3 = 1100;
registerAction2(class extends Action2 {
	constructor() {
		super({
			id: "hideCodeActionWidget",
			title: localize2("hideCodeActionWidget.title", "Hide action widget"),
			precondition: ActionWidgetContextKeys.Visible,
			keybinding: {
				weight: weight$3,
				primary: 9,
				secondary: [1033]
			}
		});
	}
	run(e) {
		e.get(IActionWidgetService).hide(!0);
	}
}), registerAction2(class extends Action2 {
	constructor() {
		super({
			id: "selectPrevCodeAction",
			title: localize2("selectPrevCodeAction.title", "Select previous action"),
			precondition: ActionWidgetContextKeys.Visible,
			keybinding: {
				weight: weight$3,
				primary: 16,
				secondary: [2064],
				mac: {
					primary: 16,
					secondary: [2064, 302]
				}
			}
		});
	}
	run(e) {
		let _ = e.get(IActionWidgetService);
		_ instanceof ActionWidgetService && _.focusPrevious();
	}
}), registerAction2(class extends Action2 {
	constructor() {
		super({
			id: "selectNextCodeAction",
			title: localize2("selectNextCodeAction.title", "Select next action"),
			precondition: ActionWidgetContextKeys.Visible,
			keybinding: {
				weight: weight$3,
				primary: 18,
				secondary: [2066],
				mac: {
					primary: 18,
					secondary: [2066, 300]
				}
			}
		});
	}
	run(e) {
		let _ = e.get(IActionWidgetService);
		_ instanceof ActionWidgetService && _.focusNext();
	}
}), registerAction2(class extends Action2 {
	constructor() {
		super({
			id: acceptSelectedActionCommand,
			title: localize2("acceptSelected.title", "Accept selected action"),
			precondition: ActionWidgetContextKeys.Visible,
			keybinding: {
				weight: weight$3,
				primary: 3,
				secondary: [2137]
			}
		});
	}
	run(e) {
		let _ = e.get(IActionWidgetService);
		_ instanceof ActionWidgetService && _.acceptSelected();
	}
}), registerAction2(class extends Action2 {
	constructor() {
		super({
			id: previewSelectedActionCommand,
			title: localize2("previewSelected.title", "Preview selected action"),
			precondition: ActionWidgetContextKeys.Visible,
			keybinding: {
				weight: weight$3,
				primary: 2051
			}
		});
	}
	run(e) {
		let _ = e.get(IActionWidgetService);
		_ instanceof ActionWidgetService && _.acceptSelected(!0);
	}
});
const SUPPORTED_CODE_ACTIONS = new RawContextKey("supportedCodeAction", "");
var CodeActionOracle = class extends Disposable {
	constructor(e, _, v, y = 250) {
		super(), this._editor = e, this._markerService = _, this._signalChange = v, this._delay = y, this._autoTriggerTimer = this._register(new TimeoutTimer()), this._register(this._markerService.onMarkerChanged((e) => this._onMarkerChanges(e))), this._register(this._editor.onDidChangeCursorPosition(() => this._tryAutoTrigger()));
	}
	trigger(e) {
		let _ = this._getRangeOfSelectionUnlessWhitespaceEnclosed(e);
		this._signalChange(_ ? {
			trigger: e,
			selection: _
		} : void 0);
	}
	_onMarkerChanges(e) {
		let _ = this._editor.getModel();
		_ && e.some((e) => isEqual(e, _.uri)) && this._tryAutoTrigger();
	}
	_tryAutoTrigger() {
		this._autoTriggerTimer.cancelAndSet(() => {
			this.trigger({
				type: 2,
				triggerAction: CodeActionTriggerSource.Default
			});
		}, this._delay);
	}
	_getRangeOfSelectionUnlessWhitespaceEnclosed(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._editor.getSelection();
		if (e.type === 1) return _;
		let v = this._editor.getOption(65).enabled;
		if (v !== ShowLightbulbIconMode.Off) {
			if (v === ShowLightbulbIconMode.On) return _;
			if (v === ShowLightbulbIconMode.OnCode) {
				if (!_.isEmpty()) return _;
				let e = this._editor.getModel(), { lineNumber: v, column: y } = _.getPosition(), b = e.getLineContent(v);
				if (b.length === 0) return;
				if (y === 1) {
					if (/\s/.test(b[0])) return;
				} else if (y === e.getLineMaxColumn(v)) {
					if (/\s/.test(b[b.length - 1])) return;
				} else if (/\s/.test(b[y - 2]) && /\s/.test(b[y - 1])) return;
			}
			return _;
		}
	}
}, CodeActionsState;
(function(e) {
	e.Empty = { type: 0 };
	class _ {
		constructor(e, _, v) {
			this.trigger = e, this.position = _, this._cancellablePromise = v, this.type = 1, this.actions = v.catch((e) => {
				if (isCancellationError(e)) return emptyCodeActionSet;
				throw e;
			});
		}
		cancel() {
			this._cancellablePromise.cancel();
		}
	}
	e.Triggered = _;
})(CodeActionsState ||= {});
var emptyCodeActionSet = Object.freeze({
	allActions: [],
	validActions: [],
	dispose: () => {},
	documentation: [],
	hasAutoFix: !1,
	hasAIFix: !1,
	allAIFixes: !1
}), CodeActionModel = class extends Disposable {
	constructor(e, _, v, y, b, x, S) {
		super(), this._editor = e, this._registry = _, this._markerService = v, this._progressService = b, this._configurationService = x, this._telemetryService = S, this._codeActionOracle = this._register(new MutableDisposable()), this._state = CodeActionsState.Empty, this._onDidChangeState = this._register(new Emitter()), this.onDidChangeState = this._onDidChangeState.event, this._disposed = !1, this._supportedCodeActions = SUPPORTED_CODE_ACTIONS.bindTo(y), this._register(this._editor.onDidChangeModel(() => this._update())), this._register(this._editor.onDidChangeModelLanguage(() => this._update())), this._register(this._registry.onDidChange(() => this._update())), this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(65) && this._update();
		})), this._update();
	}
	dispose() {
		this._disposed || (this._disposed = !0, super.dispose(), this.setState(CodeActionsState.Empty, !0));
	}
	_settingEnabledNearbyQuickfixes() {
		let e = this._editor?.getModel();
		return this._configurationService ? this._configurationService.getValue("editor.codeActionWidget.includeNearbyQuickFixes", { resource: e?.uri }) : !1;
	}
	_update() {
		if (this._disposed) return;
		this._codeActionOracle.value = void 0, this.setState(CodeActionsState.Empty);
		let e = this._editor.getModel();
		if (e && this._registry.has(e) && !this._editor.getOption(92)) {
			let _ = this._registry.all(e).flatMap((e) => e.providedCodeActionKinds ?? []);
			this._supportedCodeActions.set(_.join(" ")), this._codeActionOracle.value = new CodeActionOracle(this._editor, this._markerService, (_) => {
				if (!_) {
					this.setState(CodeActionsState.Empty);
					return;
				}
				let v = _.selection.getStartPosition(), y = createCancelablePromise(async (v) => {
					if (this._settingEnabledNearbyQuickfixes() && _.trigger.type === 1 && (_.trigger.triggerAction === CodeActionTriggerSource.QuickFix || _.trigger.filter?.include?.contains(CodeActionKind.QuickFix))) {
						let y = await getCodeActions(this._registry, e, _.selection, _.trigger, Progress.None, v), b = [...y.allActions];
						if (v.isCancellationRequested) return emptyCodeActionSet;
						let x = y.validActions?.some((e) => e.action.kind ? CodeActionKind.QuickFix.contains(new HierarchicalKind(e.action.kind)) : !1), S = this._markerService.read({ resource: e.uri });
						if (x) {
							for (let e of y.validActions) e.action.command?.arguments?.some((e) => typeof e == "string" && e.includes("_typescript.applyFixAllCodeAction")) && (e.action.diagnostics = [...S.filter((e) => e.relatedInformation)]);
							return {
								validActions: y.validActions,
								allActions: b,
								documentation: y.documentation,
								hasAutoFix: y.hasAutoFix,
								hasAIFix: y.hasAIFix,
								allAIFixes: y.allAIFixes,
								dispose: () => {
									y.dispose();
								}
							};
						} else if (!x && S.length > 0) {
							let x = _.selection.getPosition(), C = x, w = Number.MAX_VALUE, T = [...y.validActions];
							for (let E of S) {
								let D = E.endColumn, O = E.endLineNumber, k = E.startLineNumber;
								if (O === x.lineNumber || k === x.lineNumber) {
									C = new Position(O, D);
									let E = {
										type: _.trigger.type,
										triggerAction: _.trigger.triggerAction,
										filter: { include: _.trigger.filter?.include ? _.trigger.filter?.include : CodeActionKind.QuickFix },
										autoApply: _.trigger.autoApply,
										context: {
											notAvailableMessage: _.trigger.context?.notAvailableMessage || "",
											position: C
										}
									}, k = new Selection(C.lineNumber, C.column, C.lineNumber, C.column), A = await getCodeActions(this._registry, e, k, E, Progress.None, v);
									if (A.validActions.length !== 0) {
										for (let e of A.validActions) e.action.command?.arguments?.some((e) => typeof e == "string" && e.includes("_typescript.applyFixAllCodeAction")) && (e.action.diagnostics = [...S.filter((e) => e.relatedInformation)]);
										y.allActions.length === 0 && b.push(...A.allActions), Math.abs(x.column - D) < w ? T.unshift(...A.validActions) : T.push(...A.validActions);
									}
									w = Math.abs(x.column - D);
								}
							}
							let E = T.filter((e, _, v) => v.findIndex((_) => _.action.title === e.action.title) === _);
							return E.sort((e, _) => e.action.isPreferred && !_.action.isPreferred ? -1 : !e.action.isPreferred && _.action.isPreferred || e.action.isAI && !_.action.isAI ? 1 : !e.action.isAI && _.action.isAI ? -1 : 0), {
								validActions: E,
								allActions: b,
								documentation: y.documentation,
								hasAutoFix: y.hasAutoFix,
								hasAIFix: y.hasAIFix,
								allAIFixes: y.allAIFixes,
								dispose: () => {
									y.dispose();
								}
							};
						}
					}
					if (_.trigger.type === 1) {
						let y = new StopWatch(), b = await getCodeActions(this._registry, e, _.selection, _.trigger, Progress.None, v);
						return this._telemetryService && this._telemetryService.publicLog2("codeAction.invokedDurations", {
							codeActions: b.validActions.length,
							duration: y.elapsed()
						}), b;
					}
					return getCodeActions(this._registry, e, _.selection, _.trigger, Progress.None, v);
				});
				_.trigger.type === 1 && this._progressService?.showWhile(y, 250);
				let b = new CodeActionsState.Triggered(_.trigger, v, y), x = !1;
				this._state.type === 1 && (x = this._state.trigger.type === 1 && b.type === 1 && b.trigger.type === 2 && this._state.position !== b.position), x ? setTimeout(() => {
					this.setState(b);
				}, 500) : this.setState(b);
			}, void 0), this._codeActionOracle.value.trigger({
				type: 2,
				triggerAction: CodeActionTriggerSource.Default
			});
		} else this._supportedCodeActions.reset();
	}
	trigger(e) {
		this._codeActionOracle.value?.trigger(e);
	}
	setState(e, _) {
		e !== this._state && (this._state.type === 1 && this._state.cancel(), this._state = e, !_ && !this._disposed && this._onDidChangeState.fire(e));
	}
}, __decorate$92 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$92 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, CodeActionController_1, DECORATION_CLASS_NAME$1 = "quickfix-edit-highlight", CodeActionController = class extends Disposable {
	static {
		CodeActionController_1 = this;
	}
	static {
		this.ID = "editor.contrib.codeActionController";
	}
	static get(e) {
		return e.getContribution(CodeActionController_1.ID);
	}
	constructor(e, _, v, y, b, x, S, C, w, T, E) {
		super(), this._commandService = S, this._configurationService = C, this._actionWidgetService = w, this._instantiationService = T, this._telemetryService = E, this._activeCodeActions = this._register(new MutableDisposable()), this._showDisabled = !1, this._disposed = !1, this._editor = e, this._model = this._register(new CodeActionModel(this._editor, b.codeActionProvider, _, v, x, C, this._telemetryService)), this._register(this._model.onDidChangeState((e) => this.update(e))), this._lightBulbWidget = new Lazy(() => {
			let e = this._editor.getContribution(LightBulbWidget.ID);
			return e && this._register(e.onClick((e) => this.showCodeActionsFromLightbulb(e.actions, e))), e;
		}), this._resolver = y.createInstance(CodeActionKeybindingResolver), this._register(this._editor.onDidLayoutChange(() => this._actionWidgetService.hide()));
	}
	dispose() {
		this._disposed = !0, super.dispose();
	}
	async showCodeActionsFromLightbulb(e, _) {
		if (e.allAIFixes && e.validActions.length === 1) {
			let _ = e.validActions[0], v = _.action.command;
			v && v.id === "inlineChat.start" && v.arguments && v.arguments.length >= 1 && (v.arguments[0] = {
				...v.arguments[0],
				autoSend: !1
			}), await this._applyCodeAction(_, !1, !1, ApplyCodeActionReason.FromAILightbulb);
			return;
		}
		await this.showCodeActionList(e, _, {
			includeDisabledActions: !1,
			fromLightbulb: !0
		});
	}
	showCodeActions(e, _, v) {
		return this.showCodeActionList(_, v, {
			includeDisabledActions: !1,
			fromLightbulb: !1
		});
	}
	manualTriggerAtCurrentPosition(e, _, v, y) {
		if (!this._editor.hasModel()) return;
		MessageController.get(this._editor)?.closeMessage();
		let b = this._editor.getPosition();
		this._trigger({
			type: 1,
			triggerAction: _,
			filter: v,
			autoApply: y,
			context: {
				notAvailableMessage: e,
				position: b
			}
		});
	}
	_trigger(e) {
		return this._model.trigger(e);
	}
	async _applyCodeAction(e, _, v, y) {
		try {
			await this._instantiationService.invokeFunction(applyCodeAction, e, y, {
				preview: v,
				editor: this._editor
			});
		} finally {
			_ && this._trigger({
				type: 2,
				triggerAction: CodeActionTriggerSource.QuickFix,
				filter: {}
			});
		}
	}
	hideLightBulbWidget() {
		this._lightBulbWidget.rawValue?.hide(), this._lightBulbWidget.rawValue?.gutterHide();
	}
	async update(e) {
		if (e.type !== 1) {
			this.hideLightBulbWidget();
			return;
		}
		let _;
		try {
			_ = await e.actions;
		} catch (e) {
			onUnexpectedError(e);
			return;
		}
		if (!this._disposed && this._editor.getSelection()?.startLineNumber === e.position.lineNumber) if (this._lightBulbWidget.value?.update(_, e.trigger, e.position), e.trigger.type === 1) {
			if (e.trigger.filter?.include) {
				let v = this.tryGetValidActionToApply(e.trigger, _);
				if (v) {
					try {
						this.hideLightBulbWidget(), await this._applyCodeAction(v, !1, !1, ApplyCodeActionReason.FromCodeActions);
					} finally {
						_.dispose();
					}
					return;
				}
				if (e.trigger.context) {
					let v = this.getInvalidActionThatWouldHaveBeenApplied(e.trigger, _);
					if (v && v.action.disabled) {
						MessageController.get(this._editor)?.showMessage(v.action.disabled, e.trigger.context.position), _.dispose();
						return;
					}
				}
			}
			let v = !!e.trigger.filter?.include;
			if (e.trigger.context && (!_.allActions.length || !v && !_.validActions.length)) {
				MessageController.get(this._editor)?.showMessage(e.trigger.context.notAvailableMessage, e.trigger.context.position), this._activeCodeActions.value = _, _.dispose();
				return;
			}
			this._activeCodeActions.value = _, this.showCodeActionList(_, this.toCoords(e.position), {
				includeDisabledActions: v,
				fromLightbulb: !1
			});
		} else this._actionWidgetService.isVisible ? _.dispose() : this._activeCodeActions.value = _;
	}
	getInvalidActionThatWouldHaveBeenApplied(e, _) {
		if (_.allActions.length && (e.autoApply === "first" && _.validActions.length === 0 || e.autoApply === "ifSingle" && _.allActions.length === 1)) return _.allActions.find(({ action: e }) => e.disabled);
	}
	tryGetValidActionToApply(e, _) {
		if (_.validActions.length && (e.autoApply === "first" && _.validActions.length > 0 || e.autoApply === "ifSingle" && _.validActions.length === 1)) return _.validActions[0];
	}
	static {
		this.DECORATION = ModelDecorationOptions.register({
			description: "quickfix-highlight",
			className: DECORATION_CLASS_NAME$1
		});
	}
	async showCodeActionList(e, _, v) {
		let y = this._editor.createDecorationsCollection(), b = this._editor.getDomNode();
		if (!b) return;
		let x = v.includeDisabledActions && (this._showDisabled || e.validActions.length === 0) ? e.allActions : e.validActions;
		if (!x.length) return;
		let S = Position.isIPosition(_) ? this.toCoords(_) : _;
		this._actionWidgetService.show("codeActionWidget", !0, toMenuItems(x, this._shouldShowHeaders(), this._resolver.getResolver()), {
			onSelect: async (e, _) => {
				this._applyCodeAction(e, !0, !!_, v.fromLightbulb ? ApplyCodeActionReason.FromAILightbulb : ApplyCodeActionReason.FromCodeActions), this._actionWidgetService.hide(!1), y.clear();
			},
			onHide: (e) => {
				this._editor?.focus(), y.clear();
			},
			onHover: async (e, _) => {
				if (_.isCancellationRequested) return;
				let v = !1, y = e.action.kind;
				if (y) {
					let e = new HierarchicalKind(y);
					v = [
						CodeActionKind.RefactorExtract,
						CodeActionKind.RefactorInline,
						CodeActionKind.RefactorRewrite,
						CodeActionKind.RefactorMove,
						CodeActionKind.Source
					].some((_) => _.contains(e));
				}
				return { canPreview: v || !!e.action.edit?.edits.length };
			},
			onFocus: (e) => {
				if (e && e.action) {
					let _ = e.action.ranges, v = e.action.diagnostics;
					if (y.clear(), _ && _.length > 0) {
						let e = v && v?.length > 1 ? v.map((e) => ({
							range: e,
							options: CodeActionController_1.DECORATION
						})) : _.map((e) => ({
							range: e,
							options: CodeActionController_1.DECORATION
						}));
						y.set(e);
					} else if (v && v.length > 0) {
						let e = v.map((e) => ({
							range: e,
							options: CodeActionController_1.DECORATION
						}));
						y.set(e);
						let _ = v[0];
						if (_.startLineNumber && _.startColumn) {
							let e = this._editor.getModel()?.getWordAtPosition({
								lineNumber: _.startLineNumber,
								column: _.startColumn
							})?.word;
							status(localize("editingNewSelection", "Context: {0} at line {1} and column {2}.", e, _.startLineNumber, _.startColumn));
						}
					}
				} else y.clear();
			}
		}, S, b, this._getActionBarActions(e, _, v));
	}
	toCoords(e) {
		if (!this._editor.hasModel()) return {
			x: 0,
			y: 0
		};
		this._editor.revealPosition(e, 1), this._editor.render();
		let _ = this._editor.getScrolledVisiblePosition(e), v = getDomNodePagePosition(this._editor.getDomNode()), y = v.left + _.left, b = v.top + _.top + _.height;
		return {
			x: y,
			y: b
		};
	}
	_shouldShowHeaders() {
		let e = this._editor?.getModel();
		return this._configurationService.getValue("editor.codeActionWidget.showHeaders", { resource: e?.uri });
	}
	_getActionBarActions(e, _, v) {
		if (v.fromLightbulb) return [];
		let y = e.documentation.map((e) => ({
			id: e.id,
			label: e.title,
			tooltip: e.tooltip ?? "",
			class: void 0,
			enabled: !0,
			run: () => this._commandService.executeCommand(e.id, ...e.arguments ?? [])
		}));
		return v.includeDisabledActions && e.validActions.length > 0 && e.allActions.length !== e.validActions.length && y.push(this._showDisabled ? {
			id: "hideMoreActions",
			label: localize("hideMoreActions", "Hide Disabled"),
			enabled: !0,
			tooltip: "",
			class: void 0,
			run: () => (this._showDisabled = !1, this.showCodeActionList(e, _, v))
		} : {
			id: "showMoreActions",
			label: localize("showMoreActions", "Show Disabled"),
			enabled: !0,
			tooltip: "",
			class: void 0,
			run: () => (this._showDisabled = !0, this.showCodeActionList(e, _, v))
		}), y;
	}
};
CodeActionController = CodeActionController_1 = __decorate$92([
	__param$92(1, IMarkerService),
	__param$92(2, IContextKeyService),
	__param$92(3, IInstantiationService),
	__param$92(4, ILanguageFeaturesService),
	__param$92(5, IEditorProgressService),
	__param$92(6, ICommandService),
	__param$92(7, IConfigurationService),
	__param$92(8, IActionWidgetService),
	__param$92(9, IInstantiationService),
	__param$92(10, ITelemetryService)
], CodeActionController), registerThemingParticipant((e, _) => {
	((e, v) => {
		v && _.addRule(`.monaco-editor ${e} { background-color: ${v}; }`);
	})(".quickfix-edit-highlight", e.getColor(editorFindMatchHighlight));
	let v = e.getColor(editorFindMatchHighlightBorder);
	v && _.addRule(`.monaco-editor .quickfix-edit-highlight { border: 1px ${isHighContrast(e.type) ? "dotted" : "solid"} ${v}; box-sizing: border-box; }`);
});
function contextKeyForSupportedActions(e) {
	return ContextKeyExpr.regex(SUPPORTED_CODE_ACTIONS.keys()[0], /* @__PURE__ */ RegExp("(\\s|^)" + escapeRegExpCharacters(e.value) + "\\b"));
}
var argsSchema = {
	type: "object",
	defaultSnippets: [{ body: { kind: "" } }],
	properties: {
		kind: {
			type: "string",
			description: localize("args.schema.kind", "Kind of the code action to run.")
		},
		apply: {
			type: "string",
			description: localize("args.schema.apply", "Controls when the returned actions are applied."),
			default: "ifSingle",
			enum: [
				"first",
				"ifSingle",
				"never"
			],
			enumDescriptions: [
				localize("args.schema.apply.first", "Always apply the first returned code action."),
				localize("args.schema.apply.ifSingle", "Apply the first returned code action if it is the only one."),
				localize("args.schema.apply.never", "Do not apply the returned code actions.")
			]
		},
		preferred: {
			type: "boolean",
			default: !1,
			description: localize("args.schema.preferred", "Controls if only preferred code actions should be returned.")
		}
	}
};
function triggerCodeActionsForEditorSelection(e, _, v, y, b = CodeActionTriggerSource.Default) {
	e.hasModel() && CodeActionController.get(e)?.manualTriggerAtCurrentPosition(_, b, v, y);
}
var QuickFixAction = class extends EditorAction {
	constructor() {
		super({
			id: quickFixCommandId,
			label: localize("quickfix.trigger.label", "Quick Fix..."),
			alias: "Quick Fix...",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 2137,
				weight: 100
			}
		});
	}
	run(e, _) {
		return triggerCodeActionsForEditorSelection(_, localize("editor.action.quickFix.noneMessage", "No code actions available"), void 0, void 0, CodeActionTriggerSource.QuickFix);
	}
}, CodeActionCommand = class extends EditorCommand {
	constructor() {
		super({
			id: codeActionCommandId,
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
			metadata: {
				description: "Trigger a code action",
				args: [{
					name: "args",
					schema: argsSchema
				}]
			}
		});
	}
	runEditorCommand(e, _, v) {
		let y = CodeActionCommandArgs.fromUser(v, {
			kind: HierarchicalKind.Empty,
			apply: "ifSingle"
		});
		return triggerCodeActionsForEditorSelection(_, typeof v?.kind == "string" ? y.preferred ? localize("editor.action.codeAction.noneMessage.preferred.kind", "No preferred code actions for '{0}' available", v.kind) : localize("editor.action.codeAction.noneMessage.kind", "No code actions for '{0}' available", v.kind) : y.preferred ? localize("editor.action.codeAction.noneMessage.preferred", "No preferred code actions available") : localize("editor.action.codeAction.noneMessage", "No code actions available"), {
			include: y.kind,
			includeSourceActions: !0,
			onlyIncludePreferredActions: y.preferred
		}, y.apply);
	}
}, RefactorAction = class extends EditorAction {
	constructor() {
		super({
			id: refactorCommandId,
			label: localize("refactor.label", "Refactor..."),
			alias: "Refactor...",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 3120,
				mac: { primary: 1328 },
				weight: 100
			},
			contextMenuOpts: {
				group: "1_modification",
				order: 2,
				when: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.Refactor))
			},
			metadata: {
				description: "Refactor...",
				args: [{
					name: "args",
					schema: argsSchema
				}]
			}
		});
	}
	run(e, _, v) {
		let y = CodeActionCommandArgs.fromUser(v, {
			kind: CodeActionKind.Refactor,
			apply: "never"
		});
		return triggerCodeActionsForEditorSelection(_, typeof v?.kind == "string" ? y.preferred ? localize("editor.action.refactor.noneMessage.preferred.kind", "No preferred refactorings for '{0}' available", v.kind) : localize("editor.action.refactor.noneMessage.kind", "No refactorings for '{0}' available", v.kind) : y.preferred ? localize("editor.action.refactor.noneMessage.preferred", "No preferred refactorings available") : localize("editor.action.refactor.noneMessage", "No refactorings available"), {
			include: CodeActionKind.Refactor.contains(y.kind) ? y.kind : HierarchicalKind.None,
			onlyIncludePreferredActions: y.preferred
		}, y.apply, CodeActionTriggerSource.Refactor);
	}
}, SourceAction = class extends EditorAction {
	constructor() {
		super({
			id: sourceActionCommandId,
			label: localize("source.label", "Source Action..."),
			alias: "Source Action...",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
			contextMenuOpts: {
				group: "1_modification",
				order: 2.1,
				when: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.Source))
			},
			metadata: {
				description: "Source Action...",
				args: [{
					name: "args",
					schema: argsSchema
				}]
			}
		});
	}
	run(e, _, v) {
		let y = CodeActionCommandArgs.fromUser(v, {
			kind: CodeActionKind.Source,
			apply: "never"
		});
		return triggerCodeActionsForEditorSelection(_, typeof v?.kind == "string" ? y.preferred ? localize("editor.action.source.noneMessage.preferred.kind", "No preferred source actions for '{0}' available", v.kind) : localize("editor.action.source.noneMessage.kind", "No source actions for '{0}' available", v.kind) : y.preferred ? localize("editor.action.source.noneMessage.preferred", "No preferred source actions available") : localize("editor.action.source.noneMessage", "No source actions available"), {
			include: CodeActionKind.Source.contains(y.kind) ? y.kind : HierarchicalKind.None,
			includeSourceActions: !0,
			onlyIncludePreferredActions: y.preferred
		}, y.apply, CodeActionTriggerSource.SourceAction);
	}
}, OrganizeImportsAction = class extends EditorAction {
	constructor() {
		super({
			id: organizeImportsCommandId,
			label: localize("organizeImports.label", "Organize Imports"),
			alias: "Organize Imports",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.SourceOrganizeImports)),
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 1581,
				weight: 100
			}
		});
	}
	run(e, _) {
		return triggerCodeActionsForEditorSelection(_, localize("editor.action.organize.noneMessage", "No organize imports action available"), {
			include: CodeActionKind.SourceOrganizeImports,
			includeSourceActions: !0
		}, "ifSingle", CodeActionTriggerSource.OrganizeImports);
	}
}, FixAllAction = class extends EditorAction {
	constructor() {
		super({
			id: fixAllCommandId,
			label: localize("fixAll.label", "Fix All"),
			alias: "Fix All",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.SourceFixAll))
		});
	}
	run(e, _) {
		return triggerCodeActionsForEditorSelection(_, localize("fixAll.noneMessage", "No fix all action available"), {
			include: CodeActionKind.SourceFixAll,
			includeSourceActions: !0
		}, "ifSingle", CodeActionTriggerSource.FixAll);
	}
}, AutoFixAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.autoFix",
			label: localize("autoFix.label", "Auto Fix..."),
			alias: "Auto Fix...",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.QuickFix)),
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 1625,
				mac: { primary: 2649 },
				weight: 100
			}
		});
	}
	run(e, _) {
		return triggerCodeActionsForEditorSelection(_, localize("editor.action.autoFix.noneMessage", "No auto fixes available"), {
			include: CodeActionKind.QuickFix,
			onlyIncludePreferredActions: !0
		}, "ifSingle", CodeActionTriggerSource.AutoFix);
	}
};
registerEditorContribution(CodeActionController.ID, CodeActionController, 3), registerEditorContribution(LightBulbWidget.ID, LightBulbWidget, 4), registerEditorAction(QuickFixAction), registerEditorAction(RefactorAction), registerEditorAction(SourceAction), registerEditorAction(OrganizeImportsAction), registerEditorAction(AutoFixAction), registerEditorAction(FixAllAction), registerEditorCommand(new CodeActionCommand()), Registry.as(Extensions$1.Configuration).registerConfiguration({
	...editorConfigurationBaseNode,
	properties: { "editor.codeActionWidget.showHeaders": {
		type: "boolean",
		scope: 5,
		description: localize("showCodeActionHeaders", "Enable/disable showing group headers in the Code Action menu."),
		default: !0
	} }
}), Registry.as(Extensions$1.Configuration).registerConfiguration({
	...editorConfigurationBaseNode,
	properties: { "editor.codeActionWidget.includeNearbyQuickFixes": {
		type: "boolean",
		scope: 5,
		description: localize("includeNearbyQuickFixes", "Enable/disable showing nearest Quick Fix within a line when not currently on a diagnostic."),
		default: !0
	} }
}), Registry.as(Extensions$1.Configuration).registerConfiguration({
	...editorConfigurationBaseNode,
	properties: { "editor.codeActions.triggerOnFocusChange": {
		type: "boolean",
		scope: 5,
		markdownDescription: localize("triggerOnFocusChange", "Enable triggering {0} when {1} is set to {2}. Code Actions must be set to {3} to be triggered for window and focus changes.", "`#editor.codeActionsOnSave#`", "`#files.autoSave#`", "`afterDelay`", "`always`"),
		default: !1
	} }
});
var CodeLensModel = class {
	constructor() {
		this.lenses = [], this._disposables = new DisposableStore();
	}
	dispose() {
		this._disposables.dispose();
	}
	get isDisposed() {
		return this._disposables.isDisposed;
	}
	add(e, _) {
		this._disposables.add(e);
		for (let v of e.lenses) this.lenses.push({
			symbol: v,
			provider: _
		});
	}
};
async function getCodeLensModel(e, _, v) {
	let y = e.ordered(_), b = /* @__PURE__ */ new Map(), x = new CodeLensModel(), S = y.map(async (e, y) => {
		b.set(e, y);
		try {
			let y = await Promise.resolve(e.provideCodeLenses(_, v));
			y && x.add(y, e);
		} catch (e) {
			onUnexpectedExternalError(e);
		}
	});
	return await Promise.all(S), x.lenses = x.lenses.sort((e, _) => e.symbol.range.startLineNumber < _.symbol.range.startLineNumber ? -1 : e.symbol.range.startLineNumber > _.symbol.range.startLineNumber ? 1 : b.get(e.provider) < b.get(_.provider) ? -1 : b.get(e.provider) > b.get(_.provider) ? 1 : e.symbol.range.startColumn < _.symbol.range.startColumn ? -1 : e.symbol.range.startColumn > _.symbol.range.startColumn ? 1 : 0), x;
}
CommandsRegistry.registerCommand("_executeCodeLensProvider", function(e, ..._) {
	let [v, y] = _;
	assertType(URI.isUri(v)), assertType(typeof y == "number" || !y);
	let { codeLensProvider: x } = e.get(ILanguageFeaturesService), S = e.get(IModelService).getModel(v);
	if (!S) throw illegalArgument();
	let C = [], w = new DisposableStore();
	return getCodeLensModel(x, S, CancellationToken.None).then((e) => {
		w.add(e);
		let _ = [];
		for (let v of e.lenses) y == null || v.symbol.command ? C.push(v.symbol) : y-- > 0 && v.provider.resolveCodeLens && _.push(Promise.resolve(v.provider.resolveCodeLens(S, v.symbol, CancellationToken.None)).then((e) => C.push(e || v.symbol)));
		return Promise.all(_);
	}).then(() => C).finally(() => {
		setTimeout(() => w.dispose(), 100);
	});
});
var __decorate$91 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$91 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const ICodeLensCache = createDecorator("ICodeLensCache");
var CacheItem = class {
	constructor(e, _) {
		this.lineCount = e, this.data = _;
	}
}, CodeLensCache = class {
	constructor(e) {
		this._fakeProvider = new class {
			provideCodeLenses() {
				throw Error("not supported");
			}
		}(), this._cache = new LRUCache(20, .75), runWhenWindowIdle(mainWindow, () => e.remove("codelens/cache", 1));
		let _ = "codelens/cache2", v = e.get(_, 1, "{}");
		this._deserialize(v);
		let y = Event.filter(e.onWillSaveState, (e) => e.reason === WillSaveStateReason.SHUTDOWN);
		Event.once(y)((v) => {
			e.store(_, this._serialize(), 1, 1);
		});
	}
	put(e, _) {
		let v = _.lenses.map((e) => ({
			range: e.symbol.range,
			command: e.symbol.command && {
				id: "",
				title: e.symbol.command?.title
			}
		})), y = new CodeLensModel();
		y.add({
			lenses: v,
			dispose: () => {}
		}, this._fakeProvider);
		let b = new CacheItem(e.getLineCount(), y);
		this._cache.set(e.uri.toString(), b);
	}
	get(e) {
		let _ = this._cache.get(e.uri.toString());
		return _ && _.lineCount === e.getLineCount() ? _.data : void 0;
	}
	delete(e) {
		this._cache.delete(e.uri.toString());
	}
	_serialize() {
		let e = Object.create(null);
		for (let [_, v] of this._cache) {
			let y = /* @__PURE__ */ new Set();
			for (let e of v.data.lenses) y.add(e.symbol.range.startLineNumber);
			e[_] = {
				lineCount: v.lineCount,
				lines: [...y.values()]
			};
		}
		return JSON.stringify(e);
	}
	_deserialize(e) {
		try {
			let _ = JSON.parse(e);
			for (let e in _) {
				let v = _[e], y = [];
				for (let e of v.lines) y.push({ range: new Range(e, 1, e, 11) });
				let b = new CodeLensModel();
				b.add({
					lenses: y,
					dispose() {}
				}, this._fakeProvider), this._cache.set(e, new CacheItem(v.lineCount, b));
			}
		} catch {}
	}
};
CodeLensCache = __decorate$91([__param$91(0, IStorageService)], CodeLensCache), registerSingleton(ICodeLensCache, CodeLensCache, 1);
var CodeLensViewZone = class {
	constructor(e, _, v) {
		this.afterColumn = 1073741824, this.afterLineNumber = e, this.heightInPx = _, this._onHeight = v, this.suppressMouseDown = !0, this.domNode = document.createElement("div");
	}
	onComputedHeight(e) {
		this._lastHeight === void 0 ? this._lastHeight = e : this._lastHeight !== e && (this._lastHeight = e, this._onHeight());
	}
	isVisible() {
		return this._lastHeight !== 0 && this.domNode.hasAttribute("monaco-visible-view-zone");
	}
}, CodeLensContentWidget = class e {
	static {
		this._idPool = 0;
	}
	constructor(_, v) {
		this.allowEditorOverflow = !1, this.suppressMouseDown = !0, this._commands = /* @__PURE__ */ new Map(), this._isEmpty = !0, this._editor = _, this._id = `codelens.widget-${e._idPool++}`, this.updatePosition(v), this._domNode = document.createElement("span"), this._domNode.className = "codelens-decoration";
	}
	withCommands(_, v) {
		this._commands.clear();
		let y = [], b = !1;
		for (let v = 0; v < _.length; v++) {
			let x = _[v];
			if (x && (b = !0, x.command)) {
				let b = renderLabelWithIcons(x.command.title.trim());
				if (x.command.id) {
					let _ = `c${e._idPool++}`;
					y.push($("a", {
						id: _,
						title: x.command.tooltip,
						role: "button"
					}, ...b)), this._commands.set(_, x.command);
				} else y.push($("span", { title: x.command.tooltip }, ...b));
				v + 1 < _.length && y.push($("span", void 0, "\xA0|\xA0"));
			}
		}
		b ? (reset(this._domNode, ...y), this._isEmpty && v && this._domNode.classList.add("fadein"), this._isEmpty = !1) : reset(this._domNode, $("span", void 0, "no commands"));
	}
	getCommand(e) {
		return e.parentElement === this._domNode ? this._commands.get(e.id) : void 0;
	}
	getId() {
		return this._id;
	}
	getDomNode() {
		return this._domNode;
	}
	updatePosition(e) {
		let _ = this._editor.getModel().getLineFirstNonWhitespaceColumn(e);
		this._widgetPosition = {
			position: {
				lineNumber: e,
				column: _
			},
			preference: [1]
		};
	}
	getPosition() {
		return this._widgetPosition || null;
	}
}, CodeLensHelper = class {
	constructor() {
		this._removeDecorations = [], this._addDecorations = [], this._addDecorationsCallbacks = [];
	}
	addDecoration(e, _) {
		this._addDecorations.push(e), this._addDecorationsCallbacks.push(_);
	}
	removeDecoration(e) {
		this._removeDecorations.push(e);
	}
	commit(e) {
		let _ = e.deltaDecorations(this._removeDecorations, this._addDecorations);
		for (let e = 0, v = _.length; e < v; e++) this._addDecorationsCallbacks[e](_[e]);
	}
}, codeLensDecorationOptions = ModelDecorationOptions.register({
	collapseOnReplaceEdit: !0,
	description: "codelens"
}), CodeLensWidget = class {
	constructor(e, _, v, y, b, x) {
		this._isDisposed = !1, this._editor = _, this._data = e, this._decorationIds = [];
		let S, C = [];
		this._data.forEach((e, _) => {
			e.symbol.command && C.push(e.symbol), v.addDecoration({
				range: e.symbol.range,
				options: codeLensDecorationOptions
			}, (e) => this._decorationIds[_] = e), S = S ? Range.plusRange(S, e.symbol.range) : Range.lift(e.symbol.range);
		}), this._viewZone = new CodeLensViewZone(S.startLineNumber - 1, b, x), this._viewZoneId = y.addZone(this._viewZone), C.length > 0 && (this._createContentWidgetIfNecessary(), this._contentWidget.withCommands(C, !1));
	}
	_createContentWidgetIfNecessary() {
		this._contentWidget ? this._editor.layoutContentWidget(this._contentWidget) : (this._contentWidget = new CodeLensContentWidget(this._editor, this._viewZone.afterLineNumber + 1), this._editor.addContentWidget(this._contentWidget));
	}
	dispose(e, _) {
		this._decorationIds.forEach(e.removeDecoration, e), this._decorationIds = [], _?.removeZone(this._viewZoneId), this._contentWidget &&= (this._editor.removeContentWidget(this._contentWidget), void 0), this._isDisposed = !0;
	}
	isDisposed() {
		return this._isDisposed;
	}
	isValid() {
		return this._decorationIds.some((e, _) => {
			let v = this._editor.getModel().getDecorationRange(e), y = this._data[_].symbol;
			return !!(v && Range.isEmpty(y.range) === v.isEmpty());
		});
	}
	updateCodeLensSymbols(e, _) {
		this._decorationIds.forEach(_.removeDecoration, _), this._decorationIds = [], this._data = e, this._data.forEach((e, v) => {
			_.addDecoration({
				range: e.symbol.range,
				options: codeLensDecorationOptions
			}, (e) => this._decorationIds[v] = e);
		});
	}
	updateHeight(e, _) {
		this._viewZone.heightInPx = e, _.layoutZone(this._viewZoneId), this._contentWidget && this._editor.layoutContentWidget(this._contentWidget);
	}
	computeIfNecessary(e) {
		if (!this._viewZone.isVisible()) return null;
		for (let _ = 0; _ < this._decorationIds.length; _++) {
			let v = e.getDecorationRange(this._decorationIds[_]);
			v && (this._data[_].symbol.range = v);
		}
		return this._data;
	}
	updateCommands(e) {
		this._createContentWidgetIfNecessary(), this._contentWidget.withCommands(e, !0);
		for (let _ = 0; _ < this._data.length; _++) {
			let v = e[_];
			if (v) {
				let { symbol: e } = this._data[_];
				e.command = v.command || e.command;
			}
		}
	}
	getCommand(e) {
		return this._contentWidget?.getCommand(e);
	}
	getLineNumber() {
		let e = this._editor.getModel().getDecorationRange(this._decorationIds[0]);
		return e ? e.startLineNumber : -1;
	}
	update(e) {
		if (this.isValid()) {
			let _ = this._editor.getModel().getDecorationRange(this._decorationIds[0]);
			_ && (this._viewZone.afterLineNumber = _.startLineNumber - 1, e.layoutZone(this._viewZoneId), this._contentWidget && (this._contentWidget.updatePosition(_.startLineNumber), this._editor.layoutContentWidget(this._contentWidget)));
		}
	}
}, __decorate$90 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$90 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, CodeLensContribution = class {
	static {
		this.ID = "css.editor.codeLens";
	}
	constructor(e, _, v, y, b, x) {
		this._editor = e, this._languageFeaturesService = _, this._commandService = y, this._notificationService = b, this._codeLensCache = x, this._disposables = new DisposableStore(), this._localToDispose = new DisposableStore(), this._lenses = [], this._oldCodeLensModels = new DisposableStore(), this._provideCodeLensDebounce = v.for(_.codeLensProvider, "CodeLensProvide", { min: 250 }), this._resolveCodeLensesDebounce = v.for(_.codeLensProvider, "CodeLensResolve", {
			min: 250,
			salt: "resolve"
		}), this._resolveCodeLensesScheduler = new RunOnceScheduler(() => this._resolveCodeLensesInViewport(), this._resolveCodeLensesDebounce.default()), this._disposables.add(this._editor.onDidChangeModel(() => this._onModelChange())), this._disposables.add(this._editor.onDidChangeModelLanguage(() => this._onModelChange())), this._disposables.add(this._editor.onDidChangeConfiguration((e) => {
			(e.hasChanged(50) || e.hasChanged(19) || e.hasChanged(18)) && this._updateLensStyle(), e.hasChanged(17) && this._onModelChange();
		})), this._disposables.add(_.codeLensProvider.onDidChange(this._onModelChange, this)), this._onModelChange(), this._updateLensStyle();
	}
	dispose() {
		this._localDispose(), this._disposables.dispose(), this._oldCodeLensModels.dispose(), this._currentCodeLensModel?.dispose();
	}
	_getLayoutInfo() {
		let e = Math.max(1.3, this._editor.getOption(67) / this._editor.getOption(52)), _ = this._editor.getOption(19);
		return (!_ || _ < 5) && (_ = this._editor.getOption(52) * .9 | 0), {
			fontSize: _,
			codeLensHeight: _ * e | 0
		};
	}
	_updateLensStyle() {
		let { codeLensHeight: e, fontSize: _ } = this._getLayoutInfo(), v = this._editor.getOption(18), y = this._editor.getOption(50), { style: b } = this._editor.getContainerDomNode();
		b.setProperty("--vscode-editorCodeLens-lineHeight", `${e}px`), b.setProperty("--vscode-editorCodeLens-fontSize", `${_}px`), b.setProperty("--vscode-editorCodeLens-fontFeatureSettings", y.fontFeatureSettings), v && (b.setProperty("--vscode-editorCodeLens-fontFamily", v), b.setProperty("--vscode-editorCodeLens-fontFamilyDefault", EDITOR_FONT_DEFAULTS.fontFamily)), this._editor.changeViewZones((_) => {
			for (let v of this._lenses) v.updateHeight(e, _);
		});
	}
	_localDispose() {
		this._getCodeLensModelPromise?.cancel(), this._getCodeLensModelPromise = void 0, this._resolveCodeLensesPromise?.cancel(), this._resolveCodeLensesPromise = void 0, this._localToDispose.clear(), this._oldCodeLensModels.clear(), this._currentCodeLensModel?.dispose();
	}
	_onModelChange() {
		this._localDispose();
		let e = this._editor.getModel();
		if (!e || !this._editor.getOption(17) || e.isTooLargeForTokenization()) return;
		let _ = this._codeLensCache.get(e);
		if (_ && this._renderCodeLensSymbols(_), !this._languageFeaturesService.codeLensProvider.has(e)) {
			_ && disposableTimeout(() => {
				let v = this._codeLensCache.get(e);
				_ === v && (this._codeLensCache.delete(e), this._onModelChange());
			}, 30 * 1e3, this._localToDispose);
			return;
		}
		for (let _ of this._languageFeaturesService.codeLensProvider.all(e)) if (typeof _.onDidChange == "function") {
			let e = _.onDidChange(() => v.schedule());
			this._localToDispose.add(e);
		}
		let v = new RunOnceScheduler(() => {
			let _ = Date.now();
			this._getCodeLensModelPromise?.cancel(), this._getCodeLensModelPromise = createCancelablePromise((_) => getCodeLensModel(this._languageFeaturesService.codeLensProvider, e, _)), this._getCodeLensModelPromise.then((y) => {
				this._currentCodeLensModel && this._oldCodeLensModels.add(this._currentCodeLensModel), this._currentCodeLensModel = y, this._codeLensCache.put(e, y), v.delay = this._provideCodeLensDebounce.update(e, Date.now() - _), this._renderCodeLensSymbols(y), this._resolveCodeLensesInViewportSoon();
			}, onUnexpectedError);
		}, this._provideCodeLensDebounce.get(e));
		this._localToDispose.add(v), this._localToDispose.add(toDisposable(() => this._resolveCodeLensesScheduler.cancel())), this._localToDispose.add(this._editor.onDidChangeModelContent(() => {
			this._editor.changeDecorations((e) => {
				this._editor.changeViewZones((_) => {
					let v = [], y = -1;
					this._lenses.forEach((e) => {
						!e.isValid() || y === e.getLineNumber() ? v.push(e) : (e.update(_), y = e.getLineNumber());
					});
					let b = new CodeLensHelper();
					v.forEach((e) => {
						e.dispose(b, _), this._lenses.splice(this._lenses.indexOf(e), 1);
					}), b.commit(e);
				});
			}), v.schedule(), this._resolveCodeLensesScheduler.cancel(), this._resolveCodeLensesPromise?.cancel(), this._resolveCodeLensesPromise = void 0;
		})), this._localToDispose.add(this._editor.onDidFocusEditorText(() => {
			v.schedule();
		})), this._localToDispose.add(this._editor.onDidBlurEditorText(() => {
			v.cancel();
		})), this._localToDispose.add(this._editor.onDidScrollChange((e) => {
			e.scrollTopChanged && this._lenses.length > 0 && this._resolveCodeLensesInViewportSoon();
		})), this._localToDispose.add(this._editor.onDidLayoutChange(() => {
			this._resolveCodeLensesInViewportSoon();
		})), this._localToDispose.add(toDisposable(() => {
			if (this._editor.getModel()) {
				let e = StableEditorScrollState.capture(this._editor);
				this._editor.changeDecorations((e) => {
					this._editor.changeViewZones((_) => {
						this._disposeAllLenses(e, _);
					});
				}), e.restore(this._editor);
			} else this._disposeAllLenses(void 0, void 0);
		})), this._localToDispose.add(this._editor.onMouseDown((e) => {
			if (e.target.type !== 9) return;
			let _ = e.target.element;
			if (_?.tagName === "SPAN" && (_ = _.parentElement), _?.tagName === "A") for (let e of this._lenses) {
				let v = e.getCommand(_);
				if (v) {
					this._commandService.executeCommand(v.id, ...v.arguments || []).catch((e) => this._notificationService.error(e));
					break;
				}
			}
		})), v.schedule();
	}
	_disposeAllLenses(e, _) {
		let v = new CodeLensHelper();
		for (let e of this._lenses) e.dispose(v, _);
		e && v.commit(e), this._lenses.length = 0;
	}
	_renderCodeLensSymbols(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._editor.getModel().getLineCount(), v = [], y;
		for (let b of e.lenses) {
			let e = b.symbol.range.startLineNumber;
			e < 1 || e > _ || (y && y[y.length - 1].symbol.range.startLineNumber === e ? y.push(b) : (y = [b], v.push(y)));
		}
		if (!v.length && !this._lenses.length) return;
		let b = StableEditorScrollState.capture(this._editor), x = this._getLayoutInfo();
		this._editor.changeDecorations((e) => {
			this._editor.changeViewZones((_) => {
				let y = new CodeLensHelper(), b = 0, S = 0;
				for (; S < v.length && b < this._lenses.length;) {
					let e = v[S][0].symbol.range.startLineNumber, C = this._lenses[b].getLineNumber();
					C < e ? (this._lenses[b].dispose(y, _), this._lenses.splice(b, 1)) : C === e ? (this._lenses[b].updateCodeLensSymbols(v[S], y), S++, b++) : (this._lenses.splice(b, 0, new CodeLensWidget(v[S], this._editor, y, _, x.codeLensHeight, () => this._resolveCodeLensesInViewportSoon())), b++, S++);
				}
				for (; b < this._lenses.length;) this._lenses[b].dispose(y, _), this._lenses.splice(b, 1);
				for (; S < v.length;) this._lenses.push(new CodeLensWidget(v[S], this._editor, y, _, x.codeLensHeight, () => this._resolveCodeLensesInViewportSoon())), S++;
				y.commit(e);
			});
		}), b.restore(this._editor);
	}
	_resolveCodeLensesInViewportSoon() {
		this._editor.getModel() && this._resolveCodeLensesScheduler.schedule();
	}
	_resolveCodeLensesInViewport() {
		this._resolveCodeLensesPromise?.cancel(), this._resolveCodeLensesPromise = void 0;
		let e = this._editor.getModel();
		if (!e) return;
		let _ = [], v = [];
		if (this._lenses.forEach((y) => {
			let b = y.computeIfNecessary(e);
			b && (_.push(b), v.push(y));
		}), _.length === 0) return;
		let y = Date.now(), b = createCancelablePromise((y) => {
			let b = _.map((_, b) => {
				let x = Array(_.length), S = _.map((_, v) => !_.symbol.command && typeof _.provider.resolveCodeLens == "function" ? Promise.resolve(_.provider.resolveCodeLens(e, _.symbol, y)).then((e) => {
					x[v] = e;
				}, onUnexpectedExternalError) : (x[v] = _.symbol, Promise.resolve(void 0)));
				return Promise.all(S).then(() => {
					!y.isCancellationRequested && !v[b].isDisposed() && v[b].updateCommands(x);
				});
			});
			return Promise.all(b);
		});
		this._resolveCodeLensesPromise = b, this._resolveCodeLensesPromise.then(() => {
			let _ = this._resolveCodeLensesDebounce.update(e, Date.now() - y);
			this._resolveCodeLensesScheduler.delay = _, this._currentCodeLensModel && this._codeLensCache.put(e, this._currentCodeLensModel), this._oldCodeLensModels.clear(), b === this._resolveCodeLensesPromise && (this._resolveCodeLensesPromise = void 0);
		}, (e) => {
			onUnexpectedError(e), b === this._resolveCodeLensesPromise && (this._resolveCodeLensesPromise = void 0);
		});
	}
	async getModel() {
		return await this._getCodeLensModelPromise, await this._resolveCodeLensesPromise, this._currentCodeLensModel?.isDisposed ? void 0 : this._currentCodeLensModel;
	}
};
CodeLensContribution = __decorate$90([
	__param$90(1, ILanguageFeaturesService),
	__param$90(2, ILanguageFeatureDebounceService),
	__param$90(3, ICommandService),
	__param$90(4, INotificationService),
	__param$90(5, ICodeLensCache)
], CodeLensContribution), registerEditorContribution(CodeLensContribution.ID, CodeLensContribution, 1), registerEditorAction(class extends EditorAction {
	constructor() {
		super({
			id: "codelens.showLensesInCurrentLine",
			precondition: EditorContextKeys.hasCodeLensProvider,
			label: localize("showLensOnLine", "Show CodeLens Commands For Current Line"),
			alias: "Show CodeLens Commands For Current Line"
		});
	}
	async run(e, _) {
		if (!_.hasModel()) return;
		let v = e.get(IQuickInputService), y = e.get(ICommandService), b = e.get(INotificationService), x = _.getSelection().positionLineNumber, S = _.getContribution(CodeLensContribution.ID);
		if (!S) return;
		let C = await S.getModel();
		if (!C) return;
		let w = [];
		for (let e of C.lenses) e.symbol.command && e.symbol.range.startLineNumber === x && w.push({
			label: e.symbol.command.title,
			command: e.symbol.command
		});
		if (w.length === 0) return;
		let T = await v.pick(w, {
			canPickMany: !1,
			placeHolder: localize("placeHolder", "Select a command")
		});
		if (!T) return;
		let E = T.command;
		if (C.isDisposed) {
			let e = (await S.getModel())?.lenses.find((e) => e.symbol.range.startLineNumber === x && e.symbol.command?.title === E.title);
			if (!e || !e.symbol.command) return;
			E = e.symbol.command;
		}
		try {
			await y.executeCommand(E.id, ...E.arguments || []);
		} catch (e) {
			b.error(e);
		}
	}
});
var __decorate$89 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$89 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, DefaultDocumentColorProvider = class {
	constructor(e) {
		this._editorWorkerService = e;
	}
	async provideDocumentColors(e, _) {
		return this._editorWorkerService.computeDefaultDocumentColors(e.uri);
	}
	provideColorPresentations(e, _, v) {
		let y = _.range, b = _.color, x = b.alpha, S = new Color(new RGBA(Math.round(255 * b.red), Math.round(255 * b.green), Math.round(255 * b.blue), x)), C = x ? Color.Format.CSS.formatRGB(S) : Color.Format.CSS.formatRGBA(S), w = x ? Color.Format.CSS.formatHSL(S) : Color.Format.CSS.formatHSLA(S), T = x ? Color.Format.CSS.formatHex(S) : Color.Format.CSS.formatHexA(S), E = [];
		return E.push({
			label: C,
			textEdit: {
				range: y,
				text: C
			}
		}), E.push({
			label: w,
			textEdit: {
				range: y,
				text: w
			}
		}), E.push({
			label: T,
			textEdit: {
				range: y,
				text: T
			}
		}), E;
	}
};
DefaultDocumentColorProvider = __decorate$89([__param$89(0, IEditorWorkerService)], DefaultDocumentColorProvider);
var DefaultDocumentColorProviderFeature = class extends Disposable {
	constructor(e, _) {
		super(), this._register(e.colorProvider.register("*", new DefaultDocumentColorProvider(_)));
	}
};
DefaultDocumentColorProviderFeature = __decorate$89([__param$89(0, ILanguageFeaturesService), __param$89(1, IEditorWorkerService)], DefaultDocumentColorProviderFeature), registerEditorFeature(DefaultDocumentColorProviderFeature);
async function getColors(e, _, v, y = !0) {
	return _findColorData(new ColorDataCollector(), e, _, v, y);
}
function getColorPresentations(e, _, v, y) {
	return Promise.resolve(v.provideColorPresentations(e, _, y));
}
var ColorDataCollector = class {
	constructor() {}
	async compute(e, _, v, y) {
		let b = await e.provideDocumentColors(_, v);
		if (Array.isArray(b)) for (let _ of b) y.push({
			colorInfo: _,
			provider: e
		});
		return Array.isArray(b);
	}
}, ExtColorDataCollector = class {
	constructor() {}
	async compute(e, _, v, y) {
		let b = await e.provideDocumentColors(_, v);
		if (Array.isArray(b)) for (let e of b) y.push({
			range: e.range,
			color: [
				e.color.red,
				e.color.green,
				e.color.blue,
				e.color.alpha
			]
		});
		return Array.isArray(b);
	}
}, ColorPresentationsCollector = class {
	constructor(e) {
		this.colorInfo = e;
	}
	async compute(e, _, v, y) {
		let b = await e.provideColorPresentations(_, this.colorInfo, CancellationToken.None);
		return Array.isArray(b) && y.push(...b), Array.isArray(b);
	}
};
async function _findColorData(e, _, v, y, b) {
	let x = !1, S, C = [], w = _.ordered(v);
	for (let _ = w.length - 1; _ >= 0; _--) {
		let b = w[_];
		if (b instanceof DefaultDocumentColorProvider) S = b;
		else try {
			await e.compute(b, v, y, C) && (x = !0);
		} catch (e) {
			onUnexpectedExternalError(e);
		}
	}
	return x ? C : S && b ? (await e.compute(S, v, y, C), C) : [];
}
function _setupColorCommand(e, _) {
	let { colorProvider: v } = e.get(ILanguageFeaturesService), y = e.get(IModelService).getModel(_);
	if (!y) throw illegalArgument();
	let x = e.get(IConfigurationService).getValue("editor.defaultColorDecorators", { resource: _ });
	return {
		model: y,
		colorProviderRegistry: v,
		isDefaultColorDecoratorsEnabled: x
	};
}
CommandsRegistry.registerCommand("_executeDocumentColorProvider", function(e, ..._) {
	let [v] = _;
	if (!(v instanceof URI)) throw illegalArgument();
	let { model: y, colorProviderRegistry: x, isDefaultColorDecoratorsEnabled: S } = _setupColorCommand(e, v);
	return _findColorData(new ExtColorDataCollector(), x, y, CancellationToken.None, S);
}), CommandsRegistry.registerCommand("_executeColorPresentationProvider", function(e, ..._) {
	let [v, y] = _, { uri: x, range: S } = y;
	if (!(x instanceof URI) || !Array.isArray(v) || v.length !== 4 || !Range.isIRange(S)) throw illegalArgument();
	let { model: C, colorProviderRegistry: w, isDefaultColorDecoratorsEnabled: T } = _setupColorCommand(e, x), [E, D, O, k] = v;
	return _findColorData(new ColorPresentationsCollector({
		range: S,
		color: {
			red: E,
			green: D,
			blue: O,
			alpha: k
		}
	}), w, C, CancellationToken.None, T);
});
var __decorate$88 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$88 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ColorDetector_1;
const ColorDecorationInjectedTextMarker = Object.create({});
var ColorDetector = class extends Disposable {
	static {
		ColorDetector_1 = this;
	}
	static {
		this.ID = "editor.contrib.colorDetector";
	}
	static {
		this.RECOMPUTE_TIME = 1e3;
	}
	constructor(e, _, v, y) {
		super(), this._editor = e, this._configurationService = _, this._languageFeaturesService = v, this._localToDispose = this._register(new DisposableStore()), this._decorationsIds = [], this._colorDatas = /* @__PURE__ */ new Map(), this._colorDecoratorIds = this._editor.createDecorationsCollection(), this._ruleFactory = new DynamicCssRules(this._editor), this._decoratorLimitReporter = new DecoratorLimitReporter(), this._colorDecorationClassRefs = this._register(new DisposableStore()), this._debounceInformation = y.for(v.colorProvider, "Document Colors", { min: ColorDetector_1.RECOMPUTE_TIME }), this._register(e.onDidChangeModel(() => {
			this._isColorDecoratorsEnabled = this.isEnabled(), this.updateColors();
		})), this._register(e.onDidChangeModelLanguage(() => this.updateColors())), this._register(v.colorProvider.onDidChange(() => this.updateColors())), this._register(e.onDidChangeConfiguration((e) => {
			let _ = this._isColorDecoratorsEnabled;
			this._isColorDecoratorsEnabled = this.isEnabled(), this._isDefaultColorDecoratorsEnabled = this._editor.getOption(148);
			let v = _ !== this._isColorDecoratorsEnabled || e.hasChanged(21), y = e.hasChanged(148);
			(v || y) && (this._isColorDecoratorsEnabled ? this.updateColors() : this.removeAllDecorations());
		})), this._timeoutTimer = null, this._computePromise = null, this._isColorDecoratorsEnabled = this.isEnabled(), this._isDefaultColorDecoratorsEnabled = this._editor.getOption(148), this.updateColors();
	}
	isEnabled() {
		let e = this._editor.getModel();
		if (!e) return !1;
		let _ = e.getLanguageId(), v = this._configurationService.getValue(_);
		if (v && typeof v == "object") {
			let e = v.colorDecorators;
			if (e && e.enable !== void 0 && !e.enable) return e.enable;
		}
		return this._editor.getOption(20);
	}
	static get(e) {
		return e.getContribution(this.ID);
	}
	dispose() {
		this.stop(), this.removeAllDecorations(), super.dispose();
	}
	updateColors() {
		if (this.stop(), !this._isColorDecoratorsEnabled) return;
		let e = this._editor.getModel();
		!e || !this._languageFeaturesService.colorProvider.has(e) || (this._localToDispose.add(this._editor.onDidChangeModelContent(() => {
			this._timeoutTimer || (this._timeoutTimer = new TimeoutTimer(), this._timeoutTimer.cancelAndSet(() => {
				this._timeoutTimer = null, this.beginCompute();
			}, this._debounceInformation.get(e)));
		})), this.beginCompute());
	}
	async beginCompute() {
		this._computePromise = createCancelablePromise(async (e) => {
			let _ = this._editor.getModel();
			if (!_) return [];
			let v = new StopWatch(!1), y = await getColors(this._languageFeaturesService.colorProvider, _, e, this._isDefaultColorDecoratorsEnabled);
			return this._debounceInformation.update(_, v.elapsed()), y;
		});
		try {
			let e = await this._computePromise;
			this.updateDecorations(e), this.updateColorDecorators(e), this._computePromise = null;
		} catch (e) {
			onUnexpectedError(e);
		}
	}
	stop() {
		this._timeoutTimer &&= (this._timeoutTimer.cancel(), null), this._computePromise &&= (this._computePromise.cancel(), null), this._localToDispose.clear();
	}
	updateDecorations(e) {
		let _ = e.map((e) => ({
			range: {
				startLineNumber: e.colorInfo.range.startLineNumber,
				startColumn: e.colorInfo.range.startColumn,
				endLineNumber: e.colorInfo.range.endLineNumber,
				endColumn: e.colorInfo.range.endColumn
			},
			options: ModelDecorationOptions.EMPTY
		}));
		this._editor.changeDecorations((v) => {
			this._decorationsIds = v.deltaDecorations(this._decorationsIds, _), this._colorDatas = /* @__PURE__ */ new Map(), this._decorationsIds.forEach((_, v) => this._colorDatas.set(_, e[v]));
		});
	}
	updateColorDecorators(e) {
		this._colorDecorationClassRefs.clear();
		let _ = [], v = this._editor.getOption(21);
		for (let y = 0; y < e.length && _.length < v; y++) {
			let { red: v, green: b, blue: x, alpha: S } = e[y].colorInfo.color, C = new RGBA(Math.round(v * 255), Math.round(b * 255), Math.round(x * 255), S), w = `rgba(${C.r}, ${C.g}, ${C.b}, ${C.a})`, T = this._colorDecorationClassRefs.add(this._ruleFactory.createClassNameRef({ backgroundColor: w }));
			_.push({
				range: {
					startLineNumber: e[y].colorInfo.range.startLineNumber,
					startColumn: e[y].colorInfo.range.startColumn,
					endLineNumber: e[y].colorInfo.range.endLineNumber,
					endColumn: e[y].colorInfo.range.endColumn
				},
				options: {
					description: "colorDetector",
					before: {
						content: "\xA0",
						inlineClassName: `${T.className} colorpicker-color-decoration`,
						inlineClassNameAffectsLetterSpacing: !0,
						attachedData: ColorDecorationInjectedTextMarker
					}
				}
			});
		}
		let y = v < e.length ? v : !1;
		this._decoratorLimitReporter.update(e.length, y), this._colorDecoratorIds.set(_);
	}
	removeAllDecorations() {
		this._editor.removeDecorations(this._decorationsIds), this._decorationsIds = [], this._colorDecoratorIds.clear(), this._colorDecorationClassRefs.clear();
	}
	getColorData(e) {
		let _ = this._editor.getModel();
		if (!_) return null;
		let v = _.getDecorationsInRange(Range.fromPositions(e, e)).filter((e) => this._colorDatas.has(e.id));
		return v.length === 0 ? null : this._colorDatas.get(v[0].id);
	}
	isColorDecoration(e) {
		return this._colorDecoratorIds.has(e);
	}
};
ColorDetector = ColorDetector_1 = __decorate$88([
	__param$88(1, IConfigurationService),
	__param$88(2, ILanguageFeaturesService),
	__param$88(3, ILanguageFeatureDebounceService)
], ColorDetector);
var DecoratorLimitReporter = class {
	constructor() {
		this._onDidChange = new Emitter(), this._computed = 0, this._limited = !1;
	}
	update(e, _) {
		(e !== this._computed || _ !== this._limited) && (this._computed = e, this._limited = _, this._onDidChange.fire());
	}
};
registerEditorContribution(ColorDetector.ID, ColorDetector, 1);
var ColorPickerModel = class {
	get color() {
		return this._color;
	}
	set color(e) {
		this._color.equals(e) || (this._color = e, this._onDidChangeColor.fire(e));
	}
	get presentation() {
		return this.colorPresentations[this.presentationIndex];
	}
	get colorPresentations() {
		return this._colorPresentations;
	}
	set colorPresentations(e) {
		this._colorPresentations = e, this.presentationIndex > e.length - 1 && (this.presentationIndex = 0), this._onDidChangePresentation.fire(this.presentation);
	}
	constructor(e, _, v) {
		this.presentationIndex = v, this._onColorFlushed = new Emitter(), this.onColorFlushed = this._onColorFlushed.event, this._onDidChangeColor = new Emitter(), this.onDidChangeColor = this._onDidChangeColor.event, this._onDidChangePresentation = new Emitter(), this.onDidChangePresentation = this._onDidChangePresentation.event, this.originalColor = e, this._color = e, this._colorPresentations = _;
	}
	selectNextColorPresentation() {
		this.presentationIndex = (this.presentationIndex + 1) % this.colorPresentations.length, this.flushColor(), this._onDidChangePresentation.fire(this.presentation);
	}
	guessColorPresentation(e, _) {
		let v = -1;
		for (let e = 0; e < this.colorPresentations.length; e++) if (_.toLowerCase() === this.colorPresentations[e].label) {
			v = e;
			break;
		}
		if (v === -1) {
			let e = _.split("(")[0].toLowerCase();
			for (let _ = 0; _ < this.colorPresentations.length; _++) if (this.colorPresentations[_].label.toLowerCase().startsWith(e)) {
				v = _;
				break;
			}
		}
		v !== -1 && v !== this.presentationIndex && (this.presentationIndex = v, this._onDidChangePresentation.fire(this.presentation));
	}
	flushColor() {
		this._onColorFlushed.fire(this._color);
	}
}, $$6 = $, ColorPickerHeader = class extends Disposable {
	constructor(e, _, v, y = !1) {
		super(), this.model = _, this.showingStandaloneColorPicker = y, this._closeButton = null, this._domNode = $$6(".colorpicker-header"), append(e, this._domNode), this._pickedColorNode = append(this._domNode, $$6(".picked-color")), append(this._pickedColorNode, $$6("span.codicon.codicon-color-mode")), this._pickedColorPresentation = append(this._pickedColorNode, document.createElement("span")), this._pickedColorPresentation.classList.add("picked-color-presentation");
		let b = localize("clickToToggleColorOptions", "Click to toggle color options (rgb/hsl/hex)");
		this._pickedColorNode.setAttribute("title", b), this._originalColorNode = append(this._domNode, $$6(".original-color")), this._originalColorNode.style.backgroundColor = Color.Format.CSS.format(this.model.originalColor) || "", this.backgroundColor = v.getColorTheme().getColor(editorHoverBackground) || Color.white, this._register(v.onDidColorThemeChange((e) => {
			this.backgroundColor = e.getColor(editorHoverBackground) || Color.white;
		})), this._register(addDisposableListener(this._pickedColorNode, EventType$1.CLICK, () => this.model.selectNextColorPresentation())), this._register(addDisposableListener(this._originalColorNode, EventType$1.CLICK, () => {
			this.model.color = this.model.originalColor, this.model.flushColor();
		})), this._register(_.onDidChangeColor(this.onDidChangeColor, this)), this._register(_.onDidChangePresentation(this.onDidChangePresentation, this)), this._pickedColorNode.style.backgroundColor = Color.Format.CSS.format(_.color) || "", this._pickedColorNode.classList.toggle("light", _.color.rgba.a < .5 ? this.backgroundColor.isLighter() : _.color.isLighter()), this.onDidChangeColor(this.model.color), this.showingStandaloneColorPicker && (this._domNode.classList.add("standalone-colorpicker"), this._closeButton = this._register(new CloseButton(this._domNode)));
	}
	get closeButton() {
		return this._closeButton;
	}
	get pickedColorNode() {
		return this._pickedColorNode;
	}
	get originalColorNode() {
		return this._originalColorNode;
	}
	onDidChangeColor(e) {
		this._pickedColorNode.style.backgroundColor = Color.Format.CSS.format(e) || "", this._pickedColorNode.classList.toggle("light", e.rgba.a < .5 ? this.backgroundColor.isLighter() : e.isLighter()), this.onDidChangePresentation();
	}
	onDidChangePresentation() {
		this._pickedColorPresentation.textContent = this.model.presentation ? this.model.presentation.label : "";
	}
}, CloseButton = class extends Disposable {
	constructor(e) {
		super(), this._onClicked = this._register(new Emitter()), this.onClicked = this._onClicked.event, this._button = document.createElement("div"), this._button.classList.add("close-button"), append(e, this._button);
		let _ = document.createElement("div");
		_.classList.add("close-button-inner-div"), append(this._button, _), append(_, $$6(".button" + ThemeIcon.asCSSSelector(registerIcon("color-picker-close", Codicon.close, localize("closeIcon", "Icon to close the color picker"))))).classList.add("close-icon"), this._register(addDisposableListener(this._button, EventType$1.CLICK, () => {
			this._onClicked.fire();
		}));
	}
}, ColorPickerBody = class extends Disposable {
	constructor(e, _, v, y = !1) {
		super(), this.model = _, this.pixelRatio = v, this._insertButton = null, this._domNode = $$6(".colorpicker-body"), append(e, this._domNode), this._saturationBox = new SaturationBox(this._domNode, this.model, this.pixelRatio), this._register(this._saturationBox), this._register(this._saturationBox.onDidChange(this.onDidSaturationValueChange, this)), this._register(this._saturationBox.onColorFlushed(this.flushColor, this)), this._opacityStrip = new OpacityStrip(this._domNode, this.model, y), this._register(this._opacityStrip), this._register(this._opacityStrip.onDidChange(this.onDidOpacityChange, this)), this._register(this._opacityStrip.onColorFlushed(this.flushColor, this)), this._hueStrip = new HueStrip(this._domNode, this.model, y), this._register(this._hueStrip), this._register(this._hueStrip.onDidChange(this.onDidHueChange, this)), this._register(this._hueStrip.onColorFlushed(this.flushColor, this)), y && (this._insertButton = this._register(new InsertButton(this._domNode)), this._domNode.classList.add("standalone-colorpicker"));
	}
	flushColor() {
		this.model.flushColor();
	}
	onDidSaturationValueChange({ s: e, v: _ }) {
		let v = this.model.color.hsva;
		this.model.color = new Color(new HSVA(v.h, e, _, v.a));
	}
	onDidOpacityChange(e) {
		let _ = this.model.color.hsva;
		this.model.color = new Color(new HSVA(_.h, _.s, _.v, e));
	}
	onDidHueChange(e) {
		let _ = this.model.color.hsva, v = (1 - e) * 360;
		this.model.color = new Color(new HSVA(v === 360 ? 0 : v, _.s, _.v, _.a));
	}
	get domNode() {
		return this._domNode;
	}
	get saturationBox() {
		return this._saturationBox;
	}
	get enterButton() {
		return this._insertButton;
	}
	layout() {
		this._saturationBox.layout(), this._opacityStrip.layout(), this._hueStrip.layout();
	}
}, SaturationBox = class extends Disposable {
	constructor(e, _, v) {
		super(), this.model = _, this.pixelRatio = v, this._onDidChange = new Emitter(), this.onDidChange = this._onDidChange.event, this._onColorFlushed = new Emitter(), this.onColorFlushed = this._onColorFlushed.event, this._domNode = $$6(".saturation-wrap"), append(e, this._domNode), this._canvas = document.createElement("canvas"), this._canvas.className = "saturation-box", append(this._domNode, this._canvas), this.selection = $$6(".saturation-selection"), append(this._domNode, this.selection), this.layout(), this._register(addDisposableListener(this._domNode, EventType$1.POINTER_DOWN, (e) => this.onPointerDown(e))), this._register(this.model.onDidChangeColor(this.onDidChangeColor, this)), this.monitor = null;
	}
	get domNode() {
		return this._domNode;
	}
	onPointerDown(e) {
		if (!e.target || !(e.target instanceof Element)) return;
		this.monitor = this._register(new GlobalPointerMoveMonitor());
		let _ = getDomNodePagePosition(this._domNode);
		e.target !== this.selection && this.onDidChangePosition(e.offsetX, e.offsetY), this.monitor.startMonitoring(e.target, e.pointerId, e.buttons, (e) => this.onDidChangePosition(e.pageX - _.left, e.pageY - _.top), () => null);
		let v = addDisposableListener(e.target.ownerDocument, EventType$1.POINTER_UP, () => {
			this._onColorFlushed.fire(), v.dispose(), this.monitor &&= (this.monitor.stopMonitoring(!0), null);
		}, !0);
	}
	onDidChangePosition(e, _) {
		let v = Math.max(0, Math.min(1, e / this.width)), y = Math.max(0, Math.min(1, 1 - _ / this.height));
		this.paintSelection(v, y), this._onDidChange.fire({
			s: v,
			v: y
		});
	}
	layout() {
		this.width = this._domNode.offsetWidth, this.height = this._domNode.offsetHeight, this._canvas.width = this.width * this.pixelRatio, this._canvas.height = this.height * this.pixelRatio, this.paint();
		let e = this.model.color.hsva;
		this.paintSelection(e.s, e.v);
	}
	paint() {
		let e = this.model.color.hsva, _ = new Color(new HSVA(e.h, 1, 1, 1)), v = this._canvas.getContext("2d"), y = v.createLinearGradient(0, 0, this._canvas.width, 0);
		y.addColorStop(0, "rgba(255, 255, 255, 1)"), y.addColorStop(.5, "rgba(255, 255, 255, 0.5)"), y.addColorStop(1, "rgba(255, 255, 255, 0)");
		let b = v.createLinearGradient(0, 0, 0, this._canvas.height);
		b.addColorStop(0, "rgba(0, 0, 0, 0)"), b.addColorStop(1, "rgba(0, 0, 0, 1)"), v.rect(0, 0, this._canvas.width, this._canvas.height), v.fillStyle = Color.Format.CSS.format(_), v.fill(), v.fillStyle = y, v.fill(), v.fillStyle = b, v.fill();
	}
	paintSelection(e, _) {
		this.selection.style.left = `${e * this.width}px`, this.selection.style.top = `${this.height - _ * this.height}px`;
	}
	onDidChangeColor(e) {
		if (this.monitor && this.monitor.isMonitoring()) return;
		this.paint();
		let _ = e.hsva;
		this.paintSelection(_.s, _.v);
	}
}, Strip = class extends Disposable {
	constructor(e, _, v = !1) {
		super(), this.model = _, this._onDidChange = new Emitter(), this.onDidChange = this._onDidChange.event, this._onColorFlushed = new Emitter(), this.onColorFlushed = this._onColorFlushed.event, v ? (this.domNode = append(e, $$6(".standalone-strip")), this.overlay = append(this.domNode, $$6(".standalone-overlay"))) : (this.domNode = append(e, $$6(".strip")), this.overlay = append(this.domNode, $$6(".overlay"))), this.slider = append(this.domNode, $$6(".slider")), this.slider.style.top = "0px", this._register(addDisposableListener(this.domNode, EventType$1.POINTER_DOWN, (e) => this.onPointerDown(e))), this._register(_.onDidChangeColor(this.onDidChangeColor, this)), this.layout();
	}
	layout() {
		this.height = this.domNode.offsetHeight - this.slider.offsetHeight;
		let e = this.getValue(this.model.color);
		this.updateSliderPosition(e);
	}
	onDidChangeColor(e) {
		let _ = this.getValue(e);
		this.updateSliderPosition(_);
	}
	onPointerDown(e) {
		if (!e.target || !(e.target instanceof Element)) return;
		let _ = this._register(new GlobalPointerMoveMonitor()), v = getDomNodePagePosition(this.domNode);
		this.domNode.classList.add("grabbing"), e.target !== this.slider && this.onDidChangeTop(e.offsetY), _.startMonitoring(e.target, e.pointerId, e.buttons, (e) => this.onDidChangeTop(e.pageY - v.top), () => null);
		let y = addDisposableListener(e.target.ownerDocument, EventType$1.POINTER_UP, () => {
			this._onColorFlushed.fire(), y.dispose(), _.stopMonitoring(!0), this.domNode.classList.remove("grabbing");
		}, !0);
	}
	onDidChangeTop(e) {
		let _ = Math.max(0, Math.min(1, 1 - e / this.height));
		this.updateSliderPosition(_), this._onDidChange.fire(_);
	}
	updateSliderPosition(e) {
		this.slider.style.top = `${(1 - e) * this.height}px`;
	}
}, OpacityStrip = class extends Strip {
	constructor(e, _, v = !1) {
		super(e, _, v), this.domNode.classList.add("opacity-strip"), this.onDidChangeColor(this.model.color);
	}
	onDidChangeColor(e) {
		super.onDidChangeColor(e);
		let { r: _, g: v, b: y } = e.rgba, b = new Color(new RGBA(_, v, y, 1)), x = new Color(new RGBA(_, v, y, 0));
		this.overlay.style.background = `linear-gradient(to bottom, ${b} 0%, ${x} 100%)`;
	}
	getValue(e) {
		return e.hsva.a;
	}
}, HueStrip = class extends Strip {
	constructor(e, _, v = !1) {
		super(e, _, v), this.domNode.classList.add("hue-strip");
	}
	getValue(e) {
		return 1 - e.hsva.h / 360;
	}
}, InsertButton = class extends Disposable {
	constructor(e) {
		super(), this._onClicked = this._register(new Emitter()), this.onClicked = this._onClicked.event, this._button = append(e, document.createElement("button")), this._button.classList.add("insert-button"), this._button.textContent = "Insert", this._register(addDisposableListener(this._button, EventType$1.CLICK, () => {
			this._onClicked.fire();
		}));
	}
	get button() {
		return this._button;
	}
}, ColorPickerWidget = class extends Widget {
	constructor(e, _, v, y, b = !1) {
		super(), this.model = _, this.pixelRatio = v, this._register(PixelRatio.getInstance(getWindow(e)).onDidChange(() => this.layout())), this._domNode = $$6(".colorpicker-widget"), e.appendChild(this._domNode), this.header = this._register(new ColorPickerHeader(this._domNode, this.model, y, b)), this.body = this._register(new ColorPickerBody(this._domNode, this.model, this.pixelRatio, b));
	}
	layout() {
		this.body.layout();
	}
	get domNode() {
		return this._domNode;
	}
}, HoverRangeAnchor = class {
	constructor(e, _, v, y) {
		this.priority = e, this.range = _, this.initialMousePosX = v, this.initialMousePosY = y, this.type = 1;
	}
	equals(e) {
		return e.type === 1 && this.range.equalsRange(e.range);
	}
	canAdoptVisibleHover(e, _) {
		return e.type === 1 && _.lineNumber === this.range.startLineNumber;
	}
}, HoverForeignElementAnchor = class {
	constructor(e, _, v, y, b, x) {
		this.priority = e, this.owner = _, this.range = v, this.initialMousePosX = y, this.initialMousePosY = b, this.supportsMarkerHover = x, this.type = 2;
	}
	equals(e) {
		return e.type === 2 && this.owner === e.owner;
	}
	canAdoptVisibleHover(e, _) {
		return e.type === 2 && this.owner === e.owner;
	}
}, RenderedHoverParts = class {
	constructor(e) {
		this.renderedHoverParts = e;
	}
	dispose() {
		for (let e of this.renderedHoverParts) e.dispose();
	}
};
const HoverParticipantRegistry = new class {
	constructor() {
		this._participants = [];
	}
	register(e) {
		this._participants.push(e);
	}
	getAll() {
		return this._participants;
	}
}();
var __decorate$87 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$87 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ColorHover = class {
	constructor(e, _, v, y) {
		this.owner = e, this.range = _, this.model = v, this.provider = y, this.forceShowAtRange = !0;
	}
	isValidForHoverAnchor(e) {
		return e.type === 1 && this.range.startColumn <= e.range.startColumn && this.range.endColumn >= e.range.endColumn;
	}
}, ColorHoverParticipant = class {
	constructor(e, _) {
		this._editor = e, this._themeService = _, this.hoverOrdinal = 2;
	}
	computeSync(e, _) {
		return [];
	}
	computeAsync(e, _, v) {
		return AsyncIterableObject.fromPromise(this._computeAsync(e, _, v));
	}
	async _computeAsync(e, _, v) {
		if (!this._editor.hasModel()) return [];
		let y = ColorDetector.get(this._editor);
		if (!y) return [];
		for (let e of _) {
			if (!y.isColorDecoration(e)) continue;
			let _ = y.getColorData(e.range.getStartPosition());
			if (_) return [await _createColorHover(this, this._editor.getModel(), _.colorInfo, _.provider)];
		}
		return [];
	}
	renderHoverParts(e, _) {
		let v = renderHoverParts(this, this._editor, this._themeService, _, e);
		if (!v) return new RenderedHoverParts([]);
		this._colorPicker = v.colorPicker;
		let y = {
			hoverPart: v.hoverPart,
			hoverElement: this._colorPicker.domNode,
			dispose() {
				v.disposables.dispose();
			}
		};
		return new RenderedHoverParts([y]);
	}
	handleResize() {
		this._colorPicker?.layout();
	}
	isColorPickerVisible() {
		return !!this._colorPicker;
	}
};
ColorHoverParticipant = __decorate$87([__param$87(1, IThemeService)], ColorHoverParticipant);
var StandaloneColorPickerHover = class {
	constructor(e, _, v, y) {
		this.owner = e, this.range = _, this.model = v, this.provider = y;
	}
}, StandaloneColorPickerParticipant = class {
	constructor(e, _) {
		this._editor = e, this._themeService = _, this._color = null;
	}
	async createColorHover(e, _, v) {
		if (!this._editor.hasModel() || !ColorDetector.get(this._editor)) return null;
		let y = await getColors(v, this._editor.getModel(), CancellationToken.None), b = null, x = null;
		for (let _ of y) {
			let v = _.colorInfo;
			Range.containsRange(v.range, e.range) && (b = v, x = _.provider);
		}
		let S = b ?? e, C = x ?? _, w = !!b;
		return {
			colorHover: await _createColorHover(this, this._editor.getModel(), S, C),
			foundInEditor: w
		};
	}
	async updateEditorModel(e) {
		if (!this._editor.hasModel()) return;
		let _ = e.model, v = new Range(e.range.startLineNumber, e.range.startColumn, e.range.endLineNumber, e.range.endColumn);
		this._color && (await _updateColorPresentations(this._editor.getModel(), _, this._color, v, e), v = _updateEditorModel(this._editor, v, _));
	}
	renderHoverParts(e, _) {
		return renderHoverParts(this, this._editor, this._themeService, _, e);
	}
	set color(e) {
		this._color = e;
	}
	get color() {
		return this._color;
	}
};
StandaloneColorPickerParticipant = __decorate$87([__param$87(1, IThemeService)], StandaloneColorPickerParticipant);
async function _createColorHover(e, _, v, y) {
	let b = _.getValueInRange(v.range), { red: x, green: S, blue: C, alpha: w } = v.color, T = new RGBA(Math.round(x * 255), Math.round(S * 255), Math.round(C * 255), w), E = new Color(T), D = await getColorPresentations(_, v, y, CancellationToken.None), O = new ColorPickerModel(E, [], 0);
	return O.colorPresentations = D || [], O.guessColorPresentation(E, b), e instanceof ColorHoverParticipant ? new ColorHover(e, Range.lift(v.range), O, y) : new StandaloneColorPickerHover(e, Range.lift(v.range), O, y);
}
function renderHoverParts(e, _, v, y, b) {
	if (y.length === 0 || !_.hasModel()) return;
	if (b.setMinimumDimensions) {
		let e = _.getOption(67) + 8;
		b.setMinimumDimensions(new Dimension(302, e));
	}
	let x = new DisposableStore(), S = y[0], C = _.getModel(), w = S.model, T = x.add(new ColorPickerWidget(b.fragment, w, _.getOption(144), v, e instanceof StandaloneColorPickerParticipant)), E = !1, D = new Range(S.range.startLineNumber, S.range.startColumn, S.range.endLineNumber, S.range.endColumn);
	if (e instanceof StandaloneColorPickerParticipant) {
		let _ = S.model.color;
		e.color = _, _updateColorPresentations(C, w, _, D, S), x.add(w.onColorFlushed((_) => {
			e.color = _;
		}));
	} else x.add(w.onColorFlushed(async (e) => {
		await _updateColorPresentations(C, w, e, D, S), E = !0, D = _updateEditorModel(_, D, w);
	}));
	return x.add(w.onDidChangeColor((e) => {
		_updateColorPresentations(C, w, e, D, S);
	})), x.add(_.onDidChangeModelContent((e) => {
		E ? E = !1 : (b.hide(), _.focus());
	})), {
		hoverPart: S,
		colorPicker: T,
		disposables: x
	};
}
function _updateEditorModel(e, _, v) {
	let y = [], b = v.presentation.textEdit ?? {
		range: _,
		text: v.presentation.label,
		forceMoveMarkers: !1
	};
	y.push(b), v.presentation.additionalTextEdits && y.push(...v.presentation.additionalTextEdits);
	let x = Range.lift(b.range), S = e.getModel()._setTrackedRange(null, x, 3);
	return e.executeEdits("colorpicker", y), e.pushUndoStop(), e.getModel()._getTrackedRange(S) ?? x;
}
async function _updateColorPresentations(e, _, v, y, b) {
	_.colorPresentations = await getColorPresentations(e, {
		range: y,
		color: {
			red: v.rgba.r / 255,
			green: v.rgba.g / 255,
			blue: v.rgba.b / 255,
			alpha: v.rgba.a
		}
	}, b.provider, CancellationToken.None) || [];
}
const INCREASE_HOVER_VERBOSITY_ACTION_ID = "editor.action.increaseHoverVerbosityLevel", INCREASE_HOVER_VERBOSITY_ACTION_LABEL = localize({
	key: "increaseHoverVerbosityLevel",
	comment: ["Label for action that will increase the hover verbosity level."]
}, "Increase Hover Verbosity Level"), DECREASE_HOVER_VERBOSITY_ACTION_ID = "editor.action.decreaseHoverVerbosityLevel", DECREASE_HOVER_VERBOSITY_ACTION_LABEL = localize({
	key: "decreaseHoverVerbosityLevel",
	comment: ["Label for action that will decrease the hover verbosity level."]
}, "Decrease Hover Verbosity Level"), showPreviousInlineSuggestionActionId = "editor.action.inlineSuggest.showPrevious", showNextInlineSuggestionActionId = "editor.action.inlineSuggest.showNext";
var __decorate$86 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$86 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineSuggestionHintsContentWidget_1, InlineCompletionsHintsWidget = class extends Disposable {
	constructor(e, _, v) {
		super(), this.editor = e, this.model = _, this.instantiationService = v, this.alwaysShowToolbar = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(62).showToolbar === "always"), this.sessionPosition = void 0, this.position = derived(this, (e) => {
			let _ = this.model.read(e)?.primaryGhostText.read(e);
			if (!this.alwaysShowToolbar.read(e) || !_ || _.parts.length === 0) return this.sessionPosition = void 0, null;
			let v = _.parts[0].column;
			this.sessionPosition && this.sessionPosition.lineNumber !== _.lineNumber && (this.sessionPosition = void 0);
			let y = new Position(_.lineNumber, Math.min(v, this.sessionPosition?.column ?? 2 ** 53 - 1));
			return this.sessionPosition = y, y;
		}), this._register(autorunWithStore((_, v) => {
			let y = this.model.read(_);
			if (!y || !this.alwaysShowToolbar.read(_)) return;
			let b = derivedWithStore((_, v) => {
				let b = v.add(this.instantiationService.createInstance(InlineSuggestionHintsContentWidget, this.editor, !0, this.position, y.selectedInlineCompletionIndex, y.inlineCompletionsCount, y.activeCommands));
				return e.addContentWidget(b), v.add(toDisposable(() => e.removeContentWidget(b))), v.add(autorun((e) => {
					this.position.read(e) && y.lastTriggerKind.read(e) !== InlineCompletionTriggerKind.Explicit && y.triggerExplicitly();
				})), b;
			}), x = derivedObservableWithCache(this, (e, _) => !!this.position.read(e) || !!_);
			v.add(autorun((e) => {
				x.read(e) && b.read(e);
			}));
		}));
	}
};
InlineCompletionsHintsWidget = __decorate$86([__param$86(2, IInstantiationService)], InlineCompletionsHintsWidget);
var inlineSuggestionHintsNextIcon = registerIcon("inline-suggestion-hints-next", Codicon.chevronRight, localize("parameterHintsNextIcon", "Icon for show next parameter hint.")), inlineSuggestionHintsPreviousIcon = registerIcon("inline-suggestion-hints-previous", Codicon.chevronLeft, localize("parameterHintsPreviousIcon", "Icon for show previous parameter hint.")), InlineSuggestionHintsContentWidget = class extends Disposable {
	static {
		InlineSuggestionHintsContentWidget_1 = this;
	}
	static {
		this._dropDownVisible = !1;
	}
	static get dropDownVisible() {
		return this._dropDownVisible;
	}
	static {
		this.id = 0;
	}
	createCommandAction(e, _, v) {
		let y = new Action(e, _, v, !0, () => this._commandService.executeCommand(e)), b = this.keybindingService.lookupKeybinding(e, this._contextKeyService), x = _;
		return b && (x = localize({
			key: "content",
			comment: ["A label", "A keybinding"]
		}, "{0} ({1})", _, b.getLabel())), y.tooltip = x, y;
	}
	constructor(e, _, v, y, b, x, S, C, w, T, E) {
		super(), this.editor = e, this.withBorder = _, this._position = v, this._currentSuggestionIdx = y, this._suggestionCount = b, this._extraCommands = x, this._commandService = S, this.keybindingService = w, this._contextKeyService = T, this._menuService = E, this.id = `InlineSuggestionHintsContentWidget${InlineSuggestionHintsContentWidget_1.id++}`, this.allowEditorOverflow = !0, this.suppressMouseDown = !1, this.nodes = h("div.inlineSuggestionsHints", { className: this.withBorder ? ".withBorder" : "" }, [h("div@toolBar")]), this.previousAction = this.createCommandAction(showPreviousInlineSuggestionActionId, localize("previous", "Previous"), ThemeIcon.asClassName(inlineSuggestionHintsPreviousIcon)), this.availableSuggestionCountAction = new Action("inlineSuggestionHints.availableSuggestionCount", "", void 0, !1), this.nextAction = this.createCommandAction(showNextInlineSuggestionActionId, localize("next", "Next"), ThemeIcon.asClassName(inlineSuggestionHintsNextIcon)), this.inlineCompletionsActionsMenus = this._register(this._menuService.createMenu(MenuId.InlineCompletionsActions, this._contextKeyService)), this.clearAvailableSuggestionCountLabelDebounced = this._register(new RunOnceScheduler(() => {
			this.availableSuggestionCountAction.label = "";
		}, 100)), this.disableButtonsDebounced = this._register(new RunOnceScheduler(() => {
			this.previousAction.enabled = this.nextAction.enabled = !1;
		}, 100)), this.toolBar = this._register(C.createInstance(CustomizedMenuWorkbenchToolBar$1, this.nodes.toolBar, MenuId.InlineSuggestionToolbar, {
			menuOptions: { renderShortTitle: !0 },
			toolbarOptions: { primaryGroup: (e) => e.startsWith("primary") },
			actionViewItemProvider: (e, _) => {
				if (e instanceof MenuItemAction) return C.createInstance(StatusBarViewItem$1, e, void 0);
				if (e === this.availableSuggestionCountAction) {
					let _ = new ActionViewItemWithClassName(void 0, e, {
						label: !0,
						icon: !1
					});
					return _.setClass("availableSuggestionCount"), _;
				}
			},
			telemetrySource: "InlineSuggestionToolbar"
		})), this.toolBar.setPrependedPrimaryActions([
			this.previousAction,
			this.availableSuggestionCountAction,
			this.nextAction
		]), this._register(this.toolBar.onDidChangeDropdownVisibility((e) => {
			InlineSuggestionHintsContentWidget_1._dropDownVisible = e;
		})), this._register(autorun((e) => {
			this._position.read(e), this.editor.layoutContentWidget(this);
		})), this._register(autorun((e) => {
			let _ = this._suggestionCount.read(e), v = this._currentSuggestionIdx.read(e);
			_ === void 0 ? this.clearAvailableSuggestionCountLabelDebounced.schedule() : (this.clearAvailableSuggestionCountLabelDebounced.cancel(), this.availableSuggestionCountAction.label = `${v + 1}/${_}`), _ !== void 0 && _ > 1 ? (this.disableButtonsDebounced.cancel(), this.previousAction.enabled = this.nextAction.enabled = !0) : this.disableButtonsDebounced.schedule();
		})), this._register(autorun((e) => {
			let _ = this._extraCommands.read(e).map((e) => ({
				class: void 0,
				id: e.id,
				enabled: !0,
				tooltip: e.tooltip || "",
				label: e.title,
				run: (_) => this._commandService.executeCommand(e.id)
			}));
			for (let [e, v] of this.inlineCompletionsActionsMenus.getActions()) for (let e of v) e instanceof MenuItemAction && _.push(e);
			_.length > 0 && _.unshift(new Separator()), this.toolBar.setAdditionalSecondaryActions(_);
		}));
	}
	getId() {
		return this.id;
	}
	getDomNode() {
		return this.nodes.root;
	}
	getPosition() {
		return {
			position: this._position.get(),
			preference: [1, 2],
			positionAffinity: 3
		};
	}
};
InlineSuggestionHintsContentWidget = InlineSuggestionHintsContentWidget_1 = __decorate$86([
	__param$86(6, ICommandService),
	__param$86(7, IInstantiationService),
	__param$86(8, IKeybindingService),
	__param$86(9, IContextKeyService),
	__param$86(10, IMenuService)
], InlineSuggestionHintsContentWidget);
var ActionViewItemWithClassName = class extends ActionViewItem {
	constructor() {
		super(...arguments), this._className = void 0;
	}
	setClass(e) {
		this._className = e;
	}
	render(e) {
		super.render(e), this._className && e.classList.add(this._className);
	}
	updateTooltip() {}
}, StatusBarViewItem$1 = class extends MenuEntryActionViewItem {
	updateLabel() {
		let e = this._keybindingService.lookupKeybinding(this._action.id, this._contextKeyService);
		if (!e) return super.updateLabel();
		if (this.label) {
			let _ = h("div.keybinding").root;
			this._register(new KeybindingLabel(_, OS, {
				disableTitle: !0,
				...unthemedKeybindingLabelOptions
			})).set(e), this.label.textContent = this._action.label, this.label.appendChild(_), this.label.classList.add("inlineSuggestionStatusBarItemLabel");
		}
	}
	updateTooltip() {}
}, CustomizedMenuWorkbenchToolBar$1 = class extends WorkbenchToolBar {
	constructor(e, _, v, y, b, x, S, C, w) {
		super(e, {
			resetMenu: _,
			...v
		}, y, b, x, S, C, w), this.menuId = _, this.options2 = v, this.menuService = y, this.contextKeyService = b, this.menu = this._store.add(this.menuService.createMenu(this.menuId, this.contextKeyService, { emitEventsForSubmenuChanges: !0 })), this.additionalActions = [], this.prependedPrimaryActions = [], this._store.add(this.menu.onDidChange(() => this.updateToolbar())), this.updateToolbar();
	}
	updateToolbar() {
		let e = [], _ = [];
		createAndFillInActionBarActions(this.menu, this.options2?.menuOptions, {
			primary: e,
			secondary: _
		}, this.options2?.toolbarOptions?.primaryGroup, this.options2?.toolbarOptions?.shouldInlineSubmenu, this.options2?.toolbarOptions?.useSeparatorsInPrimaryActions), _.push(...this.additionalActions), e.unshift(...this.prependedPrimaryActions), this.setActions(e, _);
	}
	setPrependedPrimaryActions(e) {
		equals(this.prependedPrimaryActions, e, (e, _) => e === _) || (this.prependedPrimaryActions = e, this.updateToolbar());
	}
	setAdditionalSecondaryActions(e) {
		equals(this.additionalActions, e, (e, _) => e === _) || (this.additionalActions = e, this.updateToolbar());
	}
};
CustomizedMenuWorkbenchToolBar$1 = __decorate$86([
	__param$86(3, IMenuService),
	__param$86(4, IContextKeyService),
	__param$86(5, IContextMenuService),
	__param$86(6, IKeybindingService),
	__param$86(7, ICommandService),
	__param$86(8, ITelemetryService)
], CustomizedMenuWorkbenchToolBar$1);
function isMousePositionWithinElement(e, _, v) {
	let y = getDomNodePagePosition(e);
	return !(_ < y.left || _ > y.left + y.width || v < y.top || v > y.top + y.height);
}
var HoverResult$1 = class {
	constructor(e, _, v) {
		this.value = e, this.isComplete = _, this.hasLoadingMessage = v;
	}
}, HoverOperation = class extends Disposable {
	constructor(e, _) {
		super(), this._editor = e, this._computer = _, this._onResult = this._register(new Emitter()), this.onResult = this._onResult.event, this._firstWaitScheduler = this._register(new RunOnceScheduler(() => this._triggerAsyncComputation(), 0)), this._secondWaitScheduler = this._register(new RunOnceScheduler(() => this._triggerSyncComputation(), 0)), this._loadingMessageScheduler = this._register(new RunOnceScheduler(() => this._triggerLoadingMessage(), 0)), this._state = 0, this._asyncIterable = null, this._asyncIterableDone = !1, this._result = [];
	}
	dispose() {
		this._asyncIterable &&= (this._asyncIterable.cancel(), null), super.dispose();
	}
	get _hoverTime() {
		return this._editor.getOption(60).delay;
	}
	get _firstWaitTime() {
		return this._hoverTime / 2;
	}
	get _secondWaitTime() {
		return this._hoverTime - this._firstWaitTime;
	}
	get _loadingMessageTime() {
		return 3 * this._hoverTime;
	}
	_setState(e, _ = !0) {
		this._state = e, _ && this._fireResult();
	}
	_triggerAsyncComputation() {
		this._setState(2), this._secondWaitScheduler.schedule(this._secondWaitTime), this._computer.computeAsync ? (this._asyncIterableDone = !1, this._asyncIterable = createCancelableAsyncIterable((e) => this._computer.computeAsync(e)), (async () => {
			try {
				for await (let e of this._asyncIterable) e && (this._result.push(e), this._fireResult());
				this._asyncIterableDone = !0, (this._state === 3 || this._state === 4) && this._setState(0);
			} catch (e) {
				onUnexpectedError(e);
			}
		})()) : this._asyncIterableDone = !0;
	}
	_triggerSyncComputation() {
		this._computer.computeSync && (this._result = this._result.concat(this._computer.computeSync())), this._setState(this._asyncIterableDone ? 0 : 3);
	}
	_triggerLoadingMessage() {
		this._state === 3 && this._setState(4);
	}
	_fireResult() {
		if (this._state === 1 || this._state === 2) return;
		let e = this._state === 0, _ = this._state === 4;
		this._onResult.fire(new HoverResult$1(this._result.slice(0), e, _));
	}
	start(e) {
		if (e === 0) this._state === 0 && (this._setState(1), this._firstWaitScheduler.schedule(this._firstWaitTime), this._loadingMessageScheduler.schedule(this._loadingMessageTime));
		else switch (this._state) {
			case 0:
				this._triggerAsyncComputation(), this._secondWaitScheduler.cancel(), this._triggerSyncComputation();
				break;
			case 2:
				this._secondWaitScheduler.cancel(), this._triggerSyncComputation();
				break;
		}
	}
	cancel() {
		this._firstWaitScheduler.cancel(), this._secondWaitScheduler.cancel(), this._loadingMessageScheduler.cancel(), this._asyncIterable &&= (this._asyncIterable.cancel(), null), this._result = [], this._setState(0, !1);
	}
}, ResizableHTMLElement = class {
	constructor() {
		this._onDidWillResize = new Emitter(), this.onDidWillResize = this._onDidWillResize.event, this._onDidResize = new Emitter(), this.onDidResize = this._onDidResize.event, this._sashListener = new DisposableStore(), this._size = new Dimension(0, 0), this._minSize = new Dimension(0, 0), this._maxSize = new Dimension(2 ** 53 - 1, 2 ** 53 - 1), this.domNode = document.createElement("div"), this._eastSash = new Sash(this.domNode, { getVerticalSashLeft: () => this._size.width }, { orientation: 0 }), this._westSash = new Sash(this.domNode, { getVerticalSashLeft: () => 0 }, { orientation: 0 }), this._northSash = new Sash(this.domNode, { getHorizontalSashTop: () => 0 }, {
			orientation: 1,
			orthogonalEdge: OrthogonalEdge.North
		}), this._southSash = new Sash(this.domNode, { getHorizontalSashTop: () => this._size.height }, {
			orientation: 1,
			orthogonalEdge: OrthogonalEdge.South
		}), this._northSash.orthogonalStartSash = this._westSash, this._northSash.orthogonalEndSash = this._eastSash, this._southSash.orthogonalStartSash = this._westSash, this._southSash.orthogonalEndSash = this._eastSash;
		let e, _ = 0, v = 0;
		this._sashListener.add(Event.any(this._northSash.onDidStart, this._eastSash.onDidStart, this._southSash.onDidStart, this._westSash.onDidStart)(() => {
			e === void 0 && (this._onDidWillResize.fire(), e = this._size, _ = 0, v = 0);
		})), this._sashListener.add(Event.any(this._northSash.onDidEnd, this._eastSash.onDidEnd, this._southSash.onDidEnd, this._westSash.onDidEnd)(() => {
			e !== void 0 && (e = void 0, _ = 0, v = 0, this._onDidResize.fire({
				dimension: this._size,
				done: !0
			}));
		})), this._sashListener.add(this._eastSash.onDidChange((y) => {
			e && (v = y.currentX - y.startX, this.layout(e.height + _, e.width + v), this._onDidResize.fire({
				dimension: this._size,
				done: !1,
				east: !0
			}));
		})), this._sashListener.add(this._westSash.onDidChange((y) => {
			e && (v = -(y.currentX - y.startX), this.layout(e.height + _, e.width + v), this._onDidResize.fire({
				dimension: this._size,
				done: !1,
				west: !0
			}));
		})), this._sashListener.add(this._northSash.onDidChange((y) => {
			e && (_ = -(y.currentY - y.startY), this.layout(e.height + _, e.width + v), this._onDidResize.fire({
				dimension: this._size,
				done: !1,
				north: !0
			}));
		})), this._sashListener.add(this._southSash.onDidChange((y) => {
			e && (_ = y.currentY - y.startY, this.layout(e.height + _, e.width + v), this._onDidResize.fire({
				dimension: this._size,
				done: !1,
				south: !0
			}));
		})), this._sashListener.add(Event.any(this._eastSash.onDidReset, this._westSash.onDidReset)((e) => {
			this._preferredSize && (this.layout(this._size.height, this._preferredSize.width), this._onDidResize.fire({
				dimension: this._size,
				done: !0
			}));
		})), this._sashListener.add(Event.any(this._northSash.onDidReset, this._southSash.onDidReset)((e) => {
			this._preferredSize && (this.layout(this._preferredSize.height, this._size.width), this._onDidResize.fire({
				dimension: this._size,
				done: !0
			}));
		}));
	}
	dispose() {
		this._northSash.dispose(), this._southSash.dispose(), this._eastSash.dispose(), this._westSash.dispose(), this._sashListener.dispose(), this._onDidResize.dispose(), this._onDidWillResize.dispose(), this.domNode.remove();
	}
	enableSashes(e, _, v, y) {
		this._northSash.state = e ? 3 : 0, this._eastSash.state = _ ? 3 : 0, this._southSash.state = v ? 3 : 0, this._westSash.state = y ? 3 : 0;
	}
	layout(e = this.size.height, _ = this.size.width) {
		let { height: v, width: y } = this._minSize, { height: b, width: x } = this._maxSize;
		e = Math.max(v, Math.min(b, e)), _ = Math.max(y, Math.min(x, _));
		let S = new Dimension(_, e);
		Dimension.equals(S, this._size) || (this.domNode.style.height = e + "px", this.domNode.style.width = _ + "px", this._size = S, this._northSash.layout(), this._eastSash.layout(), this._southSash.layout(), this._westSash.layout());
	}
	clearSashHoverState() {
		this._eastSash.clearSashHoverState(), this._westSash.clearSashHoverState(), this._northSash.clearSashHoverState(), this._southSash.clearSashHoverState();
	}
	get size() {
		return this._size;
	}
	set maxSize(e) {
		this._maxSize = e;
	}
	get maxSize() {
		return this._maxSize;
	}
	set minSize(e) {
		this._minSize = e;
	}
	get minSize() {
		return this._minSize;
	}
	set preferredSize(e) {
		this._preferredSize = e;
	}
	get preferredSize() {
		return this._preferredSize;
	}
}, TOP_HEIGHT = 30, BOTTOM_HEIGHT = 24, ResizableContentWidget = class extends Disposable {
	constructor(e, _ = new Dimension(10, 10)) {
		super(), this._editor = e, this.allowEditorOverflow = !0, this.suppressMouseDown = !1, this._resizableNode = this._register(new ResizableHTMLElement()), this._contentPosition = null, this._isResizing = !1, this._resizableNode.domNode.style.position = "absolute", this._resizableNode.minSize = Dimension.lift(_), this._resizableNode.layout(_.height, _.width), this._resizableNode.enableSashes(!0, !0, !0, !0), this._register(this._resizableNode.onDidResize((e) => {
			this._resize(new Dimension(e.dimension.width, e.dimension.height)), e.done && (this._isResizing = !1);
		})), this._register(this._resizableNode.onDidWillResize(() => {
			this._isResizing = !0;
		}));
	}
	get isResizing() {
		return this._isResizing;
	}
	getDomNode() {
		return this._resizableNode.domNode;
	}
	getPosition() {
		return this._contentPosition;
	}
	get position() {
		return this._contentPosition?.position ? Position.lift(this._contentPosition.position) : void 0;
	}
	_availableVerticalSpaceAbove(e) {
		let _ = this._editor.getDomNode(), v = this._editor.getScrolledVisiblePosition(e);
		if (!(!_ || !v)) return getDomNodePagePosition(_).top + v.top - TOP_HEIGHT;
	}
	_availableVerticalSpaceBelow(e) {
		let _ = this._editor.getDomNode(), v = this._editor.getScrolledVisiblePosition(e);
		if (!_ || !v) return;
		let y = getDomNodePagePosition(_), b = getClientArea(_.ownerDocument.body), x = y.top + v.top + v.height;
		return b.height - x - BOTTOM_HEIGHT;
	}
	_findPositionPreference(e, _) {
		let v = Math.min(this._availableVerticalSpaceBelow(_) ?? Infinity, e), y = Math.min(this._availableVerticalSpaceAbove(_) ?? Infinity, e), b = Math.min(Math.max(y, v), e), x = Math.min(e, b), S;
		return S = this._editor.getOption(60).above ? x <= y ? 1 : 2 : x <= v ? 2 : 1, S === 1 ? this._resizableNode.enableSashes(!0, !0, !1, !1) : this._resizableNode.enableSashes(!1, !0, !0, !1), S;
	}
	_resize(e) {
		this._resizableNode.layout(e.height, e.width);
	}
}, __decorate$85 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$85 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ContentHoverWidget_1, HORIZONTAL_SCROLLING_BY = 30, CONTAINER_HEIGHT_PADDING = 6, ContentHoverWidget = class extends ResizableContentWidget {
	static {
		ContentHoverWidget_1 = this;
	}
	static {
		this.ID = "editor.contrib.resizableContentHoverWidget";
	}
	static {
		this._lastDimensions = new Dimension(0, 0);
	}
	get isVisibleFromKeyboard() {
		return this._renderedHover?.source === 1;
	}
	get isVisible() {
		return this._hoverVisibleKey.get() ?? !1;
	}
	get isFocused() {
		return this._hoverFocusedKey.get() ?? !1;
	}
	constructor(e, _, v, y, b) {
		let x = e.getOption(67) + 8, S = new Dimension(150, x);
		super(e, S), this._configurationService = v, this._accessibilityService = y, this._keybindingService = b, this._hover = this._register(new HoverWidget()), this._onDidResize = this._register(new Emitter()), this.onDidResize = this._onDidResize.event, this._minimumSize = S, this._hoverVisibleKey = EditorContextKeys.hoverVisible.bindTo(_), this._hoverFocusedKey = EditorContextKeys.hoverFocused.bindTo(_), append(this._resizableNode.domNode, this._hover.containerDomNode), this._resizableNode.domNode.style.zIndex = "50", this._register(this._editor.onDidLayoutChange(() => {
			this.isVisible && this._updateMaxDimensions();
		})), this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(50) && this._updateFont();
		}));
		let C = this._register(trackFocus(this._resizableNode.domNode));
		this._register(C.onDidFocus(() => {
			this._hoverFocusedKey.set(!0);
		})), this._register(C.onDidBlur(() => {
			this._hoverFocusedKey.set(!1);
		})), this._setRenderedHover(void 0), this._editor.addContentWidget(this);
	}
	dispose() {
		super.dispose(), this._renderedHover?.dispose(), this._editor.removeContentWidget(this);
	}
	getId() {
		return ContentHoverWidget_1.ID;
	}
	static _applyDimensions(e, _, v) {
		let y = typeof _ == "number" ? `${_}px` : _, b = typeof v == "number" ? `${v}px` : v;
		e.style.width = y, e.style.height = b;
	}
	_setContentsDomNodeDimensions(e, _) {
		let v = this._hover.contentsDomNode;
		return ContentHoverWidget_1._applyDimensions(v, e, _);
	}
	_setContainerDomNodeDimensions(e, _) {
		let v = this._hover.containerDomNode;
		return ContentHoverWidget_1._applyDimensions(v, e, _);
	}
	_setHoverWidgetDimensions(e, _) {
		this._setContentsDomNodeDimensions(e, _), this._setContainerDomNodeDimensions(e, _), this._layoutContentWidget();
	}
	static _applyMaxDimensions(e, _, v) {
		let y = typeof _ == "number" ? `${_}px` : _, b = typeof v == "number" ? `${v}px` : v;
		e.style.maxWidth = y, e.style.maxHeight = b;
	}
	_setHoverWidgetMaxDimensions(e, _) {
		ContentHoverWidget_1._applyMaxDimensions(this._hover.contentsDomNode, e, _), ContentHoverWidget_1._applyMaxDimensions(this._hover.containerDomNode, e, _), this._hover.containerDomNode.style.setProperty("--vscode-hover-maxWidth", typeof e == "number" ? `${e}px` : e), this._layoutContentWidget();
	}
	_setAdjustedHoverWidgetDimensions(e) {
		this._setHoverWidgetMaxDimensions("none", "none");
		let _ = e.width, v = e.height;
		this._setHoverWidgetDimensions(_, v);
	}
	_updateResizableNodeMaxDimensions() {
		let e = this._findMaximumRenderingWidth() ?? Infinity, _ = this._findMaximumRenderingHeight() ?? Infinity;
		this._resizableNode.maxSize = new Dimension(e, _), this._setHoverWidgetMaxDimensions(e, _);
	}
	_resize(e) {
		ContentHoverWidget_1._lastDimensions = new Dimension(e.width, e.height), this._setAdjustedHoverWidgetDimensions(e), this._resizableNode.layout(e.height, e.width), this._updateResizableNodeMaxDimensions(), this._hover.scrollbar.scanDomNode(), this._editor.layoutContentWidget(this), this._onDidResize.fire();
	}
	_findAvailableSpaceVertically() {
		let e = this._renderedHover?.showAtPosition;
		if (e) return this._positionPreference === 1 ? this._availableVerticalSpaceAbove(e) : this._availableVerticalSpaceBelow(e);
	}
	_findMaximumRenderingHeight() {
		let e = this._findAvailableSpaceVertically();
		if (!e) return;
		let _ = CONTAINER_HEIGHT_PADDING;
		return Array.from(this._hover.contentsDomNode.children).forEach((e) => {
			_ += e.clientHeight;
		}), Math.min(e, _);
	}
	_isHoverTextOverflowing() {
		this._hover.containerDomNode.style.setProperty("--vscode-hover-whiteSpace", "nowrap"), this._hover.containerDomNode.style.setProperty("--vscode-hover-sourceWhiteSpace", "nowrap");
		let e = Array.from(this._hover.contentsDomNode.children).some((e) => e.scrollWidth > e.clientWidth);
		return this._hover.containerDomNode.style.removeProperty("--vscode-hover-whiteSpace"), this._hover.containerDomNode.style.removeProperty("--vscode-hover-sourceWhiteSpace"), e;
	}
	_findMaximumRenderingWidth() {
		if (!this._editor || !this._editor.hasModel()) return;
		let e = this._isHoverTextOverflowing(), _ = this._contentWidth === void 0 ? 0 : this._contentWidth - 2;
		return e || this._hover.containerDomNode.clientWidth < _ ? getClientArea(this._hover.containerDomNode.ownerDocument.body).width - 14 : this._hover.containerDomNode.clientWidth + 2;
	}
	isMouseGettingCloser(e, _) {
		if (!this._renderedHover) return !1;
		if (this._renderedHover.initialMousePosX === void 0 || this._renderedHover.initialMousePosY === void 0) return this._renderedHover.initialMousePosX = e, this._renderedHover.initialMousePosY = _, !1;
		let v = getDomNodePagePosition(this.getDomNode());
		this._renderedHover.closestMouseDistance === void 0 && (this._renderedHover.closestMouseDistance = computeDistanceFromPointToRectangle(this._renderedHover.initialMousePosX, this._renderedHover.initialMousePosY, v.left, v.top, v.width, v.height));
		let y = computeDistanceFromPointToRectangle(e, _, v.left, v.top, v.width, v.height);
		return y > this._renderedHover.closestMouseDistance + 4 ? !1 : (this._renderedHover.closestMouseDistance = Math.min(this._renderedHover.closestMouseDistance, y), !0);
	}
	_setRenderedHover(e) {
		this._renderedHover?.dispose(), this._renderedHover = e, this._hoverVisibleKey.set(!!e), this._hover.containerDomNode.classList.toggle("hidden", !e);
	}
	_updateFont() {
		let { fontSize: e, lineHeight: _ } = this._editor.getOption(50), v = this._hover.contentsDomNode;
		v.style.fontSize = `${e}px`, v.style.lineHeight = `${_ / e}`, Array.prototype.slice.call(this._hover.contentsDomNode.getElementsByClassName("code")).forEach((e) => this._editor.applyFontInfo(e));
	}
	_updateContent(e) {
		let _ = this._hover.contentsDomNode;
		_.style.paddingBottom = "", _.textContent = "", _.appendChild(e);
	}
	_layoutContentWidget() {
		this._editor.layoutContentWidget(this), this._hover.onContentsChanged();
	}
	_updateMaxDimensions() {
		let e = Math.max(this._editor.getLayoutInfo().height / 4, 250, ContentHoverWidget_1._lastDimensions.height), _ = Math.max(this._editor.getLayoutInfo().width * .66, 500, ContentHoverWidget_1._lastDimensions.width);
		this._setHoverWidgetMaxDimensions(_, e);
	}
	_render(e) {
		this._setRenderedHover(e), this._updateFont(), this._updateContent(e.domNode), this._updateMaxDimensions(), this.onContentsChanged(), this._editor.render();
	}
	getPosition() {
		return this._renderedHover ? {
			position: this._renderedHover.showAtPosition,
			secondaryPosition: this._renderedHover.showAtSecondaryPosition,
			positionAffinity: this._renderedHover.shouldAppearBeforeContent ? 3 : void 0,
			preference: [this._positionPreference ?? 1]
		} : null;
	}
	show(e) {
		if (!this._editor || !this._editor.hasModel()) return;
		this._render(e);
		let _ = getTotalHeight(this._hover.containerDomNode), v = e.showAtPosition;
		this._positionPreference = this._findPositionPreference(_, v) ?? 1, this.onContentsChanged(), e.shouldFocus && this._hover.containerDomNode.focus(), this._onDidResize.fire();
		let y = this._hover.containerDomNode.ownerDocument.activeElement === this._hover.containerDomNode && getHoverAccessibleViewHint(this._configurationService.getValue("accessibility.verbosity.hover") === !0 && this._accessibilityService.isScreenReaderOptimized(), this._keybindingService.lookupKeybinding("editor.action.accessibleView")?.getAriaLabel() ?? "");
		y && (this._hover.contentsDomNode.ariaLabel = this._hover.contentsDomNode.textContent + ", " + y);
	}
	hide() {
		if (!this._renderedHover) return;
		let e = this._renderedHover.shouldFocus || this._hoverFocusedKey.get();
		this._setRenderedHover(void 0), this._resizableNode.maxSize = new Dimension(Infinity, Infinity), this._resizableNode.clearSashHoverState(), this._hoverFocusedKey.set(!1), this._editor.layoutContentWidget(this), e && this._editor.focus();
	}
	_removeConstraintsRenderNormally() {
		let e = this._editor.getLayoutInfo();
		this._resizableNode.layout(e.height, e.width), this._setHoverWidgetDimensions("auto", "auto");
	}
	setMinimumDimensions(e) {
		this._minimumSize = new Dimension(Math.max(this._minimumSize.width, e.width), Math.max(this._minimumSize.height, e.height)), this._updateMinimumWidth();
	}
	_updateMinimumWidth() {
		let e = this._contentWidth === void 0 ? this._minimumSize.width : Math.min(this._contentWidth, this._minimumSize.width);
		this._resizableNode.minSize = new Dimension(e, this._minimumSize.height);
	}
	onContentsChanged() {
		this._removeConstraintsRenderNormally();
		let e = this._hover.containerDomNode, _ = getTotalHeight(e), v = getTotalWidth(e);
		if (this._resizableNode.layout(_, v), this._setHoverWidgetDimensions(v, _), _ = getTotalHeight(e), v = getTotalWidth(e), this._contentWidth = v, this._updateMinimumWidth(), this._resizableNode.layout(_, v), this._renderedHover?.showAtPosition) {
			let e = getTotalHeight(this._hover.containerDomNode);
			this._positionPreference = this._findPositionPreference(e, this._renderedHover.showAtPosition);
		}
		this._layoutContentWidget();
	}
	focus() {
		this._hover.containerDomNode.focus();
	}
	scrollUp() {
		let e = this._hover.scrollbar.getScrollPosition().scrollTop, _ = this._editor.getOption(50);
		this._hover.scrollbar.setScrollPosition({ scrollTop: e - _.lineHeight });
	}
	scrollDown() {
		let e = this._hover.scrollbar.getScrollPosition().scrollTop, _ = this._editor.getOption(50);
		this._hover.scrollbar.setScrollPosition({ scrollTop: e + _.lineHeight });
	}
	scrollLeft() {
		let e = this._hover.scrollbar.getScrollPosition().scrollLeft;
		this._hover.scrollbar.setScrollPosition({ scrollLeft: e - HORIZONTAL_SCROLLING_BY });
	}
	scrollRight() {
		let e = this._hover.scrollbar.getScrollPosition().scrollLeft;
		this._hover.scrollbar.setScrollPosition({ scrollLeft: e + HORIZONTAL_SCROLLING_BY });
	}
	pageUp() {
		let e = this._hover.scrollbar.getScrollPosition().scrollTop, _ = this._hover.scrollbar.getScrollDimensions().height;
		this._hover.scrollbar.setScrollPosition({ scrollTop: e - _ });
	}
	pageDown() {
		let e = this._hover.scrollbar.getScrollPosition().scrollTop, _ = this._hover.scrollbar.getScrollDimensions().height;
		this._hover.scrollbar.setScrollPosition({ scrollTop: e + _ });
	}
	goToTop() {
		this._hover.scrollbar.setScrollPosition({ scrollTop: 0 });
	}
	goToBottom() {
		this._hover.scrollbar.setScrollPosition({ scrollTop: this._hover.scrollbar.getScrollDimensions().scrollHeight });
	}
};
ContentHoverWidget = ContentHoverWidget_1 = __decorate$85([
	__param$85(1, IContextKeyService),
	__param$85(2, IConfigurationService),
	__param$85(3, IAccessibilityService),
	__param$85(4, IKeybindingService)
], ContentHoverWidget);
function computeDistanceFromPointToRectangle(e, _, v, y, b, x) {
	let S = v + b / 2, C = y + x / 2, w = Math.max(Math.abs(e - S) - b / 2, 0), T = Math.max(Math.abs(_ - C) - x / 2, 0);
	return Math.sqrt(w * w + T * T);
}
var ContentHoverComputer = class e {
	get anchor() {
		return this._anchor;
	}
	set anchor(e) {
		this._anchor = e;
	}
	get shouldFocus() {
		return this._shouldFocus;
	}
	set shouldFocus(e) {
		this._shouldFocus = e;
	}
	get source() {
		return this._source;
	}
	set source(e) {
		this._source = e;
	}
	get insistOnKeepingHoverVisible() {
		return this._insistOnKeepingHoverVisible;
	}
	set insistOnKeepingHoverVisible(e) {
		this._insistOnKeepingHoverVisible = e;
	}
	constructor(e, _) {
		this._editor = e, this._participants = _, this._anchor = null, this._shouldFocus = !1, this._source = 0, this._insistOnKeepingHoverVisible = !1;
	}
	static _getLineDecorations(e, _) {
		if (_.type !== 1 && !_.supportsMarkerHover) return [];
		let v = e.getModel(), y = _.range.startLineNumber;
		if (y > v.getLineCount()) return [];
		let b = v.getLineMaxColumn(y);
		return e.getLineDecorations(y).filter((e) => {
			if (e.options.isWholeLine) return !0;
			let v = e.range.startLineNumber === y ? e.range.startColumn : 1, x = e.range.endLineNumber === y ? e.range.endColumn : b;
			if (e.options.showIfCollapsed) {
				if (v > _.range.startColumn + 1 || _.range.endColumn - 1 > x) return !1;
			} else if (v > _.range.startColumn || _.range.endColumn > x) return !1;
			return !0;
		});
	}
	computeAsync(_) {
		let v = this._anchor;
		if (!this._editor.hasModel() || !v) return AsyncIterableObject.EMPTY;
		let y = e._getLineDecorations(this._editor, v);
		return AsyncIterableObject.merge(this._participants.map((e) => e.computeAsync ? e.computeAsync(v, y, _) : AsyncIterableObject.EMPTY));
	}
	computeSync() {
		if (!this._editor.hasModel() || !this._anchor) return [];
		let _ = e._getLineDecorations(this._editor, this._anchor), v = [];
		for (let e of this._participants) v = v.concat(e.computeSync(this._anchor, _));
		return coalesce(v);
	}
}, HoverResult = class {
	constructor(e, _, v) {
		this.anchor = e, this.hoverParts = _, this.isComplete = v;
	}
	filter(e) {
		let _ = this.hoverParts.filter((_) => _.isValidForHoverAnchor(e));
		return _.length === this.hoverParts.length ? this : new FilteredHoverResult(this, this.anchor, _, this.isComplete);
	}
}, FilteredHoverResult = class extends HoverResult {
	constructor(e, _, v, y) {
		super(_, v, y), this.original = e;
	}
	filter(e) {
		return this.original.filter(e);
	}
}, __decorate$84 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$84 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, $$5 = $, EditorHoverStatusBar = class extends Disposable {
	get hasContent() {
		return this._hasContent;
	}
	constructor(e) {
		super(), this._keybindingService = e, this.actions = [], this._hasContent = !1, this.hoverElement = $$5("div.hover-row.status-bar"), this.hoverElement.tabIndex = 0, this.actionsElement = append(this.hoverElement, $$5("div.actions"));
	}
	addAction(e) {
		let _ = this._keybindingService.lookupKeybinding(e.commandId), v = _ ? _.getLabel() : null;
		this._hasContent = !0;
		let y = this._register(HoverAction.render(this.actionsElement, e, v));
		return this.actions.push(y), y;
	}
	append(e) {
		let _ = append(this.actionsElement, e);
		return this._hasContent = !0, _;
	}
};
EditorHoverStatusBar = __decorate$84([__param$84(0, IKeybindingService)], EditorHoverStatusBar);
var HoverProviderResult = class {
	constructor(e, _, v) {
		this.provider = e, this.hover = _, this.ordinal = v;
	}
};
async function executeProvider(e, _, v, y, b) {
	let x = await Promise.resolve(e.provideHover(v, y, b)).catch(onUnexpectedExternalError);
	if (!(!x || !isValid(x))) return new HoverProviderResult(e, x, _);
}
function getHoverProviderResultsAsAsyncIterable(e, _, v, y, b = !1) {
	let x = e.ordered(_, b).map((e, b) => executeProvider(e, b, _, v, y));
	return AsyncIterableObject.fromPromises(x).coalesce();
}
function getHoversPromise(e, _, v, y, b = !1) {
	return getHoverProviderResultsAsAsyncIterable(e, _, v, y, b).map((e) => e.hover).toPromise();
}
registerModelAndPositionCommand("_executeHoverProvider", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService);
	return getHoversPromise(y.hoverProvider, _, v, CancellationToken.None);
}), registerModelAndPositionCommand("_executeHoverProvider_recursive", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService);
	return getHoversPromise(y.hoverProvider, _, v, CancellationToken.None, !0);
});
function isValid(e) {
	let _ = e.range !== void 0, v = e.contents !== void 0 && e.contents && e.contents.length > 0;
	return _ && v;
}
var __decorate$83 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$83 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, $$4 = $, increaseHoverVerbosityIcon = registerIcon("hover-increase-verbosity", Codicon.add, localize("increaseHoverVerbosity", "Icon for increaseing hover verbosity.")), decreaseHoverVerbosityIcon = registerIcon("hover-decrease-verbosity", Codicon.remove, localize("decreaseHoverVerbosity", "Icon for decreasing hover verbosity.")), MarkdownHover = class {
	constructor(e, _, v, y, b, x = void 0) {
		this.owner = e, this.range = _, this.contents = v, this.isBeforeContent = y, this.ordinal = b, this.source = x;
	}
	isValidForHoverAnchor(e) {
		return e.type === 1 && this.range.startColumn <= e.range.startColumn && this.range.endColumn >= e.range.endColumn;
	}
}, HoverSource = class {
	constructor(e, _, v) {
		this.hover = e, this.hoverProvider = _, this.hoverPosition = v;
	}
	supportsVerbosityAction(e) {
		switch (e) {
			case HoverVerbosityAction.Increase: return this.hover.canIncreaseVerbosity ?? !1;
			case HoverVerbosityAction.Decrease: return this.hover.canDecreaseVerbosity ?? !1;
		}
	}
}, MarkdownHoverParticipant = class {
	constructor(e, _, v, y, b, x, S, C) {
		this._editor = e, this._languageService = _, this._openerService = v, this._configurationService = y, this._languageFeaturesService = b, this._keybindingService = x, this._hoverService = S, this._commandService = C, this.hoverOrdinal = 3;
	}
	createLoadingMessage(e) {
		return new MarkdownHover(this, e.range, [new MarkdownString().appendText(localize("modesContentHover.loading", "Loading..."))], !1, 2e3);
	}
	computeSync(e, _) {
		if (!this._editor.hasModel() || e.type !== 1) return [];
		let v = this._editor.getModel(), y = e.range.startLineNumber, b = v.getLineMaxColumn(y), x = [], S = 1e3, C = v.getLineLength(y), w = v.getLanguageIdAtPosition(e.range.startLineNumber, e.range.startColumn), T = this._editor.getOption(118), E = this._configurationService.getValue("editor.maxTokenizationLineLength", { overrideIdentifier: w }), D = !1;
		T >= 0 && C > T && e.range.startColumn >= T && (D = !0, x.push(new MarkdownHover(this, e.range, [{ value: localize("stopped rendering", "Rendering paused for long line for performance reasons. This can be configured via `editor.stopRenderingLineAfter`.") }], !1, S++))), !D && typeof E == "number" && C >= E && x.push(new MarkdownHover(this, e.range, [{ value: localize("too many characters", "Tokenization is skipped for long lines for performance reasons. This can be configured via `editor.maxTokenizationLineLength`.") }], !1, S++));
		let O = !1;
		for (let v of _) {
			let _ = v.range.startLineNumber === y ? v.range.startColumn : 1, C = v.range.endLineNumber === y ? v.range.endColumn : b, w = v.options.hoverMessage;
			if (!w || isEmptyMarkdownString(w)) continue;
			v.options.beforeContentClassName && (O = !0);
			let T = new Range(e.range.startLineNumber, _, e.range.startLineNumber, C);
			x.push(new MarkdownHover(this, T, asArray(w), O, S++));
		}
		return x;
	}
	computeAsync(e, _, v) {
		if (!this._editor.hasModel() || e.type !== 1) return AsyncIterableObject.EMPTY;
		let y = this._editor.getModel(), b = this._languageFeaturesService.hoverProvider;
		return b.has(y) ? this._getMarkdownHovers(b, y, e, v) : AsyncIterableObject.EMPTY;
	}
	_getMarkdownHovers(e, _, v, y) {
		let b = v.range.getStartPosition();
		return getHoverProviderResultsAsAsyncIterable(e, _, b, y).filter((e) => !isEmptyMarkdownString(e.hover.contents)).map((e) => {
			let _ = e.hover.range ? Range.lift(e.hover.range) : v.range, y = new HoverSource(e.hover, e.provider, b);
			return new MarkdownHover(this, _, e.hover.contents, !1, e.ordinal, y);
		});
	}
	renderHoverParts(e, _) {
		return this._renderedHoverParts = new MarkdownRenderedHoverParts(_, e.fragment, this, this._editor, this._languageService, this._openerService, this._commandService, this._keybindingService, this._hoverService, this._configurationService, e.onContentsChanged), this._renderedHoverParts;
	}
	updateMarkdownHoverVerbosityLevel(e, _, v) {
		return Promise.resolve(this._renderedHoverParts?.updateMarkdownHoverPartVerbosityLevel(e, _, v));
	}
};
MarkdownHoverParticipant = __decorate$83([
	__param$83(1, ILanguageService),
	__param$83(2, IOpenerService),
	__param$83(3, IConfigurationService),
	__param$83(4, ILanguageFeaturesService),
	__param$83(5, IKeybindingService),
	__param$83(6, IHoverService),
	__param$83(7, ICommandService)
], MarkdownHoverParticipant);
var RenderedMarkdownHoverPart = class {
	constructor(e, _, v) {
		this.hoverPart = e, this.hoverElement = _, this.disposables = v;
	}
	dispose() {
		this.disposables.dispose();
	}
}, MarkdownRenderedHoverParts = class {
	constructor(e, _, v, y, b, x, S, C, w, T, E) {
		this._hoverParticipant = v, this._editor = y, this._languageService = b, this._openerService = x, this._commandService = S, this._keybindingService = C, this._hoverService = w, this._configurationService = T, this._onFinishedRendering = E, this._ongoingHoverOperations = /* @__PURE__ */ new Map(), this._disposables = new DisposableStore(), this.renderedHoverParts = this._renderHoverParts(e, _, this._onFinishedRendering), this._disposables.add(toDisposable(() => {
			this.renderedHoverParts.forEach((e) => {
				e.dispose();
			}), this._ongoingHoverOperations.forEach((e) => {
				e.tokenSource.dispose(!0);
			});
		}));
	}
	_renderHoverParts(e, _, v) {
		return e.sort(compareBy((e) => e.ordinal, numberComparator)), e.map((e) => {
			let y = this._renderHoverPart(e, v);
			return _.appendChild(y.hoverElement), y;
		});
	}
	_renderHoverPart(e, _) {
		let v = this._renderMarkdownHover(e, _), y = v.hoverElement, b = e.source, x = new DisposableStore();
		if (x.add(v), !b) return new RenderedMarkdownHoverPart(e, y, x);
		let S = b.supportsVerbosityAction(HoverVerbosityAction.Increase), C = b.supportsVerbosityAction(HoverVerbosityAction.Decrease);
		if (!S && !C) return new RenderedMarkdownHoverPart(e, y, x);
		let w = $$4("div.verbosity-actions");
		return y.prepend(w), x.add(this._renderHoverExpansionAction(w, HoverVerbosityAction.Increase, S)), x.add(this._renderHoverExpansionAction(w, HoverVerbosityAction.Decrease, C)), new RenderedMarkdownHoverPart(e, y, x);
	}
	_renderMarkdownHover(e, _) {
		return renderMarkdownInContainer(this._editor, e, this._languageService, this._openerService, _);
	}
	_renderHoverExpansionAction(e, _, v) {
		let y = new DisposableStore(), b = _ === HoverVerbosityAction.Increase, x = append(e, $$4(ThemeIcon.asCSSSelector(b ? increaseHoverVerbosityIcon : decreaseHoverVerbosityIcon)));
		x.tabIndex = 0;
		let S = new WorkbenchHoverDelegate("mouse", !1, {
			target: e,
			position: { hoverPosition: 0 }
		}, this._configurationService, this._hoverService);
		if (y.add(this._hoverService.setupManagedHover(S, x, labelForHoverVerbosityAction(this._keybindingService, _))), !v) return x.classList.add("disabled"), y;
		x.classList.add("enabled");
		let C = () => this._commandService.executeCommand(_ === HoverVerbosityAction.Increase ? INCREASE_HOVER_VERBOSITY_ACTION_ID : DECREASE_HOVER_VERBOSITY_ACTION_ID);
		return y.add(new ClickAction(x, C)), y.add(new KeyDownAction(x, C, [3, 10])), y;
	}
	async updateMarkdownHoverPartVerbosityLevel(e, _, v = !0) {
		let y = this._editor.getModel();
		if (!y) return;
		let b = this._getRenderedHoverPartAtIndex(_), x = b?.hoverPart.source;
		if (!b || !x?.supportsVerbosityAction(e)) return;
		let S = await this._fetchHover(x, y, e);
		if (!S) return;
		let C = new HoverSource(S, x.hoverProvider, x.hoverPosition), w = b.hoverPart, T = new MarkdownHover(this._hoverParticipant, w.range, S.contents, w.isBeforeContent, w.ordinal, C), E = this._renderHoverPart(T, this._onFinishedRendering);
		return this._replaceRenderedHoverPartAtIndex(_, E, T), v && this._focusOnHoverPartWithIndex(_), {
			hoverPart: T,
			hoverElement: E.hoverElement
		};
	}
	async _fetchHover(e, _, v) {
		let y = v === HoverVerbosityAction.Increase ? 1 : -1, b = e.hoverProvider, x = this._ongoingHoverOperations.get(b);
		x && (x.tokenSource.cancel(), y += x.verbosityDelta);
		let S = new CancellationTokenSource();
		this._ongoingHoverOperations.set(b, {
			verbosityDelta: y,
			tokenSource: S
		});
		let C = { verbosityRequest: {
			verbosityDelta: y,
			previousHover: e.hover
		} }, w;
		try {
			w = await Promise.resolve(b.provideHover(_, e.hoverPosition, S.token, C));
		} catch (e) {
			onUnexpectedExternalError(e);
		}
		return S.dispose(), this._ongoingHoverOperations.delete(b), w;
	}
	_replaceRenderedHoverPartAtIndex(e, _, v) {
		if (e >= this.renderedHoverParts.length || e < 0) return;
		let y = this.renderedHoverParts[e], b = y.hoverElement, x = _.hoverElement, S = Array.from(x.children);
		b.replaceChildren(...S);
		let C = new RenderedMarkdownHoverPart(v, b, _.disposables);
		b.focus(), y.dispose(), this.renderedHoverParts[e] = C;
	}
	_focusOnHoverPartWithIndex(e) {
		this.renderedHoverParts[e].hoverElement.focus();
	}
	_getRenderedHoverPartAtIndex(e) {
		return this.renderedHoverParts[e];
	}
	dispose() {
		this._disposables.dispose();
	}
};
function renderMarkdownHovers(e, _, v, y, b) {
	_.sort(compareBy((e) => e.ordinal, numberComparator));
	let x = [];
	for (let S of _) x.push(renderMarkdownInContainer(v, S, y, b, e.onContentsChanged));
	return new RenderedHoverParts(x);
}
function renderMarkdownInContainer(e, _, v, y, b) {
	let x = new DisposableStore(), S = $$4("div.hover-row"), C = $$4("div.hover-row-contents");
	S.appendChild(C);
	let w = _.contents;
	for (let _ of w) {
		if (isEmptyMarkdownString(_)) continue;
		let S = $$4("div.markdown-hover"), w = append(S, $$4("div.hover-contents")), T = x.add(new MarkdownRenderer({ editor: e }, v, y));
		x.add(T.onDidRenderAsync(() => {
			w.className = "hover-contents code-hover-contents", b();
		}));
		let E = x.add(T.render(_));
		w.appendChild(E.element), C.appendChild(S);
	}
	return {
		hoverPart: _,
		hoverElement: S,
		dispose() {
			x.dispose();
		}
	};
}
function labelForHoverVerbosityAction(e, _) {
	switch (_) {
		case HoverVerbosityAction.Increase: {
			let _ = e.lookupKeybinding(INCREASE_HOVER_VERBOSITY_ACTION_ID);
			return _ ? localize("increaseVerbosityWithKb", "Increase Hover Verbosity ({0})", _.getLabel()) : localize("increaseVerbosity", "Increase Hover Verbosity");
		}
		case HoverVerbosityAction.Decrease: {
			let _ = e.lookupKeybinding(DECREASE_HOVER_VERBOSITY_ACTION_ID);
			return _ ? localize("decreaseVerbosityWithKb", "Decrease Hover Verbosity ({0})", _.getLabel()) : localize("decreaseVerbosity", "Decrease Hover Verbosity");
		}
	}
}
function hasModifier(e, _) {
	return !!e[_];
}
var ClickLinkMouseEvent = class {
	constructor(e, _) {
		this.target = e.target, this.isLeftClick = e.event.leftButton, this.isMiddleClick = e.event.middleButton, this.isRightClick = e.event.rightButton, this.hasTriggerModifier = hasModifier(e.event, _.triggerModifier), this.hasSideBySideModifier = hasModifier(e.event, _.triggerSideBySideModifier), this.isNoneOrSingleMouseDown = e.event.detail <= 1;
	}
}, ClickLinkKeyboardEvent = class {
	constructor(e, _) {
		this.keyCodeIsTriggerKey = e.keyCode === _.triggerKey, this.keyCodeIsSideBySideKey = e.keyCode === _.triggerSideBySideKey, this.hasTriggerModifier = hasModifier(e, _.triggerModifier);
	}
}, ClickLinkOptions = class {
	constructor(e, _, v, y) {
		this.triggerKey = e, this.triggerModifier = _, this.triggerSideBySideKey = v, this.triggerSideBySideModifier = y;
	}
	equals(e) {
		return this.triggerKey === e.triggerKey && this.triggerModifier === e.triggerModifier && this.triggerSideBySideKey === e.triggerSideBySideKey && this.triggerSideBySideModifier === e.triggerSideBySideModifier;
	}
};
function createOptions(e) {
	return e === "altKey" ? isMacintosh ? new ClickLinkOptions(57, "metaKey", 6, "altKey") : new ClickLinkOptions(5, "ctrlKey", 6, "altKey") : isMacintosh ? new ClickLinkOptions(6, "altKey", 57, "metaKey") : new ClickLinkOptions(6, "altKey", 5, "ctrlKey");
}
var ClickLinkGesture = class extends Disposable {
	constructor(e, _) {
		super(), this._onMouseMoveOrRelevantKeyDown = this._register(new Emitter()), this.onMouseMoveOrRelevantKeyDown = this._onMouseMoveOrRelevantKeyDown.event, this._onExecute = this._register(new Emitter()), this.onExecute = this._onExecute.event, this._onCancel = this._register(new Emitter()), this.onCancel = this._onCancel.event, this._editor = e, this._extractLineNumberFromMouseEvent = _?.extractLineNumberFromMouseEvent ?? ((e) => e.target.position ? e.target.position.lineNumber : 0), this._opts = createOptions(this._editor.getOption(78)), this._lastMouseMoveEvent = null, this._hasTriggerKeyOnMouseDown = !1, this._lineNumberOnMouseDown = 0, this._register(this._editor.onDidChangeConfiguration((e) => {
			if (e.hasChanged(78)) {
				let e = createOptions(this._editor.getOption(78));
				if (this._opts.equals(e)) return;
				this._opts = e, this._lastMouseMoveEvent = null, this._hasTriggerKeyOnMouseDown = !1, this._lineNumberOnMouseDown = 0, this._onCancel.fire();
			}
		})), this._register(this._editor.onMouseMove((e) => this._onEditorMouseMove(new ClickLinkMouseEvent(e, this._opts)))), this._register(this._editor.onMouseDown((e) => this._onEditorMouseDown(new ClickLinkMouseEvent(e, this._opts)))), this._register(this._editor.onMouseUp((e) => this._onEditorMouseUp(new ClickLinkMouseEvent(e, this._opts)))), this._register(this._editor.onKeyDown((e) => this._onEditorKeyDown(new ClickLinkKeyboardEvent(e, this._opts)))), this._register(this._editor.onKeyUp((e) => this._onEditorKeyUp(new ClickLinkKeyboardEvent(e, this._opts)))), this._register(this._editor.onMouseDrag(() => this._resetHandler())), this._register(this._editor.onDidChangeCursorSelection((e) => this._onDidChangeCursorSelection(e))), this._register(this._editor.onDidChangeModel((e) => this._resetHandler())), this._register(this._editor.onDidChangeModelContent(() => this._resetHandler())), this._register(this._editor.onDidScrollChange((e) => {
			(e.scrollTopChanged || e.scrollLeftChanged) && this._resetHandler();
		}));
	}
	_onDidChangeCursorSelection(e) {
		e.selection && e.selection.startColumn !== e.selection.endColumn && this._resetHandler();
	}
	_onEditorMouseMove(e) {
		this._lastMouseMoveEvent = e, this._onMouseMoveOrRelevantKeyDown.fire([e, null]);
	}
	_onEditorMouseDown(e) {
		this._hasTriggerKeyOnMouseDown = e.hasTriggerModifier, this._lineNumberOnMouseDown = this._extractLineNumberFromMouseEvent(e);
	}
	_onEditorMouseUp(e) {
		let _ = this._extractLineNumberFromMouseEvent(e);
		this._hasTriggerKeyOnMouseDown && this._lineNumberOnMouseDown && this._lineNumberOnMouseDown === _ && this._onExecute.fire(e);
	}
	_onEditorKeyDown(e) {
		this._lastMouseMoveEvent && (e.keyCodeIsTriggerKey || e.keyCodeIsSideBySideKey && e.hasTriggerModifier) ? this._onMouseMoveOrRelevantKeyDown.fire([this._lastMouseMoveEvent, e]) : e.hasTriggerModifier && this._onCancel.fire();
	}
	_onEditorKeyUp(e) {
		e.keyCodeIsTriggerKey && this._onCancel.fire();
	}
	_resetHandler() {
		this._lastMouseMoveEvent = null, this._hasTriggerKeyOnMouseDown = !1, this._onCancel.fire();
	}
}, InlayHintAnchor = class {
	constructor(e, _) {
		this.range = e, this.direction = _;
	}
}, InlayHintItem = class e {
	constructor(e, _, v) {
		this.hint = e, this.anchor = _, this.provider = v, this._isResolved = !1;
	}
	with(_) {
		let v = new e(this.hint, _.anchor, this.provider);
		return v._isResolved = this._isResolved, v._currentResolve = this._currentResolve, v;
	}
	async resolve(e) {
		if (typeof this.provider.resolveInlayHint == "function") {
			if (this._currentResolve) return await this._currentResolve, e.isCancellationRequested ? void 0 : this.resolve(e);
			this._isResolved || (this._currentResolve = this._doResolve(e).finally(() => this._currentResolve = void 0)), await this._currentResolve;
		}
	}
	async _doResolve(e) {
		try {
			let _ = await Promise.resolve(this.provider.resolveInlayHint(this.hint, e));
			this.hint.tooltip = _?.tooltip ?? this.hint.tooltip, this.hint.label = _?.label ?? this.hint.label, this.hint.textEdits = _?.textEdits ?? this.hint.textEdits, this._isResolved = !0;
		} catch (e) {
			onUnexpectedExternalError(e), this._isResolved = !1;
		}
	}
}, InlayHintsFragments = class e {
	static {
		this._emptyInlayHintList = Object.freeze({
			dispose() {},
			hints: []
		});
	}
	static async create(_, v, y, b) {
		let x = [], S = _.ordered(v).reverse().map((_) => y.map(async (y) => {
			try {
				let S = await _.provideInlayHints(v, y, b);
				(S?.hints.length || _.onDidChangeInlayHints) && x.push([S ?? e._emptyInlayHintList, _]);
			} catch (e) {
				onUnexpectedExternalError(e);
			}
		}));
		if (await Promise.all(S.flat()), b.isCancellationRequested || v.isDisposed()) throw new CancellationError();
		return new e(y, x, v);
	}
	constructor(_, v, y) {
		this._disposables = new DisposableStore(), this.ranges = _, this.provider = /* @__PURE__ */ new Set();
		let b = [];
		for (let [_, x] of v) {
			this._disposables.add(_), this.provider.add(x);
			for (let v of _.hints) {
				let _ = y.validatePosition(v.position), S = "before", C = e._getRangeAtPosition(y, _), w;
				C.getStartPosition().isBefore(_) ? (w = Range.fromPositions(C.getStartPosition(), _), S = "after") : (w = Range.fromPositions(_, C.getEndPosition()), S = "before"), b.push(new InlayHintItem(v, new InlayHintAnchor(w, S), x));
			}
		}
		this.items = b.sort((e, _) => Position.compare(e.hint.position, _.hint.position));
	}
	dispose() {
		this._disposables.dispose();
	}
	static _getRangeAtPosition(e, _) {
		let v = _.lineNumber, y = e.getWordAtPosition(_);
		if (y) return new Range(v, y.startColumn, v, y.endColumn);
		e.tokenization.tokenizeIfCheap(v);
		let b = e.tokenization.getLineTokens(v), x = _.column - 1, S = b.findTokenIndexAtOffset(x), C = b.getStartOffset(S), w = b.getEndOffset(S);
		return w - C === 1 && (C === x && S > 1 ? (C = b.getStartOffset(S - 1), w = b.getEndOffset(S - 1)) : w === x && S < b.getCount() - 1 && (C = b.getStartOffset(S + 1), w = b.getEndOffset(S + 1))), new Range(v, C + 1, v, w + 1);
	}
};
function asCommandLink(e) {
	return URI.from({
		scheme: Schemas.command,
		path: e.id,
		query: e.arguments && encodeURIComponent(JSON.stringify(e.arguments))
	}).toString();
}
var __decorate$82 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$82 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, EmbeddedCodeEditorWidget = class extends CodeEditorWidget {
	constructor(e, _, v, y, b, x, S, C, w, T, E, D, O) {
		super(e, {
			...y.getRawOptions(),
			overflowWidgetsDomNode: y.getOverflowWidgetsDomNode()
		}, v, b, x, S, C, w, T, E, D, O), this._parentEditor = y, this._overwriteOptions = _, super.updateOptions(this._overwriteOptions), this._register(y.onDidChangeConfiguration((e) => this._onParentConfigurationChanged(e)));
	}
	getParentEditor() {
		return this._parentEditor;
	}
	_onParentConfigurationChanged(e) {
		super.updateOptions(this._parentEditor.getRawOptions()), super.updateOptions(this._overwriteOptions);
	}
	updateOptions(e) {
		mixin(this._overwriteOptions, e, !0), super.updateOptions(this._overwriteOptions);
	}
};
EmbeddedCodeEditorWidget = __decorate$82([
	__param$82(4, IInstantiationService),
	__param$82(5, ICodeEditorService),
	__param$82(6, ICommandService),
	__param$82(7, IContextKeyService),
	__param$82(8, IThemeService),
	__param$82(9, INotificationService),
	__param$82(10, IAccessibilityService),
	__param$82(11, ILanguageConfigurationService),
	__param$82(12, ILanguageFeaturesService)
], EmbeddedCodeEditorWidget);
var defaultColor = new Color(new RGBA(0, 122, 204)), defaultOptions$1 = {
	showArrow: !0,
	showFrame: !0,
	className: "",
	frameColor: defaultColor,
	arrowColor: defaultColor,
	keepEditorSelection: !1
}, WIDGET_ID = "vs.editor.contrib.zoneWidget", ViewZoneDelegate = class {
	constructor(e, _, v, y, b, x, S, C) {
		this.id = "", this.domNode = e, this.afterLineNumber = _, this.afterColumn = v, this.heightInLines = y, this.showInHiddenAreas = S, this.ordinal = C, this._onDomNodeTop = b, this._onComputedHeight = x;
	}
	onDomNodeTop(e) {
		this._onDomNodeTop(e);
	}
	onComputedHeight(e) {
		this._onComputedHeight(e);
	}
}, OverlayWidgetDelegate = class {
	constructor(e, _) {
		this._id = e, this._domNode = _;
	}
	getId() {
		return this._id;
	}
	getDomNode() {
		return this._domNode;
	}
	getPosition() {
		return null;
	}
}, Arrow = class e {
	static {
		this._IdGenerator = new IdGenerator(".arrow-decoration-");
	}
	constructor(_) {
		this._editor = _, this._ruleName = e._IdGenerator.nextId(), this._decorations = this._editor.createDecorationsCollection(), this._color = null, this._height = -1;
	}
	dispose() {
		this.hide(), removeCSSRulesContainingSelector(this._ruleName);
	}
	set color(e) {
		this._color !== e && (this._color = e, this._updateStyle());
	}
	set height(e) {
		this._height !== e && (this._height = e, this._updateStyle());
	}
	_updateStyle() {
		removeCSSRulesContainingSelector(this._ruleName), createCSSRule(`.monaco-editor ${this._ruleName}`, `border-style: solid; border-color: transparent; border-bottom-color: ${this._color}; border-width: ${this._height}px; bottom: -${this._height}px !important; margin-left: -${this._height}px; `);
	}
	show(e) {
		e.column === 1 && (e = {
			lineNumber: e.lineNumber,
			column: 2
		}), this._decorations.set([{
			range: Range.fromPositions(e),
			options: {
				description: "zone-widget-arrow",
				className: this._ruleName,
				stickiness: 1
			}
		}]);
	}
	hide() {
		this._decorations.clear();
	}
}, ZoneWidget = class {
	constructor(e, _ = {}) {
		this._arrow = null, this._overlayWidget = null, this._resizeSash = null, this._viewZone = null, this._disposables = new DisposableStore(), this.container = null, this._isShowing = !1, this.editor = e, this._positionMarkerId = this.editor.createDecorationsCollection(), this.options = deepClone(_), mixin(this.options, defaultOptions$1, !1), this.domNode = document.createElement("div"), this.options.isAccessible || (this.domNode.setAttribute("aria-hidden", "true"), this.domNode.setAttribute("role", "presentation")), this._disposables.add(this.editor.onDidLayoutChange((e) => {
			let _ = this._getWidth(e);
			this.domNode.style.width = _ + "px", this.domNode.style.left = this._getLeft(e) + "px", this._onWidth(_);
		}));
	}
	dispose() {
		this._overlayWidget &&= (this.editor.removeOverlayWidget(this._overlayWidget), null), this._viewZone && this.editor.changeViewZones((e) => {
			this._viewZone && e.removeZone(this._viewZone.id), this._viewZone = null;
		}), this._positionMarkerId.clear(), this._disposables.dispose();
	}
	create() {
		this.domNode.classList.add("zone-widget"), this.options.className && this.domNode.classList.add(this.options.className), this.container = document.createElement("div"), this.container.classList.add("zone-widget-container"), this.domNode.appendChild(this.container), this.options.showArrow && (this._arrow = new Arrow(this.editor), this._disposables.add(this._arrow)), this._fillContainer(this.container), this._initSash(), this._applyStyles();
	}
	style(e) {
		e.frameColor && (this.options.frameColor = e.frameColor), e.arrowColor && (this.options.arrowColor = e.arrowColor), this._applyStyles();
	}
	_applyStyles() {
		if (this.container && this.options.frameColor) {
			let e = this.options.frameColor.toString();
			this.container.style.borderTopColor = e, this.container.style.borderBottomColor = e;
		}
		if (this._arrow && this.options.arrowColor) {
			let e = this.options.arrowColor.toString();
			this._arrow.color = e;
		}
	}
	_getWidth(e) {
		return e.width - e.minimap.minimapWidth - e.verticalScrollbarWidth;
	}
	_getLeft(e) {
		return e.minimap.minimapWidth > 0 && e.minimap.minimapLeft === 0 ? e.minimap.minimapWidth : 0;
	}
	_onViewZoneTop(e) {
		this.domNode.style.top = e + "px";
	}
	_onViewZoneHeight(e) {
		if (this.domNode.style.height = `${e}px`, this.container) {
			let _ = e - this._decoratingElementsHeight();
			this.container.style.height = `${_}px`;
			let v = this.editor.getLayoutInfo();
			this._doLayout(_, this._getWidth(v));
		}
		this._resizeSash?.layout();
	}
	get position() {
		let e = this._positionMarkerId.getRange(0);
		if (e) return e.getStartPosition();
	}
	show(e, _) {
		let v = Range.isIRange(e) ? Range.lift(e) : Range.fromPositions(e);
		this._isShowing = !0, this._showImpl(v, _), this._isShowing = !1, this._positionMarkerId.set([{
			range: v,
			options: ModelDecorationOptions.EMPTY
		}]);
	}
	hide() {
		this._viewZone &&= (this.editor.changeViewZones((e) => {
			this._viewZone && e.removeZone(this._viewZone.id);
		}), null), this._overlayWidget &&= (this.editor.removeOverlayWidget(this._overlayWidget), null), this._arrow?.hide(), this._positionMarkerId.clear();
	}
	_decoratingElementsHeight() {
		let e = this.editor.getOption(67), _ = 0;
		if (this.options.showArrow) {
			let v = Math.round(e / 3);
			_ += 2 * v;
		}
		if (this.options.showFrame) {
			let v = Math.round(e / 9);
			_ += 2 * v;
		}
		return _;
	}
	_showImpl(e, _) {
		let v = e.getStartPosition(), y = this.editor.getLayoutInfo(), b = this._getWidth(y);
		this.domNode.style.width = `${b}px`, this.domNode.style.left = this._getLeft(y) + "px";
		let x = document.createElement("div");
		x.style.overflow = "hidden";
		let S = this.editor.getOption(67);
		if (!this.options.allowUnlimitedHeight) {
			let e = Math.max(12, this.editor.getLayoutInfo().height / S * .8);
			_ = Math.min(_, e);
		}
		let C = 0, w = 0;
		if (this._arrow && this.options.showArrow && (C = Math.round(S / 3), this._arrow.height = C, this._arrow.show(v)), this.options.showFrame && (w = Math.round(S / 9)), this.editor.changeViewZones((e) => {
			this._viewZone && e.removeZone(this._viewZone.id), this._overlayWidget &&= (this.editor.removeOverlayWidget(this._overlayWidget), null), this.domNode.style.top = "-1000px", this._viewZone = new ViewZoneDelegate(x, v.lineNumber, v.column, _, (e) => this._onViewZoneTop(e), (e) => this._onViewZoneHeight(e), this.options.showInHiddenAreas, this.options.ordinal), this._viewZone.id = e.addZone(this._viewZone), this._overlayWidget = new OverlayWidgetDelegate(WIDGET_ID + this._viewZone.id, this.domNode), this.editor.addOverlayWidget(this._overlayWidget);
		}), this.container && this.options.showFrame) {
			let e = this.options.frameWidth ? this.options.frameWidth : w;
			this.container.style.borderTopWidth = e + "px", this.container.style.borderBottomWidth = e + "px";
		}
		let T = _ * S - this._decoratingElementsHeight();
		this.container && (this.container.style.top = C + "px", this.container.style.height = T + "px", this.container.style.overflow = "hidden"), this._doLayout(T, b), this.options.keepEditorSelection || this.editor.setSelection(e);
		let E = this.editor.getModel();
		if (E) {
			let _ = E.validateRange(new Range(e.startLineNumber, 1, e.endLineNumber + 1, 1));
			this.revealRange(_, _.startLineNumber === E.getLineCount());
		}
	}
	revealRange(e, _) {
		_ ? this.editor.revealLineNearTop(e.endLineNumber, 0) : this.editor.revealRange(e, 0);
	}
	setCssClass(e, _) {
		this.container && (_ && this.container.classList.remove(_), this.container.classList.add(e));
	}
	_onWidth(e) {}
	_doLayout(e, _) {}
	_relayout(e) {
		this._viewZone && this._viewZone.heightInLines !== e && this.editor.changeViewZones((_) => {
			this._viewZone && (this._viewZone.heightInLines = e, _.layoutZone(this._viewZone.id));
		});
	}
	_initSash() {
		if (this._resizeSash) return;
		this._resizeSash = this._disposables.add(new Sash(this.domNode, this, { orientation: 1 })), this.options.isResizeable || (this._resizeSash.state = 0);
		let e;
		this._disposables.add(this._resizeSash.onDidStart((_) => {
			this._viewZone && (e = {
				startY: _.startY,
				heightInLines: this._viewZone.heightInLines
			});
		})), this._disposables.add(this._resizeSash.onDidEnd(() => {
			e = void 0;
		})), this._disposables.add(this._resizeSash.onDidChange((_) => {
			if (e) {
				let v = (_.currentY - e.startY) / this.editor.getOption(67), y = v < 0 ? Math.ceil(v) : Math.floor(v), b = e.heightInLines + y;
				b > 5 && b < 35 && this._relayout(b);
			}
		}));
	}
	getHorizontalSashLeft() {
		return 0;
	}
	getHorizontalSashTop() {
		return (this.domNode.style.height === null ? 0 : parseInt(this.domNode.style.height)) - this._decoratingElementsHeight() / 2;
	}
	getHorizontalSashWidth() {
		let e = this.editor.getLayoutInfo();
		return e.width - e.minimap.minimapWidth;
	}
}, __decorate$81 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$81 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const IPeekViewService = createDecorator("IPeekViewService");
registerSingleton(IPeekViewService, class {
	constructor() {
		this._widgets = /* @__PURE__ */ new Map();
	}
	addExclusiveWidget(e, _) {
		let v = this._widgets.get(e);
		v && (v.listener.dispose(), v.widget.dispose()), this._widgets.set(e, {
			widget: _,
			listener: _.onDidClose(() => {
				let v = this._widgets.get(e);
				v && v.widget === _ && (v.listener.dispose(), this._widgets.delete(e));
			})
		});
	}
}, 1);
var PeekContext;
(function(e) {
	e.inPeekEditor = new RawContextKey("inReferenceSearchEditor", !0, localize("inReferenceSearchEditor", "Whether the current code editor is embedded inside peek")), e.notInPeekEditor = e.inPeekEditor.toNegated();
})(PeekContext ||= {});
var PeekContextController = class {
	static {
		this.ID = "editor.contrib.referenceController";
	}
	constructor(e, _) {
		e instanceof EmbeddedCodeEditorWidget && PeekContext.inPeekEditor.bindTo(_);
	}
	dispose() {}
};
PeekContextController = __decorate$81([__param$81(1, IContextKeyService)], PeekContextController), registerEditorContribution(PeekContextController.ID, PeekContextController, 0);
function getOuterEditor(e) {
	let _ = e.get(ICodeEditorService).getFocusedCodeEditor();
	return _ instanceof EmbeddedCodeEditorWidget ? _.getParentEditor() : _;
}
var defaultOptions = {
	headerBackgroundColor: Color.white,
	primaryHeadingColor: Color.fromHex("#333333"),
	secondaryHeadingColor: Color.fromHex("#6c6c6cb3")
}, PeekViewWidget = class extends ZoneWidget {
	constructor(e, _, v) {
		super(e, _), this.instantiationService = v, this._onDidClose = new Emitter(), this.onDidClose = this._onDidClose.event, mixin(this.options, defaultOptions, !1);
	}
	dispose() {
		this.disposed || (this.disposed = !0, super.dispose(), this._onDidClose.fire(this));
	}
	style(e) {
		let _ = this.options;
		e.headerBackgroundColor && (_.headerBackgroundColor = e.headerBackgroundColor), e.primaryHeadingColor && (_.primaryHeadingColor = e.primaryHeadingColor), e.secondaryHeadingColor && (_.secondaryHeadingColor = e.secondaryHeadingColor), super.style(e);
	}
	_applyStyles() {
		super._applyStyles();
		let e = this.options;
		this._headElement && e.headerBackgroundColor && (this._headElement.style.backgroundColor = e.headerBackgroundColor.toString()), this._primaryHeading && e.primaryHeadingColor && (this._primaryHeading.style.color = e.primaryHeadingColor.toString()), this._secondaryHeading && e.secondaryHeadingColor && (this._secondaryHeading.style.color = e.secondaryHeadingColor.toString()), this._bodyElement && e.frameColor && (this._bodyElement.style.borderColor = e.frameColor.toString());
	}
	_fillContainer(e) {
		this.setCssClass("peekview-widget"), this._headElement = $(".head"), this._bodyElement = $(".body"), this._fillHead(this._headElement), this._fillBody(this._bodyElement), e.appendChild(this._headElement), e.appendChild(this._bodyElement);
	}
	_fillHead(e, _) {
		this._titleElement = $(".peekview-title"), this.options.supportOnTitleClick && (this._titleElement.classList.add("clickable"), addStandardDisposableListener(this._titleElement, "click", (e) => this._onTitleClick(e))), append(this._headElement, this._titleElement), this._fillTitleIcon(this._titleElement), this._primaryHeading = $("span.filename"), this._secondaryHeading = $("span.dirname"), this._metaHeading = $("span.meta"), append(this._titleElement, this._primaryHeading, this._secondaryHeading, this._metaHeading);
		let v = $(".peekview-actions");
		append(this._headElement, v);
		let y = this._getActionBarOptions();
		this._actionbarWidget = new ActionBar(v, y), this._disposables.add(this._actionbarWidget), _ || this._actionbarWidget.push(new Action("peekview.close", localize("label.close", "Close"), ThemeIcon.asClassName(Codicon.close), !0, () => (this.dispose(), Promise.resolve())), {
			label: !1,
			icon: !0
		});
	}
	_fillTitleIcon(e) {}
	_getActionBarOptions() {
		return {
			actionViewItemProvider: createActionViewItem.bind(void 0, this.instantiationService),
			orientation: 0
		};
	}
	_onTitleClick(e) {}
	setTitle(e, _) {
		this._primaryHeading && this._secondaryHeading && (this._primaryHeading.innerText = e, this._primaryHeading.setAttribute("title", e), _ ? this._secondaryHeading.innerText = _ : clearNode(this._secondaryHeading));
	}
	setMetaTitle(e) {
		this._metaHeading && (e ? (this._metaHeading.innerText = e, show(this._metaHeading)) : hide(this._metaHeading));
	}
	_doLayout(e, _) {
		if (!this._isShowing && e < 0) {
			this.dispose();
			return;
		}
		let v = Math.ceil(this.editor.getOption(67) * 1.2), y = Math.round(e - (v + 2));
		this._doLayoutHead(v, _), this._doLayoutBody(y, _);
	}
	_doLayoutHead(e, _) {
		this._headElement && (this._headElement.style.height = `${e}px`, this._headElement.style.lineHeight = this._headElement.style.height);
	}
	_doLayoutBody(e, _) {
		this._bodyElement && (this._bodyElement.style.height = `${e}px`);
	}
};
PeekViewWidget = __decorate$81([__param$81(2, IInstantiationService)], PeekViewWidget);
const peekViewTitleBackground = registerColor("peekViewTitle.background", {
	dark: "#252526",
	light: "#F3F3F3",
	hcDark: Color.black,
	hcLight: Color.white
}, localize("peekViewTitleBackground", "Background color of the peek view title area.")), peekViewTitleForeground = registerColor("peekViewTitleLabel.foreground", {
	dark: Color.white,
	light: Color.black,
	hcDark: Color.white,
	hcLight: editorForeground
}, localize("peekViewTitleForeground", "Color of the peek view title.")), peekViewTitleInfoForeground = registerColor("peekViewTitleDescription.foreground", {
	dark: "#ccccccb3",
	light: "#616161",
	hcDark: "#FFFFFF99",
	hcLight: "#292929"
}, localize("peekViewTitleInfoForeground", "Color of the peek view title info.")), peekViewBorder = registerColor("peekView.border", {
	dark: editorInfoForeground,
	light: editorInfoForeground,
	hcDark: contrastBorder,
	hcLight: contrastBorder
}, localize("peekViewBorder", "Color of the peek view borders and arrow.")), peekViewResultsBackground = registerColor("peekViewResult.background", {
	dark: "#252526",
	light: "#F3F3F3",
	hcDark: Color.black,
	hcLight: Color.white
}, localize("peekViewResultsBackground", "Background color of the peek view result list."));
registerColor("peekViewResult.lineForeground", {
	dark: "#bbbbbb",
	light: "#646465",
	hcDark: Color.white,
	hcLight: editorForeground
}, localize("peekViewResultsMatchForeground", "Foreground color for line nodes in the peek view result list.")), registerColor("peekViewResult.fileForeground", {
	dark: Color.white,
	light: "#1E1E1E",
	hcDark: Color.white,
	hcLight: editorForeground
}, localize("peekViewResultsFileForeground", "Foreground color for file nodes in the peek view result list.")), registerColor("peekViewResult.selectionBackground", {
	dark: "#3399ff33",
	light: "#3399ff33",
	hcDark: null,
	hcLight: null
}, localize("peekViewResultsSelectionBackground", "Background color of the selected entry in the peek view result list.")), registerColor("peekViewResult.selectionForeground", {
	dark: Color.white,
	light: "#6C6C6C",
	hcDark: Color.white,
	hcLight: editorForeground
}, localize("peekViewResultsSelectionForeground", "Foreground color of the selected entry in the peek view result list."));
const peekViewEditorBackground = registerColor("peekViewEditor.background", {
	dark: "#001F33",
	light: "#F2F8FC",
	hcDark: Color.black,
	hcLight: Color.white
}, localize("peekViewEditorBackground", "Background color of the peek view editor."));
registerColor("peekViewEditorGutter.background", peekViewEditorBackground, localize("peekViewEditorGutterBackground", "Background color of the gutter in the peek view editor.")), registerColor("peekViewEditorStickyScroll.background", peekViewEditorBackground, localize("peekViewEditorStickScrollBackground", "Background color of sticky scroll in the peek view editor.")), registerColor("peekViewResult.matchHighlightBackground", {
	dark: "#ea5c004d",
	light: "#ea5c004d",
	hcDark: null,
	hcLight: null
}, localize("peekViewResultsMatchHighlight", "Match highlight color in the peek view result list.")), registerColor("peekViewEditor.matchHighlightBackground", {
	dark: "#ff8f0099",
	light: "#f5d802de",
	hcDark: null,
	hcLight: null
}, localize("peekViewEditorMatchHighlight", "Match highlight color in the peek view editor.")), registerColor("peekViewEditor.matchHighlightBorder", {
	dark: null,
	light: null,
	hcDark: activeContrastBorder,
	hcLight: activeContrastBorder
}, localize("peekViewEditorMatchHighlightBorder", "Match highlight border in the peek view editor."));
var OneReference = class {
	constructor(e, _, v, y) {
		this.isProviderFirst = e, this.parent = _, this.link = v, this._rangeCallback = y, this.id = defaultGenerator.nextId();
	}
	get uri() {
		return this.link.uri;
	}
	get range() {
		return this._range ?? this.link.targetSelectionRange ?? this.link.range;
	}
	set range(e) {
		this._range = e, this._rangeCallback(this);
	}
	get ariaMessage() {
		let e = this.parent.getPreview(this)?.preview(this.range);
		return e ? localize({
			key: "aria.oneReference.preview",
			comment: ["Placeholders are: 0: filename, 1:line number, 2: column number, 3: preview snippet of source code"]
		}, "{0} in {1} on line {2} at column {3}", e.value, basename(this.uri), this.range.startLineNumber, this.range.startColumn) : localize("aria.oneReference", "in {0} on line {1} at column {2}", basename(this.uri), this.range.startLineNumber, this.range.startColumn);
	}
}, FilePreview = class {
	constructor(e) {
		this._modelReference = e;
	}
	dispose() {
		this._modelReference.dispose();
	}
	preview(e, _ = 8) {
		let v = this._modelReference.object.textEditorModel;
		if (!v) return;
		let { startLineNumber: y, startColumn: b, endLineNumber: x, endColumn: S } = e, C = v.getWordUntilPosition({
			lineNumber: y,
			column: b - _
		}), w = new Range(y, C.startColumn, y, b), T = new Range(x, S, x, 1073741824), E = v.getValueInRange(w).replace(/^\s+/, ""), D = v.getValueInRange(e), O = v.getValueInRange(T).replace(/\s+$/, "");
		return {
			value: E + D + O,
			highlight: {
				start: E.length,
				end: E.length + D.length
			}
		};
	}
}, FileReferences = class {
	constructor(e, _) {
		this.parent = e, this.uri = _, this.children = [], this._previews = new ResourceMap();
	}
	dispose() {
		dispose(this._previews.values()), this._previews.clear();
	}
	getPreview(e) {
		return this._previews.get(e.uri);
	}
	get ariaMessage() {
		let e = this.children.length;
		return e === 1 ? localize("aria.fileReferences.1", "1 symbol in {0}, full path {1}", basename(this.uri), this.uri.fsPath) : localize("aria.fileReferences.N", "{0} symbols in {1}, full path {2}", e, basename(this.uri), this.uri.fsPath);
	}
	async resolve(e) {
		if (this._previews.size !== 0) return this;
		for (let _ of this.children) if (!this._previews.has(_.uri)) try {
			let v = await e.createModelReference(_.uri);
			this._previews.set(_.uri, new FilePreview(v));
		} catch (e) {
			onUnexpectedError(e);
		}
		return this;
	}
}, ReferencesModel = class e {
	constructor(_, v) {
		this.groups = [], this.references = [], this._onDidChangeReferenceRange = new Emitter(), this.onDidChangeReferenceRange = this._onDidChangeReferenceRange.event, this._links = _, this._title = v;
		let [y] = _;
		_.sort(e._compareReferences);
		let b;
		for (let v of _) if ((!b || !extUri.isEqual(b.uri, v.uri, !0)) && (b = new FileReferences(this, v.uri), this.groups.push(b)), b.children.length === 0 || e._compareReferences(v, b.children[b.children.length - 1]) !== 0) {
			let e = new OneReference(y === v, b, v, (e) => this._onDidChangeReferenceRange.fire(e));
			this.references.push(e), b.children.push(e);
		}
	}
	dispose() {
		dispose(this.groups), this._onDidChangeReferenceRange.dispose(), this.groups.length = 0;
	}
	clone() {
		return new e(this._links, this._title);
	}
	get title() {
		return this._title;
	}
	get isEmpty() {
		return this.groups.length === 0;
	}
	get ariaMessage() {
		return this.isEmpty ? localize("aria.result.0", "No results found") : this.references.length === 1 ? localize("aria.result.1", "Found 1 symbol in {0}", this.references[0].uri.fsPath) : this.groups.length === 1 ? localize("aria.result.n1", "Found {0} symbols in {1}", this.references.length, this.groups[0].uri.fsPath) : localize("aria.result.nm", "Found {0} symbols in {1} files", this.references.length, this.groups.length);
	}
	nextOrPreviousReference(e, _) {
		let { parent: v } = e, y = v.children.indexOf(e), b = v.children.length, x = v.parent.groups.length;
		return x === 1 || _ && y + 1 < b || !_ && y > 0 ? (y = _ ? (y + 1) % b : (y + b - 1) % b, v.children[y]) : (y = v.parent.groups.indexOf(v), _ ? (y = (y + 1) % x, v.parent.groups[y].children[0]) : (y = (y + x - 1) % x, v.parent.groups[y].children[v.parent.groups[y].children.length - 1]));
	}
	nearestReference(e, _) {
		let v = this.references.map((v, y) => ({
			idx: y,
			prefixLen: commonPrefixLength(v.uri.toString(), e.toString()),
			offsetDist: Math.abs(v.range.startLineNumber - _.lineNumber) * 100 + Math.abs(v.range.startColumn - _.column)
		})).sort((e, _) => e.prefixLen > _.prefixLen ? -1 : e.prefixLen < _.prefixLen ? 1 : e.offsetDist < _.offsetDist ? -1 : e.offsetDist > _.offsetDist ? 1 : 0)[0];
		if (v) return this.references[v.idx];
	}
	referenceAt(e, _) {
		for (let v of this.references) if (v.uri.toString() === e.toString() && Range.containsPosition(v.range, _)) return v;
	}
	firstReference() {
		for (let e of this.references) if (e.isProviderFirst) return e;
		return this.references[0];
	}
	static _compareReferences(e, _) {
		return extUri.compare(e.uri, _.uri) || Range.compareRangesUsingStarts(e.range, _.range);
	}
}, __decorate$80 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$80 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, FileReferencesRenderer_1, DataSource = class {
	constructor(e) {
		this._resolverService = e;
	}
	hasChildren(e) {
		return e instanceof ReferencesModel || e instanceof FileReferences;
	}
	getChildren(e) {
		if (e instanceof ReferencesModel) return e.groups;
		if (e instanceof FileReferences) return e.resolve(this._resolverService).then((e) => e.children);
		throw Error("bad tree");
	}
};
DataSource = __decorate$80([__param$80(0, ITextModelService)], DataSource);
var Delegate = class {
	getHeight() {
		return 23;
	}
	getTemplateId(e) {
		return e instanceof FileReferences ? FileReferencesRenderer.id : OneReferenceRenderer.id;
	}
}, StringRepresentationProvider = class {
	constructor(e) {
		this._keybindingService = e;
	}
	getKeyboardNavigationLabel(e) {
		if (e instanceof OneReference) {
			let _ = e.parent.getPreview(e)?.preview(e.range);
			if (_) return _.value;
		}
		return basename(e.uri);
	}
};
StringRepresentationProvider = __decorate$80([__param$80(0, IKeybindingService)], StringRepresentationProvider);
var IdentityProvider = class {
	getId(e) {
		return e instanceof OneReference ? e.id : e.uri;
	}
}, FileReferencesTemplate = class extends Disposable {
	constructor(e, _) {
		super(), this._labelService = _;
		let v = document.createElement("div");
		v.classList.add("reference-file"), this.file = this._register(new IconLabel(v, { supportHighlights: !0 })), this.badge = new CountBadge(append(v, $(".count")), {}, defaultCountBadgeStyles), e.appendChild(v);
	}
	set(e, _) {
		let v = dirname(e.uri);
		this.file.setLabel(this._labelService.getUriBasenameLabel(e.uri), this._labelService.getUriLabel(v, { relative: !0 }), {
			title: this._labelService.getUriLabel(e.uri),
			matches: _
		});
		let y = e.children.length;
		this.badge.setCount(y), y > 1 ? this.badge.setTitleFormat(localize("referencesCount", "{0} references", y)) : this.badge.setTitleFormat(localize("referenceCount", "{0} reference", y));
	}
};
FileReferencesTemplate = __decorate$80([__param$80(1, ILabelService)], FileReferencesTemplate);
var FileReferencesRenderer = class {
	static {
		FileReferencesRenderer_1 = this;
	}
	static {
		this.id = "FileReferencesRenderer";
	}
	constructor(e) {
		this._instantiationService = e, this.templateId = FileReferencesRenderer_1.id;
	}
	renderTemplate(e) {
		return this._instantiationService.createInstance(FileReferencesTemplate, e);
	}
	renderElement(e, _, v) {
		v.set(e.element, createMatches(e.filterData));
	}
	disposeTemplate(e) {
		e.dispose();
	}
};
FileReferencesRenderer = FileReferencesRenderer_1 = __decorate$80([__param$80(0, IInstantiationService)], FileReferencesRenderer);
var OneReferenceTemplate = class extends Disposable {
	constructor(e) {
		super(), this.label = this._register(new HighlightedLabel(e));
	}
	set(e, _) {
		let v = e.parent.getPreview(e)?.preview(e.range);
		if (!v || !v.value) this.label.set(`${basename(e.uri)}:${e.range.startLineNumber + 1}:${e.range.startColumn + 1}`);
		else {
			let { value: e, highlight: y } = v;
			_ && !FuzzyScore.isDefault(_) ? (this.label.element.classList.toggle("referenceMatch", !1), this.label.set(e, createMatches(_))) : (this.label.element.classList.toggle("referenceMatch", !0), this.label.set(e, [y]));
		}
	}
}, OneReferenceRenderer = class e {
	constructor() {
		this.templateId = e.id;
	}
	static {
		this.id = "OneReferenceRenderer";
	}
	renderTemplate(e) {
		return new OneReferenceTemplate(e);
	}
	renderElement(e, _, v) {
		v.set(e.element, e.filterData);
	}
	disposeTemplate(e) {
		e.dispose();
	}
}, AccessibilityProvider = class {
	getWidgetAriaLabel() {
		return localize("treeAriaLabel", "References");
	}
	getAriaLabel(e) {
		return e.ariaMessage;
	}
}, __decorate$79 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$79 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, DecorationsManager = class e {
	static {
		this.DecorationOptions = ModelDecorationOptions.register({
			description: "reference-decoration",
			stickiness: 1,
			className: "reference-decoration"
		});
	}
	constructor(e, _) {
		this._editor = e, this._model = _, this._decorations = /* @__PURE__ */ new Map(), this._decorationIgnoreSet = /* @__PURE__ */ new Set(), this._callOnDispose = new DisposableStore(), this._callOnModelChange = new DisposableStore(), this._callOnDispose.add(this._editor.onDidChangeModel(() => this._onModelChanged())), this._onModelChanged();
	}
	dispose() {
		this._callOnModelChange.dispose(), this._callOnDispose.dispose(), this.removeDecorations();
	}
	_onModelChanged() {
		this._callOnModelChange.clear();
		let e = this._editor.getModel();
		if (e) {
			for (let _ of this._model.references) if (_.uri.toString() === e.uri.toString()) {
				this._addDecorations(_.parent);
				return;
			}
		}
	}
	_addDecorations(_) {
		if (!this._editor.hasModel()) return;
		this._callOnModelChange.add(this._editor.getModel().onDidChangeDecorations(() => this._onDecorationChanged()));
		let v = [], y = [];
		for (let b = 0, x = _.children.length; b < x; b++) {
			let x = _.children[b];
			this._decorationIgnoreSet.has(x.id) || x.uri.toString() === this._editor.getModel().uri.toString() && (v.push({
				range: x.range,
				options: e.DecorationOptions
			}), y.push(b));
		}
		this._editor.changeDecorations((e) => {
			let b = e.deltaDecorations([], v);
			for (let e = 0; e < b.length; e++) this._decorations.set(b[e], _.children[y[e]]);
		});
	}
	_onDecorationChanged() {
		let e = [], _ = this._editor.getModel();
		if (_) {
			for (let [v, y] of this._decorations) {
				let b = _.getDecorationRange(v);
				if (!b) continue;
				let x = !1;
				if (!Range.equalsRange(b, y.range)) {
					if (Range.spansMultipleLines(b)) x = !0;
					else {
						let e = y.range.endColumn - y.range.startColumn, _ = b.endColumn - b.startColumn;
						e !== _ && (x = !0);
					}
					x ? (this._decorationIgnoreSet.add(y.id), e.push(v)) : y.range = b;
				}
			}
			for (let _ = 0, v = e.length; _ < v; _++) this._decorations.delete(e[_]);
			this._editor.removeDecorations(e);
		}
	}
	removeDecorations() {
		this._editor.removeDecorations([...this._decorations.keys()]), this._decorations.clear();
	}
}, LayoutData = class {
	constructor() {
		this.ratio = .7, this.heightInLines = 18;
	}
	static fromJSON(e) {
		let _, v;
		try {
			let y = JSON.parse(e);
			_ = y.ratio, v = y.heightInLines;
		} catch {}
		return {
			ratio: _ || .7,
			heightInLines: v || 18
		};
	}
}, ReferencesTree = class extends WorkbenchAsyncDataTree {}, ReferenceWidget = class extends PeekViewWidget {
	constructor(e, _, v, y, b, x, S, C, w) {
		super(e, {
			showFrame: !1,
			showArrow: !0,
			isResizeable: !0,
			isAccessible: !0,
			supportOnTitleClick: !0
		}, x), this._defaultTreeKeyboardSupport = _, this.layoutData = v, this._textModelResolverService = b, this._instantiationService = x, this._peekViewService = S, this._uriLabel = C, this._keybindingService = w, this._disposeOnNewModel = new DisposableStore(), this._callOnDispose = new DisposableStore(), this._onDidSelectReference = new Emitter(), this.onDidSelectReference = this._onDidSelectReference.event, this._dim = new Dimension(0, 0), this._isClosing = !1, this._applyTheme(y.getColorTheme()), this._callOnDispose.add(y.onDidColorThemeChange(this._applyTheme.bind(this))), this._peekViewService.addExclusiveWidget(e, this), this.create();
	}
	get isClosing() {
		return this._isClosing;
	}
	dispose() {
		this._isClosing = !0, this.setModel(void 0), this._callOnDispose.dispose(), this._disposeOnNewModel.dispose(), dispose(this._preview), dispose(this._previewNotAvailableMessage), dispose(this._tree), dispose(this._previewModelReference), this._splitView.dispose(), super.dispose();
	}
	_applyTheme(e) {
		let _ = e.getColor(peekViewBorder) || Color.transparent;
		this.style({
			arrowColor: _,
			frameColor: _,
			headerBackgroundColor: e.getColor(peekViewTitleBackground) || Color.transparent,
			primaryHeadingColor: e.getColor(peekViewTitleForeground),
			secondaryHeadingColor: e.getColor(peekViewTitleInfoForeground)
		});
	}
	show(e) {
		super.show(e, this.layoutData.heightInLines || 18);
	}
	focusOnReferenceTree() {
		this._tree.domFocus();
	}
	focusOnPreviewEditor() {
		this._preview.focus();
	}
	isPreviewEditorFocused() {
		return this._preview.hasTextFocus();
	}
	_onTitleClick(e) {
		this._preview && this._preview.getModel() && this._onDidSelectReference.fire({
			element: this._getFocusedReference(),
			kind: e.ctrlKey || e.metaKey || e.altKey ? "side" : "open",
			source: "title"
		});
	}
	_fillBody(e) {
		this.setCssClass("reference-zone-widget"), this._messageContainer = append(e, $("div.messages")), hide(this._messageContainer), this._splitView = new SplitView(e, { orientation: 1 }), this._previewContainer = append(e, $("div.preview.inline")), this._preview = this._instantiationService.createInstance(EmbeddedCodeEditorWidget, this._previewContainer, {
			scrollBeyondLastLine: !1,
			scrollbar: {
				verticalScrollbarSize: 14,
				horizontal: "auto",
				useShadows: !0,
				verticalHasArrows: !1,
				horizontalHasArrows: !1,
				alwaysConsumeMouseWheel: !0
			},
			overviewRulerLanes: 2,
			fixedOverflowWidgets: !0,
			minimap: { enabled: !1 }
		}, {}, this.editor), hide(this._previewContainer), this._previewNotAvailableMessage = this._instantiationService.createInstance(TextModel, localize("missingPreviewMessage", "no preview available"), PLAINTEXT_LANGUAGE_ID, TextModel.DEFAULT_CREATION_OPTIONS, null), this._treeContainer = append(e, $("div.ref-tree.inline"));
		let _ = {
			keyboardSupport: this._defaultTreeKeyboardSupport,
			accessibilityProvider: new AccessibilityProvider(),
			keyboardNavigationLabelProvider: this._instantiationService.createInstance(StringRepresentationProvider),
			identityProvider: new IdentityProvider(),
			openOnSingleClick: !0,
			selectionNavigation: !0,
			overrideStyles: { listBackground: peekViewResultsBackground }
		};
		this._defaultTreeKeyboardSupport && this._callOnDispose.add(addStandardDisposableListener(this._treeContainer, "keydown", (e) => {
			e.equals(9) && (this._keybindingService.dispatchEvent(e, e.target), e.stopPropagation());
		}, !0)), this._tree = this._instantiationService.createInstance(ReferencesTree, "ReferencesWidget", this._treeContainer, new Delegate(), [this._instantiationService.createInstance(FileReferencesRenderer), this._instantiationService.createInstance(OneReferenceRenderer)], this._instantiationService.createInstance(DataSource), _), this._splitView.addView({
			onDidChange: Event.None,
			element: this._previewContainer,
			minimumSize: 200,
			maximumSize: Number.MAX_VALUE,
			layout: (e) => {
				this._preview.layout({
					height: this._dim.height,
					width: e
				});
			}
		}, Sizing.Distribute), this._splitView.addView({
			onDidChange: Event.None,
			element: this._treeContainer,
			minimumSize: 100,
			maximumSize: Number.MAX_VALUE,
			layout: (e) => {
				this._treeContainer.style.height = `${this._dim.height}px`, this._treeContainer.style.width = `${e}px`, this._tree.layout(this._dim.height, e);
			}
		}, Sizing.Distribute), this._disposables.add(this._splitView.onDidSashChange(() => {
			this._dim.width && (this.layoutData.ratio = this._splitView.getViewSize(0) / this._dim.width);
		}, void 0));
		let v = (e, _) => {
			e instanceof OneReference && (_ === "show" && this._revealReference(e, !1), this._onDidSelectReference.fire({
				element: e,
				kind: _,
				source: "tree"
			}));
		};
		this._disposables.add(this._tree.onDidOpen((e) => {
			e.sideBySide ? v(e.element, "side") : e.editorOptions.pinned ? v(e.element, "goto") : v(e.element, "show");
		})), hide(this._treeContainer);
	}
	_onWidth(e) {
		this._dim && this._doLayoutBody(this._dim.height, e);
	}
	_doLayoutBody(e, _) {
		super._doLayoutBody(e, _), this._dim = new Dimension(_, e), this.layoutData.heightInLines = this._viewZone ? this._viewZone.heightInLines : this.layoutData.heightInLines, this._splitView.layout(_), this._splitView.resizeView(0, _ * this.layoutData.ratio);
	}
	setSelection(e) {
		return this._revealReference(e, !0).then(() => {
			this._model && (this._tree.setSelection([e]), this._tree.setFocus([e]));
		});
	}
	setModel(e) {
		return this._disposeOnNewModel.clear(), this._model = e, this._model ? this._onNewModel() : Promise.resolve();
	}
	_onNewModel() {
		return this._model ? this._model.isEmpty ? (this.setTitle(""), this._messageContainer.innerText = localize("noResults", "No results"), show(this._messageContainer), Promise.resolve(void 0)) : (hide(this._messageContainer), this._decorationsManager = new DecorationsManager(this._preview, this._model), this._disposeOnNewModel.add(this._decorationsManager), this._disposeOnNewModel.add(this._model.onDidChangeReferenceRange((e) => this._tree.rerender(e))), this._disposeOnNewModel.add(this._preview.onMouseDown((e) => {
			let { event: _, target: v } = e;
			if (_.detail !== 2) return;
			let y = this._getFocusedReference();
			y && this._onDidSelectReference.fire({
				element: {
					uri: y.uri,
					range: v.range
				},
				kind: _.ctrlKey || _.metaKey || _.altKey ? "side" : "open",
				source: "editor"
			});
		})), this.container.classList.add("results-loaded"), show(this._treeContainer), show(this._previewContainer), this._splitView.layout(this._dim.width), this.focusOnReferenceTree(), this._tree.setInput(this._model.groups.length === 1 ? this._model.groups[0] : this._model)) : Promise.resolve(void 0);
	}
	_getFocusedReference() {
		let [e] = this._tree.getFocus();
		if (e instanceof OneReference) return e;
		if (e instanceof FileReferences && e.children.length > 0) return e.children[0];
	}
	async revealReference(e) {
		await this._revealReference(e, !1), this._onDidSelectReference.fire({
			element: e,
			kind: "goto",
			source: "tree"
		});
	}
	async _revealReference(e, _) {
		if (this._revealedReference === e) return;
		this._revealedReference = e, e.uri.scheme === Schemas.inMemory ? this.setTitle(localize("peekView.alternateTitle", "References")) : this.setTitle(basenameOrAuthority(e.uri), this._uriLabel.getUriLabel(dirname(e.uri)));
		let v = this._textModelResolverService.createModelReference(e.uri);
		this._tree.getInput() === e.parent ? this._tree.reveal(e) : (_ && this._tree.reveal(e.parent), await this._tree.expand(e.parent), this._tree.reveal(e));
		let y = await v;
		if (!this._model) {
			y.dispose();
			return;
		}
		dispose(this._previewModelReference);
		let b = y.object;
		if (b) {
			let _ = this._preview.getModel() === b.textEditorModel ? 0 : 1, v = Range.lift(e.range).collapseToStart();
			this._previewModelReference = y, this._preview.setModel(b.textEditorModel), this._preview.setSelection(v), this._preview.revealRangeInCenter(v, _);
		} else this._preview.setModel(this._previewNotAvailableMessage), y.dispose();
	}
};
ReferenceWidget = __decorate$79([
	__param$79(3, IThemeService),
	__param$79(4, ITextModelService),
	__param$79(5, IInstantiationService),
	__param$79(6, IPeekViewService),
	__param$79(7, ILabelService),
	__param$79(8, IKeybindingService)
], ReferenceWidget);
var __decorate$78 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$78 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ReferencesController_1;
const ctxReferenceSearchVisible = new RawContextKey("referenceSearchVisible", !1, localize("referenceSearchVisible", "Whether reference peek is visible, like 'Peek References' or 'Peek Definition'"));
var ReferencesController = class {
	static {
		ReferencesController_1 = this;
	}
	static {
		this.ID = "editor.contrib.referencesController";
	}
	static get(e) {
		return e.getContribution(ReferencesController_1.ID);
	}
	constructor(e, _, v, y, b, x, S, C) {
		this._defaultTreeKeyboardSupport = e, this._editor = _, this._editorService = y, this._notificationService = b, this._instantiationService = x, this._storageService = S, this._configurationService = C, this._disposables = new DisposableStore(), this._requestIdPool = 0, this._ignoreModelChangeEvent = !1, this._referenceSearchVisible = ctxReferenceSearchVisible.bindTo(v);
	}
	dispose() {
		this._referenceSearchVisible.reset(), this._disposables.dispose(), this._widget?.dispose(), this._model?.dispose(), this._widget = void 0, this._model = void 0;
	}
	toggleWidget(e, _, v) {
		let y;
		if (this._widget && (y = this._widget.position), this.closeWidget(), y && e.containsPosition(y)) return;
		this._peekMode = v, this._referenceSearchVisible.set(!0), this._disposables.add(this._editor.onDidChangeModelLanguage(() => {
			this.closeWidget();
		})), this._disposables.add(this._editor.onDidChangeModel(() => {
			this._ignoreModelChangeEvent || this.closeWidget();
		}));
		let b = "peekViewLayout", x = LayoutData.fromJSON(this._storageService.get(b, 0, "{}"));
		this._widget = this._instantiationService.createInstance(ReferenceWidget, this._editor, this._defaultTreeKeyboardSupport, x), this._widget.setTitle(localize("labelLoading", "Loading...")), this._widget.show(e), this._disposables.add(this._widget.onDidClose(() => {
			_.cancel(), this._widget ? (this._storageService.store(b, JSON.stringify(this._widget.layoutData), 0, 1), this._widget.isClosing || this.closeWidget(), this._widget = void 0) : this.closeWidget();
		})), this._disposables.add(this._widget.onDidSelectReference((e) => {
			let { element: _, kind: y } = e;
			if (_) switch (y) {
				case "open":
					(e.source !== "editor" || !this._configurationService.getValue("editor.stablePeek")) && this.openReference(_, !1, !1);
					break;
				case "side":
					this.openReference(_, !0, !1);
					break;
				case "goto":
					v ? this._gotoReference(_, !0) : this.openReference(_, !1, !0);
					break;
			}
		}));
		let S = ++this._requestIdPool;
		_.then((_) => {
			if (S !== this._requestIdPool || !this._widget) {
				_.dispose();
				return;
			}
			return this._model?.dispose(), this._model = _, this._widget.setModel(this._model).then(() => {
				if (this._widget && this._model && this._editor.hasModel()) {
					this._model.isEmpty ? this._widget.setMetaTitle("") : this._widget.setMetaTitle(localize("metaTitle.N", "{0} ({1})", this._model.title, this._model.references.length));
					let _ = this._editor.getModel().uri, v = new Position(e.startLineNumber, e.startColumn), y = this._model.nearestReference(_, v);
					if (y) return this._widget.setSelection(y).then(() => {
						this._widget && this._editor.getOption(87) === "editor" && this._widget.focusOnPreviewEditor();
					});
				}
			});
		}, (e) => {
			this._notificationService.error(e);
		});
	}
	changeFocusBetweenPreviewAndReferences() {
		this._widget && (this._widget.isPreviewEditorFocused() ? this._widget.focusOnReferenceTree() : this._widget.focusOnPreviewEditor());
	}
	async goToNextOrPreviousReference(e) {
		if (!this._editor.hasModel() || !this._model || !this._widget) return;
		let _ = this._widget.position;
		if (!_) return;
		let v = this._model.nearestReference(this._editor.getModel().uri, _);
		if (!v) return;
		let y = this._model.nextOrPreviousReference(v, e), b = this._editor.hasTextFocus(), x = this._widget.isPreviewEditorFocused();
		await this._widget.setSelection(y), await this._gotoReference(y, !1), b ? this._editor.focus() : this._widget && x && this._widget.focusOnPreviewEditor();
	}
	async revealReference(e) {
		!this._editor.hasModel() || !this._model || !this._widget || await this._widget.revealReference(e);
	}
	closeWidget(e = !0) {
		this._widget?.dispose(), this._model?.dispose(), this._referenceSearchVisible.reset(), this._disposables.clear(), this._widget = void 0, this._model = void 0, e && this._editor.focus(), this._requestIdPool += 1;
	}
	_gotoReference(e, _) {
		this._widget?.hide(), this._ignoreModelChangeEvent = !0;
		let v = Range.lift(e.range).collapseToStart();
		return this._editorService.openCodeEditor({
			resource: e.uri,
			options: {
				selection: v,
				selectionSource: "code.jump",
				pinned: _
			}
		}, this._editor).then((e) => {
			if (this._ignoreModelChangeEvent = !1, !e || !this._widget) {
				this.closeWidget();
				return;
			}
			if (this._editor === e) this._widget.show(v), this._widget.focusOnReferenceTree();
			else {
				let _ = ReferencesController_1.get(e), y = this._model.clone();
				this.closeWidget(), e.focus(), _?.toggleWidget(v, createCancelablePromise((e) => Promise.resolve(y)), this._peekMode ?? !1);
			}
		}, (e) => {
			this._ignoreModelChangeEvent = !1, onUnexpectedError(e);
		});
	}
	openReference(e, _, v) {
		_ || this.closeWidget();
		let { uri: y, range: b } = e;
		this._editorService.openCodeEditor({
			resource: y,
			options: {
				selection: b,
				selectionSource: "code.jump",
				pinned: v
			}
		}, this._editor, _);
	}
};
ReferencesController = ReferencesController_1 = __decorate$78([
	__param$78(2, IContextKeyService),
	__param$78(3, ICodeEditorService),
	__param$78(4, INotificationService),
	__param$78(5, IInstantiationService),
	__param$78(6, IStorageService),
	__param$78(7, IConfigurationService)
], ReferencesController);
function withController(e, _) {
	let v = getOuterEditor(e);
	if (!v) return;
	let y = ReferencesController.get(v);
	y && _(y);
}
KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "togglePeekWidgetFocus",
	weight: 100,
	primary: KeyChord(2089, 60),
	when: ContextKeyExpr.or(ctxReferenceSearchVisible, PeekContext.inPeekEditor),
	handler(e) {
		withController(e, (e) => {
			e.changeFocusBetweenPreviewAndReferences();
		});
	}
}), KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "goToNextReference",
	weight: 90,
	primary: 62,
	secondary: [70],
	when: ContextKeyExpr.or(ctxReferenceSearchVisible, PeekContext.inPeekEditor),
	handler(e) {
		withController(e, (e) => {
			e.goToNextOrPreviousReference(!0);
		});
	}
}), KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "goToPreviousReference",
	weight: 90,
	primary: 1086,
	secondary: [1094],
	when: ContextKeyExpr.or(ctxReferenceSearchVisible, PeekContext.inPeekEditor),
	handler(e) {
		withController(e, (e) => {
			e.goToNextOrPreviousReference(!1);
		});
	}
}), CommandsRegistry.registerCommandAlias("goToNextReferenceFromEmbeddedEditor", "goToNextReference"), CommandsRegistry.registerCommandAlias("goToPreviousReferenceFromEmbeddedEditor", "goToPreviousReference"), CommandsRegistry.registerCommandAlias("closeReferenceSearchEditor", "closeReferenceSearch"), CommandsRegistry.registerCommand("closeReferenceSearch", (e) => withController(e, (e) => e.closeWidget())), KeybindingsRegistry.registerKeybindingRule({
	id: "closeReferenceSearch",
	weight: -1,
	primary: 9,
	secondary: [1033],
	when: ContextKeyExpr.and(PeekContext.inPeekEditor, ContextKeyExpr.not("config.editor.stablePeek"))
}), KeybindingsRegistry.registerKeybindingRule({
	id: "closeReferenceSearch",
	weight: 250,
	primary: 9,
	secondary: [1033],
	when: ContextKeyExpr.and(ctxReferenceSearchVisible, ContextKeyExpr.not("config.editor.stablePeek"), ContextKeyExpr.or(EditorContextKeys.editorTextFocus, InputFocusedContext.negate()))
}), KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "revealReference",
	weight: 200,
	primary: 3,
	mac: {
		primary: 3,
		secondary: [2066]
	},
	when: ContextKeyExpr.and(ctxReferenceSearchVisible, WorkbenchListFocusContextKey, WorkbenchTreeElementCanCollapse.negate(), WorkbenchTreeElementCanExpand.negate()),
	handler(e) {
		let _ = e.get(IListService).lastFocusedList?.getFocus();
		Array.isArray(_) && _[0] instanceof OneReference && withController(e, (e) => e.revealReference(_[0]));
	}
}), KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "openReferenceToSide",
	weight: 100,
	primary: 2051,
	mac: { primary: 259 },
	when: ContextKeyExpr.and(ctxReferenceSearchVisible, WorkbenchListFocusContextKey, WorkbenchTreeElementCanCollapse.negate(), WorkbenchTreeElementCanExpand.negate()),
	handler(e) {
		let _ = e.get(IListService).lastFocusedList?.getFocus();
		Array.isArray(_) && _[0] instanceof OneReference && withController(e, (e) => e.openReference(_[0], !0, !0));
	}
}), CommandsRegistry.registerCommand("openReference", (e) => {
	let _ = e.get(IListService).lastFocusedList?.getFocus();
	Array.isArray(_) && _[0] instanceof OneReference && withController(e, (e) => e.openReference(_[0], !1, !0));
});
var __decorate$77 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$77 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const ctxHasSymbols = new RawContextKey("hasSymbols", !1, localize("hasSymbols", "Whether there are symbol locations that can be navigated via keyboard-only.")), ISymbolNavigationService = createDecorator("ISymbolNavigationService");
var SymbolNavigationService = class {
	constructor(e, _, v, y) {
		this._editorService = _, this._notificationService = v, this._keybindingService = y, this._currentModel = void 0, this._currentIdx = -1, this._ignoreEditorChange = !1, this._ctxHasSymbols = ctxHasSymbols.bindTo(e);
	}
	reset() {
		this._ctxHasSymbols.reset(), this._currentState?.dispose(), this._currentMessage?.dispose(), this._currentModel = void 0, this._currentIdx = -1;
	}
	put(e) {
		let _ = e.parent.parent;
		if (_.references.length <= 1) {
			this.reset();
			return;
		}
		this._currentModel = _, this._currentIdx = _.references.indexOf(e), this._ctxHasSymbols.set(!0), this._showMessage();
		let v = new EditorState$1(this._editorService), y = v.onDidChange((e) => {
			if (this._ignoreEditorChange) return;
			let v = this._editorService.getActiveCodeEditor();
			if (!v) return;
			let y = v.getModel(), b = v.getPosition();
			if (!y || !b) return;
			let x = !1, S = !1;
			for (let e of _.references) if (isEqual(e.uri, y.uri)) x = !0, S ||= Range.containsPosition(e.range, b);
			else if (x) break;
			(!x || !S) && this.reset();
		});
		this._currentState = combinedDisposable(v, y);
	}
	revealNext(e) {
		if (!this._currentModel) return Promise.resolve();
		this._currentIdx += 1, this._currentIdx %= this._currentModel.references.length;
		let _ = this._currentModel.references[this._currentIdx];
		return this._showMessage(), this._ignoreEditorChange = !0, this._editorService.openCodeEditor({
			resource: _.uri,
			options: {
				selection: Range.collapseToStart(_.range),
				selectionRevealType: 3
			}
		}, e).finally(() => {
			this._ignoreEditorChange = !1;
		});
	}
	_showMessage() {
		this._currentMessage?.dispose();
		let e = this._keybindingService.lookupKeybinding("editor.gotoNextSymbolFromResult"), _ = e ? localize("location.kb", "Symbol {0} of {1}, {2} for next", this._currentIdx + 1, this._currentModel.references.length, e.getLabel()) : localize("location", "Symbol {0} of {1}", this._currentIdx + 1, this._currentModel.references.length);
		this._currentMessage = this._notificationService.status(_);
	}
};
SymbolNavigationService = __decorate$77([
	__param$77(0, IContextKeyService),
	__param$77(1, ICodeEditorService),
	__param$77(2, INotificationService),
	__param$77(3, IKeybindingService)
], SymbolNavigationService), registerSingleton(ISymbolNavigationService, SymbolNavigationService, 1), registerEditorCommand(new class extends EditorCommand {
	constructor() {
		super({
			id: "editor.gotoNextSymbolFromResult",
			precondition: ctxHasSymbols,
			kbOpts: {
				weight: 100,
				primary: 70
			}
		});
	}
	runEditorCommand(e, _) {
		return e.get(ISymbolNavigationService).revealNext(_);
	}
}()), KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "editor.gotoNextSymbolFromResult.cancel",
	weight: 100,
	when: ctxHasSymbols,
	primary: 9,
	handler(e) {
		e.get(ISymbolNavigationService).reset();
	}
});
var EditorState$1 = class {
	constructor(e) {
		this._listener = /* @__PURE__ */ new Map(), this._disposables = new DisposableStore(), this._onDidChange = new Emitter(), this.onDidChange = this._onDidChange.event, this._disposables.add(e.onCodeEditorRemove(this._onDidRemoveEditor, this)), this._disposables.add(e.onCodeEditorAdd(this._onDidAddEditor, this)), e.listCodeEditors().forEach(this._onDidAddEditor, this);
	}
	dispose() {
		this._disposables.dispose(), this._onDidChange.dispose(), dispose(this._listener.values());
	}
	_onDidAddEditor(e) {
		this._listener.set(e, combinedDisposable(e.onDidChangeCursorPosition((_) => this._onDidChange.fire({ editor: e })), e.onDidChangeModelContent((_) => this._onDidChange.fire({ editor: e }))));
	}
	_onDidRemoveEditor(e) {
		this._listener.get(e)?.dispose(), this._listener.delete(e);
	}
};
EditorState$1 = __decorate$77([__param$77(0, ICodeEditorService)], EditorState$1);
function shouldIncludeLocationLink(e, _) {
	return _.uri.scheme === e.uri.scheme ? !0 : !matchesSomeScheme(_.uri, Schemas.walkThroughSnippet, Schemas.vscodeChatCodeBlock, Schemas.vscodeChatCodeCompareBlock);
}
async function getLocationLinks(e, _, v, y, b) {
	let x = v.ordered(e, y).map((v) => Promise.resolve(b(v, e, _)).then(void 0, (e) => {
		onUnexpectedExternalError(e);
	})), S = await Promise.all(x);
	return coalesce(S.flat()).filter((_) => shouldIncludeLocationLink(e, _));
}
function getDefinitionsAtPosition(e, _, v, y, b) {
	return getLocationLinks(_, v, e, y, (e, _, v) => e.provideDefinition(_, v, b));
}
function getDeclarationsAtPosition(e, _, v, y, b) {
	return getLocationLinks(_, v, e, y, (e, _, v) => e.provideDeclaration(_, v, b));
}
function getImplementationsAtPosition(e, _, v, y, b) {
	return getLocationLinks(_, v, e, y, (e, _, v) => e.provideImplementation(_, v, b));
}
function getTypeDefinitionsAtPosition(e, _, v, y, b) {
	return getLocationLinks(_, v, e, y, (e, _, v) => e.provideTypeDefinition(_, v, b));
}
function getReferencesAtPosition(e, _, v, y, b, x) {
	return getLocationLinks(_, v, e, b, async (e, _, v) => {
		let b = (await e.provideReferences(_, v, { includeDeclaration: !0 }, x))?.filter((e) => shouldIncludeLocationLink(_, e));
		if (!y || !b || b.length !== 2) return b;
		let S = (await e.provideReferences(_, v, { includeDeclaration: !1 }, x))?.filter((e) => shouldIncludeLocationLink(_, e));
		return S && S.length === 1 ? S : b;
	});
}
async function _sortedAndDeduped(e) {
	let _ = await e(), v = new ReferencesModel(_, ""), y = v.references.map((e) => e.link);
	return v.dispose(), y;
}
registerModelAndPositionCommand("_executeDefinitionProvider", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getDefinitionsAtPosition(y.definitionProvider, _, v, !1, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeDefinitionProvider_recursive", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getDefinitionsAtPosition(y.definitionProvider, _, v, !0, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeTypeDefinitionProvider", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getTypeDefinitionsAtPosition(y.typeDefinitionProvider, _, v, !1, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeTypeDefinitionProvider_recursive", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getTypeDefinitionsAtPosition(y.typeDefinitionProvider, _, v, !0, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeDeclarationProvider", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getDeclarationsAtPosition(y.declarationProvider, _, v, !1, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeDeclarationProvider_recursive", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getDeclarationsAtPosition(y.declarationProvider, _, v, !0, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeReferenceProvider", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getReferencesAtPosition(y.referenceProvider, _, v, !1, !1, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeReferenceProvider_recursive", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getReferencesAtPosition(y.referenceProvider, _, v, !1, !0, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeImplementationProvider", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getImplementationsAtPosition(y.implementationProvider, _, v, !1, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), registerModelAndPositionCommand("_executeImplementationProvider_recursive", (e, _, v) => {
	let y = e.get(ILanguageFeaturesService), b = getImplementationsAtPosition(y.implementationProvider, _, v, !0, CancellationToken.None);
	return _sortedAndDeduped(() => b);
}), MenuRegistry.appendMenuItem(MenuId.EditorContext, {
	submenu: MenuId.EditorContextPeek,
	title: localize("peek.submenu", "Peek"),
	group: "navigation",
	order: 100
});
var SymbolNavigationAnchor = class e {
	static is(_) {
		return !_ || typeof _ != "object" ? !1 : !!(_ instanceof e || Position.isIPosition(_.position) && _.model);
	}
	constructor(e, _) {
		this.model = e, this.position = _;
	}
}, SymbolNavigationAction = class e extends EditorAction2 {
	static {
		this._allSymbolNavigationCommands = /* @__PURE__ */ new Map();
	}
	static {
		this._activeAlternativeCommands = /* @__PURE__ */ new Set();
	}
	static all() {
		return e._allSymbolNavigationCommands.values();
	}
	static _patchConfig(e) {
		let _ = {
			...e,
			f1: !0
		};
		if (_.menu) for (let v of Iterable.wrap(_.menu)) (v.id === MenuId.EditorContext || v.id === MenuId.EditorContextPeek) && (v.when = ContextKeyExpr.and(e.precondition, v.when));
		return _;
	}
	constructor(_, v) {
		super(e._patchConfig(v)), this.configuration = _, e._allSymbolNavigationCommands.set(v.id, this);
	}
	runEditorCommand(_, v, y, b) {
		if (!v.hasModel()) return Promise.resolve(void 0);
		let x = _.get(INotificationService), S = _.get(ICodeEditorService), C = _.get(IEditorProgressService), w = _.get(ISymbolNavigationService), T = _.get(ILanguageFeaturesService), E = _.get(IInstantiationService), D = v.getModel(), O = v.getPosition(), k = SymbolNavigationAnchor.is(y) ? y : new SymbolNavigationAnchor(D, O), A = new EditorStateCancellationTokenSource(v, 5), j = raceCancellation(this._getLocationModel(T, k.model, k.position, A.token), A.token).then(async (_) => {
			if (!_ || A.token.isCancellationRequested) return;
			alert(_.ariaMessage);
			let x;
			if (_.referenceAt(D.uri, O)) {
				let _ = this._getAlternativeCommand(v);
				!e._activeAlternativeCommands.has(_) && e._allSymbolNavigationCommands.has(_) && (x = e._allSymbolNavigationCommands.get(_));
			}
			let C = _.references.length;
			if (C === 0) {
				if (!this.configuration.muteMessage) {
					let e = D.getWordAtPosition(O);
					MessageController.get(v)?.showMessage(this._getNoResultFoundMessage(e), O);
				}
			} else if (C === 1 && x) e._activeAlternativeCommands.add(this.desc.id), E.invokeFunction((_) => x.runEditorCommand(_, v, y, b).finally(() => {
				e._activeAlternativeCommands.delete(this.desc.id);
			}));
			else return this._onResult(S, w, v, _, b);
		}, (e) => {
			x.error(e);
		}).finally(() => {
			A.dispose();
		});
		return C.showWhile(j, 250), j;
	}
	async _onResult(e, _, v, y, b) {
		let x = this._getGoToPreference(v);
		if (!(v instanceof EmbeddedCodeEditorWidget) && (this.configuration.openInPeek || x === "peek" && y.references.length > 1)) this._openInPeek(v, y, b);
		else {
			let S = y.firstReference(), C = y.references.length > 1 && x === "gotoAndPeek", w = await this._openReference(v, e, S, this.configuration.openToSide, !C);
			C && w ? this._openInPeek(w, y, b) : y.dispose(), x === "goto" && _.put(S);
		}
	}
	async _openReference(e, _, v, y, b) {
		let x;
		if (isLocationLink(v) && (x = v.targetSelectionRange), x ||= v.range, !x) return;
		let S = await _.openCodeEditor({
			resource: v.uri,
			options: {
				selection: Range.collapseToStart(x),
				selectionRevealType: 3,
				selectionSource: "code.jump"
			}
		}, e, y);
		if (S) {
			if (b) {
				let e = S.getModel(), _ = S.createDecorationsCollection([{
					range: x,
					options: {
						description: "symbol-navigate-action-highlight",
						className: "symbolHighlight"
					}
				}]);
				setTimeout(() => {
					S.getModel() === e && _.clear();
				}, 350);
			}
			return S;
		}
	}
	_openInPeek(e, _, v) {
		let y = ReferencesController.get(e);
		y && e.hasModel() ? y.toggleWidget(v ?? e.getSelection(), createCancelablePromise((e) => Promise.resolve(_)), this.configuration.openInPeek) : _.dispose();
	}
}, DefinitionAction = class extends SymbolNavigationAction {
	async _getLocationModel(e, _, v, y) {
		return new ReferencesModel(await getDefinitionsAtPosition(e.definitionProvider, _, v, !1, y), localize("def.title", "Definitions"));
	}
	_getNoResultFoundMessage(e) {
		return e && e.word ? localize("noResultWord", "No definition found for '{0}'", e.word) : localize("generic.noResults", "No definition found");
	}
	_getAlternativeCommand(e) {
		return e.getOption(58).alternativeDefinitionCommand;
	}
	_getGoToPreference(e) {
		return e.getOption(58).multipleDefinitions;
	}
};
registerAction2(class e extends DefinitionAction {
	static {
		this.id = "editor.action.revealDefinition";
	}
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !1,
			muteMessage: !1
		}, {
			id: e.id,
			title: {
				...localize2("actions.goToDecl.label", "Go to Definition"),
				mnemonicTitle: localize({
					key: "miGotoDefinition",
					comment: ["&& denotes a mnemonic"]
				}, "Go to &&Definition")
			},
			precondition: EditorContextKeys.hasDefinitionProvider,
			keybinding: [{
				when: EditorContextKeys.editorTextFocus,
				primary: 70,
				weight: 100
			}, {
				when: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, IsWebContext),
				primary: 2118,
				weight: 100
			}],
			menu: [{
				id: MenuId.EditorContext,
				group: "navigation",
				order: 1.1
			}, {
				id: MenuId.MenubarGoMenu,
				precondition: null,
				group: "4_symbol_nav",
				order: 2
			}]
		}), CommandsRegistry.registerCommandAlias("editor.action.goToDeclaration", e.id);
	}
}), registerAction2(class e extends DefinitionAction {
	static {
		this.id = "editor.action.revealDefinitionAside";
	}
	constructor() {
		super({
			openToSide: !0,
			openInPeek: !1,
			muteMessage: !1
		}, {
			id: e.id,
			title: localize2("actions.goToDeclToSide.label", "Open Definition to the Side"),
			precondition: ContextKeyExpr.and(EditorContextKeys.hasDefinitionProvider, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			keybinding: [{
				when: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 70),
				weight: 100
			}, {
				when: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, IsWebContext),
				primary: KeyChord(2089, 2118),
				weight: 100
			}]
		}), CommandsRegistry.registerCommandAlias("editor.action.openDeclarationToTheSide", e.id);
	}
}), registerAction2(class e extends DefinitionAction {
	static {
		this.id = "editor.action.peekDefinition";
	}
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !0,
			muteMessage: !1
		}, {
			id: e.id,
			title: localize2("actions.previewDecl.label", "Peek Definition"),
			precondition: ContextKeyExpr.and(EditorContextKeys.hasDefinitionProvider, PeekContext.notInPeekEditor, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			keybinding: {
				when: EditorContextKeys.editorTextFocus,
				primary: 582,
				linux: { primary: 3140 },
				weight: 100
			},
			menu: {
				id: MenuId.EditorContextPeek,
				group: "peek",
				order: 2
			}
		}), CommandsRegistry.registerCommandAlias("editor.action.previewDeclaration", e.id);
	}
});
var DeclarationAction = class extends SymbolNavigationAction {
	async _getLocationModel(e, _, v, y) {
		return new ReferencesModel(await getDeclarationsAtPosition(e.declarationProvider, _, v, !1, y), localize("decl.title", "Declarations"));
	}
	_getNoResultFoundMessage(e) {
		return e && e.word ? localize("decl.noResultWord", "No declaration found for '{0}'", e.word) : localize("decl.generic.noResults", "No declaration found");
	}
	_getAlternativeCommand(e) {
		return e.getOption(58).alternativeDeclarationCommand;
	}
	_getGoToPreference(e) {
		return e.getOption(58).multipleDeclarations;
	}
};
registerAction2(class e extends DeclarationAction {
	static {
		this.id = "editor.action.revealDeclaration";
	}
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !1,
			muteMessage: !1
		}, {
			id: e.id,
			title: {
				...localize2("actions.goToDeclaration.label", "Go to Declaration"),
				mnemonicTitle: localize({
					key: "miGotoDeclaration",
					comment: ["&& denotes a mnemonic"]
				}, "Go to &&Declaration")
			},
			precondition: ContextKeyExpr.and(EditorContextKeys.hasDeclarationProvider, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			menu: [{
				id: MenuId.EditorContext,
				group: "navigation",
				order: 1.3
			}, {
				id: MenuId.MenubarGoMenu,
				precondition: null,
				group: "4_symbol_nav",
				order: 3
			}]
		});
	}
	_getNoResultFoundMessage(e) {
		return e && e.word ? localize("decl.noResultWord", "No declaration found for '{0}'", e.word) : localize("decl.generic.noResults", "No declaration found");
	}
}), registerAction2(class extends DeclarationAction {
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !0,
			muteMessage: !1
		}, {
			id: "editor.action.peekDeclaration",
			title: localize2("actions.peekDecl.label", "Peek Declaration"),
			precondition: ContextKeyExpr.and(EditorContextKeys.hasDeclarationProvider, PeekContext.notInPeekEditor, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			menu: {
				id: MenuId.EditorContextPeek,
				group: "peek",
				order: 3
			}
		});
	}
});
var TypeDefinitionAction = class extends SymbolNavigationAction {
	async _getLocationModel(e, _, v, y) {
		return new ReferencesModel(await getTypeDefinitionsAtPosition(e.typeDefinitionProvider, _, v, !1, y), localize("typedef.title", "Type Definitions"));
	}
	_getNoResultFoundMessage(e) {
		return e && e.word ? localize("goToTypeDefinition.noResultWord", "No type definition found for '{0}'", e.word) : localize("goToTypeDefinition.generic.noResults", "No type definition found");
	}
	_getAlternativeCommand(e) {
		return e.getOption(58).alternativeTypeDefinitionCommand;
	}
	_getGoToPreference(e) {
		return e.getOption(58).multipleTypeDefinitions;
	}
};
registerAction2(class e extends TypeDefinitionAction {
	static {
		this.ID = "editor.action.goToTypeDefinition";
	}
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !1,
			muteMessage: !1
		}, {
			id: e.ID,
			title: {
				...localize2("actions.goToTypeDefinition.label", "Go to Type Definition"),
				mnemonicTitle: localize({
					key: "miGotoTypeDefinition",
					comment: ["&& denotes a mnemonic"]
				}, "Go to &&Type Definition")
			},
			precondition: EditorContextKeys.hasTypeDefinitionProvider,
			keybinding: {
				when: EditorContextKeys.editorTextFocus,
				primary: 0,
				weight: 100
			},
			menu: [{
				id: MenuId.EditorContext,
				group: "navigation",
				order: 1.4
			}, {
				id: MenuId.MenubarGoMenu,
				precondition: null,
				group: "4_symbol_nav",
				order: 3
			}]
		});
	}
}), registerAction2(class e extends TypeDefinitionAction {
	static {
		this.ID = "editor.action.peekTypeDefinition";
	}
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !0,
			muteMessage: !1
		}, {
			id: e.ID,
			title: localize2("actions.peekTypeDefinition.label", "Peek Type Definition"),
			precondition: ContextKeyExpr.and(EditorContextKeys.hasTypeDefinitionProvider, PeekContext.notInPeekEditor, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			menu: {
				id: MenuId.EditorContextPeek,
				group: "peek",
				order: 4
			}
		});
	}
});
var ImplementationAction = class extends SymbolNavigationAction {
	async _getLocationModel(e, _, v, y) {
		return new ReferencesModel(await getImplementationsAtPosition(e.implementationProvider, _, v, !1, y), localize("impl.title", "Implementations"));
	}
	_getNoResultFoundMessage(e) {
		return e && e.word ? localize("goToImplementation.noResultWord", "No implementation found for '{0}'", e.word) : localize("goToImplementation.generic.noResults", "No implementation found");
	}
	_getAlternativeCommand(e) {
		return e.getOption(58).alternativeImplementationCommand;
	}
	_getGoToPreference(e) {
		return e.getOption(58).multipleImplementations;
	}
};
registerAction2(class e extends ImplementationAction {
	static {
		this.ID = "editor.action.goToImplementation";
	}
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !1,
			muteMessage: !1
		}, {
			id: e.ID,
			title: {
				...localize2("actions.goToImplementation.label", "Go to Implementations"),
				mnemonicTitle: localize({
					key: "miGotoImplementation",
					comment: ["&& denotes a mnemonic"]
				}, "Go to &&Implementations")
			},
			precondition: EditorContextKeys.hasImplementationProvider,
			keybinding: {
				when: EditorContextKeys.editorTextFocus,
				primary: 2118,
				weight: 100
			},
			menu: [{
				id: MenuId.EditorContext,
				group: "navigation",
				order: 1.45
			}, {
				id: MenuId.MenubarGoMenu,
				precondition: null,
				group: "4_symbol_nav",
				order: 4
			}]
		});
	}
}), registerAction2(class e extends ImplementationAction {
	static {
		this.ID = "editor.action.peekImplementation";
	}
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !0,
			muteMessage: !1
		}, {
			id: e.ID,
			title: localize2("actions.peekImplementation.label", "Peek Implementations"),
			precondition: ContextKeyExpr.and(EditorContextKeys.hasImplementationProvider, PeekContext.notInPeekEditor, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			keybinding: {
				when: EditorContextKeys.editorTextFocus,
				primary: 3142,
				weight: 100
			},
			menu: {
				id: MenuId.EditorContextPeek,
				group: "peek",
				order: 5
			}
		});
	}
});
var ReferencesAction = class extends SymbolNavigationAction {
	_getNoResultFoundMessage(e) {
		return e ? localize("references.no", "No references found for '{0}'", e.word) : localize("references.noGeneric", "No references found");
	}
	_getAlternativeCommand(e) {
		return e.getOption(58).alternativeReferenceCommand;
	}
	_getGoToPreference(e) {
		return e.getOption(58).multipleReferences;
	}
};
registerAction2(class extends ReferencesAction {
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !1,
			muteMessage: !1
		}, {
			id: "editor.action.goToReferences",
			title: {
				...localize2("goToReferences.label", "Go to References"),
				mnemonicTitle: localize({
					key: "miGotoReference",
					comment: ["&& denotes a mnemonic"]
				}, "Go to &&References")
			},
			precondition: ContextKeyExpr.and(EditorContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			keybinding: {
				when: EditorContextKeys.editorTextFocus,
				primary: 1094,
				weight: 100
			},
			menu: [{
				id: MenuId.EditorContext,
				group: "navigation",
				order: 1.45
			}, {
				id: MenuId.MenubarGoMenu,
				precondition: null,
				group: "4_symbol_nav",
				order: 5
			}]
		});
	}
	async _getLocationModel(e, _, v, y) {
		return new ReferencesModel(await getReferencesAtPosition(e.referenceProvider, _, v, !0, !1, y), localize("ref.title", "References"));
	}
}), registerAction2(class extends ReferencesAction {
	constructor() {
		super({
			openToSide: !1,
			openInPeek: !0,
			muteMessage: !1
		}, {
			id: "editor.action.referenceSearch.trigger",
			title: localize2("references.action.label", "Peek References"),
			precondition: ContextKeyExpr.and(EditorContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor, EditorContextKeys.isInEmbeddedEditor.toNegated()),
			menu: {
				id: MenuId.EditorContextPeek,
				group: "peek",
				order: 6
			}
		});
	}
	async _getLocationModel(e, _, v, y) {
		return new ReferencesModel(await getReferencesAtPosition(e.referenceProvider, _, v, !1, !1, y), localize("ref.title", "References"));
	}
});
var GenericGoToLocationAction = class extends SymbolNavigationAction {
	constructor(e, _, v) {
		super(e, {
			id: "editor.action.goToLocation",
			title: localize2("label.generic", "Go to Any Symbol"),
			precondition: ContextKeyExpr.and(PeekContext.notInPeekEditor, EditorContextKeys.isInEmbeddedEditor.toNegated())
		}), this._references = _, this._gotoMultipleBehaviour = v;
	}
	async _getLocationModel(e, _, v, y) {
		return new ReferencesModel(this._references, localize("generic.title", "Locations"));
	}
	_getNoResultFoundMessage(e) {
		return e && localize("generic.noResult", "No results for '{0}'", e.word) || "";
	}
	_getGoToPreference(e) {
		return this._gotoMultipleBehaviour ?? e.getOption(58).multipleReferences;
	}
	_getAlternativeCommand() {
		return "";
	}
};
CommandsRegistry.registerCommand({
	id: "editor.action.goToLocations",
	metadata: {
		description: "Go to locations from a position in a file",
		args: [
			{
				name: "uri",
				description: "The text document in which to start",
				constraint: URI
			},
			{
				name: "position",
				description: "The position at which to start",
				constraint: Position.isIPosition
			},
			{
				name: "locations",
				description: "An array of locations.",
				constraint: Array
			},
			{
				name: "multiple",
				description: "Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto`"
			},
			{
				name: "noResultsMessage",
				description: "Human readable message that shows when locations is empty."
			}
		]
	},
	handler: async (e, _, v, y, b, x, S) => {
		assertType(URI.isUri(_)), assertType(Position.isIPosition(v)), assertType(Array.isArray(y)), assertType(b === void 0 || typeof b == "string"), assertType(S === void 0 || typeof S == "boolean");
		let C = e.get(ICodeEditorService), w = await C.openCodeEditor({ resource: _ }, C.getFocusedCodeEditor());
		if (isCodeEditor(w)) return w.setPosition(v), w.revealPositionInCenterIfOutsideViewport(v, 0), w.invokeWithinContext((e) => {
			let _ = new class extends GenericGoToLocationAction {
				_getNoResultFoundMessage(e) {
					return x || super._getNoResultFoundMessage(e);
				}
			}({
				muteMessage: !x,
				openInPeek: !!S,
				openToSide: !1
			}, y, b);
			e.get(IInstantiationService).invokeFunction(_.run.bind(_), w);
		});
	}
}), CommandsRegistry.registerCommand({
	id: "editor.action.peekLocations",
	metadata: {
		description: "Peek locations from a position in a file",
		args: [
			{
				name: "uri",
				description: "The text document in which to start",
				constraint: URI
			},
			{
				name: "position",
				description: "The position at which to start",
				constraint: Position.isIPosition
			},
			{
				name: "locations",
				description: "An array of locations.",
				constraint: Array
			},
			{
				name: "multiple",
				description: "Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto`"
			}
		]
	},
	handler: async (e, _, v, y, b) => {
		e.get(ICommandService).executeCommand("editor.action.goToLocations", _, v, y, b, void 0, !0);
	}
}), CommandsRegistry.registerCommand({
	id: "editor.action.findReferences",
	handler: (e, _, v) => {
		assertType(URI.isUri(_)), assertType(Position.isIPosition(v));
		let y = e.get(ILanguageFeaturesService), b = e.get(ICodeEditorService);
		return b.openCodeEditor({ resource: _ }, b.getFocusedCodeEditor()).then((e) => {
			if (!isCodeEditor(e) || !e.hasModel()) return;
			let _ = ReferencesController.get(e);
			if (!_) return;
			let b = createCancelablePromise((_) => getReferencesAtPosition(y.referenceProvider, e.getModel(), Position.lift(v), !1, !1, _).then((e) => new ReferencesModel(e, localize("ref.title", "References")))), x = new Range(v.lineNumber, v.column, v.lineNumber, v.column);
			return Promise.resolve(_.toggleWidget(x, b, !1));
		});
	}
}), CommandsRegistry.registerCommandAlias("editor.action.showReferences", "editor.action.peekLocations");
async function showGoToContextMenu(e, _, v, y) {
	let b = e.get(ITextModelService), x = e.get(IContextMenuService), S = e.get(ICommandService), C = e.get(IInstantiationService), T = e.get(INotificationService);
	if (await y.item.resolve(CancellationToken.None), !y.part.location) return;
	let E = y.part.location, D = [], O = new Set(MenuRegistry.getMenuItems(MenuId.EditorContext).map((e) => isIMenuItem(e) ? e.command.id : generateUuid()));
	for (let e of SymbolNavigationAction.all()) O.has(e.desc.id) && D.push(new Action(e.desc.id, MenuItemAction.label(e.desc, { renderShortTitle: !0 }), void 0, !0, async () => {
		let v = await b.createModelReference(E.uri);
		try {
			let b = new SymbolNavigationAnchor(v.object.textEditorModel, Range.getStartPosition(E.range)), x = y.item.anchor.range;
			await C.invokeFunction(e.runEditorCommand.bind(e), _, b, x);
		} finally {
			v.dispose();
		}
	}));
	if (y.part.command) {
		let { command: e } = y.part;
		D.push(new Separator()), D.push(new Action(e.id, e.title, void 0, !0, async () => {
			try {
				await S.executeCommand(e.id, ...e.arguments ?? []);
			} catch (e) {
				T.notify({
					severity: Severity.Error,
					source: y.item.provider.displayName,
					message: e
				});
			}
		}));
	}
	let k = _.getOption(128);
	x.showContextMenu({
		domForShadowRoot: k ? _.getDomNode() ?? void 0 : void 0,
		getAnchor: () => {
			let e = getDomNodePagePosition(v);
			return {
				x: e.left,
				y: e.top + e.height + 8
			};
		},
		getActions: () => D,
		onHide: () => {
			_.focus();
		},
		autoSelectFirstItem: !0
	});
}
async function goToDefinitionWithLocation(e, _, v, y) {
	let b = await e.get(ITextModelService).createModelReference(y.uri);
	await v.invokeWithinContext(async (e) => {
		let x = _.hasSideBySideModifier, S = e.get(IContextKeyService), C = PeekContext.inPeekEditor.getValue(S), w = !x && v.getOption(89) && !C;
		return new DefinitionAction({
			openToSide: x,
			openInPeek: w,
			muteMessage: !0
		}, {
			title: {
				value: "",
				original: ""
			},
			id: "",
			precondition: void 0
		}).run(e, new SymbolNavigationAnchor(b.object.textEditorModel, Range.getStartPosition(y.range)), Range.lift(y.range));
	}), b.dispose();
}
var __decorate$76 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$76 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlayHintsController_1, InlayHintsCache = class e {
	constructor() {
		this._entries = new LRUCache(50);
	}
	get(_) {
		let v = e._key(_);
		return this._entries.get(v);
	}
	set(_, v) {
		let y = e._key(_);
		this._entries.set(y, v);
	}
	static _key(e) {
		return `${e.uri.toString()}/${e.getVersionId()}`;
	}
}, IInlayHintsCache = createDecorator("IInlayHintsCache");
registerSingleton(IInlayHintsCache, InlayHintsCache, 1);
var RenderedInlayHintLabelPart = class {
	constructor(e, _) {
		this.item = e, this.index = _;
	}
	get part() {
		let e = this.item.hint.label;
		return typeof e == "string" ? { label: e } : e[this.index];
	}
}, ActiveInlayHintInfo = class {
	constructor(e, _) {
		this.part = e, this.hasTriggerModifier = _;
	}
}, InlayHintsController = class {
	static {
		InlayHintsController_1 = this;
	}
	static {
		this.ID = "editor.contrib.InlayHints";
	}
	static {
		this._MAX_DECORATORS = 1500;
	}
	static {
		this._MAX_LABEL_LEN = 43;
	}
	static get(e) {
		return e.getContribution(InlayHintsController_1.ID) ?? void 0;
	}
	constructor(e, _, v, y, b, x, S) {
		this._editor = e, this._languageFeaturesService = _, this._inlayHintsCache = y, this._commandService = b, this._notificationService = x, this._instaService = S, this._disposables = new DisposableStore(), this._sessionDisposables = new DisposableStore(), this._decorationsMetadata = /* @__PURE__ */ new Map(), this._ruleFactory = new DynamicCssRules(this._editor), this._activeRenderMode = 0, this._debounceInfo = v.for(_.inlayHintsProvider, "InlayHint", { min: 25 }), this._disposables.add(_.inlayHintsProvider.onDidChange(() => this._update())), this._disposables.add(e.onDidChangeModel(() => this._update())), this._disposables.add(e.onDidChangeModelLanguage(() => this._update())), this._disposables.add(e.onDidChangeConfiguration((e) => {
			e.hasChanged(142) && this._update();
		})), this._update();
	}
	dispose() {
		this._sessionDisposables.dispose(), this._removeAllDecorations(), this._disposables.dispose();
	}
	_update() {
		this._sessionDisposables.clear(), this._removeAllDecorations();
		let e = this._editor.getOption(142);
		if (e.enabled === "off") return;
		let _ = this._editor.getModel();
		if (!_ || !this._languageFeaturesService.inlayHintsProvider.has(_)) return;
		if (e.enabled === "on") this._activeRenderMode = 0;
		else {
			let _, v;
			e.enabled === "onUnlessPressed" ? (_ = 0, v = 1) : (_ = 1, v = 0), this._activeRenderMode = _, this._sessionDisposables.add(ModifierKeyEmitter.getInstance().event((e) => {
				if (!this._editor.hasModel()) return;
				let y = e.altKey && e.ctrlKey && !(e.shiftKey || e.metaKey) ? v : _;
				if (y !== this._activeRenderMode) {
					this._activeRenderMode = y;
					let e = this._editor.getModel(), _ = this._copyInlayHintsWithCurrentAnchor(e);
					this._updateHintsDecorators([e.getFullModelRange()], _), x.schedule(0);
				}
			}));
		}
		let v = this._inlayHintsCache.get(_);
		v && this._updateHintsDecorators([_.getFullModelRange()], v), this._sessionDisposables.add(toDisposable(() => {
			_.isDisposed() || this._cacheHintsForFastRestore(_);
		}));
		let y, b = /* @__PURE__ */ new Set(), x = new RunOnceScheduler(async () => {
			let e = Date.now();
			y?.dispose(!0), y = new CancellationTokenSource();
			let v = _.onWillDispose(() => y?.cancel());
			try {
				let v = y.token, S = await InlayHintsFragments.create(this._languageFeaturesService.inlayHintsProvider, _, this._getHintsRanges(), v);
				if (x.delay = this._debounceInfo.update(_, Date.now() - e), v.isCancellationRequested) {
					S.dispose();
					return;
				}
				for (let e of S.provider) typeof e.onDidChangeInlayHints == "function" && !b.has(e) && (b.add(e), this._sessionDisposables.add(e.onDidChangeInlayHints(() => {
					x.isScheduled() || x.schedule();
				})));
				this._sessionDisposables.add(S), this._updateHintsDecorators(S.ranges, S.items), this._cacheHintsForFastRestore(_);
			} catch (e) {
				onUnexpectedError(e);
			} finally {
				y.dispose(), v.dispose();
			}
		}, this._debounceInfo.get(_));
		this._sessionDisposables.add(x), this._sessionDisposables.add(toDisposable(() => y?.dispose(!0))), x.schedule(0), this._sessionDisposables.add(this._editor.onDidScrollChange((e) => {
			(e.scrollTopChanged || !x.isScheduled()) && x.schedule();
		})), this._sessionDisposables.add(this._editor.onDidChangeModelContent((e) => {
			y?.cancel();
			let _ = Math.max(x.delay, 1250);
			x.schedule(_);
		})), this._sessionDisposables.add(this._installDblClickGesture(() => x.schedule(0))), this._sessionDisposables.add(this._installLinkGesture()), this._sessionDisposables.add(this._installContextMenu());
	}
	_installLinkGesture() {
		let e = new DisposableStore(), _ = e.add(new ClickLinkGesture(this._editor)), v = new DisposableStore();
		return e.add(v), e.add(_.onMouseMoveOrRelevantKeyDown((e) => {
			let [_] = e, y = this._getInlayHintLabelPart(_), b = this._editor.getModel();
			if (!y || !b) {
				v.clear();
				return;
			}
			let x = new CancellationTokenSource();
			v.add(toDisposable(() => x.dispose(!0))), y.item.resolve(x.token), this._activeInlayHintPart = y.part.command || y.part.location ? new ActiveInlayHintInfo(y, _.hasTriggerModifier) : void 0;
			let S = b.validatePosition(y.item.hint.position).lineNumber, C = new Range(S, 1, S, b.getLineMaxColumn(S)), w = this._getInlineHintsForRange(C);
			this._updateHintsDecorators([C], w), v.add(toDisposable(() => {
				this._activeInlayHintPart = void 0, this._updateHintsDecorators([C], w);
			}));
		})), e.add(_.onCancel(() => v.clear())), e.add(_.onExecute(async (e) => {
			let _ = this._getInlayHintLabelPart(e);
			if (_) {
				let v = _.part;
				v.location ? this._instaService.invokeFunction(goToDefinitionWithLocation, e, this._editor, v.location) : Command$1.is(v.command) && await this._invokeCommand(v.command, _.item);
			}
		})), e;
	}
	_getInlineHintsForRange(e) {
		let _ = /* @__PURE__ */ new Set();
		for (let v of this._decorationsMetadata.values()) e.containsRange(v.item.anchor.range) && _.add(v.item);
		return Array.from(_);
	}
	_installDblClickGesture(e) {
		return this._editor.onMouseUp(async (_) => {
			if (_.event.detail !== 2) return;
			let v = this._getInlayHintLabelPart(_);
			if (v && (_.event.preventDefault(), await v.item.resolve(CancellationToken.None), isNonEmptyArray(v.item.hint.textEdits))) {
				let _ = v.item.hint.textEdits.map((e) => EditOperation.replace(Range.lift(e.range), e.text));
				this._editor.executeEdits("inlayHint.default", _), e();
			}
		});
	}
	_installContextMenu() {
		return this._editor.onContextMenu(async (e) => {
			if (!isHTMLElement(e.event.target)) return;
			let _ = this._getInlayHintLabelPart(e);
			_ && await this._instaService.invokeFunction(showGoToContextMenu, this._editor, e.event.target, _);
		});
	}
	_getInlayHintLabelPart(e) {
		if (e.target.type !== 6) return;
		let _ = e.target.detail.injectedText?.options;
		if (_ instanceof ModelDecorationInjectedTextOptions && _?.attachedData instanceof RenderedInlayHintLabelPart) return _.attachedData;
	}
	async _invokeCommand(e, _) {
		try {
			await this._commandService.executeCommand(e.id, ...e.arguments ?? []);
		} catch (e) {
			this._notificationService.notify({
				severity: Severity.Error,
				source: _.provider.displayName,
				message: e
			});
		}
	}
	_cacheHintsForFastRestore(e) {
		let _ = this._copyInlayHintsWithCurrentAnchor(e);
		this._inlayHintsCache.set(e, _);
	}
	_copyInlayHintsWithCurrentAnchor(e) {
		let _ = /* @__PURE__ */ new Map();
		for (let [v, y] of this._decorationsMetadata) {
			if (_.has(y.item)) continue;
			let b = e.getDecorationRange(v);
			if (b) {
				let e = new InlayHintAnchor(b, y.item.anchor.direction), v = y.item.with({ anchor: e });
				_.set(y.item, v);
			}
		}
		return Array.from(_.values());
	}
	_getHintsRanges() {
		let e = this._editor.getModel(), _ = this._editor.getVisibleRangesPlusViewportAboveBelow(), v = [];
		for (let y of _.sort(Range.compareRangesUsingStarts)) {
			let _ = e.validateRange(new Range(y.startLineNumber - 30, y.startColumn, y.endLineNumber + 30, y.endColumn));
			v.length === 0 || !Range.areIntersectingOrTouching(v[v.length - 1], _) ? v.push(_) : v[v.length - 1] = Range.plusRange(v[v.length - 1], _);
		}
		return v;
	}
	_updateHintsDecorators(e, _) {
		let v = [], y = (e, _, y, b, x) => {
			let S = {
				content: y,
				inlineClassNameAffectsLetterSpacing: !0,
				inlineClassName: _.className,
				cursorStops: b,
				attachedData: x
			};
			v.push({
				item: e,
				classNameRef: _,
				decoration: {
					range: e.anchor.range,
					options: {
						description: "InlayHint",
						showIfCollapsed: e.anchor.range.isEmpty(),
						collapseOnReplaceEdit: !e.anchor.range.isEmpty(),
						stickiness: 0,
						[e.anchor.direction]: this._activeRenderMode === 0 ? S : void 0
					}
				}
			});
		}, b = (e, _) => {
			let v = this._ruleFactory.createClassNameRef({
				width: `${x / 3 | 0}px`,
				display: "inline-block"
			});
			y(e, v, " ", _ ? InjectedTextCursorStops.Right : InjectedTextCursorStops.None);
		}, { fontSize: x, fontFamily: S, padding: C, isUniform: w } = this._getLayoutInfo(), T = "--code-editorInlayHintsFontFamily";
		this._editor.getContainerDomNode().style.setProperty(T, S);
		let E = {
			line: 0,
			totalLen: 0
		};
		for (let e of _) {
			if (E.line !== e.anchor.range.startLineNumber && (E = {
				line: e.anchor.range.startLineNumber,
				totalLen: 0
			}), E.totalLen > InlayHintsController_1._MAX_LABEL_LEN) continue;
			e.hint.paddingLeft && b(e, !1);
			let _ = typeof e.hint.label == "string" ? [{ label: e.hint.label }] : e.hint.label;
			for (let v = 0; v < _.length; v++) {
				let b = _[v], S = v === 0, D = v === _.length - 1, O = {
					fontSize: `${x}px`,
					fontFamily: `var(${T}), ${EDITOR_FONT_DEFAULTS.fontFamily}`,
					verticalAlign: w ? "baseline" : "middle",
					unicodeBidi: "isolate"
				};
				isNonEmptyArray(e.hint.textEdits) && (O.cursor = "default"), this._fillInColors(O, e.hint), (b.command || b.location) && this._activeInlayHintPart?.part.item === e && this._activeInlayHintPart.part.index === v && (O.textDecoration = "underline", this._activeInlayHintPart.hasTriggerModifier && (O.color = themeColorFromId(editorActiveLinkForeground), O.cursor = "pointer")), C && (S && D ? (O.padding = `1px ${Math.max(1, x / 4) | 0}px`, O.borderRadius = `${x / 4 | 0}px`) : S ? (O.padding = `1px 0 1px ${Math.max(1, x / 4) | 0}px`, O.borderRadius = `${x / 4 | 0}px 0 0 ${x / 4 | 0}px`) : D ? (O.padding = `1px ${Math.max(1, x / 4) | 0}px 1px 0`, O.borderRadius = `0 ${x / 4 | 0}px ${x / 4 | 0}px 0`) : O.padding = "1px 0 1px 0");
				let k = b.label;
				E.totalLen += k.length;
				let A = !1, j = E.totalLen - InlayHintsController_1._MAX_LABEL_LEN;
				if (j > 0 && (k = k.slice(0, -j) + "…", A = !0), y(e, this._ruleFactory.createClassNameRef(O), fixSpace(k), D && !e.hint.paddingRight ? InjectedTextCursorStops.Right : InjectedTextCursorStops.None, new RenderedInlayHintLabelPart(e, v)), A) break;
			}
			if (e.hint.paddingRight && b(e, !0), v.length > InlayHintsController_1._MAX_DECORATORS) break;
		}
		let D = [];
		for (let [_, v] of this._decorationsMetadata) {
			let y = this._editor.getModel()?.getDecorationRange(_);
			y && e.some((e) => e.containsRange(y)) && (D.push(_), v.classNameRef.dispose(), this._decorationsMetadata.delete(_));
		}
		let O = StableEditorScrollState.capture(this._editor);
		this._editor.changeDecorations((e) => {
			let _ = e.deltaDecorations(D, v.map((e) => e.decoration));
			for (let e = 0; e < _.length; e++) {
				let y = v[e];
				this._decorationsMetadata.set(_[e], y);
			}
		}), O.restore(this._editor);
	}
	_fillInColors(e, _) {
		_.kind === InlayHintKind$1.Parameter ? (e.backgroundColor = themeColorFromId(editorInlayHintParameterBackground), e.color = themeColorFromId(editorInlayHintParameterForeground)) : _.kind === InlayHintKind$1.Type ? (e.backgroundColor = themeColorFromId(editorInlayHintTypeBackground), e.color = themeColorFromId(editorInlayHintTypeForeground)) : (e.backgroundColor = themeColorFromId(editorInlayHintBackground), e.color = themeColorFromId(editorInlayHintForeground));
	}
	_getLayoutInfo() {
		let e = this._editor.getOption(142), _ = e.padding, v = this._editor.getOption(52), y = this._editor.getOption(49), b = e.fontSize;
		(!b || b < 5 || b > v) && (b = v);
		let x = e.fontFamily || y;
		return {
			fontSize: b,
			fontFamily: x,
			padding: _,
			isUniform: !_ && x === y && b === v
		};
	}
	_removeAllDecorations() {
		this._editor.removeDecorations(Array.from(this._decorationsMetadata.keys()));
		for (let e of this._decorationsMetadata.values()) e.classNameRef.dispose();
		this._decorationsMetadata.clear();
	}
};
InlayHintsController = InlayHintsController_1 = __decorate$76([
	__param$76(1, ILanguageFeaturesService),
	__param$76(2, ILanguageFeatureDebounceService),
	__param$76(3, IInlayHintsCache),
	__param$76(4, ICommandService),
	__param$76(5, INotificationService),
	__param$76(6, IInstantiationService)
], InlayHintsController);
function fixSpace(e) {
	return e.replace(/[ \t]/g, "\xA0");
}
CommandsRegistry.registerCommand("_executeInlayHintProvider", async (e, ..._) => {
	let [v, y] = _;
	assertType(URI.isUri(v)), assertType(Range.isIRange(y));
	let { inlayHintsProvider: b } = e.get(ILanguageFeaturesService), x = await e.get(ITextModelService).createModelReference(v);
	try {
		let e = await InlayHintsFragments.create(b, x.object.textEditorModel, [Range.lift(y)], CancellationToken.None), _ = e.items.map((e) => e.hint);
		return setTimeout(() => e.dispose(), 0), _;
	} finally {
		x.dispose();
	}
});
var __decorate$75 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$75 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlayHintsHoverAnchor = class extends HoverForeignElementAnchor {
	constructor(e, _, v, y) {
		super(10, _, e.item.anchor.range, v, y, !0), this.part = e;
	}
}, InlayHintsHover = class extends MarkdownHoverParticipant {
	constructor(e, _, v, y, b, x, S, C, w) {
		super(e, _, v, x, C, y, b, w), this._resolverService = S, this.hoverOrdinal = 6;
	}
	suggestHoverAnchor(e) {
		if (!InlayHintsController.get(this._editor) || e.target.type !== 6) return null;
		let _ = e.target.detail.injectedText?.options;
		return _ instanceof ModelDecorationInjectedTextOptions && _.attachedData instanceof RenderedInlayHintLabelPart ? new InlayHintsHoverAnchor(_.attachedData, this, e.event.posx, e.event.posy) : null;
	}
	computeSync() {
		return [];
	}
	computeAsync(e, _, v) {
		return e instanceof InlayHintsHoverAnchor ? new AsyncIterableObject(async (_) => {
			let { part: y } = e;
			if (await y.item.resolve(v), v.isCancellationRequested) return;
			let b;
			typeof y.item.hint.tooltip == "string" ? b = new MarkdownString().appendText(y.item.hint.tooltip) : y.item.hint.tooltip && (b = y.item.hint.tooltip), b && _.emitOne(new MarkdownHover(this, e.range, [b], !1, 0)), isNonEmptyArray(y.item.hint.textEdits) && _.emitOne(new MarkdownHover(this, e.range, [new MarkdownString().appendText(localize("hint.dbl", "Double-click to insert"))], !1, 10001));
			let x;
			if (typeof y.part.tooltip == "string" ? x = new MarkdownString().appendText(y.part.tooltip) : y.part.tooltip && (x = y.part.tooltip), x && _.emitOne(new MarkdownHover(this, e.range, [x], !1, 1)), y.part.location || y.part.command) {
				let v, b = this._editor.getOption(78) === "altKey" ? isMacintosh ? localize("links.navigate.kb.meta.mac", "cmd + click") : localize("links.navigate.kb.meta", "ctrl + click") : isMacintosh ? localize("links.navigate.kb.alt.mac", "option + click") : localize("links.navigate.kb.alt", "alt + click");
				y.part.location && y.part.command ? v = new MarkdownString().appendText(localize("hint.defAndCommand", "Go to Definition ({0}), right click for more", b)) : y.part.location ? v = new MarkdownString().appendText(localize("hint.def", "Go to Definition ({0})", b)) : y.part.command && (v = new MarkdownString(`[${localize("hint.cmd", "Execute Command")}](${asCommandLink(y.part.command)} "${y.part.command.title}") (${b})`, { isTrusted: !0 })), v && _.emitOne(new MarkdownHover(this, e.range, [v], !1, 1e4));
			}
			let S = await this._resolveInlayHintLabelPartHover(y, v);
			for await (let e of S) _.emitOne(e);
		}) : AsyncIterableObject.EMPTY;
	}
	async _resolveInlayHintLabelPartHover(e, _) {
		if (!e.part.location) return AsyncIterableObject.EMPTY;
		let { uri: v, range: y } = e.part.location, b = await this._resolverService.createModelReference(v);
		try {
			let v = b.object.textEditorModel;
			return this._languageFeaturesService.hoverProvider.has(v) ? getHoverProviderResultsAsAsyncIterable(this._languageFeaturesService.hoverProvider, v, new Position(y.startLineNumber, y.startColumn), _).filter((e) => !isEmptyMarkdownString(e.hover.contents)).map((_) => new MarkdownHover(this, e.item.anchor.range, _.hover.contents, !1, 2 + _.ordinal)) : AsyncIterableObject.EMPTY;
		} finally {
			b.dispose();
		}
	}
};
InlayHintsHover = __decorate$75([
	__param$75(1, ILanguageService),
	__param$75(2, IOpenerService),
	__param$75(3, IKeybindingService),
	__param$75(4, IHoverService),
	__param$75(5, IConfigurationService),
	__param$75(6, ITextModelService),
	__param$75(7, ILanguageFeaturesService),
	__param$75(8, ICommandService)
], InlayHintsHover);
var RenderedContentHover = class e extends Disposable {
	constructor(_, v, y, b, x, S) {
		super();
		let C = v.anchor, w = v.hoverParts;
		this._renderedHoverParts = this._register(new RenderedContentHoverParts(_, y, w, S, x));
		let { showAtPosition: T, showAtSecondaryPosition: E } = e.computeHoverPositions(_, C.range, w);
		this.shouldAppearBeforeContent = w.some((e) => e.isBeforeContent), this.showAtPosition = T, this.showAtSecondaryPosition = E, this.initialMousePosX = C.initialMousePosX, this.initialMousePosY = C.initialMousePosY, this.shouldFocus = b.shouldFocus, this.source = b.source;
	}
	get domNode() {
		return this._renderedHoverParts.domNode;
	}
	get domNodeHasChildren() {
		return this._renderedHoverParts.domNodeHasChildren;
	}
	get focusedHoverPartIndex() {
		return this._renderedHoverParts.focusedHoverPartIndex;
	}
	async updateHoverVerbosityLevel(e, _, v) {
		this._renderedHoverParts.updateHoverVerbosityLevel(e, _, v);
	}
	isColorPickerVisible() {
		return this._renderedHoverParts.isColorPickerVisible();
	}
	static computeHoverPositions(e, _, v) {
		let y = 1;
		if (e.hasModel()) {
			let v = e._getViewModel(), b = v.coordinatesConverter, x = b.convertModelRangeToViewRange(_), S = v.getLineMinColumn(x.startLineNumber), C = new Position(x.startLineNumber, S);
			y = b.convertViewPositionToModelPosition(C).column;
		}
		let b = _.startLineNumber, x = _.startColumn, S;
		for (let e of v) {
			let _ = e.range, v = _.startLineNumber === b, C = _.endLineNumber === b;
			if (v && C) {
				let e = _.startColumn, v = Math.min(x, e);
				x = Math.max(v, y);
			}
			e.forceShowAtRange && (S = _);
		}
		let C, w;
		if (S) {
			let e = S.getStartPosition();
			C = e, w = e;
		} else C = _.getStartPosition(), w = new Position(b, x);
		return {
			showAtPosition: C,
			showAtSecondaryPosition: w
		};
	}
}, RenderedStatusBar = class {
	constructor(e, _) {
		this._statusBar = _, e.appendChild(this._statusBar.hoverElement);
	}
	get hoverElement() {
		return this._statusBar.hoverElement;
	}
	get actions() {
		return this._statusBar.actions;
	}
	dispose() {
		this._statusBar.dispose();
	}
}, RenderedContentHoverParts = class e extends Disposable {
	static {
		this._DECORATION_OPTIONS = ModelDecorationOptions.register({
			description: "content-hover-highlight",
			className: "hoverHighlight"
		});
	}
	constructor(e, _, v, y, b) {
		super(), this._renderedParts = [], this._focusedHoverPartIndex = -1, this._context = b, this._fragment = document.createDocumentFragment(), this._register(this._renderParts(_, v, b, y)), this._register(this._registerListenersOnRenderedParts()), this._register(this._createEditorDecorations(e, v)), this._updateMarkdownAndColorParticipantInfo(_);
	}
	_createEditorDecorations(_, v) {
		if (v.length === 0) return Disposable.None;
		let y = v[0].range;
		for (let e of v) {
			let _ = e.range;
			y = Range.plusRange(y, _);
		}
		let b = _.createDecorationsCollection();
		return b.set([{
			range: y,
			options: e._DECORATION_OPTIONS
		}]), toDisposable(() => {
			b.clear();
		});
	}
	_renderParts(e, _, v, y) {
		let b = new EditorHoverStatusBar(y), x = {
			fragment: this._fragment,
			statusBar: b,
			...v
		}, S = new DisposableStore();
		for (let v of e) {
			let e = this._renderHoverPartsForParticipant(_, v, x);
			S.add(e);
			for (let _ of e.renderedHoverParts) this._renderedParts.push({
				type: "hoverPart",
				participant: v,
				hoverPart: _.hoverPart,
				hoverElement: _.hoverElement
			});
		}
		let C = this._renderStatusBar(this._fragment, b);
		return C && (S.add(C), this._renderedParts.push({
			type: "statusBar",
			hoverElement: C.hoverElement,
			actions: C.actions
		})), toDisposable(() => {
			S.dispose();
		});
	}
	_renderHoverPartsForParticipant(e, _, v) {
		let y = e.filter((e) => e.owner === _);
		return y.length > 0 ? _.renderHoverParts(v, y) : new RenderedHoverParts([]);
	}
	_renderStatusBar(e, _) {
		if (_.hasContent) return new RenderedStatusBar(e, _);
	}
	_registerListenersOnRenderedParts() {
		let e = new DisposableStore();
		return this._renderedParts.forEach((_, v) => {
			let y = _.hoverElement;
			y.tabIndex = 0, e.add(addDisposableListener(y, EventType$1.FOCUS_IN, (e) => {
				e.stopPropagation(), this._focusedHoverPartIndex = v;
			})), e.add(addDisposableListener(y, EventType$1.FOCUS_OUT, (e) => {
				e.stopPropagation(), this._focusedHoverPartIndex = -1;
			}));
		}), e;
	}
	_updateMarkdownAndColorParticipantInfo(e) {
		let _ = e.find((e) => e instanceof MarkdownHoverParticipant && !(e instanceof InlayHintsHover));
		_ && (this._markdownHoverParticipant = _), this._colorHoverParticipant = e.find((e) => e instanceof ColorHoverParticipant);
	}
	async updateHoverVerbosityLevel(e, _, v) {
		if (!this._markdownHoverParticipant) return;
		let y = this._normalizedIndexToMarkdownHoverIndexRange(this._markdownHoverParticipant, _);
		if (y === void 0) return;
		let b = await this._markdownHoverParticipant.updateMarkdownHoverVerbosityLevel(e, y, v);
		b && (this._renderedParts[_] = {
			type: "hoverPart",
			participant: this._markdownHoverParticipant,
			hoverPart: b.hoverPart,
			hoverElement: b.hoverElement
		}, this._context.onContentsChanged());
	}
	isColorPickerVisible() {
		return this._colorHoverParticipant?.isColorPickerVisible() ?? !1;
	}
	_normalizedIndexToMarkdownHoverIndexRange(e, _) {
		let v = this._renderedParts[_];
		if (!v || v.type !== "hoverPart" || v.participant !== e) return;
		let y = this._renderedParts.findIndex((_) => _.type === "hoverPart" && _.participant === e);
		if (y === -1) throw new BugIndicatingError();
		return _ - y;
	}
	get domNode() {
		return this._fragment;
	}
	get domNodeHasChildren() {
		return this._fragment.hasChildNodes();
	}
	get focusedHoverPartIndex() {
		return this._focusedHoverPartIndex;
	}
}, __decorate$74 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$74 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ContentHoverWidgetWrapper = class extends Disposable {
	constructor(e, _, v) {
		super(), this._editor = e, this._instantiationService = _, this._keybindingService = v, this._currentResult = null, this._onContentsChanged = this._register(new Emitter()), this.onContentsChanged = this._onContentsChanged.event, this._contentHoverWidget = this._register(this._instantiationService.createInstance(ContentHoverWidget, this._editor)), this._participants = this._initializeHoverParticipants(), this._computer = new ContentHoverComputer(this._editor, this._participants), this._hoverOperation = this._register(new HoverOperation(this._editor, this._computer)), this._registerListeners();
	}
	_initializeHoverParticipants() {
		let e = [];
		for (let _ of HoverParticipantRegistry.getAll()) {
			let v = this._instantiationService.createInstance(_, this._editor);
			e.push(v);
		}
		return e.sort((e, _) => e.hoverOrdinal - _.hoverOrdinal), this._register(this._contentHoverWidget.onDidResize(() => {
			this._participants.forEach((e) => e.handleResize?.());
		})), e;
	}
	_registerListeners() {
		this._register(this._hoverOperation.onResult((e) => {
			if (!this._computer.anchor) return;
			let _ = e.hasLoadingMessage ? this._addLoadingMessage(e.value) : e.value;
			this._withResult(new HoverResult(this._computer.anchor, _, e.isComplete));
		}));
		let e = this._contentHoverWidget.getDomNode();
		this._register(addStandardDisposableListener(e, "keydown", (e) => {
			e.equals(9) && this.hide();
		})), this._register(addStandardDisposableListener(e, "mouseleave", (e) => {
			this._onMouseLeave(e);
		})), this._register(TokenizationRegistry.onDidChange(() => {
			this._contentHoverWidget.position && this._currentResult && this._setCurrentResult(this._currentResult);
		}));
	}
	_startShowingOrUpdateHover(e, _, v, y, b) {
		if (!(this._contentHoverWidget.position && this._currentResult)) return e ? (this._startHoverOperationIfNecessary(e, _, v, y, !1), !0) : !1;
		let x = this._editor.getOption(60).sticky, S = b && this._contentHoverWidget.isMouseGettingCloser(b.event.posx, b.event.posy);
		return x && S ? (e && this._startHoverOperationIfNecessary(e, _, v, y, !0), !0) : e ? this._currentResult.anchor.equals(e) ? !0 : e.canAdoptVisibleHover(this._currentResult.anchor, this._contentHoverWidget.position) ? (this._setCurrentResult(this._currentResult.filter(e)), this._startHoverOperationIfNecessary(e, _, v, y, !1), !0) : (this._setCurrentResult(null), this._startHoverOperationIfNecessary(e, _, v, y, !1), !0) : (this._setCurrentResult(null), !1);
	}
	_startHoverOperationIfNecessary(e, _, v, y, b) {
		this._computer.anchor && this._computer.anchor.equals(e) || (this._hoverOperation.cancel(), this._computer.anchor = e, this._computer.shouldFocus = y, this._computer.source = v, this._computer.insistOnKeepingHoverVisible = b, this._hoverOperation.start(_));
	}
	_setCurrentResult(e) {
		let _ = e;
		this._currentResult !== _ && (_ && _.hoverParts.length === 0 && (_ = null), this._currentResult = _, this._currentResult ? this._showHover(this._currentResult) : this._hideHover());
	}
	_addLoadingMessage(e) {
		if (!this._computer.anchor) return e;
		for (let _ of this._participants) {
			if (!_.createLoadingMessage) continue;
			let v = _.createLoadingMessage(this._computer.anchor);
			if (v) return e.slice(0).concat([v]);
		}
		return e;
	}
	_withResult(e) {
		if (this._contentHoverWidget.position && this._currentResult && this._currentResult.isComplete || this._setCurrentResult(e), !e.isComplete) return;
		let _ = e.hoverParts.length === 0, v = this._computer.insistOnKeepingHoverVisible;
		_ && v || this._setCurrentResult(e);
	}
	_showHover(e) {
		let _ = this._getHoverContext();
		this._renderedContentHover = new RenderedContentHover(this._editor, e, this._participants, this._computer, _, this._keybindingService), this._renderedContentHover.domNodeHasChildren ? this._contentHoverWidget.show(this._renderedContentHover) : this._renderedContentHover.dispose();
	}
	_hideHover() {
		this._contentHoverWidget.hide();
	}
	_getHoverContext() {
		return {
			hide: () => {
				this.hide();
			},
			onContentsChanged: () => {
				this._onContentsChanged.fire(), this._contentHoverWidget.onContentsChanged();
			},
			setMinimumDimensions: (e) => {
				this._contentHoverWidget.setMinimumDimensions(e);
			}
		};
	}
	showsOrWillShow(e) {
		if (this._contentHoverWidget.isResizing) return !0;
		let _ = this._findHoverAnchorCandidates(e);
		if (!(_.length > 0)) return this._startShowingOrUpdateHover(null, 0, 0, !1, e);
		let v = _[0];
		return this._startShowingOrUpdateHover(v, 0, 0, !1, e);
	}
	_findHoverAnchorCandidates(e) {
		let _ = [];
		for (let v of this._participants) {
			if (!v.suggestHoverAnchor) continue;
			let y = v.suggestHoverAnchor(e);
			y && _.push(y);
		}
		let v = e.target;
		switch (v.type) {
			case 6:
				_.push(new HoverRangeAnchor(0, v.range, e.event.posx, e.event.posy));
				break;
			case 7: {
				let y = this._editor.getOption(50).typicalHalfwidthCharacterWidth / 2;
				if (!(!v.detail.isAfterLines && typeof v.detail.horizontalDistanceToText == "number" && v.detail.horizontalDistanceToText < y)) break;
				_.push(new HoverRangeAnchor(0, v.range, e.event.posx, e.event.posy));
				break;
			}
		}
		return _.sort((e, _) => _.priority - e.priority), _;
	}
	_onMouseLeave(e) {
		let _ = this._editor.getDomNode();
		(!_ || !isMousePositionWithinElement(_, e.x, e.y)) && this.hide();
	}
	startShowingAtRange(e, _, v, y) {
		this._startShowingOrUpdateHover(new HoverRangeAnchor(0, e, void 0, void 0), _, v, y, null);
	}
	async updateHoverVerbosityLevel(e, _, v) {
		this._renderedContentHover?.updateHoverVerbosityLevel(e, _, v);
	}
	focusedHoverPartIndex() {
		return this._renderedContentHover?.focusedHoverPartIndex ?? -1;
	}
	containsNode(e) {
		return e ? this._contentHoverWidget.getDomNode().contains(e) : !1;
	}
	focus() {
		this._contentHoverWidget.focus();
	}
	scrollUp() {
		this._contentHoverWidget.scrollUp();
	}
	scrollDown() {
		this._contentHoverWidget.scrollDown();
	}
	scrollLeft() {
		this._contentHoverWidget.scrollLeft();
	}
	scrollRight() {
		this._contentHoverWidget.scrollRight();
	}
	pageUp() {
		this._contentHoverWidget.pageUp();
	}
	pageDown() {
		this._contentHoverWidget.pageDown();
	}
	goToTop() {
		this._contentHoverWidget.goToTop();
	}
	goToBottom() {
		this._contentHoverWidget.goToBottom();
	}
	hide() {
		this._computer.anchor = null, this._hoverOperation.cancel(), this._setCurrentResult(null);
	}
	getDomNode() {
		return this._contentHoverWidget.getDomNode();
	}
	get isColorPickerVisible() {
		return this._renderedContentHover?.isColorPickerVisible() ?? !1;
	}
	get isVisibleFromKeyboard() {
		return this._contentHoverWidget.isVisibleFromKeyboard;
	}
	get isVisible() {
		return this._contentHoverWidget.isVisible;
	}
	get isFocused() {
		return this._contentHoverWidget.isFocused;
	}
	get isResizing() {
		return this._contentHoverWidget.isResizing;
	}
	get widget() {
		return this._contentHoverWidget;
	}
};
ContentHoverWidgetWrapper = __decorate$74([__param$74(1, IInstantiationService), __param$74(2, IKeybindingService)], ContentHoverWidgetWrapper);
var __decorate$73 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$73 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ContentHoverController_1, ContentHoverController = class extends Disposable {
	static {
		ContentHoverController_1 = this;
	}
	static {
		this.ID = "editor.contrib.contentHover";
	}
	constructor(e, _, v) {
		super(), this._editor = e, this._instantiationService = _, this._keybindingService = v, this._onHoverContentsChanged = this._register(new Emitter()), this.shouldKeepOpenOnEditorMouseMoveOrLeave = !1, this._listenersStore = new DisposableStore(), this._hoverState = {
			mouseDown: !1,
			activatedByDecoratorClick: !1
		}, this._reactToEditorMouseMoveRunner = this._register(new RunOnceScheduler(() => this._reactToEditorMouseMove(this._mouseMoveEvent), 0)), this._hookListeners(), this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(60) && (this._unhookListeners(), this._hookListeners());
		}));
	}
	static get(e) {
		return e.getContribution(ContentHoverController_1.ID);
	}
	_hookListeners() {
		let e = this._editor.getOption(60);
		this._hoverSettings = {
			enabled: e.enabled,
			sticky: e.sticky,
			hidingDelay: e.hidingDelay
		}, e.enabled ? (this._listenersStore.add(this._editor.onMouseDown((e) => this._onEditorMouseDown(e))), this._listenersStore.add(this._editor.onMouseUp(() => this._onEditorMouseUp())), this._listenersStore.add(this._editor.onMouseMove((e) => this._onEditorMouseMove(e))), this._listenersStore.add(this._editor.onKeyDown((e) => this._onKeyDown(e)))) : (this._listenersStore.add(this._editor.onMouseMove((e) => this._onEditorMouseMove(e))), this._listenersStore.add(this._editor.onKeyDown((e) => this._onKeyDown(e)))), this._listenersStore.add(this._editor.onMouseLeave((e) => this._onEditorMouseLeave(e))), this._listenersStore.add(this._editor.onDidChangeModel(() => {
			this._cancelScheduler(), this._hideWidgets();
		})), this._listenersStore.add(this._editor.onDidChangeModelContent(() => this._cancelScheduler())), this._listenersStore.add(this._editor.onDidScrollChange((e) => this._onEditorScrollChanged(e)));
	}
	_unhookListeners() {
		this._listenersStore.clear();
	}
	_cancelScheduler() {
		this._mouseMoveEvent = void 0, this._reactToEditorMouseMoveRunner.cancel();
	}
	_onEditorScrollChanged(e) {
		(e.scrollTopChanged || e.scrollLeftChanged) && this._hideWidgets();
	}
	_onEditorMouseDown(e) {
		this._hoverState.mouseDown = !0, !this._shouldNotHideCurrentHoverWidget(e) && this._hideWidgets();
	}
	_shouldNotHideCurrentHoverWidget(e) {
		return this._isMouseOnContentHoverWidget(e) || this._isContentWidgetResizing();
	}
	_isMouseOnContentHoverWidget(e) {
		let _ = this._contentWidget?.getDomNode();
		return _ ? isMousePositionWithinElement(_, e.event.posx, e.event.posy) : !1;
	}
	_onEditorMouseUp() {
		this._hoverState.mouseDown = !1;
	}
	_onEditorMouseLeave(e) {
		this.shouldKeepOpenOnEditorMouseMoveOrLeave || (this._cancelScheduler(), !this._shouldNotHideCurrentHoverWidget(e) && this._hideWidgets());
	}
	_shouldNotRecomputeCurrentHoverWidget(e) {
		let _ = this._hoverSettings.sticky;
		return ((e, _) => {
			let v = this._isMouseOnContentHoverWidget(e);
			return _ && v;
		})(e, _) || ((e) => {
			let _ = this._isMouseOnContentHoverWidget(e), v = this._contentWidget?.isColorPickerVisible ?? !1;
			return _ && v;
		})(e) || ((e, _) => (_ && this._contentWidget?.containsNode(e.event.browserEvent.view?.document.activeElement) && !e.event.browserEvent.view?.getSelection()?.isCollapsed) ?? !1)(e, _);
	}
	_onEditorMouseMove(e) {
		if (this.shouldKeepOpenOnEditorMouseMoveOrLeave || (this._mouseMoveEvent = e, this._contentWidget?.isFocused || this._contentWidget?.isResizing)) return;
		let _ = this._hoverSettings.sticky;
		if (_ && this._contentWidget?.isVisibleFromKeyboard) return;
		if (this._shouldNotRecomputeCurrentHoverWidget(e)) {
			this._reactToEditorMouseMoveRunner.cancel();
			return;
		}
		let v = this._hoverSettings.hidingDelay;
		if (this._contentWidget?.isVisible && _ && v > 0) {
			this._reactToEditorMouseMoveRunner.isScheduled() || this._reactToEditorMouseMoveRunner.schedule(v);
			return;
		}
		this._reactToEditorMouseMove(e);
	}
	_reactToEditorMouseMove(e) {
		if (!e) return;
		let _ = e.target.element?.classList.contains("colorpicker-color-decoration"), v = this._editor.getOption(149), y = this._hoverSettings.enabled, b = this._hoverState.activatedByDecoratorClick;
		if (_ && (v === "click" && !b || v === "hover" && !y || v === "clickAndHover" && !y && !b) || !_ && !y && !b) {
			this._hideWidgets();
			return;
		}
		this._tryShowHoverWidget(e) || this._hideWidgets();
	}
	_tryShowHoverWidget(e) {
		return this._getOrCreateContentWidget().showsOrWillShow(e);
	}
	_onKeyDown(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._keybindingService.softDispatch(e, this._editor.getDomNode()), v = _.kind === 1 || _.kind === 2 && (_.commandId === "editor.action.showHover" || _.commandId === "editor.action.increaseHoverVerbosityLevel" || _.commandId === "editor.action.decreaseHoverVerbosityLevel") && this._contentWidget?.isVisible;
		e.keyCode === 5 || e.keyCode === 6 || e.keyCode === 57 || e.keyCode === 4 || v || this._hideWidgets();
	}
	_hideWidgets() {
		this._hoverState.mouseDown && this._contentWidget?.isColorPickerVisible || InlineSuggestionHintsContentWidget.dropDownVisible || (this._hoverState.activatedByDecoratorClick = !1, this._contentWidget?.hide());
	}
	_getOrCreateContentWidget() {
		return this._contentWidget || (this._contentWidget = this._instantiationService.createInstance(ContentHoverWidgetWrapper, this._editor), this._listenersStore.add(this._contentWidget.onContentsChanged(() => this._onHoverContentsChanged.fire()))), this._contentWidget;
	}
	showContentHover(e, _, v, y, b = !1) {
		this._hoverState.activatedByDecoratorClick = b, this._getOrCreateContentWidget().startShowingAtRange(e, _, v, y);
	}
	_isContentWidgetResizing() {
		return this._contentWidget?.widget.isResizing || !1;
	}
	focusedHoverPartIndex() {
		return this._getOrCreateContentWidget().focusedHoverPartIndex();
	}
	updateHoverVerbosityLevel(e, _, v) {
		this._getOrCreateContentWidget().updateHoverVerbosityLevel(e, _, v);
	}
	focus() {
		this._contentWidget?.focus();
	}
	scrollUp() {
		this._contentWidget?.scrollUp();
	}
	scrollDown() {
		this._contentWidget?.scrollDown();
	}
	scrollLeft() {
		this._contentWidget?.scrollLeft();
	}
	scrollRight() {
		this._contentWidget?.scrollRight();
	}
	pageUp() {
		this._contentWidget?.pageUp();
	}
	pageDown() {
		this._contentWidget?.pageDown();
	}
	goToTop() {
		this._contentWidget?.goToTop();
	}
	goToBottom() {
		this._contentWidget?.goToBottom();
	}
	get isColorPickerVisible() {
		return this._contentWidget?.isColorPickerVisible;
	}
	get isHoverVisible() {
		return this._contentWidget?.isVisible;
	}
	dispose() {
		super.dispose(), this._unhookListeners(), this._listenersStore.dispose(), this._contentWidget?.dispose();
	}
};
ContentHoverController = ContentHoverController_1 = __decorate$73([__param$73(1, IInstantiationService), __param$73(2, IKeybindingService)], ContentHoverController);
var ColorContribution = class extends Disposable {
	static {
		this.ID = "editor.contrib.colorContribution";
	}
	constructor(e) {
		super(), this._editor = e, this._register(e.onMouseDown((e) => this.onMouseDown(e)));
	}
	dispose() {
		super.dispose();
	}
	onMouseDown(e) {
		let _ = this._editor.getOption(149);
		if (_ !== "click" && _ !== "clickAndHover") return;
		let v = e.target;
		if (v.type !== 6 || !v.detail.injectedText || v.detail.injectedText.options.attachedData !== ColorDecorationInjectedTextMarker || !v.range) return;
		let y = this._editor.getContribution(ContentHoverController.ID);
		if (y && !y.isColorPickerVisible) {
			let e = new Range(v.range.startLineNumber, v.range.startColumn + 1, v.range.endLineNumber, v.range.endColumn + 1);
			y.showContentHover(e, 1, 0, !1, !0);
		}
	}
};
registerEditorContribution(ColorContribution.ID, ColorContribution, 2), HoverParticipantRegistry.register(ColorHoverParticipant);
var __decorate$72 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$72 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, StandaloneColorPickerController_1, StandaloneColorPickerWidget_1, StandaloneColorPickerController = class extends Disposable {
	static {
		StandaloneColorPickerController_1 = this;
	}
	static {
		this.ID = "editor.contrib.standaloneColorPickerController";
	}
	constructor(e, _, v) {
		super(), this._editor = e, this._instantiationService = v, this._standaloneColorPickerWidget = null, this._standaloneColorPickerVisible = EditorContextKeys.standaloneColorPickerVisible.bindTo(_), this._standaloneColorPickerFocused = EditorContextKeys.standaloneColorPickerFocused.bindTo(_);
	}
	showOrFocus() {
		this._editor.hasModel() && (this._standaloneColorPickerVisible.get() ? this._standaloneColorPickerFocused.get() || this._standaloneColorPickerWidget?.focus() : this._standaloneColorPickerWidget = this._instantiationService.createInstance(StandaloneColorPickerWidget, this._editor, this._standaloneColorPickerVisible, this._standaloneColorPickerFocused));
	}
	hide() {
		this._standaloneColorPickerFocused.set(!1), this._standaloneColorPickerVisible.set(!1), this._standaloneColorPickerWidget?.hide(), this._editor.focus();
	}
	insertColor() {
		this._standaloneColorPickerWidget?.updateEditor(), this.hide();
	}
	static get(e) {
		return e.getContribution(StandaloneColorPickerController_1.ID);
	}
};
StandaloneColorPickerController = StandaloneColorPickerController_1 = __decorate$72([__param$72(1, IContextKeyService), __param$72(2, IInstantiationService)], StandaloneColorPickerController), registerEditorContribution(StandaloneColorPickerController.ID, StandaloneColorPickerController, 1);
var PADDING = 8, CLOSE_BUTTON_WIDTH = 22, StandaloneColorPickerWidget = class extends Disposable {
	static {
		StandaloneColorPickerWidget_1 = this;
	}
	static {
		this.ID = "editor.contrib.standaloneColorPickerWidget";
	}
	constructor(e, _, v, y, b, x, S) {
		super(), this._editor = e, this._standaloneColorPickerVisible = _, this._standaloneColorPickerFocused = v, this._keybindingService = b, this._languageFeaturesService = x, this._editorWorkerService = S, this.allowEditorOverflow = !0, this._position = void 0, this._body = document.createElement("div"), this._colorHover = null, this._selectionSetInEditor = !1, this._onResult = this._register(new Emitter()), this.onResult = this._onResult.event, this._standaloneColorPickerVisible.set(!0), this._standaloneColorPickerParticipant = y.createInstance(StandaloneColorPickerParticipant, this._editor), this._position = this._editor._getViewModel()?.getPrimaryCursorState().modelState.position;
		let C = this._editor.getSelection(), w = C ? {
			startLineNumber: C.startLineNumber,
			startColumn: C.startColumn,
			endLineNumber: C.endLineNumber,
			endColumn: C.endColumn
		} : {
			startLineNumber: 0,
			endLineNumber: 0,
			endColumn: 0,
			startColumn: 0
		}, T = this._register(trackFocus(this._body));
		this._register(T.onDidBlur((e) => {
			this.hide();
		})), this._register(T.onDidFocus((e) => {
			this.focus();
		})), this._register(this._editor.onDidChangeCursorPosition(() => {
			this._selectionSetInEditor ? this._selectionSetInEditor = !1 : this.hide();
		})), this._register(this._editor.onMouseMove((e) => {
			let _ = e.target.element?.classList;
			_ && _.contains("colorpicker-color-decoration") && this.hide();
		})), this._register(this.onResult((e) => {
			this._render(e.value, e.foundInEditor);
		})), this._start(w), this._body.style.zIndex = "50", this._editor.addContentWidget(this);
	}
	updateEditor() {
		this._colorHover && this._standaloneColorPickerParticipant.updateEditorModel(this._colorHover);
	}
	getId() {
		return StandaloneColorPickerWidget_1.ID;
	}
	getDomNode() {
		return this._body;
	}
	getPosition() {
		if (!this._position) return null;
		let e = this._editor.getOption(60).above;
		return {
			position: this._position,
			secondaryPosition: this._position,
			preference: e ? [1, 2] : [2, 1],
			positionAffinity: 2
		};
	}
	hide() {
		this.dispose(), this._standaloneColorPickerVisible.set(!1), this._standaloneColorPickerFocused.set(!1), this._editor.removeContentWidget(this), this._editor.focus();
	}
	focus() {
		this._standaloneColorPickerFocused.set(!0), this._body.focus();
	}
	async _start(e) {
		let _ = await this._computeAsync(e);
		_ && this._onResult.fire(new StandaloneColorPickerResult(_.result, _.foundInEditor));
	}
	async _computeAsync(e) {
		if (!this._editor.hasModel()) return null;
		let _ = {
			range: e,
			color: {
				red: 0,
				green: 0,
				blue: 0,
				alpha: 1
			}
		}, v = await this._standaloneColorPickerParticipant.createColorHover(_, new DefaultDocumentColorProvider(this._editorWorkerService), this._languageFeaturesService.colorProvider);
		return v ? {
			result: v.colorHover,
			foundInEditor: v.foundInEditor
		} : null;
	}
	_render(e, _) {
		let v = document.createDocumentFragment(), y = this._register(new EditorHoverStatusBar(this._keybindingService)), b = {
			fragment: v,
			statusBar: y,
			onContentsChanged: () => {},
			hide: () => this.hide()
		};
		this._colorHover = e;
		let x = this._standaloneColorPickerParticipant.renderHoverParts(b, [e]);
		if (!x) return;
		this._register(x.disposables);
		let S = x.colorPicker;
		this._body.classList.add("standalone-colorpicker-body"), this._body.style.maxHeight = Math.max(this._editor.getLayoutInfo().height / 4, 250) + "px", this._body.style.maxWidth = Math.max(this._editor.getLayoutInfo().width * .66, 500) + "px", this._body.tabIndex = 0, this._body.appendChild(v), S.layout();
		let C = S.body, w = C.saturationBox.domNode.clientWidth, T = C.domNode.clientWidth - w - CLOSE_BUTTON_WIDTH - PADDING, E = S.body.enterButton;
		E?.onClicked(() => {
			this.updateEditor(), this.hide();
		});
		let D = S.header, O = D.pickedColorNode;
		O.style.width = w + PADDING + "px";
		let k = D.originalColorNode;
		k.style.width = T + "px", S.header.closeButton?.onClicked(() => {
			this.hide();
		}), _ && (E && (E.button.textContent = "Replace"), this._selectionSetInEditor = !0, this._editor.setSelection(e.range)), this._editor.layoutContentWidget(this);
	}
};
StandaloneColorPickerWidget = StandaloneColorPickerWidget_1 = __decorate$72([
	__param$72(3, IInstantiationService),
	__param$72(4, IKeybindingService),
	__param$72(5, ILanguageFeaturesService),
	__param$72(6, IEditorWorkerService)
], StandaloneColorPickerWidget);
var StandaloneColorPickerResult = class {
	constructor(e, _) {
		this.value = e, this.foundInEditor = _;
	}
}, ShowOrFocusStandaloneColorPicker = class extends EditorAction2 {
	constructor() {
		super({
			id: "editor.action.showOrFocusStandaloneColorPicker",
			title: {
				...localize2("showOrFocusStandaloneColorPicker", "Show or Focus Standalone Color Picker"),
				mnemonicTitle: localize({
					key: "mishowOrFocusStandaloneColorPicker",
					comment: ["&& denotes a mnemonic"]
				}, "&&Show or Focus Standalone Color Picker")
			},
			precondition: void 0,
			menu: [{ id: MenuId.CommandPalette }],
			metadata: { description: localize2("showOrFocusStandaloneColorPickerDescription", "Show or focus a standalone color picker which uses the default color provider. It displays hex/rgb/hsl colors.") }
		});
	}
	runEditorCommand(e, _) {
		StandaloneColorPickerController.get(_)?.showOrFocus();
	}
}, HideStandaloneColorPicker = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.hideColorPicker",
			label: localize({
				key: "hideColorPicker",
				comment: ["Action that hides the color picker"]
			}, "Hide the Color Picker"),
			alias: "Hide the Color Picker",
			precondition: EditorContextKeys.standaloneColorPickerVisible.isEqualTo(!0),
			kbOpts: {
				primary: 9,
				weight: 100
			},
			metadata: { description: localize2("hideColorPickerDescription", "Hide the standalone color picker.") }
		});
	}
	run(e, _) {
		StandaloneColorPickerController.get(_)?.hide();
	}
}, InsertColorWithStandaloneColorPicker = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.insertColorWithStandaloneColorPicker",
			label: localize({
				key: "insertColorWithStandaloneColorPicker",
				comment: ["Action that inserts color with standalone color picker"]
			}, "Insert Color with Standalone Color Picker"),
			alias: "Insert Color with Standalone Color Picker",
			precondition: EditorContextKeys.standaloneColorPickerFocused.isEqualTo(!0),
			kbOpts: {
				primary: 3,
				weight: 100
			},
			metadata: { description: localize2("insertColorWithStandaloneColorPickerDescription", "Insert hex/rgb/hsl colors with the focused standalone color picker.") }
		});
	}
	run(e, _) {
		StandaloneColorPickerController.get(_)?.insertColor();
	}
};
registerEditorAction(HideStandaloneColorPicker), registerEditorAction(InsertColorWithStandaloneColorPicker), registerAction2(ShowOrFocusStandaloneColorPicker);
var BlockCommentCommand = class e {
	constructor(e, _, v) {
		this.languageConfigurationService = v, this._selection = e, this._insertSpace = _, this._usedEndToken = null;
	}
	static _haystackHasNeedleAtOffset(e, _, v) {
		if (v < 0) return !1;
		let y = _.length, b = e.length;
		if (v + y > b) return !1;
		for (let b = 0; b < y; b++) {
			let y = e.charCodeAt(v + b), x = _.charCodeAt(b);
			if (y !== x && !(y >= 65 && y <= 90 && y + 32 === x) && !(x >= 65 && x <= 90 && x + 32 === y)) return !1;
		}
		return !0;
	}
	_createOperationsForBlockComment(_, v, y, b, x, S) {
		let C = _.startLineNumber, w = _.startColumn, T = _.endLineNumber, E = _.endColumn, D = x.getLineContent(C), O = x.getLineContent(T), k = D.lastIndexOf(v, w - 1 + v.length), A = O.indexOf(y, E - 1 - y.length);
		if (k !== -1 && A !== -1) if (C === T) D.substring(k + v.length, A).indexOf(y) >= 0 && (k = -1, A = -1);
		else {
			let e = D.substring(k + v.length), _ = O.substring(0, A);
			(e.indexOf(y) >= 0 || _.indexOf(y) >= 0) && (k = -1, A = -1);
		}
		let j;
		k !== -1 && A !== -1 ? (b && k + v.length < D.length && D.charCodeAt(k + v.length) === 32 && (v += " "), b && A > 0 && O.charCodeAt(A - 1) === 32 && (y = " " + y, --A), j = e._createRemoveBlockCommentOperations(new Range(C, k + v.length + 1, T, A + 1), v, y)) : (j = e._createAddBlockCommentOperations(_, v, y, this._insertSpace), this._usedEndToken = j.length === 1 ? y : null);
		for (let e of j) S.addTrackedEditOperation(e.range, e.text);
	}
	static _createRemoveBlockCommentOperations(e, _, v) {
		let y = [];
		return Range.isEmpty(e) ? y.push(EditOperation.delete(new Range(e.startLineNumber, e.startColumn - _.length, e.endLineNumber, e.endColumn + v.length))) : (y.push(EditOperation.delete(new Range(e.startLineNumber, e.startColumn - _.length, e.startLineNumber, e.startColumn))), y.push(EditOperation.delete(new Range(e.endLineNumber, e.endColumn, e.endLineNumber, e.endColumn + v.length)))), y;
	}
	static _createAddBlockCommentOperations(e, _, v, y) {
		let b = [];
		return Range.isEmpty(e) ? b.push(EditOperation.replace(new Range(e.startLineNumber, e.startColumn, e.endLineNumber, e.endColumn), _ + "  " + v)) : (b.push(EditOperation.insert(new Position(e.startLineNumber, e.startColumn), _ + (y ? " " : ""))), b.push(EditOperation.insert(new Position(e.endLineNumber, e.endColumn), (y ? " " : "") + v))), b;
	}
	getEditOperations(e, _) {
		let v = this._selection.startLineNumber, y = this._selection.startColumn;
		e.tokenization.tokenizeIfCheap(v);
		let b = e.getLanguageIdAtPosition(v, y), x = this.languageConfigurationService.getLanguageConfiguration(b).comments;
		!x || !x.blockCommentStartToken || !x.blockCommentEndToken || this._createOperationsForBlockComment(this._selection, x.blockCommentStartToken, x.blockCommentEndToken, this._insertSpace, e, _);
	}
	computeCursorState(e, _) {
		let v = _.getInverseEditOperations();
		if (v.length === 2) {
			let e = v[0], _ = v[1];
			return new Selection(e.range.endLineNumber, e.range.endColumn, _.range.startLineNumber, _.range.startColumn);
		} else {
			let e = v[0].range, _ = this._usedEndToken ? -this._usedEndToken.length - 1 : 0;
			return new Selection(e.endLineNumber, e.endColumn + _, e.endLineNumber, e.endColumn + _);
		}
	}
}, LineCommentCommand = class e {
	constructor(e, _, v, y, b, x, S) {
		this.languageConfigurationService = e, this._selection = _, this._indentSize = v, this._type = y, this._insertSpace = b, this._selectionId = null, this._deltaColumn = 0, this._moveEndPositionDown = !1, this._ignoreEmptyLines = x, this._ignoreFirstLine = S || !1;
	}
	static _gatherPreflightCommentStrings(e, _, v, y) {
		e.tokenization.tokenizeIfCheap(_);
		let b = e.getLanguageIdAtPosition(_, 1), x = y.getLanguageConfiguration(b).comments, S = x ? x.lineCommentToken : null;
		if (!S) return null;
		let C = [];
		for (let e = 0, y = v - _ + 1; e < y; e++) C[e] = {
			ignore: !1,
			commentStr: S,
			commentStrOffset: 0,
			commentStrLength: S.length
		};
		return C;
	}
	static _analyzeLines(e, _, v, y, b, x, S, C) {
		let w = !0, T;
		T = e === 0 ? !0 : e !== 1;
		for (let C = 0, E = y.length; C < E; C++) {
			let E = y[C], D = b + C;
			if (D === b && S) {
				E.ignore = !0;
				continue;
			}
			let O = v.getLineContent(D), k = firstNonWhitespaceIndex(O);
			if (k === -1) {
				E.ignore = x, E.commentStrOffset = O.length;
				continue;
			}
			if (w = !1, E.ignore = !1, E.commentStrOffset = k, T && !BlockCommentCommand._haystackHasNeedleAtOffset(O, E.commentStr, k) && (e === 0 ? T = !1 : e === 1 || (E.ignore = !0)), T && _) {
				let e = k + E.commentStrLength;
				e < O.length && O.charCodeAt(e) === 32 && (E.commentStrLength += 1);
			}
		}
		if (e === 0 && w) {
			T = !1;
			for (let e = 0, _ = y.length; e < _; e++) y[e].ignore = !1;
		}
		return {
			supported: !0,
			shouldRemoveComments: T,
			lines: y
		};
	}
	static _gatherPreflightData(_, v, y, b, x, S, C, w) {
		let T = e._gatherPreflightCommentStrings(y, b, x, w);
		return T === null ? { supported: !1 } : e._analyzeLines(_, v, y, T, b, S, C, w);
	}
	_executeLineComments(_, v, y, b) {
		let x;
		y.shouldRemoveComments ? x = e._createRemoveLineCommentsOperations(y.lines, b.startLineNumber) : (e._normalizeInsertionPoint(_, y.lines, b.startLineNumber, this._indentSize), x = this._createAddLineCommentsOperations(y.lines, b.startLineNumber));
		let S = new Position(b.positionLineNumber, b.positionColumn);
		for (let e = 0, y = x.length; e < y; e++) v.addEditOperation(x[e].range, x[e].text), Range.isEmpty(x[e].range) && Range.getStartPosition(x[e].range).equals(S) && _.getLineContent(S.lineNumber).length + 1 === S.column && (this._deltaColumn = (x[e].text || "").length);
		this._selectionId = v.trackSelection(b);
	}
	_attemptRemoveBlockComment(e, _, v, y) {
		let b = _.startLineNumber, x = _.endLineNumber, S = y.length + Math.max(e.getLineFirstNonWhitespaceColumn(_.startLineNumber), _.startColumn), C = e.getLineContent(b).lastIndexOf(v, S - 1), w = e.getLineContent(x).indexOf(y, _.endColumn - 1 - v.length);
		return C !== -1 && w === -1 && (w = e.getLineContent(b).indexOf(y, C + v.length), x = b), C === -1 && w !== -1 && (C = e.getLineContent(x).lastIndexOf(v, w), b = x), _.isEmpty() && (C === -1 || w === -1) && (C = e.getLineContent(b).indexOf(v), C !== -1 && (w = e.getLineContent(b).indexOf(y, C + v.length))), C !== -1 && e.getLineContent(b).charCodeAt(C + v.length) === 32 && (v += " "), w !== -1 && e.getLineContent(x).charCodeAt(w - 1) === 32 && (y = " " + y, --w), C !== -1 && w !== -1 ? BlockCommentCommand._createRemoveBlockCommentOperations(new Range(b, C + v.length + 1, x, w + 1), v, y) : null;
	}
	_executeBlockComment(e, _, v) {
		e.tokenization.tokenizeIfCheap(v.startLineNumber);
		let y = e.getLanguageIdAtPosition(v.startLineNumber, 1), b = this.languageConfigurationService.getLanguageConfiguration(y).comments;
		if (!b || !b.blockCommentStartToken || !b.blockCommentEndToken) return;
		let x = b.blockCommentStartToken, S = b.blockCommentEndToken, C = this._attemptRemoveBlockComment(e, v, x, S);
		if (!C) {
			if (v.isEmpty()) {
				let _ = e.getLineContent(v.startLineNumber), y = firstNonWhitespaceIndex(_);
				y === -1 && (y = _.length), C = BlockCommentCommand._createAddBlockCommentOperations(new Range(v.startLineNumber, y + 1, v.startLineNumber, _.length + 1), x, S, this._insertSpace);
			} else C = BlockCommentCommand._createAddBlockCommentOperations(new Range(v.startLineNumber, e.getLineFirstNonWhitespaceColumn(v.startLineNumber), v.endLineNumber, e.getLineMaxColumn(v.endLineNumber)), x, S, this._insertSpace);
			C.length === 1 && (this._deltaColumn = x.length + 1);
		}
		this._selectionId = _.trackSelection(v);
		for (let e of C) _.addEditOperation(e.range, e.text);
	}
	getEditOperations(_, v) {
		let y = this._selection;
		if (this._moveEndPositionDown = !1, y.startLineNumber === y.endLineNumber && this._ignoreFirstLine) {
			v.addEditOperation(new Range(y.startLineNumber, _.getLineMaxColumn(y.startLineNumber), y.startLineNumber + 1, 1), y.startLineNumber === _.getLineCount() ? "" : "\n"), this._selectionId = v.trackSelection(y);
			return;
		}
		y.startLineNumber < y.endLineNumber && y.endColumn === 1 && (this._moveEndPositionDown = !0, y = y.setEndPosition(y.endLineNumber - 1, _.getLineMaxColumn(y.endLineNumber - 1)));
		let b = e._gatherPreflightData(this._type, this._insertSpace, _, y.startLineNumber, y.endLineNumber, this._ignoreEmptyLines, this._ignoreFirstLine, this.languageConfigurationService);
		return b.supported ? this._executeLineComments(_, v, b, y) : this._executeBlockComment(_, v, y);
	}
	computeCursorState(e, _) {
		let v = _.getTrackedSelection(this._selectionId);
		return this._moveEndPositionDown && (v = v.setEndPosition(v.endLineNumber + 1, 1)), new Selection(v.selectionStartLineNumber, v.selectionStartColumn + this._deltaColumn, v.positionLineNumber, v.positionColumn + this._deltaColumn);
	}
	static _createRemoveLineCommentsOperations(e, _) {
		let v = [];
		for (let y = 0, b = e.length; y < b; y++) {
			let b = e[y];
			b.ignore || v.push(EditOperation.delete(new Range(_ + y, b.commentStrOffset + 1, _ + y, b.commentStrOffset + b.commentStrLength + 1)));
		}
		return v;
	}
	_createAddLineCommentsOperations(e, _) {
		let v = [], y = this._insertSpace ? " " : "";
		for (let b = 0, x = e.length; b < x; b++) {
			let x = e[b];
			x.ignore || v.push(EditOperation.insert(new Position(_ + b, x.commentStrOffset + 1), x.commentStr + y));
		}
		return v;
	}
	static nextVisibleColumn(e, _, v, y) {
		return v ? e + (_ - e % _) : e + y;
	}
	static _normalizeInsertionPoint(_, v, y, b) {
		let x = 1073741824, S, C;
		for (let S = 0, C = v.length; S < C; S++) {
			if (v[S].ignore) continue;
			let C = _.getLineContent(y + S), w = 0;
			for (let _ = 0, y = v[S].commentStrOffset; w < x && _ < y; _++) w = e.nextVisibleColumn(w, b, C.charCodeAt(_) === 9, 1);
			w < x && (x = w);
		}
		x = Math.floor(x / b) * b;
		for (let w = 0, T = v.length; w < T; w++) {
			if (v[w].ignore) continue;
			let T = _.getLineContent(y + w), E = 0;
			for (S = 0, C = v[w].commentStrOffset; E < x && S < C; S++) E = e.nextVisibleColumn(E, b, T.charCodeAt(S) === 9, 1);
			E > x ? v[w].commentStrOffset = S - 1 : v[w].commentStrOffset = S;
		}
	}
}, CommentLineAction = class extends EditorAction {
	constructor(e, _) {
		super(_), this._type = e;
	}
	run(e, _) {
		let v = e.get(ILanguageConfigurationService);
		if (!_.hasModel()) return;
		let y = _.getModel(), b = [], x = y.getOptions(), S = _.getOption(23), C = _.getSelections().map((e, _) => ({
			selection: e,
			index: _,
			ignoreFirstLine: !1
		}));
		C.sort((e, _) => Range.compareRangesUsingStarts(e.selection, _.selection));
		let w = C[0];
		for (let e = 1; e < C.length; e++) {
			let _ = C[e];
			w.selection.endLineNumber === _.selection.startLineNumber && (w.index < _.index ? _.ignoreFirstLine = !0 : (w.ignoreFirstLine = !0, w = _));
		}
		for (let e of C) b.push(new LineCommentCommand(v, e.selection, x.indentSize, this._type, S.insertSpace, S.ignoreEmptyLines, e.ignoreFirstLine));
		_.pushUndoStop(), _.executeCommands(this.id, b), _.pushUndoStop();
	}
}, ToggleCommentLineAction = class extends CommentLineAction {
	constructor() {
		super(0, {
			id: "editor.action.commentLine",
			label: localize("comment.line", "Toggle Line Comment"),
			alias: "Toggle Line Comment",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2138,
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarEditMenu,
				group: "5_insert",
				title: localize({
					key: "miToggleLineComment",
					comment: ["&& denotes a mnemonic"]
				}, "&&Toggle Line Comment"),
				order: 1
			}
		});
	}
}, AddLineCommentAction = class extends CommentLineAction {
	constructor() {
		super(1, {
			id: "editor.action.addCommentLine",
			label: localize("comment.line.add", "Add Line Comment"),
			alias: "Add Line Comment",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2081),
				weight: 100
			}
		});
	}
}, RemoveLineCommentAction = class extends CommentLineAction {
	constructor() {
		super(2, {
			id: "editor.action.removeCommentLine",
			label: localize("comment.line.remove", "Remove Line Comment"),
			alias: "Remove Line Comment",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2099),
				weight: 100
			}
		});
	}
}, BlockCommentAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.blockComment",
			label: localize("comment.block", "Toggle Block Comment"),
			alias: "Toggle Block Comment",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1567,
				linux: { primary: 3103 },
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarEditMenu,
				group: "5_insert",
				title: localize({
					key: "miToggleBlockComment",
					comment: ["&& denotes a mnemonic"]
				}, "Toggle &&Block Comment"),
				order: 2
			}
		});
	}
	run(e, _) {
		let v = e.get(ILanguageConfigurationService);
		if (!_.hasModel()) return;
		let y = _.getOption(23), b = [], x = _.getSelections();
		for (let e of x) b.push(new BlockCommentCommand(e, y.insertSpace, v));
		_.pushUndoStop(), _.executeCommands(this.id, b), _.pushUndoStop();
	}
};
registerEditorAction(ToggleCommentLineAction), registerEditorAction(AddLineCommentAction), registerEditorAction(RemoveLineCommentAction), registerEditorAction(BlockCommentAction);
var __decorate$71 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$71 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ContextMenuController_1, ContextMenuController = class {
	static {
		ContextMenuController_1 = this;
	}
	static {
		this.ID = "editor.contrib.contextmenu";
	}
	static get(e) {
		return e.getContribution(ContextMenuController_1.ID);
	}
	constructor(e, _, v, y, b, x, S, C) {
		this._contextMenuService = _, this._contextViewService = v, this._contextKeyService = y, this._keybindingService = b, this._menuService = x, this._configurationService = S, this._workspaceContextService = C, this._toDispose = new DisposableStore(), this._contextMenuIsBeingShownCount = 0, this._editor = e, this._toDispose.add(this._editor.onContextMenu((e) => this._onContextMenu(e))), this._toDispose.add(this._editor.onMouseWheel((e) => {
			if (this._contextMenuIsBeingShownCount > 0) {
				let _ = this._contextViewService.getContextViewElement(), v = e.srcElement;
				v.shadowRoot && getShadowRoot(_) === v.shadowRoot || this._contextViewService.hideContextView();
			}
		})), this._toDispose.add(this._editor.onKeyDown((e) => {
			this._editor.getOption(24) && e.keyCode === 58 && (e.preventDefault(), e.stopPropagation(), this.showContextMenu());
		}));
	}
	_onContextMenu(e) {
		if (!this._editor.hasModel()) return;
		if (!this._editor.getOption(24)) {
			this._editor.focus(), e.target.position && !this._editor.getSelection().containsPosition(e.target.position) && this._editor.setPosition(e.target.position);
			return;
		}
		if (e.target.type === 12 || e.target.type === 6 && e.target.detail.injectedText) return;
		if (e.event.preventDefault(), e.event.stopPropagation(), e.target.type === 11) return this._showScrollbarContextMenu(e.event);
		if (e.target.type !== 6 && e.target.type !== 7 && e.target.type !== 1) return;
		if (this._editor.focus(), e.target.position) {
			let _ = !1;
			for (let v of this._editor.getSelections()) if (v.containsPosition(e.target.position)) {
				_ = !0;
				break;
			}
			_ || this._editor.setPosition(e.target.position);
		}
		let _ = null;
		e.target.type !== 1 && (_ = e.event), this.showContextMenu(_);
	}
	showContextMenu(e) {
		if (!this._editor.getOption(24) || !this._editor.hasModel()) return;
		let _ = this._getMenuActions(this._editor.getModel(), this._editor.contextMenuId);
		_.length > 0 && this._doShowContextMenu(_, e);
	}
	_getMenuActions(e, _) {
		let v = [], y = this._menuService.getMenuActions(_, this._contextKeyService, { arg: e.uri });
		for (let _ of y) {
			let [, y] = _, b = 0;
			for (let _ of y) if (_ instanceof SubmenuItemAction) {
				let y = this._getMenuActions(e, _.item.submenu);
				y.length > 0 && (v.push(new SubmenuAction(_.id, _.label, y)), b++);
			} else v.push(_), b++;
			b && v.push(new Separator());
		}
		return v.length && v.pop(), v;
	}
	_doShowContextMenu(e, _ = null) {
		if (!this._editor.hasModel()) return;
		let v = this._editor.getOption(60);
		this._editor.updateOptions({ hover: { enabled: !1 } });
		let y = _;
		if (!y) {
			this._editor.revealPosition(this._editor.getPosition(), 1), this._editor.render();
			let e = this._editor.getScrolledVisiblePosition(this._editor.getPosition()), _ = getDomNodePagePosition(this._editor.getDomNode()), v = _.left + e.left, b = _.top + e.top + e.height;
			y = {
				x: v,
				y: b
			};
		}
		let b = this._editor.getOption(128) && !isIOS;
		this._contextMenuIsBeingShownCount++, this._contextMenuService.showContextMenu({
			domForShadowRoot: b ? this._editor.getOverflowWidgetsDomNode() ?? this._editor.getDomNode() : void 0,
			getAnchor: () => y,
			getActions: () => e,
			getActionViewItem: (e) => {
				let _ = this._keybindingFor(e);
				if (_) return new ActionViewItem(e, e, {
					label: !0,
					keybinding: _.getLabel(),
					isMenu: !0
				});
				let v = e;
				return typeof v.getActionViewItem == "function" ? v.getActionViewItem() : new ActionViewItem(e, e, {
					icon: !0,
					label: !0,
					isMenu: !0
				});
			},
			getKeyBinding: (e) => this._keybindingFor(e),
			onHide: (e) => {
				this._contextMenuIsBeingShownCount--, this._editor.updateOptions({ hover: v });
			}
		});
	}
	_showScrollbarContextMenu(e) {
		if (!this._editor.hasModel() || isStandaloneEditorWorkspace(this._workspaceContextService.getWorkspace())) return;
		let _ = this._editor.getOption(73), v = 0, y = (e) => ({
			id: `menu-action-${++v}`,
			label: e.label,
			tooltip: "",
			class: void 0,
			enabled: e.enabled === void 0 ? !0 : e.enabled,
			checked: e.checked,
			run: e.run
		}), b = (e, _) => new SubmenuAction(`menu-action-${++v}`, e, _, void 0), x = (e, _, v, x, S) => {
			if (!_) return y({
				label: e,
				enabled: _,
				run: () => {}
			});
			let C = (e) => () => {
				this._configurationService.updateValue(v, e);
			}, w = [];
			for (let e of S) w.push(y({
				label: e.label,
				checked: x === e.value,
				run: C(e.value)
			}));
			return b(e, w);
		}, S = [];
		S.push(y({
			label: localize("context.minimap.minimap", "Minimap"),
			checked: _.enabled,
			run: () => {
				this._configurationService.updateValue("editor.minimap.enabled", !_.enabled);
			}
		})), S.push(new Separator()), S.push(y({
			label: localize("context.minimap.renderCharacters", "Render Characters"),
			enabled: _.enabled,
			checked: _.renderCharacters,
			run: () => {
				this._configurationService.updateValue("editor.minimap.renderCharacters", !_.renderCharacters);
			}
		})), S.push(x(localize("context.minimap.size", "Vertical size"), _.enabled, "editor.minimap.size", _.size, [
			{
				label: localize("context.minimap.size.proportional", "Proportional"),
				value: "proportional"
			},
			{
				label: localize("context.minimap.size.fill", "Fill"),
				value: "fill"
			},
			{
				label: localize("context.minimap.size.fit", "Fit"),
				value: "fit"
			}
		])), S.push(x(localize("context.minimap.slider", "Slider"), _.enabled, "editor.minimap.showSlider", _.showSlider, [{
			label: localize("context.minimap.slider.mouseover", "Mouse Over"),
			value: "mouseover"
		}, {
			label: localize("context.minimap.slider.always", "Always"),
			value: "always"
		}]));
		let C = this._editor.getOption(128) && !isIOS;
		this._contextMenuIsBeingShownCount++, this._contextMenuService.showContextMenu({
			domForShadowRoot: C ? this._editor.getDomNode() : void 0,
			getAnchor: () => e,
			getActions: () => S,
			onHide: (e) => {
				this._contextMenuIsBeingShownCount--, this._editor.focus();
			}
		});
	}
	_keybindingFor(e) {
		return this._keybindingService.lookupKeybinding(e.id);
	}
	dispose() {
		this._contextMenuIsBeingShownCount > 0 && this._contextViewService.hideContextView(), this._toDispose.dispose();
	}
};
ContextMenuController = ContextMenuController_1 = __decorate$71([
	__param$71(1, IContextMenuService),
	__param$71(2, IContextViewService),
	__param$71(3, IContextKeyService),
	__param$71(4, IKeybindingService),
	__param$71(5, IMenuService),
	__param$71(6, IConfigurationService),
	__param$71(7, IWorkspaceContextService)
], ContextMenuController);
var ShowContextMenu = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.showContextMenu",
			label: localize("action.showContextMenu.label", "Show Editor Context Menu"),
			alias: "Show Editor Context Menu",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 1092,
				weight: 100
			}
		});
	}
	run(e, _) {
		ContextMenuController.get(_)?.showContextMenu();
	}
};
registerEditorContribution(ContextMenuController.ID, ContextMenuController, 2), registerEditorAction(ShowContextMenu);
var CursorState$1 = class {
	constructor(e) {
		this.selections = e;
	}
	equals(e) {
		let _ = this.selections.length, v = e.selections.length;
		if (_ !== v) return !1;
		for (let v = 0; v < _; v++) if (!this.selections[v].equalsSelection(e.selections[v])) return !1;
		return !0;
	}
}, StackElement = class {
	constructor(e, _, v) {
		this.cursorState = e, this.scrollTop = _, this.scrollLeft = v;
	}
}, CursorUndoRedoController = class e extends Disposable {
	static {
		this.ID = "editor.contrib.cursorUndoRedoController";
	}
	static get(_) {
		return _.getContribution(e.ID);
	}
	constructor(e) {
		super(), this._editor = e, this._isCursorUndoRedo = !1, this._undoStack = [], this._redoStack = [], this._register(e.onDidChangeModel((e) => {
			this._undoStack = [], this._redoStack = [];
		})), this._register(e.onDidChangeModelContent((e) => {
			this._undoStack = [], this._redoStack = [];
		})), this._register(e.onDidChangeCursorSelection((_) => {
			if (this._isCursorUndoRedo || !_.oldSelections || _.oldModelVersionId !== _.modelVersionId) return;
			let v = new CursorState$1(_.oldSelections);
			this._undoStack.length > 0 && this._undoStack[this._undoStack.length - 1].cursorState.equals(v) || (this._undoStack.push(new StackElement(v, e.getScrollTop(), e.getScrollLeft())), this._redoStack = [], this._undoStack.length > 50 && this._undoStack.shift());
		}));
	}
	cursorUndo() {
		!this._editor.hasModel() || this._undoStack.length === 0 || (this._redoStack.push(new StackElement(new CursorState$1(this._editor.getSelections()), this._editor.getScrollTop(), this._editor.getScrollLeft())), this._applyState(this._undoStack.pop()));
	}
	cursorRedo() {
		!this._editor.hasModel() || this._redoStack.length === 0 || (this._undoStack.push(new StackElement(new CursorState$1(this._editor.getSelections()), this._editor.getScrollTop(), this._editor.getScrollLeft())), this._applyState(this._redoStack.pop()));
	}
	_applyState(e) {
		this._isCursorUndoRedo = !0, this._editor.setSelections(e.cursorState.selections), this._editor.setScrollPosition({
			scrollTop: e.scrollTop,
			scrollLeft: e.scrollLeft
		}), this._isCursorUndoRedo = !1;
	}
}, CursorUndo = class extends EditorAction {
	constructor() {
		super({
			id: "cursorUndo",
			label: localize("cursor.undo", "Cursor Undo"),
			alias: "Cursor Undo",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 2099,
				weight: 100
			}
		});
	}
	run(e, _, v) {
		CursorUndoRedoController.get(_)?.cursorUndo();
	}
}, CursorRedo = class extends EditorAction {
	constructor() {
		super({
			id: "cursorRedo",
			label: localize("cursor.redo", "Cursor Redo"),
			alias: "Cursor Redo",
			precondition: void 0
		});
	}
	run(e, _, v) {
		CursorUndoRedoController.get(_)?.cursorRedo();
	}
};
registerEditorContribution(CursorUndoRedoController.ID, CursorUndoRedoController, 0), registerEditorAction(CursorUndo), registerEditorAction(CursorRedo);
var DragAndDropCommand = class {
	constructor(e, _, v) {
		this.selection = e, this.targetPosition = _, this.copy = v, this.targetSelection = null;
	}
	getEditOperations(e, _) {
		let v = e.getValueInRange(this.selection);
		if (this.copy || _.addEditOperation(this.selection, null), _.addEditOperation(new Range(this.targetPosition.lineNumber, this.targetPosition.column, this.targetPosition.lineNumber, this.targetPosition.column), v), this.selection.containsPosition(this.targetPosition) && !(this.copy && (this.selection.getEndPosition().equals(this.targetPosition) || this.selection.getStartPosition().equals(this.targetPosition)))) {
			this.targetSelection = this.selection;
			return;
		}
		if (this.copy) {
			this.targetSelection = new Selection(this.targetPosition.lineNumber, this.targetPosition.column, this.selection.endLineNumber - this.selection.startLineNumber + this.targetPosition.lineNumber, this.selection.startLineNumber === this.selection.endLineNumber ? this.targetPosition.column + this.selection.endColumn - this.selection.startColumn : this.selection.endColumn);
			return;
		}
		if (this.targetPosition.lineNumber > this.selection.endLineNumber) {
			this.targetSelection = new Selection(this.targetPosition.lineNumber - this.selection.endLineNumber + this.selection.startLineNumber, this.targetPosition.column, this.targetPosition.lineNumber, this.selection.startLineNumber === this.selection.endLineNumber ? this.targetPosition.column + this.selection.endColumn - this.selection.startColumn : this.selection.endColumn);
			return;
		}
		if (this.targetPosition.lineNumber < this.selection.endLineNumber) {
			this.targetSelection = new Selection(this.targetPosition.lineNumber, this.targetPosition.column, this.targetPosition.lineNumber + this.selection.endLineNumber - this.selection.startLineNumber, this.selection.startLineNumber === this.selection.endLineNumber ? this.targetPosition.column + this.selection.endColumn - this.selection.startColumn : this.selection.endColumn);
			return;
		}
		this.selection.endColumn <= this.targetPosition.column ? this.targetSelection = new Selection(this.targetPosition.lineNumber - this.selection.endLineNumber + this.selection.startLineNumber, (this.selection.startLineNumber, this.selection.endLineNumber, this.targetPosition.column - this.selection.endColumn + this.selection.startColumn), this.targetPosition.lineNumber, this.selection.startLineNumber === this.selection.endLineNumber ? this.targetPosition.column : this.selection.endColumn) : this.targetSelection = new Selection(this.targetPosition.lineNumber - this.selection.endLineNumber + this.selection.startLineNumber, this.targetPosition.column, this.targetPosition.lineNumber, this.targetPosition.column + this.selection.endColumn - this.selection.startColumn);
	}
	computeCursorState(e, _) {
		return this.targetSelection;
	}
};
function hasTriggerModifier(e) {
	return isMacintosh ? e.altKey : e.ctrlKey;
}
var DragAndDropController = class e extends Disposable {
	static {
		this.ID = "editor.contrib.dragAndDrop";
	}
	static {
		this.TRIGGER_KEY_VALUE = isMacintosh ? 6 : 5;
	}
	constructor(e) {
		super(), this._editor = e, this._dndDecorationIds = this._editor.createDecorationsCollection(), this._register(this._editor.onMouseDown((e) => this._onEditorMouseDown(e))), this._register(this._editor.onMouseUp((e) => this._onEditorMouseUp(e))), this._register(this._editor.onMouseDrag((e) => this._onEditorMouseDrag(e))), this._register(this._editor.onMouseDrop((e) => this._onEditorMouseDrop(e))), this._register(this._editor.onMouseDropCanceled(() => this._onEditorMouseDropCanceled())), this._register(this._editor.onKeyDown((e) => this.onEditorKeyDown(e))), this._register(this._editor.onKeyUp((e) => this.onEditorKeyUp(e))), this._register(this._editor.onDidBlurEditorWidget(() => this.onEditorBlur())), this._register(this._editor.onDidBlurEditorText(() => this.onEditorBlur())), this._mouseDown = !1, this._modifierPressed = !1, this._dragSelection = null;
	}
	onEditorBlur() {
		this._removeDecoration(), this._dragSelection = null, this._mouseDown = !1, this._modifierPressed = !1;
	}
	onEditorKeyDown(e) {
		!this._editor.getOption(35) || this._editor.getOption(22) || (hasTriggerModifier(e) && (this._modifierPressed = !0), this._mouseDown && hasTriggerModifier(e) && this._editor.updateOptions({ mouseStyle: "copy" }));
	}
	onEditorKeyUp(_) {
		!this._editor.getOption(35) || this._editor.getOption(22) || (hasTriggerModifier(_) && (this._modifierPressed = !1), this._mouseDown && _.keyCode === e.TRIGGER_KEY_VALUE && this._editor.updateOptions({ mouseStyle: "default" }));
	}
	_onEditorMouseDown(e) {
		this._mouseDown = !0;
	}
	_onEditorMouseUp(e) {
		this._mouseDown = !1, this._editor.updateOptions({ mouseStyle: "text" });
	}
	_onEditorMouseDrag(e) {
		let _ = e.target;
		if (this._dragSelection === null) {
			let e = (this._editor.getSelections() || []).filter((e) => _.position && e.containsPosition(_.position));
			if (e.length === 1) this._dragSelection = e[0];
			else return;
		}
		hasTriggerModifier(e.event) ? this._editor.updateOptions({ mouseStyle: "copy" }) : this._editor.updateOptions({ mouseStyle: "default" }), _.position && (this._dragSelection.containsPosition(_.position) ? this._removeDecoration() : this.showAt(_.position));
	}
	_onEditorMouseDropCanceled() {
		this._editor.updateOptions({ mouseStyle: "text" }), this._removeDecoration(), this._dragSelection = null, this._mouseDown = !1;
	}
	_onEditorMouseDrop(_) {
		if (_.target && (this._hitContent(_.target) || this._hitMargin(_.target)) && _.target.position) {
			let v = new Position(_.target.position.lineNumber, _.target.position.column);
			if (this._dragSelection === null) {
				let e = null;
				if (_.event.shiftKey) {
					let _ = this._editor.getSelection();
					if (_) {
						let { selectionStartLineNumber: y, selectionStartColumn: b } = _;
						e = [new Selection(y, b, v.lineNumber, v.column)];
					}
				} else e = (this._editor.getSelections() || []).map((e) => e.containsPosition(v) ? new Selection(v.lineNumber, v.column, v.lineNumber, v.column) : e);
				this._editor.setSelections(e || [], "mouse", 3);
			} else (!this._dragSelection.containsPosition(v) || (hasTriggerModifier(_.event) || this._modifierPressed) && (this._dragSelection.getEndPosition().equals(v) || this._dragSelection.getStartPosition().equals(v))) && (this._editor.pushUndoStop(), this._editor.executeCommand(e.ID, new DragAndDropCommand(this._dragSelection, v, hasTriggerModifier(_.event) || this._modifierPressed)), this._editor.pushUndoStop());
		}
		this._editor.updateOptions({ mouseStyle: "text" }), this._removeDecoration(), this._dragSelection = null, this._mouseDown = !1;
	}
	static {
		this._DECORATION_OPTIONS = ModelDecorationOptions.register({
			description: "dnd-target",
			className: "dnd-target"
		});
	}
	showAt(_) {
		this._dndDecorationIds.set([{
			range: new Range(_.lineNumber, _.column, _.lineNumber, _.column),
			options: e._DECORATION_OPTIONS
		}]), this._editor.revealPosition(_, 1);
	}
	_removeDecoration() {
		this._dndDecorationIds.clear();
	}
	_hitContent(e) {
		return e.type === 6 || e.type === 7;
	}
	_hitMargin(e) {
		return e.type === 2 || e.type === 3 || e.type === 4;
	}
	dispose() {
		this._removeDecoration(), this._dragSelection = null, this._mouseDown = !1, this._modifierPressed = !1, super.dispose();
	}
};
registerEditorContribution(DragAndDropController.ID, DragAndDropController, 2), registerEditorContribution(CopyPasteController.ID, CopyPasteController, 0), registerEditorFeature(DefaultPasteProvidersFeature), registerEditorCommand(new class extends EditorCommand {
	constructor() {
		super({
			id: changePasteTypeCommandId,
			precondition: pasteWidgetVisibleCtx,
			kbOpts: {
				weight: 100,
				primary: 2137
			}
		});
	}
	runEditorCommand(e, _) {
		return CopyPasteController.get(_)?.changePasteType();
	}
}()), registerEditorCommand(new class extends EditorCommand {
	constructor() {
		super({
			id: "editor.hidePasteWidget",
			precondition: pasteWidgetVisibleCtx,
			kbOpts: {
				weight: 100,
				primary: 9
			}
		});
	}
	runEditorCommand(e, _) {
		CopyPasteController.get(_)?.clearWidgets();
	}
}()), registerEditorAction(class e extends EditorAction {
	static {
		this.argsSchema = {
			type: "object",
			properties: { kind: {
				type: "string",
				description: localize("pasteAs.kind", "The kind of the paste edit to try applying. If not provided or there are multiple edits for this kind, the editor will show a picker.")
			} }
		};
	}
	constructor() {
		super({
			id: "editor.action.pasteAs",
			label: localize("pasteAs", "Paste As..."),
			alias: "Paste As...",
			precondition: EditorContextKeys.writable,
			metadata: {
				description: "Paste as",
				args: [{
					name: "args",
					schema: e.argsSchema
				}]
			}
		});
	}
	run(e, _, v) {
		let y = typeof v?.kind == "string" ? v.kind : void 0;
		return !y && v && (y = typeof v.id == "string" ? v.id : void 0), CopyPasteController.get(_)?.pasteAs(y ? new HierarchicalKind(y) : void 0);
	}
}), registerEditorAction(class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.pasteAsText",
			label: localize("pasteAsText", "Paste as Text"),
			alias: "Paste as Text",
			precondition: EditorContextKeys.writable
		});
	}
	run(e, _) {
		return CopyPasteController.get(_)?.pasteAs({ providerId: DefaultTextPasteOrDropEditProvider.id });
	}
});
var TreeViewsDnDService = class {
	constructor() {
		this._dragOperations = /* @__PURE__ */ new Map();
	}
	removeDragOperationTransfer(e) {
		if (e && this._dragOperations.has(e)) {
			let _ = this._dragOperations.get(e);
			return this._dragOperations.delete(e), _;
		}
	}
}, DraggedTreeItemsIdentifier = class {
	constructor(e) {
		this.identifier = e;
	}
};
const ITreeViewsDnDService = createDecorator("treeViewsDndService");
registerSingleton(ITreeViewsDnDService, TreeViewsDnDService, 1);
var __decorate$70 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$70 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, DropIntoEditorController_1;
const defaultProviderConfig = "editor.experimental.dropIntoEditor.defaultProvider", changeDropTypeCommandId = "editor.changeDropType", dropWidgetVisibleCtx = new RawContextKey("dropWidgetVisible", !1, localize("dropWidgetVisible", "Whether the drop widget is showing"));
var DropIntoEditorController = class extends Disposable {
	static {
		DropIntoEditorController_1 = this;
	}
	static {
		this.ID = "editor.contrib.dropIntoEditorController";
	}
	static get(e) {
		return e.getContribution(DropIntoEditorController_1.ID);
	}
	constructor(e, _, v, y, b) {
		super(), this._configService = v, this._languageFeaturesService = y, this._treeViewsDragAndDropService = b, this.treeItemsTransfer = LocalSelectionTransfer.getInstance(), this._dropProgressManager = this._register(_.createInstance(InlineProgressManager, "dropIntoEditor", e)), this._postDropWidgetManager = this._register(_.createInstance(PostEditWidgetManager, "dropIntoEditor", e, dropWidgetVisibleCtx, {
			id: changeDropTypeCommandId,
			label: localize("postDropWidgetTitle", "Show drop options...")
		})), this._register(e.onDropIntoEditor((_) => this.onDropIntoEditor(e, _.position, _.event)));
	}
	clearWidgets() {
		this._postDropWidgetManager.clear();
	}
	changeDropType() {
		this._postDropWidgetManager.tryShowSelector();
	}
	async onDropIntoEditor(e, _, v) {
		if (!v.dataTransfer || !e.hasModel()) return;
		this._currentOperation?.cancel(), e.focus(), e.setPosition(_);
		let y = createCancelablePromise(async (b) => {
			let x = new DisposableStore(), S = x.add(new EditorStateCancellationTokenSource(e, 1, void 0, b));
			try {
				let y = await this.extractDataTransferData(v);
				if (y.size === 0 || S.token.isCancellationRequested) return;
				let C = e.getModel();
				if (!C) return;
				let w = this._languageFeaturesService.documentDropEditProvider.ordered(C).filter((e) => e.dropMimeTypes ? e.dropMimeTypes.some((e) => y.matches(e)) : !0), T = x.add(await this.getDropEdits(w, C, _, y, S));
				if (S.token.isCancellationRequested) return;
				if (T.edits.length) {
					let v = this.getInitialActiveEditIndex(C, T.edits), y = e.getOption(36).showDropSelector === "afterDrop";
					await this._postDropWidgetManager.applyEditAndShowIfNeeded([Range.fromPositions(_)], {
						activeEditIndex: v,
						allEdits: T.edits
					}, y, async (e) => e, b);
				}
			} finally {
				x.dispose(), this._currentOperation === y && (this._currentOperation = void 0);
			}
		});
		this._dropProgressManager.showWhile(_, localize("dropIntoEditorProgress", "Running drop handlers. Click to cancel"), y, { cancel: () => y.cancel() }), this._currentOperation = y;
	}
	async getDropEdits(e, _, v, y, b) {
		let x = new DisposableStore(), S = await raceCancellation(Promise.all(e.map(async (e) => {
			try {
				let S = await e.provideDocumentDropEdits(_, v, y, b.token);
				return S && x.add(S), S?.edits.map((_) => ({
					..._,
					providerId: e.id
				}));
			} catch (e) {
				console.error(e);
			}
		})), b.token), C = coalesce(S ?? []).flat();
		return {
			edits: sortEditsByYieldTo(C),
			dispose: () => x.dispose()
		};
	}
	getInitialActiveEditIndex(e, _) {
		let v = this._configService.getValue(defaultProviderConfig, { resource: e.uri });
		for (let [e, y] of Object.entries(v)) {
			let v = new HierarchicalKind(y), b = _.findIndex((_) => v.value === _.providerId && _.handledMimeType && matchesMimeType(e, [_.handledMimeType]));
			if (b >= 0) return b;
		}
		return 0;
	}
	async extractDataTransferData(e) {
		if (!e.dataTransfer) return new VSDataTransfer();
		let _ = toExternalVSDataTransfer(e.dataTransfer);
		if (this.treeItemsTransfer.hasData(DraggedTreeItemsIdentifier.prototype)) {
			let e = this.treeItemsTransfer.getData(DraggedTreeItemsIdentifier.prototype);
			if (Array.isArray(e)) for (let v of e) {
				let e = await this._treeViewsDragAndDropService.removeDragOperationTransfer(v.identifier);
				if (e) for (let [v, y] of e) _.replace(v, y);
			}
		}
		return _;
	}
};
DropIntoEditorController = DropIntoEditorController_1 = __decorate$70([
	__param$70(1, IInstantiationService),
	__param$70(2, IConfigurationService),
	__param$70(3, ILanguageFeaturesService),
	__param$70(4, ITreeViewsDnDService)
], DropIntoEditorController), registerEditorContribution(DropIntoEditorController.ID, DropIntoEditorController, 2), registerEditorFeature(DefaultDropProvidersFeature), registerEditorCommand(new class extends EditorCommand {
	constructor() {
		super({
			id: changeDropTypeCommandId,
			precondition: dropWidgetVisibleCtx,
			kbOpts: {
				weight: 100,
				primary: 2137
			}
		});
	}
	runEditorCommand(e, _, v) {
		DropIntoEditorController.get(_)?.changeDropType();
	}
}()), registerEditorCommand(new class extends EditorCommand {
	constructor() {
		super({
			id: "editor.hideDropWidget",
			precondition: dropWidgetVisibleCtx,
			kbOpts: {
				weight: 100,
				primary: 9
			}
		});
	}
	runEditorCommand(e, _, v) {
		DropIntoEditorController.get(_)?.clearWidgets();
	}
}()), Registry.as(Extensions$1.Configuration).registerConfiguration({
	...editorConfigurationBaseNode,
	properties: { [defaultProviderConfig]: {
		type: "object",
		scope: 5,
		description: localize("defaultProviderDescription", "Configures the default drop provider to use for content of a given mime type."),
		default: {},
		additionalProperties: { type: "string" }
	} }
});
var FindDecorations = class e {
	constructor(e) {
		this._editor = e, this._decorations = [], this._overviewRulerApproximateDecorations = [], this._findScopeDecorationIds = [], this._rangeHighlightDecorationId = null, this._highlightedDecorationId = null, this._startPosition = this._editor.getPosition();
	}
	dispose() {
		this._editor.removeDecorations(this._allDecorations()), this._decorations = [], this._overviewRulerApproximateDecorations = [], this._findScopeDecorationIds = [], this._rangeHighlightDecorationId = null, this._highlightedDecorationId = null;
	}
	reset() {
		this._decorations = [], this._overviewRulerApproximateDecorations = [], this._findScopeDecorationIds = [], this._rangeHighlightDecorationId = null, this._highlightedDecorationId = null;
	}
	getCount() {
		return this._decorations.length;
	}
	getFindScope() {
		return this._findScopeDecorationIds[0] ? this._editor.getModel().getDecorationRange(this._findScopeDecorationIds[0]) : null;
	}
	getFindScopes() {
		if (this._findScopeDecorationIds.length) {
			let e = this._findScopeDecorationIds.map((e) => this._editor.getModel().getDecorationRange(e)).filter((e) => !!e);
			if (e.length) return e;
		}
		return null;
	}
	getStartPosition() {
		return this._startPosition;
	}
	setStartPosition(e) {
		this._startPosition = e, this.setCurrentFindMatch(null);
	}
	_getDecorationIndex(e) {
		let _ = this._decorations.indexOf(e);
		return _ >= 0 ? _ + 1 : 1;
	}
	getDecorationRangeAt(e) {
		let _ = e < this._decorations.length ? this._decorations[e] : null;
		return _ ? this._editor.getModel().getDecorationRange(_) : null;
	}
	getCurrentMatchesPosition(_) {
		let v = this._editor.getModel().getDecorationsInRange(_);
		for (let _ of v) {
			let v = _.options;
			if (v === e._FIND_MATCH_DECORATION || v === e._CURRENT_FIND_MATCH_DECORATION) return this._getDecorationIndex(_.id);
		}
		return 0;
	}
	setCurrentFindMatch(_) {
		let v = null, y = 0;
		if (_) for (let e = 0, b = this._decorations.length; e < b; e++) {
			let b = this._editor.getModel().getDecorationRange(this._decorations[e]);
			if (_.equalsRange(b)) {
				v = this._decorations[e], y = e + 1;
				break;
			}
		}
		return (this._highlightedDecorationId !== null || v !== null) && this._editor.changeDecorations((_) => {
			if (this._highlightedDecorationId !== null && (_.changeDecorationOptions(this._highlightedDecorationId, e._FIND_MATCH_DECORATION), this._highlightedDecorationId = null), v !== null && (this._highlightedDecorationId = v, _.changeDecorationOptions(this._highlightedDecorationId, e._CURRENT_FIND_MATCH_DECORATION)), this._rangeHighlightDecorationId !== null && (_.removeDecoration(this._rangeHighlightDecorationId), this._rangeHighlightDecorationId = null), v !== null) {
				let y = this._editor.getModel().getDecorationRange(v);
				if (y.startLineNumber !== y.endLineNumber && y.endColumn === 1) {
					let e = y.endLineNumber - 1, _ = this._editor.getModel().getLineMaxColumn(e);
					y = new Range(y.startLineNumber, y.startColumn, e, _);
				}
				this._rangeHighlightDecorationId = _.addDecoration(y, e._RANGE_HIGHLIGHT_DECORATION);
			}
		}), y;
	}
	set(_, v) {
		this._editor.changeDecorations((y) => {
			let b = e._FIND_MATCH_DECORATION, x = [];
			if (_.length > 1e3) {
				b = e._FIND_MATCH_NO_OVERVIEW_DECORATION;
				let v = this._editor.getModel().getLineCount(), y = this._editor.getLayoutInfo().height / v, S = Math.max(2, Math.ceil(3 / y)), C = _[0].range.startLineNumber, w = _[0].range.endLineNumber;
				for (let v = 1, y = _.length; v < y; v++) {
					let y = _[v].range;
					w + S >= y.startLineNumber ? y.endLineNumber > w && (w = y.endLineNumber) : (x.push({
						range: new Range(C, 1, w, 1),
						options: e._FIND_MATCH_ONLY_OVERVIEW_DECORATION
					}), C = y.startLineNumber, w = y.endLineNumber);
				}
				x.push({
					range: new Range(C, 1, w, 1),
					options: e._FIND_MATCH_ONLY_OVERVIEW_DECORATION
				});
			}
			let S = Array(_.length);
			for (let e = 0, v = _.length; e < v; e++) S[e] = {
				range: _[e].range,
				options: b
			};
			this._decorations = y.deltaDecorations(this._decorations, S), this._overviewRulerApproximateDecorations = y.deltaDecorations(this._overviewRulerApproximateDecorations, x), this._rangeHighlightDecorationId &&= (y.removeDecoration(this._rangeHighlightDecorationId), null), this._findScopeDecorationIds.length && (this._findScopeDecorationIds.forEach((e) => y.removeDecoration(e)), this._findScopeDecorationIds = []), v?.length && (this._findScopeDecorationIds = v.map((_) => y.addDecoration(_, e._FIND_SCOPE_DECORATION)));
		});
	}
	matchBeforePosition(e) {
		if (this._decorations.length === 0) return null;
		for (let _ = this._decorations.length - 1; _ >= 0; _--) {
			let v = this._decorations[_], y = this._editor.getModel().getDecorationRange(v);
			if (!(!y || y.endLineNumber > e.lineNumber) && (y.endLineNumber < e.lineNumber || !(y.endColumn > e.column))) return y;
		}
		return this._editor.getModel().getDecorationRange(this._decorations[this._decorations.length - 1]);
	}
	matchAfterPosition(e) {
		if (this._decorations.length === 0) return null;
		for (let _ = 0, v = this._decorations.length; _ < v; _++) {
			let v = this._decorations[_], y = this._editor.getModel().getDecorationRange(v);
			if (!(!y || y.startLineNumber < e.lineNumber) && (y.startLineNumber > e.lineNumber || !(y.startColumn < e.column))) return y;
		}
		return this._editor.getModel().getDecorationRange(this._decorations[0]);
	}
	_allDecorations() {
		let e = [];
		return e = e.concat(this._decorations), e = e.concat(this._overviewRulerApproximateDecorations), this._findScopeDecorationIds.length && e.push(...this._findScopeDecorationIds), this._rangeHighlightDecorationId && e.push(this._rangeHighlightDecorationId), e;
	}
	static {
		this._CURRENT_FIND_MATCH_DECORATION = ModelDecorationOptions.register({
			description: "current-find-match",
			stickiness: 1,
			zIndex: 13,
			className: "currentFindMatch",
			inlineClassName: "currentFindMatchInline",
			showIfCollapsed: !0,
			overviewRuler: {
				color: themeColorFromId(overviewRulerFindMatchForeground),
				position: OverviewRulerLane.Center
			},
			minimap: {
				color: themeColorFromId(minimapFindMatch),
				position: 1
			}
		});
	}
	static {
		this._FIND_MATCH_DECORATION = ModelDecorationOptions.register({
			description: "find-match",
			stickiness: 1,
			zIndex: 10,
			className: "findMatch",
			inlineClassName: "findMatchInline",
			showIfCollapsed: !0,
			overviewRuler: {
				color: themeColorFromId(overviewRulerFindMatchForeground),
				position: OverviewRulerLane.Center
			},
			minimap: {
				color: themeColorFromId(minimapFindMatch),
				position: 1
			}
		});
	}
	static {
		this._FIND_MATCH_NO_OVERVIEW_DECORATION = ModelDecorationOptions.register({
			description: "find-match-no-overview",
			stickiness: 1,
			className: "findMatch",
			showIfCollapsed: !0
		});
	}
	static {
		this._FIND_MATCH_ONLY_OVERVIEW_DECORATION = ModelDecorationOptions.register({
			description: "find-match-only-overview",
			stickiness: 1,
			overviewRuler: {
				color: themeColorFromId(overviewRulerFindMatchForeground),
				position: OverviewRulerLane.Center
			}
		});
	}
	static {
		this._RANGE_HIGHLIGHT_DECORATION = ModelDecorationOptions.register({
			description: "find-range-highlight",
			stickiness: 1,
			className: "rangeHighlight",
			isWholeLine: !0
		});
	}
	static {
		this._FIND_SCOPE_DECORATION = ModelDecorationOptions.register({
			description: "find-scope",
			className: "findScope",
			isWholeLine: !0
		});
	}
}, ReplaceAllCommand = class {
	constructor(e, _, v) {
		this._editorSelection = e, this._ranges = _, this._replaceStrings = v, this._trackedEditorSelectionId = null;
	}
	getEditOperations(e, _) {
		if (this._ranges.length > 0) {
			let e = [];
			for (let _ = 0; _ < this._ranges.length; _++) e.push({
				range: this._ranges[_],
				text: this._replaceStrings[_]
			});
			e.sort((e, _) => Range.compareRangesUsingStarts(e.range, _.range));
			let v = [], y = e[0];
			for (let _ = 1; _ < e.length; _++) y.range.endLineNumber === e[_].range.startLineNumber && y.range.endColumn === e[_].range.startColumn ? (y.range = y.range.plusRange(e[_].range), y.text += e[_].text) : (v.push(y), y = e[_]);
			v.push(y);
			for (let e of v) _.addEditOperation(e.range, e.text);
		}
		this._trackedEditorSelectionId = _.trackSelection(this._editorSelection);
	}
	computeCursorState(e, _) {
		return _.getTrackedSelection(this._trackedEditorSelectionId);
	}
};
function buildReplaceStringWithCasePreserved(e, _) {
	if (e && e[0] !== "") {
		let v = validateSpecificSpecialCharacter(e, _, "-"), y = validateSpecificSpecialCharacter(e, _, "_");
		return v && !y ? buildReplaceStringForSpecificSpecialCharacter(e, _, "-") : !v && y ? buildReplaceStringForSpecificSpecialCharacter(e, _, "_") : e[0].toUpperCase() === e[0] ? _.toUpperCase() : e[0].toLowerCase() === e[0] ? _.toLowerCase() : containsUppercaseCharacter(e[0][0]) && _.length > 0 ? _[0].toUpperCase() + _.substr(1) : e[0][0].toUpperCase() !== e[0][0] && _.length > 0 ? _[0].toLowerCase() + _.substr(1) : _;
	} else return _;
}
function validateSpecificSpecialCharacter(e, _, v) {
	return e[0].indexOf(v) !== -1 && _.indexOf(v) !== -1 && e[0].split(v).length === _.split(v).length;
}
function buildReplaceStringForSpecificSpecialCharacter(e, _, v) {
	let y = _.split(v), b = e[0].split(v), x = "";
	return y.forEach((e, _) => {
		x += buildReplaceStringWithCasePreserved([b[_]], e) + v;
	}), x.slice(0, -1);
}
var StaticValueReplacePattern = class {
	constructor(e) {
		this.staticValue = e, this.kind = 0;
	}
}, DynamicPiecesReplacePattern = class {
	constructor(e) {
		this.pieces = e, this.kind = 1;
	}
}, ReplacePattern = class e {
	static fromStaticValue(_) {
		return new e([ReplacePiece.staticValue(_)]);
	}
	get hasReplacementPatterns() {
		return this._state.kind === 1;
	}
	constructor(e) {
		!e || e.length === 0 ? this._state = new StaticValueReplacePattern("") : e.length === 1 && e[0].staticValue !== null ? this._state = new StaticValueReplacePattern(e[0].staticValue) : this._state = new DynamicPiecesReplacePattern(e);
	}
	buildReplaceString(_, v) {
		if (this._state.kind === 0) return v ? buildReplaceStringWithCasePreserved(_, this._state.staticValue) : this._state.staticValue;
		let y = "";
		for (let v = 0, b = this._state.pieces.length; v < b; v++) {
			let b = this._state.pieces[v];
			if (b.staticValue !== null) {
				y += b.staticValue;
				continue;
			}
			let x = e._substitute(b.matchIndex, _);
			if (b.caseOps !== null && b.caseOps.length > 0) {
				let e = [], _ = b.caseOps.length, v = 0;
				for (let y = 0, S = x.length; y < S; y++) {
					if (v >= _) {
						e.push(x.slice(y));
						break;
					}
					switch (b.caseOps[v]) {
						case "U":
							e.push(x[y].toUpperCase());
							break;
						case "u":
							e.push(x[y].toUpperCase()), v++;
							break;
						case "L":
							e.push(x[y].toLowerCase());
							break;
						case "l":
							e.push(x[y].toLowerCase()), v++;
							break;
						default: e.push(x[y]);
					}
				}
				x = e.join("");
			}
			y += x;
		}
		return y;
	}
	static _substitute(e, _) {
		if (_ === null) return "";
		if (e === 0) return _[0];
		let v = "";
		for (; e > 0;) {
			if (e < _.length) return (_[e] || "") + v;
			v = String(e % 10) + v, e = Math.floor(e / 10);
		}
		return "$" + v;
	}
}, ReplacePiece = class e {
	static staticValue(_) {
		return new e(_, -1, null);
	}
	static caseOps(_, v) {
		return new e(null, _, v);
	}
	constructor(e, _, v) {
		this.staticValue = e, this.matchIndex = _, !v || v.length === 0 ? this.caseOps = null : this.caseOps = v.slice(0);
	}
}, ReplacePieceBuilder = class {
	constructor(e) {
		this._source = e, this._lastCharIndex = 0, this._result = [], this._resultLen = 0, this._currentStaticPiece = "";
	}
	emitUnchanged(e) {
		this._emitStatic(this._source.substring(this._lastCharIndex, e)), this._lastCharIndex = e;
	}
	emitStatic(e, _) {
		this._emitStatic(e), this._lastCharIndex = _;
	}
	_emitStatic(e) {
		e.length !== 0 && (this._currentStaticPiece += e);
	}
	emitMatchIndex(e, _, v) {
		this._currentStaticPiece.length !== 0 && (this._result[this._resultLen++] = ReplacePiece.staticValue(this._currentStaticPiece), this._currentStaticPiece = ""), this._result[this._resultLen++] = ReplacePiece.caseOps(e, v), this._lastCharIndex = _;
	}
	finalize() {
		return this.emitUnchanged(this._source.length), this._currentStaticPiece.length !== 0 && (this._result[this._resultLen++] = ReplacePiece.staticValue(this._currentStaticPiece), this._currentStaticPiece = ""), new ReplacePattern(this._result);
	}
};
function parseReplaceString(e) {
	if (!e || e.length === 0) return new ReplacePattern(null);
	let _ = [], v = new ReplacePieceBuilder(e);
	for (let y = 0, b = e.length; y < b; y++) {
		let x = e.charCodeAt(y);
		if (x === 92) {
			if (y++, y >= b) break;
			let x = e.charCodeAt(y);
			switch (x) {
				case 92:
					v.emitUnchanged(y - 1), v.emitStatic("\\", y + 1);
					break;
				case 110:
					v.emitUnchanged(y - 1), v.emitStatic("\n", y + 1);
					break;
				case 116:
					v.emitUnchanged(y - 1), v.emitStatic("	", y + 1);
					break;
				case 117:
				case 85:
				case 108:
				case 76:
					v.emitUnchanged(y - 1), v.emitStatic("", y + 1), _.push(String.fromCharCode(x));
					break;
			}
			continue;
		}
		if (x === 36) {
			if (y++, y >= b) break;
			let x = e.charCodeAt(y);
			if (x === 36) {
				v.emitUnchanged(y - 1), v.emitStatic("$", y + 1);
				continue;
			}
			if (x === 48 || x === 38) {
				v.emitUnchanged(y - 1), v.emitMatchIndex(0, y + 1, _), _.length = 0;
				continue;
			}
			if (49 <= x && x <= 57) {
				let S = x - 48;
				if (y + 1 < b) {
					let b = e.charCodeAt(y + 1);
					if (48 <= b && b <= 57) {
						y++, S = S * 10 + (b - 48), v.emitUnchanged(y - 2), v.emitMatchIndex(S, y + 1, _), _.length = 0;
						continue;
					}
				}
				v.emitUnchanged(y - 1), v.emitMatchIndex(S, y + 1, _), _.length = 0;
				continue;
			}
		}
	}
	return v.finalize();
}
const CONTEXT_FIND_WIDGET_VISIBLE = new RawContextKey("findWidgetVisible", !1);
CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
const CONTEXT_FIND_INPUT_FOCUSED = new RawContextKey("findInputFocussed", !1), CONTEXT_REPLACE_INPUT_FOCUSED = new RawContextKey("replaceInputFocussed", !1), ToggleCaseSensitiveKeybinding = {
	primary: 545,
	mac: { primary: 2593 }
}, ToggleWholeWordKeybinding = {
	primary: 565,
	mac: { primary: 2613 }
}, ToggleRegexKeybinding = {
	primary: 560,
	mac: { primary: 2608 }
}, ToggleSearchScopeKeybinding = {
	primary: 554,
	mac: { primary: 2602 }
}, TogglePreserveCaseKeybinding = {
	primary: 558,
	mac: { primary: 2606 }
}, FIND_IDS = {
	StartFindAction: "actions.find",
	StartFindWithSelection: "actions.findWithSelection",
	StartFindWithArgs: "editor.actions.findWithArgs",
	NextMatchFindAction: "editor.action.nextMatchFindAction",
	PreviousMatchFindAction: "editor.action.previousMatchFindAction",
	GoToMatchFindAction: "editor.action.goToMatchFindAction",
	NextSelectionMatchFindAction: "editor.action.nextSelectionMatchFindAction",
	PreviousSelectionMatchFindAction: "editor.action.previousSelectionMatchFindAction",
	StartFindReplaceAction: "editor.action.startFindReplaceAction",
	CloseFindWidgetCommand: "closeFindWidget",
	ToggleCaseSensitiveCommand: "toggleFindCaseSensitive",
	ToggleWholeWordCommand: "toggleFindWholeWord",
	ToggleRegexCommand: "toggleFindRegex",
	ToggleSearchScopeCommand: "toggleFindInSelection",
	TogglePreserveCaseCommand: "togglePreserveCase",
	ReplaceOneAction: "editor.action.replaceOne",
	ReplaceAllAction: "editor.action.replaceAll",
	SelectAllMatchesAction: "editor.action.selectAllMatches"
}, MATCHES_LIMIT = 19999;
var RESEARCH_DELAY = 240, FindModelBoundToEditorModel = class e {
	constructor(e, _) {
		this._toDispose = new DisposableStore(), this._editor = e, this._state = _, this._isDisposed = !1, this._startSearchingTimer = new TimeoutTimer(), this._decorations = new FindDecorations(e), this._toDispose.add(this._decorations), this._updateDecorationsScheduler = new RunOnceScheduler(() => {
			if (this._editor.hasModel()) return this.research(!1);
		}, 100), this._toDispose.add(this._updateDecorationsScheduler), this._toDispose.add(this._editor.onDidChangeCursorPosition((e) => {
			(e.reason === 3 || e.reason === 5 || e.reason === 6) && this._decorations.setStartPosition(this._editor.getPosition());
		})), this._ignoreModelContentChanged = !1, this._toDispose.add(this._editor.onDidChangeModelContent((e) => {
			this._ignoreModelContentChanged || (e.isFlush && this._decorations.reset(), this._decorations.setStartPosition(this._editor.getPosition()), this._updateDecorationsScheduler.schedule());
		})), this._toDispose.add(this._state.onFindReplaceStateChange((e) => this._onStateChanged(e))), this.research(!1, this._state.searchScope);
	}
	dispose() {
		this._isDisposed = !0, dispose(this._startSearchingTimer), this._toDispose.dispose();
	}
	_onStateChanged(e) {
		this._isDisposed || this._editor.hasModel() && (e.searchString || e.isReplaceRevealed || e.isRegex || e.wholeWord || e.matchCase || e.searchScope) && (this._editor.getModel().isTooLargeForSyncing() ? (this._startSearchingTimer.cancel(), this._startSearchingTimer.setIfNotSet(() => {
			e.searchScope ? this.research(e.moveCursor, this._state.searchScope) : this.research(e.moveCursor);
		}, RESEARCH_DELAY)) : e.searchScope ? this.research(e.moveCursor, this._state.searchScope) : this.research(e.moveCursor));
	}
	static _getSearchRange(e, _) {
		return _ || e.getFullModelRange();
	}
	research(e, _) {
		let v = null;
		_ === void 0 ? v = this._decorations.getFindScopes() : _ !== null && (v = Array.isArray(_) ? _ : [_]), v !== null && (v = v.map((e) => {
			if (e.startLineNumber !== e.endLineNumber) {
				let _ = e.endLineNumber;
				return e.endColumn === 1 && --_, new Range(e.startLineNumber, 1, _, this._editor.getModel().getLineMaxColumn(_));
			}
			return e;
		}));
		let y = this._findMatches(v, !1, MATCHES_LIMIT);
		this._decorations.set(y, v);
		let b = this._editor.getSelection(), x = this._decorations.getCurrentMatchesPosition(b);
		if (x === 0 && y.length > 0) {
			let e = findFirstIdxMonotonousOrArrLen(y.map((e) => e.range), (e) => Range.compareRangesUsingStarts(e, b) >= 0);
			x = e > 0 ? e - 1 + 1 : x;
		}
		this._state.changeMatchInfo(x, this._decorations.getCount(), void 0), e && this._editor.getOption(41).cursorMoveOnType && this._moveToNextMatch(this._decorations.getStartPosition());
	}
	_hasMatches() {
		return this._state.matchesCount > 0;
	}
	_cannotFind() {
		if (!this._hasMatches()) {
			let e = this._decorations.getFindScope();
			return e && this._editor.revealRangeInCenterIfOutsideViewport(e, 0), !0;
		}
		return !1;
	}
	_setCurrentFindMatch(e) {
		let _ = this._decorations.setCurrentFindMatch(e);
		this._state.changeMatchInfo(_, this._decorations.getCount(), e), this._editor.setSelection(e), this._editor.revealRangeInCenterIfOutsideViewport(e, 0);
	}
	_prevSearchPosition(e) {
		let _ = this._state.isRegex && (this._state.searchString.indexOf("^") >= 0 || this._state.searchString.indexOf("$") >= 0), { lineNumber: v, column: y } = e, b = this._editor.getModel();
		return _ || y === 1 ? (v === 1 ? v = b.getLineCount() : v--, y = b.getLineMaxColumn(v)) : y--, new Position(v, y);
	}
	_moveToPrevMatch(_, v = !1) {
		if (!this._state.canNavigateBack()) {
			let e = this._decorations.matchAfterPosition(_);
			e && this._setCurrentFindMatch(e);
			return;
		}
		if (this._decorations.getCount() < 19999) {
			let e = this._decorations.matchBeforePosition(_);
			e && e.isEmpty() && e.getStartPosition().equals(_) && (_ = this._prevSearchPosition(_), e = this._decorations.matchBeforePosition(_)), e && this._setCurrentFindMatch(e);
			return;
		}
		if (this._cannotFind()) return;
		let y = this._decorations.getFindScope(), b = e._getSearchRange(this._editor.getModel(), y);
		b.getEndPosition().isBefore(_) && (_ = b.getEndPosition()), _.isBefore(b.getStartPosition()) && (_ = b.getEndPosition());
		let { lineNumber: x, column: S } = _, C = this._editor.getModel(), w = new Position(x, S), T = C.findPreviousMatch(this._state.searchString, w, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(132) : null, !1);
		if (T && T.range.isEmpty() && T.range.getStartPosition().equals(w) && (w = this._prevSearchPosition(w), T = C.findPreviousMatch(this._state.searchString, w, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(132) : null, !1)), T) {
			if (!v && !b.containsRange(T.range)) return this._moveToPrevMatch(T.range.getStartPosition(), !0);
			this._setCurrentFindMatch(T.range);
		}
	}
	moveToPrevMatch() {
		this._moveToPrevMatch(this._editor.getSelection().getStartPosition());
	}
	_nextSearchPosition(e) {
		let _ = this._state.isRegex && (this._state.searchString.indexOf("^") >= 0 || this._state.searchString.indexOf("$") >= 0), { lineNumber: v, column: y } = e, b = this._editor.getModel();
		return _ || y === b.getLineMaxColumn(v) ? (v === b.getLineCount() ? v = 1 : v++, y = 1) : y++, new Position(v, y);
	}
	_moveToNextMatch(e) {
		if (!this._state.canNavigateForward()) {
			let _ = this._decorations.matchBeforePosition(e);
			_ && this._setCurrentFindMatch(_);
			return;
		}
		if (this._decorations.getCount() < 19999) {
			let _ = this._decorations.matchAfterPosition(e);
			_ && _.isEmpty() && _.getStartPosition().equals(e) && (e = this._nextSearchPosition(e), _ = this._decorations.matchAfterPosition(e)), _ && this._setCurrentFindMatch(_);
			return;
		}
		let _ = this._getNextMatch(e, !1, !0);
		_ && this._setCurrentFindMatch(_.range);
	}
	_getNextMatch(_, v, y, b = !1) {
		if (this._cannotFind()) return null;
		let x = this._decorations.getFindScope(), S = e._getSearchRange(this._editor.getModel(), x);
		S.getEndPosition().isBefore(_) && (_ = S.getStartPosition()), _.isBefore(S.getStartPosition()) && (_ = S.getStartPosition());
		let { lineNumber: C, column: w } = _, T = this._editor.getModel(), E = new Position(C, w), D = T.findNextMatch(this._state.searchString, E, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(132) : null, v);
		return y && D && D.range.isEmpty() && D.range.getStartPosition().equals(E) && (E = this._nextSearchPosition(E), D = T.findNextMatch(this._state.searchString, E, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(132) : null, v)), D ? !b && !S.containsRange(D.range) ? this._getNextMatch(D.range.getEndPosition(), v, y, !0) : D : null;
	}
	moveToNextMatch() {
		this._moveToNextMatch(this._editor.getSelection().getEndPosition());
	}
	_moveToMatch(e) {
		let _ = this._decorations.getDecorationRangeAt(e);
		_ && this._setCurrentFindMatch(_);
	}
	moveToMatch(e) {
		this._moveToMatch(e);
	}
	_getReplacePattern() {
		return this._state.isRegex ? parseReplaceString(this._state.replaceString) : ReplacePattern.fromStaticValue(this._state.replaceString);
	}
	replace() {
		if (!this._hasMatches()) return;
		let e = this._getReplacePattern(), _ = this._editor.getSelection(), v = this._getNextMatch(_.getStartPosition(), !0, !1);
		if (v) if (_.equalsRange(v.range)) {
			let y = e.buildReplaceString(v.matches, this._state.preserveCase), b = new ReplaceCommand(_, y);
			this._executeEditorCommand("replace", b), this._decorations.setStartPosition(new Position(_.startLineNumber, _.startColumn + y.length)), this.research(!0);
		} else this._decorations.setStartPosition(this._editor.getPosition()), this._setCurrentFindMatch(v.range);
	}
	_findMatches(_, v, y) {
		let b = (_ || [null]).map((_) => e._getSearchRange(this._editor.getModel(), _));
		return this._editor.getModel().findMatches(this._state.searchString, b, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(132) : null, v, y);
	}
	replaceAll() {
		if (!this._hasMatches()) return;
		let e = this._decorations.getFindScopes();
		e === null && this._state.matchesCount >= 19999 ? this._largeReplaceAll() : this._regularReplaceAll(e), this.research(!1);
	}
	_largeReplaceAll() {
		let e = new SearchParams(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(132) : null).parseSearchRequest();
		if (!e) return;
		let _ = e.regex;
		if (!_.multiline) {
			let e = "mu";
			_.ignoreCase && (e += "i"), _.global && (e += "g"), _ = new RegExp(_.source, e);
		}
		let v = this._editor.getModel(), y = v.getValue(1), b = v.getFullModelRange(), x = this._getReplacePattern(), S, C = this._state.preserveCase;
		S = x.hasReplacementPatterns || C ? y.replace(_, function() {
			return x.buildReplaceString(arguments, C);
		}) : y.replace(_, x.buildReplaceString(null, C));
		let w = new ReplaceCommandThatPreservesSelection(b, S, this._editor.getSelection());
		this._executeEditorCommand("replaceAll", w);
	}
	_regularReplaceAll(e) {
		let _ = this._getReplacePattern(), v = this._findMatches(e, _.hasReplacementPatterns || this._state.preserveCase, 1073741824), y = [];
		for (let e = 0, b = v.length; e < b; e++) y[e] = _.buildReplaceString(v[e].matches, this._state.preserveCase);
		let b = new ReplaceAllCommand(this._editor.getSelection(), v.map((e) => e.range), y);
		this._executeEditorCommand("replaceAll", b);
	}
	selectAllMatches() {
		if (!this._hasMatches()) return;
		let e = this._decorations.getFindScopes(), _ = this._findMatches(e, !1, 1073741824).map((e) => new Selection(e.range.startLineNumber, e.range.startColumn, e.range.endLineNumber, e.range.endColumn)), v = this._editor.getSelection();
		for (let e = 0, y = _.length; e < y; e++) if (_[e].equalsRange(v)) {
			_ = [v].concat(_.slice(0, e), _.slice(e + 1));
			break;
		}
		this._editor.setSelections(_);
	}
	_executeEditorCommand(e, _) {
		try {
			this._ignoreModelContentChanged = !0, this._editor.pushUndoStop(), this._editor.executeCommand(e, _), this._editor.pushUndoStop();
		} finally {
			this._ignoreModelContentChanged = !1;
		}
	}
}, FindOptionsWidget = class e extends Widget {
	static {
		this.ID = "editor.contrib.findOptionsWidget";
	}
	constructor(e, _, v) {
		super(), this._hideSoon = this._register(new RunOnceScheduler(() => this._hide(), 2e3)), this._isVisible = !1, this._editor = e, this._state = _, this._keybindingService = v, this._domNode = document.createElement("div"), this._domNode.className = "findOptionsWidget", this._domNode.style.display = "none", this._domNode.style.top = "10px", this._domNode.style.zIndex = "12", this._domNode.setAttribute("role", "presentation"), this._domNode.setAttribute("aria-hidden", "true");
		let y = {
			inputActiveOptionBorder: asCssVariable(inputActiveOptionBorder),
			inputActiveOptionForeground: asCssVariable(inputActiveOptionForeground),
			inputActiveOptionBackground: asCssVariable(inputActiveOptionBackground)
		}, b = this._register(createInstantHoverDelegate());
		this.caseSensitive = this._register(new CaseSensitiveToggle({
			appendTitle: this._keybindingLabelFor(FIND_IDS.ToggleCaseSensitiveCommand),
			isChecked: this._state.matchCase,
			hoverDelegate: b,
			...y
		})), this._domNode.appendChild(this.caseSensitive.domNode), this._register(this.caseSensitive.onChange(() => {
			this._state.change({ matchCase: this.caseSensitive.checked }, !1);
		})), this.wholeWords = this._register(new WholeWordsToggle({
			appendTitle: this._keybindingLabelFor(FIND_IDS.ToggleWholeWordCommand),
			isChecked: this._state.wholeWord,
			hoverDelegate: b,
			...y
		})), this._domNode.appendChild(this.wholeWords.domNode), this._register(this.wholeWords.onChange(() => {
			this._state.change({ wholeWord: this.wholeWords.checked }, !1);
		})), this.regex = this._register(new RegexToggle({
			appendTitle: this._keybindingLabelFor(FIND_IDS.ToggleRegexCommand),
			isChecked: this._state.isRegex,
			hoverDelegate: b,
			...y
		})), this._domNode.appendChild(this.regex.domNode), this._register(this.regex.onChange(() => {
			this._state.change({ isRegex: this.regex.checked }, !1);
		})), this._editor.addOverlayWidget(this), this._register(this._state.onFindReplaceStateChange((e) => {
			let _ = !1;
			e.isRegex && (this.regex.checked = this._state.isRegex, _ = !0), e.wholeWord && (this.wholeWords.checked = this._state.wholeWord, _ = !0), e.matchCase && (this.caseSensitive.checked = this._state.matchCase, _ = !0), !this._state.isRevealed && _ && this._revealTemporarily();
		})), this._register(addDisposableListener(this._domNode, EventType$1.MOUSE_LEAVE, (e) => this._onMouseLeave())), this._register(addDisposableListener(this._domNode, "mouseover", (e) => this._onMouseOver()));
	}
	_keybindingLabelFor(e) {
		let _ = this._keybindingService.lookupKeybinding(e);
		return _ ? ` (${_.getLabel()})` : "";
	}
	dispose() {
		this._editor.removeOverlayWidget(this), super.dispose();
	}
	getId() {
		return e.ID;
	}
	getDomNode() {
		return this._domNode;
	}
	getPosition() {
		return { preference: 0 };
	}
	highlightFindOptions() {
		this._revealTemporarily();
	}
	_revealTemporarily() {
		this._show(), this._hideSoon.schedule();
	}
	_onMouseLeave() {
		this._hideSoon.schedule();
	}
	_onMouseOver() {
		this._hideSoon.cancel();
	}
	_show() {
		this._isVisible || (this._isVisible = !0, this._domNode.style.display = "block");
	}
	_hide() {
		this._isVisible && (this._isVisible = !1, this._domNode.style.display = "none");
	}
};
function effectiveOptionValue(e, _) {
	return e === 1 ? !0 : e === 2 ? !1 : _;
}
var FindReplaceState = class extends Disposable {
	get searchString() {
		return this._searchString;
	}
	get replaceString() {
		return this._replaceString;
	}
	get isRevealed() {
		return this._isRevealed;
	}
	get isReplaceRevealed() {
		return this._isReplaceRevealed;
	}
	get isRegex() {
		return effectiveOptionValue(this._isRegexOverride, this._isRegex);
	}
	get wholeWord() {
		return effectiveOptionValue(this._wholeWordOverride, this._wholeWord);
	}
	get matchCase() {
		return effectiveOptionValue(this._matchCaseOverride, this._matchCase);
	}
	get preserveCase() {
		return effectiveOptionValue(this._preserveCaseOverride, this._preserveCase);
	}
	get actualIsRegex() {
		return this._isRegex;
	}
	get actualWholeWord() {
		return this._wholeWord;
	}
	get actualMatchCase() {
		return this._matchCase;
	}
	get actualPreserveCase() {
		return this._preserveCase;
	}
	get searchScope() {
		return this._searchScope;
	}
	get matchesPosition() {
		return this._matchesPosition;
	}
	get matchesCount() {
		return this._matchesCount;
	}
	get currentMatch() {
		return this._currentMatch;
	}
	constructor() {
		super(), this._onFindReplaceStateChange = this._register(new Emitter()), this.onFindReplaceStateChange = this._onFindReplaceStateChange.event, this._searchString = "", this._replaceString = "", this._isRevealed = !1, this._isReplaceRevealed = !1, this._isRegex = !1, this._isRegexOverride = 0, this._wholeWord = !1, this._wholeWordOverride = 0, this._matchCase = !1, this._matchCaseOverride = 0, this._preserveCase = !1, this._preserveCaseOverride = 0, this._searchScope = null, this._matchesPosition = 0, this._matchesCount = 0, this._currentMatch = null, this._loop = !0, this._isSearching = !1, this._filters = null;
	}
	changeMatchInfo(e, _, v) {
		let y = {
			moveCursor: !1,
			updateHistory: !1,
			searchString: !1,
			replaceString: !1,
			isRevealed: !1,
			isReplaceRevealed: !1,
			isRegex: !1,
			wholeWord: !1,
			matchCase: !1,
			preserveCase: !1,
			searchScope: !1,
			matchesPosition: !1,
			matchesCount: !1,
			currentMatch: !1,
			loop: !1,
			isSearching: !1,
			filters: !1
		}, b = !1;
		_ === 0 && (e = 0), e > _ && (e = _), this._matchesPosition !== e && (this._matchesPosition = e, y.matchesPosition = !0, b = !0), this._matchesCount !== _ && (this._matchesCount = _, y.matchesCount = !0, b = !0), v !== void 0 && (Range.equalsRange(this._currentMatch, v) || (this._currentMatch = v, y.currentMatch = !0, b = !0)), b && this._onFindReplaceStateChange.fire(y);
	}
	change(e, _, v = !0) {
		let y = {
			moveCursor: _,
			updateHistory: v,
			searchString: !1,
			replaceString: !1,
			isRevealed: !1,
			isReplaceRevealed: !1,
			isRegex: !1,
			wholeWord: !1,
			matchCase: !1,
			preserveCase: !1,
			searchScope: !1,
			matchesPosition: !1,
			matchesCount: !1,
			currentMatch: !1,
			loop: !1,
			isSearching: !1,
			filters: !1
		}, b = !1, x = this.isRegex, S = this.wholeWord, C = this.matchCase, w = this.preserveCase;
		e.searchString !== void 0 && this._searchString !== e.searchString && (this._searchString = e.searchString, y.searchString = !0, b = !0), e.replaceString !== void 0 && this._replaceString !== e.replaceString && (this._replaceString = e.replaceString, y.replaceString = !0, b = !0), e.isRevealed !== void 0 && this._isRevealed !== e.isRevealed && (this._isRevealed = e.isRevealed, y.isRevealed = !0, b = !0), e.isReplaceRevealed !== void 0 && this._isReplaceRevealed !== e.isReplaceRevealed && (this._isReplaceRevealed = e.isReplaceRevealed, y.isReplaceRevealed = !0, b = !0), e.isRegex !== void 0 && (this._isRegex = e.isRegex), e.wholeWord !== void 0 && (this._wholeWord = e.wholeWord), e.matchCase !== void 0 && (this._matchCase = e.matchCase), e.preserveCase !== void 0 && (this._preserveCase = e.preserveCase), e.searchScope !== void 0 && (e.searchScope?.every((e) => this._searchScope?.some((_) => !Range.equalsRange(_, e))) || (this._searchScope = e.searchScope, y.searchScope = !0, b = !0)), e.loop !== void 0 && this._loop !== e.loop && (this._loop = e.loop, y.loop = !0, b = !0), e.isSearching !== void 0 && this._isSearching !== e.isSearching && (this._isSearching = e.isSearching, y.isSearching = !0, b = !0), e.filters !== void 0 && (this._filters ? this._filters.update(e.filters) : this._filters = e.filters, y.filters = !0, b = !0), this._isRegexOverride = e.isRegexOverride === void 0 ? 0 : e.isRegexOverride, this._wholeWordOverride = e.wholeWordOverride === void 0 ? 0 : e.wholeWordOverride, this._matchCaseOverride = e.matchCaseOverride === void 0 ? 0 : e.matchCaseOverride, this._preserveCaseOverride = e.preserveCaseOverride === void 0 ? 0 : e.preserveCaseOverride, x !== this.isRegex && (b = !0, y.isRegex = !0), S !== this.wholeWord && (b = !0, y.wholeWord = !0), C !== this.matchCase && (b = !0, y.matchCase = !0), w !== this.preserveCase && (b = !0, y.preserveCase = !0), b && this._onFindReplaceStateChange.fire(y);
	}
	canNavigateBack() {
		return this.canNavigateInLoop() || this.matchesPosition !== 1;
	}
	canNavigateForward() {
		return this.canNavigateInLoop() || this.matchesPosition < this.matchesCount;
	}
	canNavigateInLoop() {
		return this._loop || this.matchesCount >= 19999;
	}
}, NLS_DEFAULT_LABEL = localize("defaultLabel", "input"), NLS_PRESERVE_CASE_LABEL = localize("label.preserveCaseToggle", "Preserve Case"), PreserveCaseToggle = class extends Toggle {
	constructor(e) {
		super({
			icon: Codicon.preserveCase,
			title: NLS_PRESERVE_CASE_LABEL + e.appendTitle,
			isChecked: e.isChecked,
			hoverDelegate: e.hoverDelegate ?? getDefaultHoverDelegate("element"),
			inputActiveOptionBorder: e.inputActiveOptionBorder,
			inputActiveOptionForeground: e.inputActiveOptionForeground,
			inputActiveOptionBackground: e.inputActiveOptionBackground
		});
	}
}, ReplaceInput = class extends Widget {
	constructor(e, _, v, y) {
		super(), this._showOptionButtons = v, this.fixFocusOnOptionClickEnabled = !0, this.cachedOptionsWidth = 0, this._onDidOptionChange = this._register(new Emitter()), this.onDidOptionChange = this._onDidOptionChange.event, this._onKeyDown = this._register(new Emitter()), this.onKeyDown = this._onKeyDown.event, this._onMouseDown = this._register(new Emitter()), this._onInput = this._register(new Emitter()), this._onKeyUp = this._register(new Emitter()), this._onPreserveCaseKeyDown = this._register(new Emitter()), this.onPreserveCaseKeyDown = this._onPreserveCaseKeyDown.event, this.contextViewProvider = _, this.placeholder = y.placeholder || "", this.validation = y.validation, this.label = y.label || NLS_DEFAULT_LABEL;
		let b = y.appendPreserveCaseLabel || "", x = y.history || [], S = !!y.flexibleHeight, C = !!y.flexibleWidth, w = y.flexibleMaxHeight;
		this.domNode = document.createElement("div"), this.domNode.classList.add("monaco-findInput"), this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
			ariaLabel: this.label || "",
			placeholder: this.placeholder || "",
			validationOptions: { validation: this.validation },
			history: x,
			showHistoryHint: y.showHistoryHint,
			flexibleHeight: S,
			flexibleWidth: C,
			flexibleMaxHeight: w,
			inputBoxStyles: y.inputBoxStyles
		})), this.preserveCase = this._register(new PreserveCaseToggle({
			appendTitle: b,
			isChecked: !1,
			...y.toggleStyles
		})), this._register(this.preserveCase.onChange((e) => {
			this._onDidOptionChange.fire(e), !e && this.fixFocusOnOptionClickEnabled && this.inputBox.focus(), this.validate();
		})), this._register(this.preserveCase.onKeyDown((e) => {
			this._onPreserveCaseKeyDown.fire(e);
		})), this._showOptionButtons ? this.cachedOptionsWidth = this.preserveCase.width() : this.cachedOptionsWidth = 0;
		let T = [this.preserveCase.domNode];
		this.onkeydown(this.domNode, (e) => {
			if (e.equals(15) || e.equals(17) || e.equals(9)) {
				let _ = T.indexOf(this.domNode.ownerDocument.activeElement);
				if (_ >= 0) {
					let v = -1;
					e.equals(17) ? v = (_ + 1) % T.length : e.equals(15) && (v = _ === 0 ? T.length - 1 : _ - 1), e.equals(9) ? (T[_].blur(), this.inputBox.focus()) : v >= 0 && T[v].focus(), EventHelper.stop(e, !0);
				}
			}
		});
		let E = document.createElement("div");
		E.className = "controls", E.style.display = this._showOptionButtons ? "block" : "none", E.appendChild(this.preserveCase.domNode), this.domNode.appendChild(E), e?.appendChild(this.domNode), this.onkeydown(this.inputBox.inputElement, (e) => this._onKeyDown.fire(e)), this.onkeyup(this.inputBox.inputElement, (e) => this._onKeyUp.fire(e)), this.oninput(this.inputBox.inputElement, (e) => this._onInput.fire()), this.onmousedown(this.inputBox.inputElement, (e) => this._onMouseDown.fire(e));
	}
	enable() {
		this.domNode.classList.remove("disabled"), this.inputBox.enable(), this.preserveCase.enable();
	}
	disable() {
		this.domNode.classList.add("disabled"), this.inputBox.disable(), this.preserveCase.disable();
	}
	setEnabled(e) {
		e ? this.enable() : this.disable();
	}
	select() {
		this.inputBox.select();
	}
	focus() {
		this.inputBox.focus();
	}
	getPreserveCase() {
		return this.preserveCase.checked;
	}
	setPreserveCase(e) {
		this.preserveCase.checked = e;
	}
	focusOnPreserve() {
		this.preserveCase.focus();
	}
	validate() {
		this.inputBox?.validate();
	}
	set width(e) {
		this.inputBox.paddingRight = this.cachedOptionsWidth, this.domNode.style.width = e + "px";
	}
	dispose() {
		super.dispose();
	}
}, __decorate$69 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$69 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const historyNavigationVisible = new RawContextKey("suggestWidgetVisible", !1, localize("suggestWidgetVisible", "Whether suggestion are visible"));
var HistoryNavigationWidgetFocusContext = "historyNavigationWidgetFocus", HistoryNavigationForwardsEnablementContext = "historyNavigationForwardsEnabled", HistoryNavigationBackwardsEnablementContext = "historyNavigationBackwardsEnabled", lastFocusedWidget = void 0, widgets = [];
function registerAndCreateHistoryNavigationContext(e, _) {
	if (widgets.includes(_)) throw Error("Cannot register the same widget multiple times");
	widgets.push(_);
	let v = new DisposableStore(), y = new RawContextKey(HistoryNavigationWidgetFocusContext, !1).bindTo(e), b = new RawContextKey(HistoryNavigationForwardsEnablementContext, !0).bindTo(e), x = new RawContextKey(HistoryNavigationBackwardsEnablementContext, !0).bindTo(e), S = () => {
		y.set(!0), lastFocusedWidget = _;
	}, C = () => {
		y.set(!1), lastFocusedWidget === _ && (lastFocusedWidget = void 0);
	};
	return isActiveElement(_.element) && S(), v.add(_.onDidFocus(() => S())), v.add(_.onDidBlur(() => C())), v.add(toDisposable(() => {
		widgets.splice(widgets.indexOf(_), 1), C();
	})), {
		historyNavigationForwardsEnablement: b,
		historyNavigationBackwardsEnablement: x,
		dispose() {
			v.dispose();
		}
	};
}
var ContextScopedFindInput = class extends FindInput {
	constructor(e, _, v, y) {
		super(e, _, v);
		let b = this._register(y.createScoped(this.inputBox.element));
		this._register(registerAndCreateHistoryNavigationContext(b, this.inputBox));
	}
};
ContextScopedFindInput = __decorate$69([__param$69(3, IContextKeyService)], ContextScopedFindInput);
var ContextScopedReplaceInput = class extends ReplaceInput {
	constructor(e, _, v, y, b = !1) {
		super(e, _, b, v);
		let x = this._register(y.createScoped(this.inputBox.element));
		this._register(registerAndCreateHistoryNavigationContext(x, this.inputBox));
	}
};
ContextScopedReplaceInput = __decorate$69([__param$69(3, IContextKeyService)], ContextScopedReplaceInput), KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "history.showPrevious",
	weight: 200,
	when: ContextKeyExpr.and(ContextKeyExpr.has(HistoryNavigationWidgetFocusContext), ContextKeyExpr.equals(HistoryNavigationBackwardsEnablementContext, !0), ContextKeyExpr.not("isComposing"), historyNavigationVisible.isEqualTo(!1)),
	primary: 16,
	secondary: [528],
	handler: (e) => {
		lastFocusedWidget?.showPreviousValue();
	}
}), KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: "history.showNext",
	weight: 200,
	when: ContextKeyExpr.and(ContextKeyExpr.has(HistoryNavigationWidgetFocusContext), ContextKeyExpr.equals(HistoryNavigationForwardsEnablementContext, !0), ContextKeyExpr.not("isComposing"), historyNavigationVisible.isEqualTo(!1)),
	primary: 18,
	secondary: [530],
	handler: (e) => {
		lastFocusedWidget?.showNextValue();
	}
});
function showHistoryKeybindingHint(e) {
	return e.lookupKeybinding("history.showPrevious")?.getElectronAccelerator() === "Up" && e.lookupKeybinding("history.showNext")?.getElectronAccelerator() === "Down";
}
var findCollapsedIcon = registerIcon("find-collapsed", Codicon.chevronRight, localize("findCollapsedIcon", "Icon to indicate that the editor find widget is collapsed.")), findExpandedIcon = registerIcon("find-expanded", Codicon.chevronDown, localize("findExpandedIcon", "Icon to indicate that the editor find widget is expanded."));
const findSelectionIcon = registerIcon("find-selection", Codicon.selection, localize("findSelectionIcon", "Icon for 'Find in Selection' in the editor find widget.")), findReplaceIcon = registerIcon("find-replace", Codicon.replace, localize("findReplaceIcon", "Icon for 'Replace' in the editor find widget.")), findReplaceAllIcon = registerIcon("find-replace-all", Codicon.replaceAll, localize("findReplaceAllIcon", "Icon for 'Replace All' in the editor find widget.")), findPreviousMatchIcon = registerIcon("find-previous-match", Codicon.arrowUp, localize("findPreviousMatchIcon", "Icon for 'Find Previous' in the editor find widget.")), findNextMatchIcon = registerIcon("find-next-match", Codicon.arrowDown, localize("findNextMatchIcon", "Icon for 'Find Next' in the editor find widget."));
var NLS_FIND_DIALOG_LABEL = localize("label.findDialog", "Find / Replace"), NLS_FIND_INPUT_LABEL = localize("label.find", "Find"), NLS_FIND_INPUT_PLACEHOLDER = localize("placeholder.find", "Find"), NLS_PREVIOUS_MATCH_BTN_LABEL = localize("label.previousMatchButton", "Previous Match"), NLS_NEXT_MATCH_BTN_LABEL = localize("label.nextMatchButton", "Next Match"), NLS_TOGGLE_SELECTION_FIND_TITLE = localize("label.toggleSelectionFind", "Find in Selection"), NLS_CLOSE_BTN_LABEL = localize("label.closeButton", "Close"), NLS_REPLACE_INPUT_LABEL = localize("label.replace", "Replace"), NLS_REPLACE_INPUT_PLACEHOLDER = localize("placeholder.replace", "Replace"), NLS_REPLACE_BTN_LABEL = localize("label.replaceButton", "Replace"), NLS_REPLACE_ALL_BTN_LABEL = localize("label.replaceAllButton", "Replace All"), NLS_TOGGLE_REPLACE_MODE_BTN_LABEL = localize("label.toggleReplaceButton", "Toggle Replace"), NLS_MATCHES_COUNT_LIMIT_TITLE = localize("title.matchesCountLimit", "Only the first {0} results are highlighted, but all find operations work on the entire text.", MATCHES_LIMIT);
const NLS_MATCHES_LOCATION = localize("label.matchesLocation", "{0} of {1}"), NLS_NO_RESULTS = localize("label.noResults", "No results");
var FIND_WIDGET_INITIAL_WIDTH = 419, FIND_INPUT_AREA_WIDTH = 221, MAX_MATCHES_COUNT_WIDTH = 69, FIND_INPUT_AREA_HEIGHT = 33, ctrlEnterReplaceAllWarningPromptedKey = "ctrlEnterReplaceAll.windows.donotask", ctrlKeyMod = isMacintosh ? 256 : 2048, FindWidgetViewZone = class {
	constructor(e) {
		this.afterLineNumber = e, this.heightInPx = FIND_INPUT_AREA_HEIGHT, this.suppressMouseDown = !1, this.domNode = document.createElement("div"), this.domNode.className = "dock-find-viewzone";
	}
};
function stopPropagationForMultiLineUpwards(e, _, v) {
	let y = !!_.match(/\n/);
	if (v && y && v.selectionStart > 0) {
		e.stopPropagation();
		return;
	}
}
function stopPropagationForMultiLineDownwards(e, _, v) {
	let y = !!_.match(/\n/);
	if (v && y && v.selectionEnd < v.value.length) {
		e.stopPropagation();
		return;
	}
}
var FindWidget = class e extends Widget {
	static {
		this.ID = "editor.contrib.findWidget";
	}
	constructor(e, _, v, y, b, x, S, C, w, T) {
		super(), this._hoverService = T, this._cachedHeight = null, this._revealTimeouts = [], this._codeEditor = e, this._controller = _, this._state = v, this._contextViewProvider = y, this._keybindingService = b, this._contextKeyService = x, this._storageService = C, this._notificationService = w, this._ctrlEnterReplaceAllWarningPrompted = !!C.getBoolean(ctrlEnterReplaceAllWarningPromptedKey, 0), this._isVisible = !1, this._isReplaceVisible = !1, this._ignoreChangeEvent = !1, this._updateHistoryDelayer = new Delayer(500), this._register(toDisposable(() => this._updateHistoryDelayer.cancel())), this._register(this._state.onFindReplaceStateChange((e) => this._onStateChanged(e))), this._buildDomNode(), this._updateButtons(), this._tryUpdateWidgetWidth(), this._findInput.inputBox.layout(), this._register(this._codeEditor.onDidChangeConfiguration((e) => {
			if (e.hasChanged(92) && (this._codeEditor.getOption(92) && this._state.change({ isReplaceRevealed: !1 }, !1), this._updateButtons()), e.hasChanged(146) && this._tryUpdateWidgetWidth(), e.hasChanged(2) && this.updateAccessibilitySupport(), e.hasChanged(41)) {
				let e = this._codeEditor.getOption(41).loop;
				this._state.change({ loop: e }, !1);
				let _ = this._codeEditor.getOption(41).addExtraSpaceOnTop;
				_ && !this._viewZone && (this._viewZone = new FindWidgetViewZone(0), this._showViewZone()), !_ && this._viewZone && this._removeViewZone();
			}
		})), this.updateAccessibilitySupport(), this._register(this._codeEditor.onDidChangeCursorSelection(() => {
			this._isVisible && this._updateToggleSelectionFindButton();
		})), this._register(this._codeEditor.onDidFocusEditorWidget(async () => {
			if (this._isVisible) {
				let e = await this._controller.getGlobalBufferTerm();
				e && e !== this._state.searchString && (this._state.change({ searchString: e }, !1), this._findInput.select());
			}
		})), this._findInputFocused = CONTEXT_FIND_INPUT_FOCUSED.bindTo(x), this._findFocusTracker = this._register(trackFocus(this._findInput.inputBox.inputElement)), this._register(this._findFocusTracker.onDidFocus(() => {
			this._findInputFocused.set(!0), this._updateSearchScope();
		})), this._register(this._findFocusTracker.onDidBlur(() => {
			this._findInputFocused.set(!1);
		})), this._replaceInputFocused = CONTEXT_REPLACE_INPUT_FOCUSED.bindTo(x), this._replaceFocusTracker = this._register(trackFocus(this._replaceInput.inputBox.inputElement)), this._register(this._replaceFocusTracker.onDidFocus(() => {
			this._replaceInputFocused.set(!0), this._updateSearchScope();
		})), this._register(this._replaceFocusTracker.onDidBlur(() => {
			this._replaceInputFocused.set(!1);
		})), this._codeEditor.addOverlayWidget(this), this._codeEditor.getOption(41).addExtraSpaceOnTop && (this._viewZone = new FindWidgetViewZone(0)), this._register(this._codeEditor.onDidChangeModel(() => {
			this._isVisible && (this._viewZoneId = void 0);
		})), this._register(this._codeEditor.onDidScrollChange((e) => {
			if (e.scrollTopChanged) {
				this._layoutViewZone();
				return;
			}
			setTimeout(() => {
				this._layoutViewZone();
			}, 0);
		}));
	}
	getId() {
		return e.ID;
	}
	getDomNode() {
		return this._domNode;
	}
	getPosition() {
		return this._isVisible ? { preference: 0 } : null;
	}
	_onStateChanged(e) {
		if (e.searchString) {
			try {
				this._ignoreChangeEvent = !0, this._findInput.setValue(this._state.searchString);
			} finally {
				this._ignoreChangeEvent = !1;
			}
			this._updateButtons();
		}
		if (e.replaceString && (this._replaceInput.inputBox.value = this._state.replaceString), e.isRevealed && (this._state.isRevealed ? this._reveal() : this._hide(!0)), e.isReplaceRevealed && (this._state.isReplaceRevealed ? !this._codeEditor.getOption(92) && !this._isReplaceVisible && (this._isReplaceVisible = !0, this._replaceInput.width = getTotalWidth(this._findInput.domNode), this._updateButtons(), this._replaceInput.inputBox.layout()) : this._isReplaceVisible && (this._isReplaceVisible = !1, this._updateButtons())), (e.isRevealed || e.isReplaceRevealed) && (this._state.isRevealed || this._state.isReplaceRevealed) && this._tryUpdateHeight() && this._showViewZone(), e.isRegex && this._findInput.setRegex(this._state.isRegex), e.wholeWord && this._findInput.setWholeWords(this._state.wholeWord), e.matchCase && this._findInput.setCaseSensitive(this._state.matchCase), e.preserveCase && this._replaceInput.setPreserveCase(this._state.preserveCase), e.searchScope && (this._state.searchScope ? this._toggleSelectionFind.checked = !0 : this._toggleSelectionFind.checked = !1, this._updateToggleSelectionFindButton()), e.searchString || e.matchesCount || e.matchesPosition) {
			let e = this._state.searchString.length > 0 && this._state.matchesCount === 0;
			this._domNode.classList.toggle("no-results", e), this._updateMatchesCount(), this._updateButtons();
		}
		(e.searchString || e.currentMatch) && this._layoutViewZone(), e.updateHistory && this._delayedUpdateHistory(), e.loop && this._updateButtons();
	}
	_delayedUpdateHistory() {
		this._updateHistoryDelayer.trigger(this._updateHistory.bind(this)).then(void 0, onUnexpectedError);
	}
	_updateHistory() {
		this._state.searchString && this._findInput.inputBox.addToHistory(), this._state.replaceString && this._replaceInput.inputBox.addToHistory();
	}
	_updateMatchesCount() {
		this._matchesCount.style.minWidth = MAX_MATCHES_COUNT_WIDTH + "px", this._state.matchesCount >= 19999 ? this._matchesCount.title = NLS_MATCHES_COUNT_LIMIT_TITLE : this._matchesCount.title = "", this._matchesCount.firstChild?.remove();
		let e;
		if (this._state.matchesCount > 0) {
			let _ = String(this._state.matchesCount);
			this._state.matchesCount >= 19999 && (_ += "+");
			let v = String(this._state.matchesPosition);
			v === "0" && (v = "?"), e = format(NLS_MATCHES_LOCATION, v, _);
		} else e = NLS_NO_RESULTS;
		this._matchesCount.appendChild(document.createTextNode(e)), alert(this._getAriaLabel(e, this._state.currentMatch, this._state.searchString)), MAX_MATCHES_COUNT_WIDTH = Math.max(MAX_MATCHES_COUNT_WIDTH, this._matchesCount.clientWidth);
	}
	_getAriaLabel(e, _, v) {
		if (e === NLS_NO_RESULTS) return v === "" ? localize("ariaSearchNoResultEmpty", "{0} found", e) : localize("ariaSearchNoResult", "{0} found for '{1}'", e, v);
		if (_) {
			let y = localize("ariaSearchNoResultWithLineNum", "{0} found for '{1}', at {2}", e, v, _.startLineNumber + ":" + _.startColumn), b = this._codeEditor.getModel();
			return b && _.startLineNumber <= b.getLineCount() && _.startLineNumber >= 1 ? `${b.getLineContent(_.startLineNumber)}, ${y}` : y;
		}
		return localize("ariaSearchNoResultWithLineNumNoCurrentMatch", "{0} found for '{1}'", e, v);
	}
	_updateToggleSelectionFindButton() {
		let e = this._codeEditor.getSelection(), _ = e ? e.startLineNumber !== e.endLineNumber || e.startColumn !== e.endColumn : !1, v = this._toggleSelectionFind.checked;
		this._isVisible && (v || _) ? this._toggleSelectionFind.enable() : this._toggleSelectionFind.disable();
	}
	_updateButtons() {
		this._findInput.setEnabled(this._isVisible), this._replaceInput.setEnabled(this._isVisible && this._isReplaceVisible), this._updateToggleSelectionFindButton(), this._closeBtn.setEnabled(this._isVisible);
		let e = this._state.searchString.length > 0, _ = !!this._state.matchesCount;
		this._prevBtn.setEnabled(this._isVisible && e && _ && this._state.canNavigateBack()), this._nextBtn.setEnabled(this._isVisible && e && _ && this._state.canNavigateForward()), this._replaceBtn.setEnabled(this._isVisible && this._isReplaceVisible && e), this._replaceAllBtn.setEnabled(this._isVisible && this._isReplaceVisible && e), this._domNode.classList.toggle("replaceToggled", this._isReplaceVisible), this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
		let v = !this._codeEditor.getOption(92);
		this._toggleReplaceBtn.setEnabled(this._isVisible && v);
	}
	_reveal() {
		if (this._revealTimeouts.forEach((e) => {
			clearTimeout(e);
		}), this._revealTimeouts = [], !this._isVisible) {
			this._isVisible = !0;
			let e = this._codeEditor.getSelection();
			switch (this._codeEditor.getOption(41).autoFindInSelection) {
				case "always":
					this._toggleSelectionFind.checked = !0;
					break;
				case "never":
					this._toggleSelectionFind.checked = !1;
					break;
				case "multiline": {
					let _ = !!e && e.startLineNumber !== e.endLineNumber;
					this._toggleSelectionFind.checked = _;
					break;
				}
				default: break;
			}
			this._tryUpdateWidgetWidth(), this._updateButtons(), this._revealTimeouts.push(setTimeout(() => {
				this._domNode.classList.add("visible"), this._domNode.setAttribute("aria-hidden", "false");
			}, 0)), this._revealTimeouts.push(setTimeout(() => {
				this._findInput.validate();
			}, 200)), this._codeEditor.layoutOverlayWidget(this);
			let _ = !0;
			if (this._codeEditor.getOption(41).seedSearchStringFromSelection && e) {
				let v = this._codeEditor.getDomNode();
				if (v) {
					let y = getDomNodePagePosition(v), b = this._codeEditor.getScrolledVisiblePosition(e.getStartPosition()), x = y.left + (b ? b.left : 0), S = b ? b.top : 0;
					if (this._viewZone && S < this._viewZone.heightInPx) {
						e.endLineNumber > e.startLineNumber && (_ = !1);
						let v = getTopLeftOffset(this._domNode).left;
						x > v && (_ = !1);
						let b = this._codeEditor.getScrolledVisiblePosition(e.getEndPosition());
						y.left + (b ? b.left : 0) > v && (_ = !1);
					}
				}
			}
			this._showViewZone(_);
		}
	}
	_hide(e) {
		this._revealTimeouts.forEach((e) => {
			clearTimeout(e);
		}), this._revealTimeouts = [], this._isVisible && (this._isVisible = !1, this._updateButtons(), this._domNode.classList.remove("visible"), this._domNode.setAttribute("aria-hidden", "true"), this._findInput.clearMessage(), e && this._codeEditor.focus(), this._codeEditor.layoutOverlayWidget(this), this._removeViewZone());
	}
	_layoutViewZone(e) {
		if (!this._codeEditor.getOption(41).addExtraSpaceOnTop) {
			this._removeViewZone();
			return;
		}
		if (!this._isVisible) return;
		let _ = this._viewZone;
		this._viewZoneId !== void 0 || !_ || this._codeEditor.changeViewZones((v) => {
			_.heightInPx = this._getHeight(), this._viewZoneId = v.addZone(_), this._codeEditor.setScrollTop(e || this._codeEditor.getScrollTop() + _.heightInPx);
		});
	}
	_showViewZone(e = !0) {
		if (!this._isVisible || !this._codeEditor.getOption(41).addExtraSpaceOnTop) return;
		this._viewZone === void 0 && (this._viewZone = new FindWidgetViewZone(0));
		let _ = this._viewZone;
		this._codeEditor.changeViewZones((v) => {
			if (this._viewZoneId !== void 0) {
				let y = this._getHeight();
				if (y === _.heightInPx) return;
				let b = y - _.heightInPx;
				_.heightInPx = y, v.layoutZone(this._viewZoneId), e && this._codeEditor.setScrollTop(this._codeEditor.getScrollTop() + b);
				return;
			} else {
				let y = this._getHeight();
				if (y -= this._codeEditor.getOption(84).top, y <= 0) return;
				_.heightInPx = y, this._viewZoneId = v.addZone(_), e && this._codeEditor.setScrollTop(this._codeEditor.getScrollTop() + y);
			}
		});
	}
	_removeViewZone() {
		this._codeEditor.changeViewZones((e) => {
			this._viewZoneId !== void 0 && (e.removeZone(this._viewZoneId), this._viewZoneId = void 0, this._viewZone &&= (this._codeEditor.setScrollTop(this._codeEditor.getScrollTop() - this._viewZone.heightInPx), void 0));
		});
	}
	_tryUpdateWidgetWidth() {
		if (!this._isVisible || !this._domNode.isConnected) return;
		let e = this._codeEditor.getLayoutInfo();
		if (e.contentWidth <= 0) {
			this._domNode.classList.add("hiddenEditor");
			return;
		} else this._domNode.classList.contains("hiddenEditor") && this._domNode.classList.remove("hiddenEditor");
		let _ = e.width, v = e.minimap.minimapWidth, y = !1, b = !1, x = !1;
		if (this._resized && getTotalWidth(this._domNode) > FIND_WIDGET_INITIAL_WIDTH) {
			this._domNode.style.maxWidth = `${_ - 28 - v - 15}px`, this._replaceInput.width = getTotalWidth(this._findInput.domNode);
			return;
		}
		if (FIND_WIDGET_INITIAL_WIDTH + 28 + v >= _ && (b = !0), FIND_WIDGET_INITIAL_WIDTH + 28 + v - MAX_MATCHES_COUNT_WIDTH >= _ && (x = !0), FIND_WIDGET_INITIAL_WIDTH + 28 + v - MAX_MATCHES_COUNT_WIDTH >= _ + 50 && (y = !0), this._domNode.classList.toggle("collapsed-find-widget", y), this._domNode.classList.toggle("narrow-find-widget", x), this._domNode.classList.toggle("reduced-find-widget", b), !x && !y && (this._domNode.style.maxWidth = `${_ - 28 - v - 15}px`), this._findInput.layout({
			collapsedFindWidget: y,
			narrowFindWidget: x,
			reducedFindWidget: b
		}), this._resized) {
			let e = this._findInput.inputBox.element.clientWidth;
			e > 0 && (this._replaceInput.width = e);
		} else this._isReplaceVisible && (this._replaceInput.width = getTotalWidth(this._findInput.domNode));
	}
	_getHeight() {
		let e = 0;
		return e += 4, e += this._findInput.inputBox.height + 2, this._isReplaceVisible && (e += 4, e += this._replaceInput.inputBox.height + 2), e += 4, e;
	}
	_tryUpdateHeight() {
		let e = this._getHeight();
		return this._cachedHeight !== null && this._cachedHeight === e ? !1 : (this._cachedHeight = e, this._domNode.style.height = `${e}px`, !0);
	}
	focusFindInput() {
		this._findInput.select(), this._findInput.focus();
	}
	focusReplaceInput() {
		this._replaceInput.select(), this._replaceInput.focus();
	}
	highlightFindOptions() {
		this._findInput.highlightFindOptions();
	}
	_updateSearchScope() {
		if (this._codeEditor.hasModel() && this._toggleSelectionFind.checked) {
			let e = this._codeEditor.getSelections();
			e.map((e) => {
				e.endColumn === 1 && e.endLineNumber > e.startLineNumber && (e = e.setEndPosition(e.endLineNumber - 1, this._codeEditor.getModel().getLineMaxColumn(e.endLineNumber - 1)));
				let _ = this._state.currentMatch;
				return e.startLineNumber !== e.endLineNumber && !Range.equalsRange(e, _) ? e : null;
			}).filter((e) => !!e), e.length && this._state.change({ searchScope: e }, !0);
		}
	}
	_onFindInputMouseDown(e) {
		e.middleButton && e.stopPropagation();
	}
	_onFindInputKeyDown(e) {
		if (e.equals(ctrlKeyMod | 3)) if (this._keybindingService.dispatchEvent(e, e.target)) {
			e.preventDefault();
			return;
		} else {
			this._findInput.inputBox.insertAtCursor("\n"), e.preventDefault();
			return;
		}
		if (e.equals(2)) {
			this._isReplaceVisible ? this._replaceInput.focus() : this._findInput.focusOnCaseSensitive(), e.preventDefault();
			return;
		}
		if (e.equals(2066)) {
			this._codeEditor.focus(), e.preventDefault();
			return;
		}
		if (e.equals(16)) return stopPropagationForMultiLineUpwards(e, this._findInput.getValue(), this._findInput.domNode.querySelector("textarea"));
		if (e.equals(18)) return stopPropagationForMultiLineDownwards(e, this._findInput.getValue(), this._findInput.domNode.querySelector("textarea"));
	}
	_onReplaceInputKeyDown(e) {
		if (e.equals(ctrlKeyMod | 3)) if (this._keybindingService.dispatchEvent(e, e.target)) {
			e.preventDefault();
			return;
		} else {
			isWindows && isNative && !this._ctrlEnterReplaceAllWarningPrompted && (this._notificationService.info(localize("ctrlEnter.keybindingChanged", "Ctrl+Enter now inserts line break instead of replacing all. You can modify the keybinding for editor.action.replaceAll to override this behavior.")), this._ctrlEnterReplaceAllWarningPrompted = !0, this._storageService.store(ctrlEnterReplaceAllWarningPromptedKey, !0, 0, 0)), this._replaceInput.inputBox.insertAtCursor("\n"), e.preventDefault();
			return;
		}
		if (e.equals(2)) {
			this._findInput.focusOnCaseSensitive(), e.preventDefault();
			return;
		}
		if (e.equals(1026)) {
			this._findInput.focus(), e.preventDefault();
			return;
		}
		if (e.equals(2066)) {
			this._codeEditor.focus(), e.preventDefault();
			return;
		}
		if (e.equals(16)) return stopPropagationForMultiLineUpwards(e, this._replaceInput.inputBox.value, this._replaceInput.inputBox.element.querySelector("textarea"));
		if (e.equals(18)) return stopPropagationForMultiLineDownwards(e, this._replaceInput.inputBox.value, this._replaceInput.inputBox.element.querySelector("textarea"));
	}
	getVerticalSashLeft(e) {
		return 0;
	}
	_keybindingLabelFor(e) {
		let _ = this._keybindingService.lookupKeybinding(e);
		return _ ? ` (${_.getLabel()})` : "";
	}
	_buildDomNode() {
		this._findInput = this._register(new ContextScopedFindInput(null, this._contextViewProvider, {
			width: FIND_INPUT_AREA_WIDTH,
			label: NLS_FIND_INPUT_LABEL,
			placeholder: NLS_FIND_INPUT_PLACEHOLDER,
			appendCaseSensitiveLabel: this._keybindingLabelFor(FIND_IDS.ToggleCaseSensitiveCommand),
			appendWholeWordsLabel: this._keybindingLabelFor(FIND_IDS.ToggleWholeWordCommand),
			appendRegexLabel: this._keybindingLabelFor(FIND_IDS.ToggleRegexCommand),
			validation: (e) => {
				if (e.length === 0 || !this._findInput.getRegex()) return null;
				try {
					return new RegExp(e, "gu"), null;
				} catch (e) {
					return { content: e.message };
				}
			},
			flexibleHeight: !0,
			flexibleWidth: !0,
			flexibleMaxHeight: 118,
			showCommonFindToggles: !0,
			showHistoryHint: () => showHistoryKeybindingHint(this._keybindingService),
			inputBoxStyles: defaultInputBoxStyles,
			toggleStyles: defaultToggleStyles
		}, this._contextKeyService)), this._findInput.setRegex(!!this._state.isRegex), this._findInput.setCaseSensitive(!!this._state.matchCase), this._findInput.setWholeWords(!!this._state.wholeWord), this._register(this._findInput.onKeyDown((e) => this._onFindInputKeyDown(e))), this._register(this._findInput.inputBox.onDidChange(() => {
			this._ignoreChangeEvent || this._state.change({ searchString: this._findInput.getValue() }, !0);
		})), this._register(this._findInput.onDidOptionChange(() => {
			this._state.change({
				isRegex: this._findInput.getRegex(),
				wholeWord: this._findInput.getWholeWords(),
				matchCase: this._findInput.getCaseSensitive()
			}, !0);
		})), this._register(this._findInput.onCaseSensitiveKeyDown((e) => {
			e.equals(1026) && this._isReplaceVisible && (this._replaceInput.focus(), e.preventDefault());
		})), this._register(this._findInput.onRegexKeyDown((e) => {
			e.equals(2) && this._isReplaceVisible && (this._replaceInput.focusOnPreserve(), e.preventDefault());
		})), this._register(this._findInput.inputBox.onDidHeightChange((e) => {
			this._tryUpdateHeight() && this._showViewZone();
		})), isLinux && this._register(this._findInput.onMouseDown((e) => this._onFindInputMouseDown(e))), this._matchesCount = document.createElement("div"), this._matchesCount.className = "matchesCount", this._updateMatchesCount();
		let e = this._register(createInstantHoverDelegate());
		this._prevBtn = this._register(new SimpleButton({
			label: NLS_PREVIOUS_MATCH_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.PreviousMatchFindAction),
			icon: findPreviousMatchIcon,
			hoverDelegate: e,
			onTrigger: () => {
				assertIsDefined(this._codeEditor.getAction(FIND_IDS.PreviousMatchFindAction)).run().then(void 0, onUnexpectedError);
			}
		}, this._hoverService)), this._nextBtn = this._register(new SimpleButton({
			label: NLS_NEXT_MATCH_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.NextMatchFindAction),
			icon: findNextMatchIcon,
			hoverDelegate: e,
			onTrigger: () => {
				assertIsDefined(this._codeEditor.getAction(FIND_IDS.NextMatchFindAction)).run().then(void 0, onUnexpectedError);
			}
		}, this._hoverService));
		let _ = document.createElement("div");
		_.className = "find-part", _.appendChild(this._findInput.domNode);
		let v = document.createElement("div");
		v.className = "find-actions", _.appendChild(v), v.appendChild(this._matchesCount), v.appendChild(this._prevBtn.domNode), v.appendChild(this._nextBtn.domNode), this._toggleSelectionFind = this._register(new Toggle({
			icon: findSelectionIcon,
			title: NLS_TOGGLE_SELECTION_FIND_TITLE + this._keybindingLabelFor(FIND_IDS.ToggleSearchScopeCommand),
			isChecked: !1,
			hoverDelegate: e,
			inputActiveOptionBackground: asCssVariable(inputActiveOptionBackground),
			inputActiveOptionBorder: asCssVariable(inputActiveOptionBorder),
			inputActiveOptionForeground: asCssVariable(inputActiveOptionForeground)
		})), this._register(this._toggleSelectionFind.onChange(() => {
			if (this._toggleSelectionFind.checked) {
				if (this._codeEditor.hasModel()) {
					let e = this._codeEditor.getSelections();
					e = e.map((e) => (e.endColumn === 1 && e.endLineNumber > e.startLineNumber && (e = e.setEndPosition(e.endLineNumber - 1, this._codeEditor.getModel().getLineMaxColumn(e.endLineNumber - 1))), e.isEmpty() ? null : e)).filter((e) => !!e), e.length && this._state.change({ searchScope: e }, !0);
				}
			} else this._state.change({ searchScope: null }, !0);
		})), v.appendChild(this._toggleSelectionFind.domNode), this._closeBtn = this._register(new SimpleButton({
			label: NLS_CLOSE_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.CloseFindWidgetCommand),
			icon: widgetClose,
			hoverDelegate: e,
			onTrigger: () => {
				this._state.change({
					isRevealed: !1,
					searchScope: null
				}, !1);
			},
			onKeyDown: (e) => {
				e.equals(2) && this._isReplaceVisible && (this._replaceBtn.isEnabled() ? this._replaceBtn.focus() : this._codeEditor.focus(), e.preventDefault());
			}
		}, this._hoverService)), this._replaceInput = this._register(new ContextScopedReplaceInput(null, void 0, {
			label: NLS_REPLACE_INPUT_LABEL,
			placeholder: NLS_REPLACE_INPUT_PLACEHOLDER,
			appendPreserveCaseLabel: this._keybindingLabelFor(FIND_IDS.TogglePreserveCaseCommand),
			history: [],
			flexibleHeight: !0,
			flexibleWidth: !0,
			flexibleMaxHeight: 118,
			showHistoryHint: () => showHistoryKeybindingHint(this._keybindingService),
			inputBoxStyles: defaultInputBoxStyles,
			toggleStyles: defaultToggleStyles
		}, this._contextKeyService, !0)), this._replaceInput.setPreserveCase(!!this._state.preserveCase), this._register(this._replaceInput.onKeyDown((e) => this._onReplaceInputKeyDown(e))), this._register(this._replaceInput.inputBox.onDidChange(() => {
			this._state.change({ replaceString: this._replaceInput.inputBox.value }, !1);
		})), this._register(this._replaceInput.inputBox.onDidHeightChange((e) => {
			this._isReplaceVisible && this._tryUpdateHeight() && this._showViewZone();
		})), this._register(this._replaceInput.onDidOptionChange(() => {
			this._state.change({ preserveCase: this._replaceInput.getPreserveCase() }, !0);
		})), this._register(this._replaceInput.onPreserveCaseKeyDown((e) => {
			e.equals(2) && (this._prevBtn.isEnabled() ? this._prevBtn.focus() : this._nextBtn.isEnabled() ? this._nextBtn.focus() : this._toggleSelectionFind.enabled ? this._toggleSelectionFind.focus() : this._closeBtn.isEnabled() && this._closeBtn.focus(), e.preventDefault());
		}));
		let y = this._register(createInstantHoverDelegate());
		this._replaceBtn = this._register(new SimpleButton({
			label: NLS_REPLACE_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.ReplaceOneAction),
			icon: findReplaceIcon,
			hoverDelegate: y,
			onTrigger: () => {
				this._controller.replace();
			},
			onKeyDown: (e) => {
				e.equals(1026) && (this._closeBtn.focus(), e.preventDefault());
			}
		}, this._hoverService)), this._replaceAllBtn = this._register(new SimpleButton({
			label: NLS_REPLACE_ALL_BTN_LABEL + this._keybindingLabelFor(FIND_IDS.ReplaceAllAction),
			icon: findReplaceAllIcon,
			hoverDelegate: y,
			onTrigger: () => {
				this._controller.replaceAll();
			}
		}, this._hoverService));
		let b = document.createElement("div");
		b.className = "replace-part", b.appendChild(this._replaceInput.domNode);
		let x = document.createElement("div");
		x.className = "replace-actions", b.appendChild(x), x.appendChild(this._replaceBtn.domNode), x.appendChild(this._replaceAllBtn.domNode), this._toggleReplaceBtn = this._register(new SimpleButton({
			label: NLS_TOGGLE_REPLACE_MODE_BTN_LABEL,
			className: "codicon toggle left",
			onTrigger: () => {
				this._state.change({ isReplaceRevealed: !this._isReplaceVisible }, !1), this._isReplaceVisible && (this._replaceInput.width = getTotalWidth(this._findInput.domNode), this._replaceInput.inputBox.layout()), this._showViewZone();
			}
		}, this._hoverService)), this._toggleReplaceBtn.setExpanded(this._isReplaceVisible), this._domNode = document.createElement("div"), this._domNode.className = "editor-widget find-widget", this._domNode.setAttribute("aria-hidden", "true"), this._domNode.ariaLabel = NLS_FIND_DIALOG_LABEL, this._domNode.role = "dialog", this._domNode.style.width = `${FIND_WIDGET_INITIAL_WIDTH}px`, this._domNode.appendChild(this._toggleReplaceBtn.domNode), this._domNode.appendChild(_), this._domNode.appendChild(this._closeBtn.domNode), this._domNode.appendChild(b), this._resizeSash = this._register(new Sash(this._domNode, this, {
			orientation: 0,
			size: 2
		})), this._resized = !1;
		let S = FIND_WIDGET_INITIAL_WIDTH;
		this._register(this._resizeSash.onDidStart(() => {
			S = getTotalWidth(this._domNode);
		})), this._register(this._resizeSash.onDidChange((e) => {
			this._resized = !0;
			let _ = S + e.startX - e.currentX;
			if (_ < FIND_WIDGET_INITIAL_WIDTH) return;
			let v = parseFloat(getComputedStyle(this._domNode).maxWidth) || 0;
			_ > v || (this._domNode.style.width = `${_}px`, this._isReplaceVisible && (this._replaceInput.width = getTotalWidth(this._findInput.domNode)), this._findInput.inputBox.layout(), this._tryUpdateHeight());
		})), this._register(this._resizeSash.onDidReset(() => {
			let e = getTotalWidth(this._domNode);
			if (e < FIND_WIDGET_INITIAL_WIDTH) return;
			let _ = FIND_WIDGET_INITIAL_WIDTH;
			if (!this._resized || e === FIND_WIDGET_INITIAL_WIDTH) {
				let e = this._codeEditor.getLayoutInfo();
				_ = e.width - 28 - e.minimap.minimapWidth - 15, this._resized = !0;
			}
			this._domNode.style.width = `${_}px`, this._isReplaceVisible && (this._replaceInput.width = getTotalWidth(this._findInput.domNode)), this._findInput.inputBox.layout();
		}));
	}
	updateAccessibilitySupport() {
		let e = this._codeEditor.getOption(2);
		this._findInput.setFocusInputOnOptionClick(e !== 2);
	}
}, SimpleButton = class extends Widget {
	constructor(e, _) {
		super(), this._opts = e;
		let v = "button";
		this._opts.className && (v = v + " " + this._opts.className), this._opts.icon && (v = v + " " + ThemeIcon.asClassName(this._opts.icon)), this._domNode = document.createElement("div"), this._domNode.tabIndex = 0, this._domNode.className = v, this._domNode.setAttribute("role", "button"), this._domNode.setAttribute("aria-label", this._opts.label), this._register(_.setupManagedHover(e.hoverDelegate ?? getDefaultHoverDelegate("element"), this._domNode, this._opts.label)), this.onclick(this._domNode, (e) => {
			this._opts.onTrigger(), e.preventDefault();
		}), this.onkeydown(this._domNode, (e) => {
			if (e.equals(10) || e.equals(3)) {
				this._opts.onTrigger(), e.preventDefault();
				return;
			}
			this._opts.onKeyDown?.(e);
		});
	}
	get domNode() {
		return this._domNode;
	}
	isEnabled() {
		return this._domNode.tabIndex >= 0;
	}
	focus() {
		this._domNode.focus();
	}
	setEnabled(e) {
		this._domNode.classList.toggle("disabled", !e), this._domNode.setAttribute("aria-disabled", String(!e)), this._domNode.tabIndex = e ? 0 : -1;
	}
	setExpanded(e) {
		this._domNode.setAttribute("aria-expanded", String(!!e)), e ? (this._domNode.classList.remove(...ThemeIcon.asClassNameArray(findCollapsedIcon)), this._domNode.classList.add(...ThemeIcon.asClassNameArray(findExpandedIcon))) : (this._domNode.classList.remove(...ThemeIcon.asClassNameArray(findExpandedIcon)), this._domNode.classList.add(...ThemeIcon.asClassNameArray(findCollapsedIcon)));
	}
};
registerThemingParticipant((e, _) => {
	let v = e.getColor(editorFindMatchHighlightBorder);
	v && _.addRule(`.monaco-editor .findMatch { border: 1px ${isHighContrast(e.type) ? "dotted" : "solid"} ${v}; box-sizing: border-box; }`);
	let y = e.getColor(editorFindRangeHighlightBorder);
	y && _.addRule(`.monaco-editor .findScope { border: 1px ${isHighContrast(e.type) ? "dashed" : "solid"} ${y}; }`);
	let b = e.getColor(contrastBorder);
	b && _.addRule(`.monaco-editor .find-widget { border: 1px solid ${b}; }`);
	let x = e.getColor(editorFindMatchForeground);
	x && _.addRule(`.monaco-editor .findMatchInline { color: ${x}; }`);
	let S = e.getColor(editorFindMatchHighlightForeground);
	S && _.addRule(`.monaco-editor .currentFindMatchInline { color: ${S}; }`);
});
var __decorate$68 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$68 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, CommonFindController_1, SEARCH_STRING_MAX_LENGTH = 524288;
function getSelectionSearchString(e, _ = "single", v = !1) {
	if (!e.hasModel()) return null;
	let y = e.getSelection();
	if (_ === "single" && y.startLineNumber === y.endLineNumber || _ === "multiple") {
		if (y.isEmpty()) {
			let _ = e.getConfiguredWordAtPosition(y.getStartPosition());
			if (_ && !1 === v) return _.word;
		} else if (e.getModel().getValueLengthInRange(y) < SEARCH_STRING_MAX_LENGTH) return e.getModel().getValueInRange(y);
	}
	return null;
}
var CommonFindController = class extends Disposable {
	static {
		CommonFindController_1 = this;
	}
	static {
		this.ID = "editor.contrib.findController";
	}
	get editor() {
		return this._editor;
	}
	static get(e) {
		return e.getContribution(CommonFindController_1.ID);
	}
	constructor(e, _, v, y, b, x) {
		super(), this._editor = e, this._findWidgetVisible = CONTEXT_FIND_WIDGET_VISIBLE.bindTo(_), this._contextKeyService = _, this._storageService = v, this._clipboardService = y, this._notificationService = b, this._hoverService = x, this._updateHistoryDelayer = new Delayer(500), this._state = this._register(new FindReplaceState()), this.loadQueryState(), this._register(this._state.onFindReplaceStateChange((e) => this._onStateChanged(e))), this._model = null, this._register(this._editor.onDidChangeModel(() => {
			let e = this._editor.getModel() && this._state.isRevealed;
			this.disposeModel(), this._state.change({
				searchScope: null,
				matchCase: this._storageService.getBoolean("editor.matchCase", 1, !1),
				wholeWord: this._storageService.getBoolean("editor.wholeWord", 1, !1),
				isRegex: this._storageService.getBoolean("editor.isRegex", 1, !1),
				preserveCase: this._storageService.getBoolean("editor.preserveCase", 1, !1)
			}, !1), e && this._start({
				forceRevealReplace: !1,
				seedSearchStringFromSelection: "none",
				seedSearchStringFromNonEmptySelection: !1,
				seedSearchStringFromGlobalClipboard: !1,
				shouldFocus: 0,
				shouldAnimate: !1,
				updateSearchScope: !1,
				loop: this._editor.getOption(41).loop
			});
		}));
	}
	dispose() {
		this.disposeModel(), super.dispose();
	}
	disposeModel() {
		this._model &&= (this._model.dispose(), null);
	}
	_onStateChanged(e) {
		this.saveQueryState(e), e.isRevealed && (this._state.isRevealed ? this._findWidgetVisible.set(!0) : (this._findWidgetVisible.reset(), this.disposeModel())), e.searchString && this.setGlobalBufferTerm(this._state.searchString);
	}
	saveQueryState(e) {
		e.isRegex && this._storageService.store("editor.isRegex", this._state.actualIsRegex, 1, 1), e.wholeWord && this._storageService.store("editor.wholeWord", this._state.actualWholeWord, 1, 1), e.matchCase && this._storageService.store("editor.matchCase", this._state.actualMatchCase, 1, 1), e.preserveCase && this._storageService.store("editor.preserveCase", this._state.actualPreserveCase, 1, 1);
	}
	loadQueryState() {
		this._state.change({
			matchCase: this._storageService.getBoolean("editor.matchCase", 1, this._state.matchCase),
			wholeWord: this._storageService.getBoolean("editor.wholeWord", 1, this._state.wholeWord),
			isRegex: this._storageService.getBoolean("editor.isRegex", 1, this._state.isRegex),
			preserveCase: this._storageService.getBoolean("editor.preserveCase", 1, this._state.preserveCase)
		}, !1);
	}
	isFindInputFocused() {
		return !!CONTEXT_FIND_INPUT_FOCUSED.getValue(this._contextKeyService);
	}
	getState() {
		return this._state;
	}
	closeFindWidget() {
		this._state.change({
			isRevealed: !1,
			searchScope: null
		}, !1), this._editor.focus();
	}
	toggleCaseSensitive() {
		this._state.change({ matchCase: !this._state.matchCase }, !1), this._state.isRevealed || this.highlightFindOptions();
	}
	toggleWholeWords() {
		this._state.change({ wholeWord: !this._state.wholeWord }, !1), this._state.isRevealed || this.highlightFindOptions();
	}
	toggleRegex() {
		this._state.change({ isRegex: !this._state.isRegex }, !1), this._state.isRevealed || this.highlightFindOptions();
	}
	togglePreserveCase() {
		this._state.change({ preserveCase: !this._state.preserveCase }, !1), this._state.isRevealed || this.highlightFindOptions();
	}
	toggleSearchScope() {
		if (this._state.searchScope) this._state.change({ searchScope: null }, !0);
		else if (this._editor.hasModel()) {
			let e = this._editor.getSelections();
			e = e.map((e) => (e.endColumn === 1 && e.endLineNumber > e.startLineNumber && (e = e.setEndPosition(e.endLineNumber - 1, this._editor.getModel().getLineMaxColumn(e.endLineNumber - 1))), e.isEmpty() ? null : e)).filter((e) => !!e), e.length && this._state.change({ searchScope: e }, !0);
		}
	}
	setSearchString(e) {
		this._state.isRegex && (e = escapeRegExpCharacters(e)), this._state.change({ searchString: e }, !1);
	}
	highlightFindOptions(e = !1) {}
	async _start(e, _) {
		if (this.disposeModel(), !this._editor.hasModel()) return;
		let v = {
			..._,
			isRevealed: !0
		};
		if (e.seedSearchStringFromSelection === "single") {
			let _ = getSelectionSearchString(this._editor, e.seedSearchStringFromSelection, e.seedSearchStringFromNonEmptySelection);
			_ && (this._state.isRegex ? v.searchString = escapeRegExpCharacters(_) : v.searchString = _);
		} else if (e.seedSearchStringFromSelection === "multiple" && !e.updateSearchScope) {
			let _ = getSelectionSearchString(this._editor, e.seedSearchStringFromSelection);
			_ && (v.searchString = _);
		}
		if (!v.searchString && e.seedSearchStringFromGlobalClipboard) {
			let e = await this.getGlobalBufferTerm();
			if (!this._editor.hasModel()) return;
			e && (v.searchString = e);
		}
		if (e.forceRevealReplace || v.isReplaceRevealed ? v.isReplaceRevealed = !0 : this._findWidgetVisible.get() || (v.isReplaceRevealed = !1), e.updateSearchScope) {
			let e = this._editor.getSelections();
			e.some((e) => !e.isEmpty()) && (v.searchScope = e);
		}
		v.loop = e.loop, this._state.change(v, !1), this._model ||= new FindModelBoundToEditorModel(this._editor, this._state);
	}
	start(e, _) {
		return this._start(e, _);
	}
	moveToNextMatch() {
		return this._model ? (this._model.moveToNextMatch(), !0) : !1;
	}
	moveToPrevMatch() {
		return this._model ? (this._model.moveToPrevMatch(), !0) : !1;
	}
	goToMatch(e) {
		return this._model ? (this._model.moveToMatch(e), !0) : !1;
	}
	replace() {
		return this._model ? (this._model.replace(), !0) : !1;
	}
	replaceAll() {
		return this._model ? this._editor.getModel()?.isTooLargeForHeapOperation() ? (this._notificationService.warn(localize("too.large.for.replaceall", "The file is too large to perform a replace all operation.")), !1) : (this._model.replaceAll(), !0) : !1;
	}
	selectAllMatches() {
		return this._model ? (this._model.selectAllMatches(), this._editor.focus(), !0) : !1;
	}
	async getGlobalBufferTerm() {
		return this._editor.getOption(41).globalFindClipboard && this._editor.hasModel() && !this._editor.getModel().isTooLargeForSyncing() ? this._clipboardService.readFindText() : "";
	}
	setGlobalBufferTerm(e) {
		this._editor.getOption(41).globalFindClipboard && this._editor.hasModel() && !this._editor.getModel().isTooLargeForSyncing() && this._clipboardService.writeFindText(e);
	}
};
CommonFindController = CommonFindController_1 = __decorate$68([
	__param$68(1, IContextKeyService),
	__param$68(2, IStorageService),
	__param$68(3, IClipboardService),
	__param$68(4, INotificationService),
	__param$68(5, IHoverService)
], CommonFindController);
var FindController = class extends CommonFindController {
	constructor(e, _, v, y, b, x, S, C, w) {
		super(e, v, S, C, x, w), this._contextViewService = _, this._keybindingService = y, this._themeService = b, this._widget = null, this._findOptionsWidget = null;
	}
	async _start(e, _) {
		this._widget || this._createFindWidget();
		let v = this._editor.getSelection(), y = !1;
		switch (this._editor.getOption(41).autoFindInSelection) {
			case "always":
				y = !0;
				break;
			case "never":
				y = !1;
				break;
			case "multiline":
				y = !!v && v.startLineNumber !== v.endLineNumber;
				break;
			default: break;
		}
		e.updateSearchScope = e.updateSearchScope || y, await super._start(e, _), this._widget && (e.shouldFocus === 2 ? this._widget.focusReplaceInput() : e.shouldFocus === 1 && this._widget.focusFindInput());
	}
	highlightFindOptions(e = !1) {
		this._widget || this._createFindWidget(), this._state.isRevealed && !e ? this._widget.highlightFindOptions() : this._findOptionsWidget.highlightFindOptions();
	}
	_createFindWidget() {
		this._widget = this._register(new FindWidget(this._editor, this, this._state, this._contextViewService, this._keybindingService, this._contextKeyService, this._themeService, this._storageService, this._notificationService, this._hoverService)), this._findOptionsWidget = this._register(new FindOptionsWidget(this._editor, this._state, this._keybindingService));
	}
};
FindController = __decorate$68([
	__param$68(1, IContextViewService),
	__param$68(2, IContextKeyService),
	__param$68(3, IKeybindingService),
	__param$68(4, IThemeService),
	__param$68(5, INotificationService),
	__param$68(6, IStorageService),
	__param$68(7, IClipboardService),
	__param$68(8, IHoverService)
], FindController), registerMultiEditorAction(new MultiEditorAction({
	id: FIND_IDS.StartFindAction,
	label: localize("startFindAction", "Find"),
	alias: "Find",
	precondition: ContextKeyExpr.or(EditorContextKeys.focus, ContextKeyExpr.has("editorIsOpen")),
	kbOpts: {
		kbExpr: null,
		primary: 2084,
		weight: 100
	},
	menuOpts: {
		menuId: MenuId.MenubarEditMenu,
		group: "3_find",
		title: localize({
			key: "miFind",
			comment: ["&& denotes a mnemonic"]
		}, "&&Find"),
		order: 1
	}
})).addImplementation(0, (e, _, v) => {
	let y = CommonFindController.get(_);
	return y ? y.start({
		forceRevealReplace: !1,
		seedSearchStringFromSelection: _.getOption(41).seedSearchStringFromSelection === "never" ? "none" : "single",
		seedSearchStringFromNonEmptySelection: _.getOption(41).seedSearchStringFromSelection === "selection",
		seedSearchStringFromGlobalClipboard: _.getOption(41).globalFindClipboard,
		shouldFocus: 1,
		shouldAnimate: !0,
		updateSearchScope: !1,
		loop: _.getOption(41).loop
	}) : !1;
});
var findArgDescription = {
	description: "Open a new In-Editor Find Widget.",
	args: [{
		name: "Open a new In-Editor Find Widget args",
		schema: { properties: {
			searchString: { type: "string" },
			replaceString: { type: "string" },
			isRegex: { type: "boolean" },
			matchWholeWord: { type: "boolean" },
			isCaseSensitive: { type: "boolean" },
			preserveCase: { type: "boolean" },
			findInSelection: { type: "boolean" }
		} }
	}]
}, StartFindWithArgsAction = class extends EditorAction {
	constructor() {
		super({
			id: FIND_IDS.StartFindWithArgs,
			label: localize("startFindWithArgsAction", "Find With Arguments"),
			alias: "Find With Arguments",
			precondition: void 0,
			kbOpts: {
				kbExpr: null,
				primary: 0,
				weight: 100
			},
			metadata: findArgDescription
		});
	}
	async run(e, _, v) {
		let y = CommonFindController.get(_);
		if (y) {
			let e = v ? {
				searchString: v.searchString,
				replaceString: v.replaceString,
				isReplaceRevealed: v.replaceString !== void 0,
				isRegex: v.isRegex,
				wholeWord: v.matchWholeWord,
				matchCase: v.isCaseSensitive,
				preserveCase: v.preserveCase
			} : {};
			await y.start({
				forceRevealReplace: !1,
				seedSearchStringFromSelection: y.getState().searchString.length === 0 && _.getOption(41).seedSearchStringFromSelection !== "never" ? "single" : "none",
				seedSearchStringFromNonEmptySelection: _.getOption(41).seedSearchStringFromSelection === "selection",
				seedSearchStringFromGlobalClipboard: !0,
				shouldFocus: 1,
				shouldAnimate: !0,
				updateSearchScope: v?.findInSelection || !1,
				loop: _.getOption(41).loop
			}, e), y.setGlobalBufferTerm(y.getState().searchString);
		}
	}
}, StartFindWithSelectionAction = class extends EditorAction {
	constructor() {
		super({
			id: FIND_IDS.StartFindWithSelection,
			label: localize("startFindWithSelectionAction", "Find With Selection"),
			alias: "Find With Selection",
			precondition: void 0,
			kbOpts: {
				kbExpr: null,
				primary: 0,
				mac: { primary: 2083 },
				weight: 100
			}
		});
	}
	async run(e, _) {
		let v = CommonFindController.get(_);
		v && (await v.start({
			forceRevealReplace: !1,
			seedSearchStringFromSelection: "multiple",
			seedSearchStringFromNonEmptySelection: !1,
			seedSearchStringFromGlobalClipboard: !1,
			shouldFocus: 0,
			shouldAnimate: !0,
			updateSearchScope: !1,
			loop: _.getOption(41).loop
		}), v.setGlobalBufferTerm(v.getState().searchString));
	}
}, MatchFindAction = class extends EditorAction {
	async run(e, _) {
		let v = CommonFindController.get(_);
		v && !this._run(v) && (await v.start({
			forceRevealReplace: !1,
			seedSearchStringFromSelection: v.getState().searchString.length === 0 && _.getOption(41).seedSearchStringFromSelection !== "never" ? "single" : "none",
			seedSearchStringFromNonEmptySelection: _.getOption(41).seedSearchStringFromSelection === "selection",
			seedSearchStringFromGlobalClipboard: !0,
			shouldFocus: 0,
			shouldAnimate: !0,
			updateSearchScope: !1,
			loop: _.getOption(41).loop
		}), this._run(v));
	}
}, NextMatchFindAction = class extends MatchFindAction {
	constructor() {
		super({
			id: FIND_IDS.NextMatchFindAction,
			label: localize("findNextMatchAction", "Find Next"),
			alias: "Find Next",
			precondition: void 0,
			kbOpts: [{
				kbExpr: EditorContextKeys.focus,
				primary: 61,
				mac: {
					primary: 2085,
					secondary: [61]
				},
				weight: 100
			}, {
				kbExpr: ContextKeyExpr.and(EditorContextKeys.focus, CONTEXT_FIND_INPUT_FOCUSED),
				primary: 3,
				weight: 100
			}]
		});
	}
	_run(e) {
		return e.moveToNextMatch() ? (e.editor.pushUndoStop(), !0) : !1;
	}
}, PreviousMatchFindAction = class extends MatchFindAction {
	constructor() {
		super({
			id: FIND_IDS.PreviousMatchFindAction,
			label: localize("findPreviousMatchAction", "Find Previous"),
			alias: "Find Previous",
			precondition: void 0,
			kbOpts: [{
				kbExpr: EditorContextKeys.focus,
				primary: 1085,
				mac: {
					primary: 3109,
					secondary: [1085]
				},
				weight: 100
			}, {
				kbExpr: ContextKeyExpr.and(EditorContextKeys.focus, CONTEXT_FIND_INPUT_FOCUSED),
				primary: 1027,
				weight: 100
			}]
		});
	}
	_run(e) {
		return e.moveToPrevMatch();
	}
}, MoveToMatchFindAction = class extends EditorAction {
	constructor() {
		super({
			id: FIND_IDS.GoToMatchFindAction,
			label: localize("findMatchAction.goToMatch", "Go to Match..."),
			alias: "Go to Match...",
			precondition: CONTEXT_FIND_WIDGET_VISIBLE
		}), this._highlightDecorations = [];
	}
	run(e, _, v) {
		let y = CommonFindController.get(_);
		if (!y) return;
		let b = y.getState().matchesCount;
		if (b < 1) {
			e.get(INotificationService).notify({
				severity: Severity.Warning,
				message: localize("findMatchAction.noResults", "No matches. Try searching for something else.")
			});
			return;
		}
		let x = e.get(IQuickInputService), S = new DisposableStore(), C = S.add(x.createInputBox());
		C.placeholder = localize("findMatchAction.inputPlaceHolder", "Type a number to go to a specific match (between 1 and {0})", b);
		let w = (e) => {
			let _ = parseInt(e);
			if (isNaN(_)) return;
			let v = y.getState().matchesCount;
			if (_ > 0 && _ <= v) return _ - 1;
			if (_ < 0 && _ >= -v) return v + _;
		}, T = (e) => {
			let v = w(e);
			if (typeof v == "number") {
				C.validationMessage = void 0, y.goToMatch(v);
				let e = y.getState().currentMatch;
				e && this.addDecorations(_, e);
			} else C.validationMessage = localize("findMatchAction.inputValidationMessage", "Please type a number between 1 and {0}", y.getState().matchesCount), this.clearDecorations(_);
		};
		S.add(C.onDidChangeValue((e) => {
			T(e);
		})), S.add(C.onDidAccept(() => {
			let e = w(C.value);
			typeof e == "number" ? (y.goToMatch(e), C.hide()) : C.validationMessage = localize("findMatchAction.inputValidationMessage", "Please type a number between 1 and {0}", y.getState().matchesCount);
		})), S.add(C.onDidHide(() => {
			this.clearDecorations(_), S.dispose();
		})), C.show();
	}
	clearDecorations(e) {
		e.changeDecorations((e) => {
			this._highlightDecorations = e.deltaDecorations(this._highlightDecorations, []);
		});
	}
	addDecorations(e, _) {
		e.changeDecorations((e) => {
			this._highlightDecorations = e.deltaDecorations(this._highlightDecorations, [{
				range: _,
				options: {
					description: "find-match-quick-access-range-highlight",
					className: "rangeHighlight",
					isWholeLine: !0
				}
			}, {
				range: _,
				options: {
					description: "find-match-quick-access-range-highlight-overview",
					overviewRuler: {
						color: themeColorFromId(overviewRulerRangeHighlight),
						position: OverviewRulerLane.Full
					}
				}
			}]);
		});
	}
}, SelectionMatchFindAction = class extends EditorAction {
	async run(e, _) {
		let v = CommonFindController.get(_);
		if (!v) return;
		let y = getSelectionSearchString(_, "single", !1);
		y && v.setSearchString(y), this._run(v) || (await v.start({
			forceRevealReplace: !1,
			seedSearchStringFromSelection: "none",
			seedSearchStringFromNonEmptySelection: !1,
			seedSearchStringFromGlobalClipboard: !1,
			shouldFocus: 0,
			shouldAnimate: !0,
			updateSearchScope: !1,
			loop: _.getOption(41).loop
		}), this._run(v));
	}
}, NextSelectionMatchFindAction = class extends SelectionMatchFindAction {
	constructor() {
		super({
			id: FIND_IDS.NextSelectionMatchFindAction,
			label: localize("nextSelectionMatchFindAction", "Find Next Selection"),
			alias: "Find Next Selection",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 2109,
				weight: 100
			}
		});
	}
	_run(e) {
		return e.moveToNextMatch();
	}
}, PreviousSelectionMatchFindAction = class extends SelectionMatchFindAction {
	constructor() {
		super({
			id: FIND_IDS.PreviousSelectionMatchFindAction,
			label: localize("previousSelectionMatchFindAction", "Find Previous Selection"),
			alias: "Find Previous Selection",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 3133,
				weight: 100
			}
		});
	}
	_run(e) {
		return e.moveToPrevMatch();
	}
};
registerMultiEditorAction(new MultiEditorAction({
	id: FIND_IDS.StartFindReplaceAction,
	label: localize("startReplace", "Replace"),
	alias: "Replace",
	precondition: ContextKeyExpr.or(EditorContextKeys.focus, ContextKeyExpr.has("editorIsOpen")),
	kbOpts: {
		kbExpr: null,
		primary: 2086,
		mac: { primary: 2596 },
		weight: 100
	},
	menuOpts: {
		menuId: MenuId.MenubarEditMenu,
		group: "3_find",
		title: localize({
			key: "miReplace",
			comment: ["&& denotes a mnemonic"]
		}, "&&Replace"),
		order: 2
	}
})).addImplementation(0, (e, _, v) => {
	if (!_.hasModel() || _.getOption(92)) return !1;
	let y = CommonFindController.get(_);
	if (!y) return !1;
	let b = _.getSelection(), x = y.isFindInputFocused(), S = !b.isEmpty() && b.startLineNumber === b.endLineNumber && _.getOption(41).seedSearchStringFromSelection !== "never" && !x, C = x || S ? 2 : 1;
	return y.start({
		forceRevealReplace: !0,
		seedSearchStringFromSelection: S ? "single" : "none",
		seedSearchStringFromNonEmptySelection: _.getOption(41).seedSearchStringFromSelection === "selection",
		seedSearchStringFromGlobalClipboard: _.getOption(41).seedSearchStringFromSelection !== "never",
		shouldFocus: C,
		shouldAnimate: !0,
		updateSearchScope: !1,
		loop: _.getOption(41).loop
	});
}), registerEditorContribution(CommonFindController.ID, FindController, 0), registerEditorAction(StartFindWithArgsAction), registerEditorAction(StartFindWithSelectionAction), registerEditorAction(NextMatchFindAction), registerEditorAction(PreviousMatchFindAction), registerEditorAction(MoveToMatchFindAction), registerEditorAction(NextSelectionMatchFindAction), registerEditorAction(PreviousSelectionMatchFindAction);
var FindCommand = EditorCommand.bindToContribution(CommonFindController.get);
registerEditorCommand(new FindCommand({
	id: FIND_IDS.CloseFindWidgetCommand,
	precondition: CONTEXT_FIND_WIDGET_VISIBLE,
	handler: (e) => e.closeFindWidget(),
	kbOpts: {
		weight: 105,
		kbExpr: ContextKeyExpr.and(EditorContextKeys.focus, ContextKeyExpr.not("isComposing")),
		primary: 9,
		secondary: [1033]
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ToggleCaseSensitiveCommand,
	precondition: void 0,
	handler: (e) => e.toggleCaseSensitive(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: ToggleCaseSensitiveKeybinding.primary,
		mac: ToggleCaseSensitiveKeybinding.mac,
		win: ToggleCaseSensitiveKeybinding.win,
		linux: ToggleCaseSensitiveKeybinding.linux
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ToggleWholeWordCommand,
	precondition: void 0,
	handler: (e) => e.toggleWholeWords(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: ToggleWholeWordKeybinding.primary,
		mac: ToggleWholeWordKeybinding.mac,
		win: ToggleWholeWordKeybinding.win,
		linux: ToggleWholeWordKeybinding.linux
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ToggleRegexCommand,
	precondition: void 0,
	handler: (e) => e.toggleRegex(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: ToggleRegexKeybinding.primary,
		mac: ToggleRegexKeybinding.mac,
		win: ToggleRegexKeybinding.win,
		linux: ToggleRegexKeybinding.linux
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ToggleSearchScopeCommand,
	precondition: void 0,
	handler: (e) => e.toggleSearchScope(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: ToggleSearchScopeKeybinding.primary,
		mac: ToggleSearchScopeKeybinding.mac,
		win: ToggleSearchScopeKeybinding.win,
		linux: ToggleSearchScopeKeybinding.linux
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.TogglePreserveCaseCommand,
	precondition: void 0,
	handler: (e) => e.togglePreserveCase(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: TogglePreserveCaseKeybinding.primary,
		mac: TogglePreserveCaseKeybinding.mac,
		win: TogglePreserveCaseKeybinding.win,
		linux: TogglePreserveCaseKeybinding.linux
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ReplaceOneAction,
	precondition: CONTEXT_FIND_WIDGET_VISIBLE,
	handler: (e) => e.replace(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: 3094
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ReplaceOneAction,
	precondition: CONTEXT_FIND_WIDGET_VISIBLE,
	handler: (e) => e.replace(),
	kbOpts: {
		weight: 105,
		kbExpr: ContextKeyExpr.and(EditorContextKeys.focus, CONTEXT_REPLACE_INPUT_FOCUSED),
		primary: 3
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ReplaceAllAction,
	precondition: CONTEXT_FIND_WIDGET_VISIBLE,
	handler: (e) => e.replaceAll(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: 2563
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.ReplaceAllAction,
	precondition: CONTEXT_FIND_WIDGET_VISIBLE,
	handler: (e) => e.replaceAll(),
	kbOpts: {
		weight: 105,
		kbExpr: ContextKeyExpr.and(EditorContextKeys.focus, CONTEXT_REPLACE_INPUT_FOCUSED),
		primary: void 0,
		mac: { primary: 2051 }
	}
})), registerEditorCommand(new FindCommand({
	id: FIND_IDS.SelectAllMatchesAction,
	precondition: CONTEXT_FIND_WIDGET_VISIBLE,
	handler: (e) => e.selectAllMatches(),
	kbOpts: {
		weight: 105,
		kbExpr: EditorContextKeys.focus,
		primary: 515
	}
}));
const foldSourceAbbr = {
	0: " ",
	1: "u",
	2: "r"
}, MAX_LINE_NUMBER = 16777215;
var MASK_INDENT = 4278190080, BitField = class {
	constructor(e) {
		let _ = Math.ceil(e / 32);
		this._states = new Uint32Array(_);
	}
	get(e) {
		let _ = e / 32 | 0, v = e % 32;
		return (this._states[_] & 1 << v) != 0;
	}
	set(e, _) {
		let v = e / 32 | 0, y = e % 32, b = this._states[v];
		_ ? this._states[v] = b | 1 << y : this._states[v] = b & ~(1 << y);
	}
}, FoldingRegions = class e {
	constructor(e, _, v) {
		if (e.length !== _.length || e.length > 65535) throw Error("invalid startIndexes or endIndexes size");
		this._startIndexes = e, this._endIndexes = _, this._collapseStates = new BitField(e.length), this._userDefinedStates = new BitField(e.length), this._recoveredStates = new BitField(e.length), this._types = v, this._parentsComputed = !1;
	}
	ensureParentIndices() {
		if (!this._parentsComputed) {
			this._parentsComputed = !0;
			let e = [], _ = (_, v) => {
				let y = e[e.length - 1];
				return this.getStartLineNumber(y) <= _ && this.getEndLineNumber(y) >= v;
			};
			for (let v = 0, y = this._startIndexes.length; v < y; v++) {
				let y = this._startIndexes[v], b = this._endIndexes[v];
				if (y > 16777215 || b > 16777215) throw Error("startLineNumber or endLineNumber must not exceed " + MAX_LINE_NUMBER);
				for (; e.length > 0 && !_(y, b);) e.pop();
				let x = e.length > 0 ? e[e.length - 1] : -1;
				e.push(v), this._startIndexes[v] = y + ((x & 255) << 24), this._endIndexes[v] = b + ((x & 65280) << 16);
			}
		}
	}
	get length() {
		return this._startIndexes.length;
	}
	getStartLineNumber(e) {
		return this._startIndexes[e] & MAX_LINE_NUMBER;
	}
	getEndLineNumber(e) {
		return this._endIndexes[e] & MAX_LINE_NUMBER;
	}
	getType(e) {
		return this._types ? this._types[e] : void 0;
	}
	hasTypes() {
		return !!this._types;
	}
	isCollapsed(e) {
		return this._collapseStates.get(e);
	}
	setCollapsed(e, _) {
		this._collapseStates.set(e, _);
	}
	isUserDefined(e) {
		return this._userDefinedStates.get(e);
	}
	setUserDefined(e, _) {
		return this._userDefinedStates.set(e, _);
	}
	isRecovered(e) {
		return this._recoveredStates.get(e);
	}
	setRecovered(e, _) {
		return this._recoveredStates.set(e, _);
	}
	getSource(e) {
		return this.isUserDefined(e) ? 1 : this.isRecovered(e) ? 2 : 0;
	}
	setSource(e, _) {
		_ === 1 ? (this.setUserDefined(e, !0), this.setRecovered(e, !1)) : _ === 2 ? (this.setUserDefined(e, !1), this.setRecovered(e, !0)) : (this.setUserDefined(e, !1), this.setRecovered(e, !1));
	}
	setCollapsedAllOfType(e, _) {
		let v = !1;
		if (this._types) for (let y = 0; y < this._types.length; y++) this._types[y] === e && (this.setCollapsed(y, _), v = !0);
		return v;
	}
	toRegion(e) {
		return new FoldingRegion(this, e);
	}
	getParentIndex(e) {
		this.ensureParentIndices();
		let _ = ((this._startIndexes[e] & MASK_INDENT) >>> 24) + ((this._endIndexes[e] & MASK_INDENT) >>> 16);
		return _ === 65535 ? -1 : _;
	}
	contains(e, _) {
		return this.getStartLineNumber(e) <= _ && this.getEndLineNumber(e) >= _;
	}
	findIndex(e) {
		let _ = 0, v = this._startIndexes.length;
		if (v === 0) return -1;
		for (; _ < v;) {
			let y = Math.floor((_ + v) / 2);
			e < this.getStartLineNumber(y) ? v = y : _ = y + 1;
		}
		return _ - 1;
	}
	findRange(e) {
		let _ = this.findIndex(e);
		if (_ >= 0) {
			if (this.getEndLineNumber(_) >= e) return _;
			for (_ = this.getParentIndex(_); _ !== -1;) {
				if (this.contains(_, e)) return _;
				_ = this.getParentIndex(_);
			}
		}
		return -1;
	}
	toString() {
		let e = [];
		for (let _ = 0; _ < this.length; _++) e[_] = `[${foldSourceAbbr[this.getSource(_)]}${this.isCollapsed(_) ? "+" : "-"}] ${this.getStartLineNumber(_)}/${this.getEndLineNumber(_)}`;
		return e.join(", ");
	}
	toFoldRange(e) {
		return {
			startLineNumber: this._startIndexes[e] & MAX_LINE_NUMBER,
			endLineNumber: this._endIndexes[e] & MAX_LINE_NUMBER,
			type: this._types ? this._types[e] : void 0,
			isCollapsed: this.isCollapsed(e),
			source: this.getSource(e)
		};
	}
	static fromFoldRanges(_) {
		let v = _.length, y = new Uint32Array(v), b = new Uint32Array(v), x = [], S = !1;
		for (let e = 0; e < v; e++) {
			let v = _[e];
			y[e] = v.startLineNumber, b[e] = v.endLineNumber, x.push(v.type), v.type && (S = !0);
		}
		S || (x = void 0);
		let C = new e(y, b, x);
		for (let e = 0; e < v; e++) _[e].isCollapsed && C.setCollapsed(e, !0), C.setSource(e, _[e].source);
		return C;
	}
	static sanitizeAndMerge(e, _, v, y) {
		v ??= Number.MAX_VALUE;
		let b = (e, _) => Array.isArray(e) ? ((v) => v < _ ? e[v] : void 0) : ((v) => v < _ ? e.toFoldRange(v) : void 0), x = b(e, e.length), S = b(_, _.length), C = 0, w = 0, T = x(0), E = S(0), D = [], O, k = 0, A = [];
		for (; T || E;) {
			let e;
			if (E && (!T || T.startLineNumber >= E.startLineNumber)) T && T.startLineNumber === E.startLineNumber ? (E.source === 1 ? e = E : (e = T, e.isCollapsed = E.isCollapsed && (T.endLineNumber === E.endLineNumber || !y?.startsInside(T.startLineNumber + 1, T.endLineNumber + 1)), e.source = 0), T = x(++C)) : (e = E, E.isCollapsed && E.source === 0 && (e.source = 2)), E = S(++w);
			else {
				let _ = w, v = E;
				for (;;) {
					if (!v || v.startLineNumber > T.endLineNumber) {
						e = T;
						break;
					}
					if (v.source === 1 && v.endLineNumber > T.endLineNumber) break;
					v = S(++_);
				}
				T = x(++C);
			}
			if (e) {
				for (; O && O.endLineNumber < e.startLineNumber;) O = D.pop();
				e.endLineNumber > e.startLineNumber && e.startLineNumber > k && e.endLineNumber <= v && (!O || O.endLineNumber >= e.endLineNumber) && (A.push(e), k = e.startLineNumber, O && D.push(O), O = e);
			}
		}
		return A;
	}
}, FoldingRegion = class {
	constructor(e, _) {
		this.ranges = e, this.index = _;
	}
	get startLineNumber() {
		return this.ranges.getStartLineNumber(this.index);
	}
	get endLineNumber() {
		return this.ranges.getEndLineNumber(this.index);
	}
	get regionIndex() {
		return this.index;
	}
	get parentIndex() {
		return this.ranges.getParentIndex(this.index);
	}
	get isCollapsed() {
		return this.ranges.isCollapsed(this.index);
	}
	containedBy(e) {
		return e.startLineNumber <= this.startLineNumber && e.endLineNumber >= this.endLineNumber;
	}
	containsLine(e) {
		return this.startLineNumber <= e && e <= this.endLineNumber;
	}
}, FoldingModel = class {
	get regions() {
		return this._regions;
	}
	get textModel() {
		return this._textModel;
	}
	constructor(e, _) {
		this._updateEventEmitter = new Emitter(), this.onDidChange = this._updateEventEmitter.event, this._textModel = e, this._decorationProvider = _, this._regions = new FoldingRegions(new Uint32Array(), new Uint32Array()), this._editorDecorationIds = [];
	}
	toggleCollapseState(e) {
		if (!e.length) return;
		e = e.sort((e, _) => e.regionIndex - _.regionIndex);
		let _ = {};
		this._decorationProvider.changeDecorations((v) => {
			let y = 0, b = -1, x = -1, S = (e) => {
				for (; y < e;) {
					let e = this._regions.getEndLineNumber(y), _ = this._regions.isCollapsed(y);
					if (e <= b) {
						let b = this.regions.getSource(y) !== 0;
						v.changeDecorationOptions(this._editorDecorationIds[y], this._decorationProvider.getDecorationOption(_, e <= x, b));
					}
					_ && e > x && (x = e), y++;
				}
			};
			for (let v of e) {
				let e = v.regionIndex, y = this._editorDecorationIds[e];
				if (y && !_[y]) {
					_[y] = !0, S(e);
					let v = !this._regions.isCollapsed(e);
					this._regions.setCollapsed(e, v), b = Math.max(b, this._regions.getEndLineNumber(e));
				}
			}
			S(this._regions.length);
		}), this._updateEventEmitter.fire({
			model: this,
			collapseStateChanged: e
		});
	}
	removeManualRanges(e) {
		let _ = [], v = (_) => {
			for (let v of e) if (!(v.startLineNumber > _.endLineNumber || _.startLineNumber > v.endLineNumber)) return !0;
			return !1;
		};
		for (let e = 0; e < this._regions.length; e++) {
			let y = this._regions.toFoldRange(e);
			(y.source === 0 || !v(y)) && _.push(y);
		}
		this.updatePost(FoldingRegions.fromFoldRanges(_));
	}
	update(e, _) {
		let v = this._currentFoldedOrManualRanges(_), y = FoldingRegions.sanitizeAndMerge(e, v, this._textModel.getLineCount(), _);
		this.updatePost(FoldingRegions.fromFoldRanges(y));
	}
	updatePost(e) {
		let _ = [], v = -1;
		for (let y = 0, b = e.length; y < b; y++) {
			let b = e.getStartLineNumber(y), x = e.getEndLineNumber(y), S = e.isCollapsed(y), C = e.getSource(y) !== 0, w = {
				startLineNumber: b,
				startColumn: this._textModel.getLineMaxColumn(b),
				endLineNumber: x,
				endColumn: this._textModel.getLineMaxColumn(x) + 1
			};
			_.push({
				range: w,
				options: this._decorationProvider.getDecorationOption(S, x <= v, C)
			}), S && x > v && (v = x);
		}
		this._decorationProvider.changeDecorations((e) => this._editorDecorationIds = e.deltaDecorations(this._editorDecorationIds, _)), this._regions = e, this._updateEventEmitter.fire({ model: this });
	}
	_currentFoldedOrManualRanges(e) {
		let _ = [];
		for (let v = 0, y = this._regions.length; v < y; v++) {
			let y = this.regions.isCollapsed(v), b = this.regions.getSource(v);
			if (y || b !== 0) {
				let x = this._regions.toFoldRange(v), S = this._textModel.getDecorationRange(this._editorDecorationIds[v]);
				S && (y && e?.startsInside(S.startLineNumber + 1, S.endLineNumber) && (y = !1), _.push({
					startLineNumber: S.startLineNumber,
					endLineNumber: S.endLineNumber,
					type: x.type,
					isCollapsed: y,
					source: b
				}));
			}
		}
		return _;
	}
	getMemento() {
		let e = this._currentFoldedOrManualRanges(), _ = [], v = this._textModel.getLineCount();
		for (let y = 0, b = e.length; y < b; y++) {
			let b = e[y];
			if (b.startLineNumber >= b.endLineNumber || b.startLineNumber < 1 || b.endLineNumber > v) continue;
			let x = this._getLinesChecksum(b.startLineNumber + 1, b.endLineNumber);
			_.push({
				startLineNumber: b.startLineNumber,
				endLineNumber: b.endLineNumber,
				isCollapsed: b.isCollapsed,
				source: b.source,
				checksum: x
			});
		}
		return _.length > 0 ? _ : void 0;
	}
	applyMemento(e) {
		if (!Array.isArray(e)) return;
		let _ = [], v = this._textModel.getLineCount();
		for (let y of e) {
			if (y.startLineNumber >= y.endLineNumber || y.startLineNumber < 1 || y.endLineNumber > v) continue;
			let e = this._getLinesChecksum(y.startLineNumber + 1, y.endLineNumber);
			(!y.checksum || e === y.checksum) && _.push({
				startLineNumber: y.startLineNumber,
				endLineNumber: y.endLineNumber,
				type: void 0,
				isCollapsed: y.isCollapsed ?? !0,
				source: y.source ?? 0
			});
		}
		let y = FoldingRegions.sanitizeAndMerge(this._regions, _, v);
		this.updatePost(FoldingRegions.fromFoldRanges(y));
	}
	_getLinesChecksum(e, _) {
		return hash(this._textModel.getLineContent(e) + this._textModel.getLineContent(_)) % 1e6;
	}
	dispose() {
		this._decorationProvider.removeDecorations(this._editorDecorationIds);
	}
	getAllRegionsAtLine(e, _) {
		let v = [];
		if (this._regions) {
			let y = this._regions.findRange(e), b = 1;
			for (; y >= 0;) {
				let e = this._regions.toRegion(y);
				(!_ || _(e, b)) && v.push(e), b++, y = e.parentIndex;
			}
		}
		return v;
	}
	getRegionAtLine(e) {
		if (this._regions) {
			let _ = this._regions.findRange(e);
			if (_ >= 0) return this._regions.toRegion(_);
		}
		return null;
	}
	getRegionsInside(e, _) {
		let v = [], y = e ? e.regionIndex + 1 : 0, b = e ? e.endLineNumber : Number.MAX_VALUE;
		if (_ && _.length === 2) {
			let e = [];
			for (let x = y, S = this._regions.length; x < S; x++) {
				let y = this._regions.toRegion(x);
				if (this._regions.getStartLineNumber(x) < b) {
					for (; e.length > 0 && !y.containedBy(e[e.length - 1]);) e.pop();
					e.push(y), _(y, e.length) && v.push(y);
				} else break;
			}
		} else for (let e = y, x = this._regions.length; e < x; e++) {
			let y = this._regions.toRegion(e);
			if (this._regions.getStartLineNumber(e) < b) (!_ || _(y)) && v.push(y);
			else break;
		}
		return v;
	}
};
function toggleCollapseState(e, _, v) {
	let y = [];
	for (let b of v) {
		let v = e.getRegionAtLine(b);
		if (v) {
			let b = !v.isCollapsed;
			if (y.push(v), _ > 1) {
				let x = e.getRegionsInside(v, (e, v) => e.isCollapsed !== b && v < _);
				y.push(...x);
			}
		}
	}
	e.toggleCollapseState(y);
}
function setCollapseStateLevelsDown(e, _, v = Number.MAX_VALUE, y) {
	let b = [];
	if (y && y.length > 0) for (let x of y) {
		let y = e.getRegionAtLine(x);
		if (y && (y.isCollapsed !== _ && b.push(y), v > 1)) {
			let x = e.getRegionsInside(y, (e, y) => e.isCollapsed !== _ && y < v);
			b.push(...x);
		}
	}
	else {
		let y = e.getRegionsInside(null, (e, y) => e.isCollapsed !== _ && y < v);
		b.push(...y);
	}
	e.toggleCollapseState(b);
}
function setCollapseStateLevelsUp(e, _, v, y) {
	let b = [];
	for (let x of y) {
		let y = e.getAllRegionsAtLine(x, (e, y) => e.isCollapsed !== _ && y <= v);
		b.push(...y);
	}
	e.toggleCollapseState(b);
}
function setCollapseStateUp(e, _, v) {
	let y = [];
	for (let b of v) {
		let v = e.getAllRegionsAtLine(b, (e) => e.isCollapsed !== _);
		v.length > 0 && y.push(v[0]);
	}
	e.toggleCollapseState(y);
}
function setCollapseStateAtLevel(e, _, v, y) {
	let b = e.getRegionsInside(null, (e, b) => b === _ && e.isCollapsed !== v && !y.some((_) => e.containsLine(_)));
	e.toggleCollapseState(b);
}
function setCollapseStateForRest(e, _, v) {
	let y = [];
	for (let _ of v) {
		let v = e.getAllRegionsAtLine(_, void 0);
		v.length > 0 && y.push(v[0]);
	}
	let b = e.getRegionsInside(null, (e) => y.every((_) => !_.containedBy(e) && !e.containedBy(_)) && e.isCollapsed !== _);
	e.toggleCollapseState(b);
}
function setCollapseStateForMatchingLines(e, _, v) {
	let y = e.textModel, b = e.regions, x = [];
	for (let e = b.length - 1; e >= 0; e--) if (v !== b.isCollapsed(e)) {
		let v = b.getStartLineNumber(e);
		_.test(y.getLineContent(v)) && x.push(b.toRegion(e));
	}
	e.toggleCollapseState(x);
}
function setCollapseStateForType(e, _, v) {
	let y = e.regions, b = [];
	for (let e = y.length - 1; e >= 0; e--) v !== y.isCollapsed(e) && _ === y.getType(e) && b.push(y.toRegion(e));
	e.toggleCollapseState(b);
}
function getParentFoldLine(e, _) {
	let v = null, y = _.getRegionAtLine(e);
	if (y !== null && (v = y.startLineNumber, e === v)) {
		let e = y.parentIndex;
		v = e === -1 ? null : _.regions.getStartLineNumber(e);
	}
	return v;
}
function getPreviousFoldLine(e, _) {
	let v = _.getRegionAtLine(e);
	if (v !== null && v.startLineNumber === e) {
		if (e !== v.startLineNumber) return v.startLineNumber;
		{
			let e = v.parentIndex, y = 0;
			for (e !== -1 && (y = _.regions.getStartLineNumber(v.parentIndex)); v !== null;) if (v.regionIndex > 0) {
				if (v = _.regions.toRegion(v.regionIndex - 1), v.startLineNumber <= y) return null;
				if (v.parentIndex === e) return v.startLineNumber;
			} else return null;
		}
	} else if (_.regions.length > 0) for (v = _.regions.toRegion(_.regions.length - 1); v !== null;) {
		if (v.startLineNumber < e) return v.startLineNumber;
		v = v.regionIndex > 0 ? _.regions.toRegion(v.regionIndex - 1) : null;
	}
	return null;
}
function getNextFoldLine(e, _) {
	let v = _.getRegionAtLine(e);
	if (v !== null && v.startLineNumber === e) {
		let e = v.parentIndex, y = 0;
		if (e !== -1) y = _.regions.getEndLineNumber(v.parentIndex);
		else if (_.regions.length === 0) return null;
		else y = _.regions.getEndLineNumber(_.regions.length - 1);
		for (; v !== null;) if (v.regionIndex < _.regions.length) {
			if (v = _.regions.toRegion(v.regionIndex + 1), v.startLineNumber >= y) return null;
			if (v.parentIndex === e) return v.startLineNumber;
		} else return null;
	} else if (_.regions.length > 0) for (v = _.regions.toRegion(0); v !== null;) {
		if (v.startLineNumber > e) return v.startLineNumber;
		v = v.regionIndex < _.regions.length ? _.regions.toRegion(v.regionIndex + 1) : null;
	}
	return null;
}
var HiddenRangeModel = class {
	get onDidChange() {
		return this._updateEventEmitter.event;
	}
	get hiddenRanges() {
		return this._hiddenRanges;
	}
	constructor(e) {
		this._updateEventEmitter = new Emitter(), this._hasLineChanges = !1, this._foldingModel = e, this._foldingModelListener = e.onDidChange((e) => this.updateHiddenRanges()), this._hiddenRanges = [], e.regions.length && this.updateHiddenRanges();
	}
	notifyChangeModelContent(e) {
		this._hiddenRanges.length && !this._hasLineChanges && (this._hasLineChanges = e.changes.some((e) => e.range.endLineNumber !== e.range.startLineNumber || countEOL(e.text)[0] !== 0));
	}
	updateHiddenRanges() {
		let e = !1, _ = [], v = 0, y = 0, b = Number.MAX_VALUE, x = -1, S = this._foldingModel.regions;
		for (; v < S.length; v++) {
			if (!S.isCollapsed(v)) continue;
			let C = S.getStartLineNumber(v) + 1, w = S.getEndLineNumber(v);
			b <= C && w <= x || (!e && y < this._hiddenRanges.length && this._hiddenRanges[y].startLineNumber === C && this._hiddenRanges[y].endLineNumber === w ? (_.push(this._hiddenRanges[y]), y++) : (e = !0, _.push(new Range(C, 1, w, 1))), b = C, x = w);
		}
		(this._hasLineChanges || e || y < this._hiddenRanges.length) && this.applyHiddenRanges(_);
	}
	applyHiddenRanges(e) {
		this._hiddenRanges = e, this._hasLineChanges = !1, this._updateEventEmitter.fire(e);
	}
	hasRanges() {
		return this._hiddenRanges.length > 0;
	}
	isHidden(e) {
		return findRange(this._hiddenRanges, e) !== null;
	}
	adjustSelections(e) {
		let _ = !1, v = this._foldingModel.textModel, y = null, b = (e) => ((!y || !isInside(e, y)) && (y = findRange(this._hiddenRanges, e)), y ? y.startLineNumber - 1 : null);
		for (let y = 0, x = e.length; y < x; y++) {
			let x = e[y], S = b(x.startLineNumber);
			S && (x = x.setStartPosition(S, v.getLineMaxColumn(S)), _ = !0);
			let C = b(x.endLineNumber);
			C && (x = x.setEndPosition(C, v.getLineMaxColumn(C)), _ = !0), e[y] = x;
		}
		return _;
	}
	dispose() {
		this.hiddenRanges.length > 0 && (this._hiddenRanges = [], this._updateEventEmitter.fire(this._hiddenRanges)), this._foldingModelListener &&= (this._foldingModelListener.dispose(), null);
	}
};
function isInside(e, _) {
	return e >= _.startLineNumber && e <= _.endLineNumber;
}
function findRange(e, _) {
	let v = findFirstIdxMonotonousOrArrLen(e, (e) => _ < e.startLineNumber) - 1;
	return v >= 0 && e[v].endLineNumber >= _ ? e[v] : null;
}
var MAX_FOLDING_REGIONS_FOR_INDENT_DEFAULT = 5e3, ID_INDENT_PROVIDER = "indent", IndentRangeProvider = class {
	constructor(e, _, v) {
		this.editorModel = e, this.languageConfigurationService = _, this.foldingRangesLimit = v, this.id = ID_INDENT_PROVIDER;
	}
	dispose() {}
	compute(e) {
		let _ = this.languageConfigurationService.getLanguageConfiguration(this.editorModel.getLanguageId()).foldingRules, v = _ && !!_.offSide, y = _ && _.markers;
		return Promise.resolve(computeRanges(this.editorModel, v, y, this.foldingRangesLimit));
	}
}, RangesCollector$1 = class {
	constructor(e) {
		this._startIndexes = [], this._endIndexes = [], this._indentOccurrences = [], this._length = 0, this._foldingRangesLimit = e;
	}
	insertFirst(e, _, v) {
		if (e > 16777215 || _ > 16777215) return;
		let y = this._length;
		this._startIndexes[y] = e, this._endIndexes[y] = _, this._length++, v < 1e3 && (this._indentOccurrences[v] = (this._indentOccurrences[v] || 0) + 1);
	}
	toIndentRanges(e) {
		let _ = this._foldingRangesLimit.limit;
		if (this._length <= _) {
			this._foldingRangesLimit.update(this._length, !1);
			let e = new Uint32Array(this._length), _ = new Uint32Array(this._length);
			for (let v = this._length - 1, y = 0; v >= 0; v--, y++) e[y] = this._startIndexes[v], _[y] = this._endIndexes[v];
			return new FoldingRegions(e, _);
		} else {
			this._foldingRangesLimit.update(this._length, _);
			let v = 0, y = this._indentOccurrences.length;
			for (let e = 0; e < this._indentOccurrences.length; e++) {
				let b = this._indentOccurrences[e];
				if (b) {
					if (b + v > _) {
						y = e;
						break;
					}
					v += b;
				}
			}
			let b = e.getOptions().tabSize, x = new Uint32Array(_), S = new Uint32Array(_);
			for (let C = this._length - 1, w = 0; C >= 0; C--) {
				let T = this._startIndexes[C], E = e.getLineContent(T), D = computeIndentLevel(E, b);
				(D < y || D === y && v++ < _) && (x[w] = T, S[w] = this._endIndexes[C], w++);
			}
			return new FoldingRegions(x, S);
		}
	}
}, foldingRangesLimitDefault = {
	limit: MAX_FOLDING_REGIONS_FOR_INDENT_DEFAULT,
	update: () => {}
};
function computeRanges(e, _, v, y = foldingRangesLimitDefault) {
	let b = e.getOptions().tabSize, x = new RangesCollector$1(y), S;
	v && (S = /* @__PURE__ */ RegExp(`(${v.start.source})|(?:${v.end.source})`));
	let C = [], w = e.getLineCount() + 1;
	C.push({
		indent: -1,
		endAbove: w,
		line: w
	});
	for (let v = e.getLineCount(); v > 0; v--) {
		let y = e.getLineContent(v), w = computeIndentLevel(y, b), T = C[C.length - 1];
		if (w === -1) {
			_ && (T.endAbove = v);
			continue;
		}
		let E;
		if (S && (E = y.match(S))) if (E[1]) {
			let e = C.length - 1;
			for (; e > 0 && C[e].indent !== -2;) e--;
			if (e > 0) {
				C.length = e + 1, T = C[e], x.insertFirst(v, T.line, w), T.line = v, T.indent = w, T.endAbove = v;
				continue;
			}
		} else {
			C.push({
				indent: -2,
				endAbove: v,
				line: v
			});
			continue;
		}
		if (T.indent > w) {
			do
				C.pop(), T = C[C.length - 1];
			while (T.indent > w);
			let e = T.endAbove - 1;
			e - v >= 1 && x.insertFirst(v, e, w);
		}
		T.indent === w ? T.endAbove = v : C.push({
			indent: w,
			endAbove: v,
			line: v
		});
	}
	return x.toIndentRanges(e);
}
var foldBackground = registerColor("editor.foldBackground", {
	light: transparent(editorSelectionBackground, .3),
	dark: transparent(editorSelectionBackground, .3),
	hcDark: null,
	hcLight: null
}, localize("foldBackgroundBackground", "Background color behind folded ranges. The color must not be opaque so as not to hide underlying decorations."), !0);
registerColor("editor.foldPlaceholderForeground", {
	light: "#808080",
	dark: "#808080",
	hcDark: null,
	hcLight: null
}, localize("collapsedTextColor", "Color of the collapsed text after the first line of a folded range.")), registerColor("editorGutter.foldingControlForeground", iconForeground, localize("editorGutter.foldingControlForeground", "Color of the folding control in the editor gutter."));
const foldingExpandedIcon = registerIcon("folding-expanded", Codicon.chevronDown, localize("foldingExpandedIcon", "Icon for expanded ranges in the editor glyph margin.")), foldingCollapsedIcon = registerIcon("folding-collapsed", Codicon.chevronRight, localize("foldingCollapsedIcon", "Icon for collapsed ranges in the editor glyph margin.")), foldingManualCollapsedIcon = registerIcon("folding-manual-collapsed", foldingCollapsedIcon, localize("foldingManualCollapedIcon", "Icon for manually collapsed ranges in the editor glyph margin.")), foldingManualExpandedIcon = registerIcon("folding-manual-expanded", foldingExpandedIcon, localize("foldingManualExpandedIcon", "Icon for manually expanded ranges in the editor glyph margin."));
var foldedBackgroundMinimap = {
	color: themeColorFromId(foldBackground),
	position: 1
}, collapsed = localize("linesCollapsed", "Click to expand the range."), expanded = localize("linesExpanded", "Click to collapse the range."), FoldingDecorationProvider = class e {
	static {
		this.COLLAPSED_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-collapsed-visual-decoration",
			stickiness: 0,
			afterContentClassName: "inline-folded",
			isWholeLine: !0,
			linesDecorationsTooltip: collapsed,
			firstLineDecorationClassName: ThemeIcon.asClassName(foldingCollapsedIcon)
		});
	}
	static {
		this.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-collapsed-highlighted-visual-decoration",
			stickiness: 0,
			afterContentClassName: "inline-folded",
			className: "folded-background",
			minimap: foldedBackgroundMinimap,
			isWholeLine: !0,
			linesDecorationsTooltip: collapsed,
			firstLineDecorationClassName: ThemeIcon.asClassName(foldingCollapsedIcon)
		});
	}
	static {
		this.MANUALLY_COLLAPSED_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-manually-collapsed-visual-decoration",
			stickiness: 0,
			afterContentClassName: "inline-folded",
			isWholeLine: !0,
			linesDecorationsTooltip: collapsed,
			firstLineDecorationClassName: ThemeIcon.asClassName(foldingManualCollapsedIcon)
		});
	}
	static {
		this.MANUALLY_COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-manually-collapsed-highlighted-visual-decoration",
			stickiness: 0,
			afterContentClassName: "inline-folded",
			className: "folded-background",
			minimap: foldedBackgroundMinimap,
			isWholeLine: !0,
			linesDecorationsTooltip: collapsed,
			firstLineDecorationClassName: ThemeIcon.asClassName(foldingManualCollapsedIcon)
		});
	}
	static {
		this.NO_CONTROLS_COLLAPSED_RANGE_DECORATION = ModelDecorationOptions.register({
			description: "folding-no-controls-range-decoration",
			stickiness: 0,
			afterContentClassName: "inline-folded",
			isWholeLine: !0,
			linesDecorationsTooltip: collapsed
		});
	}
	static {
		this.NO_CONTROLS_COLLAPSED_HIGHLIGHTED_RANGE_DECORATION = ModelDecorationOptions.register({
			description: "folding-no-controls-range-decoration",
			stickiness: 0,
			afterContentClassName: "inline-folded",
			className: "folded-background",
			minimap: foldedBackgroundMinimap,
			isWholeLine: !0,
			linesDecorationsTooltip: collapsed
		});
	}
	static {
		this.EXPANDED_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-expanded-visual-decoration",
			stickiness: 1,
			isWholeLine: !0,
			firstLineDecorationClassName: "alwaysShowFoldIcons " + ThemeIcon.asClassName(foldingExpandedIcon),
			linesDecorationsTooltip: expanded
		});
	}
	static {
		this.EXPANDED_AUTO_HIDE_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-expanded-auto-hide-visual-decoration",
			stickiness: 1,
			isWholeLine: !0,
			firstLineDecorationClassName: ThemeIcon.asClassName(foldingExpandedIcon),
			linesDecorationsTooltip: expanded
		});
	}
	static {
		this.MANUALLY_EXPANDED_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-manually-expanded-visual-decoration",
			stickiness: 0,
			isWholeLine: !0,
			firstLineDecorationClassName: "alwaysShowFoldIcons " + ThemeIcon.asClassName(foldingManualExpandedIcon),
			linesDecorationsTooltip: expanded
		});
	}
	static {
		this.MANUALLY_EXPANDED_AUTO_HIDE_VISUAL_DECORATION = ModelDecorationOptions.register({
			description: "folding-manually-expanded-auto-hide-visual-decoration",
			stickiness: 0,
			isWholeLine: !0,
			firstLineDecorationClassName: ThemeIcon.asClassName(foldingManualExpandedIcon),
			linesDecorationsTooltip: expanded
		});
	}
	static {
		this.NO_CONTROLS_EXPANDED_RANGE_DECORATION = ModelDecorationOptions.register({
			description: "folding-no-controls-range-decoration",
			stickiness: 0,
			isWholeLine: !0
		});
	}
	static {
		this.HIDDEN_RANGE_DECORATION = ModelDecorationOptions.register({
			description: "folding-hidden-range-decoration",
			stickiness: 1
		});
	}
	constructor(e) {
		this.editor = e, this.showFoldingControls = "mouseover", this.showFoldingHighlights = !0;
	}
	getDecorationOption(_, v, y) {
		return v ? e.HIDDEN_RANGE_DECORATION : this.showFoldingControls === "never" ? _ ? this.showFoldingHighlights ? e.NO_CONTROLS_COLLAPSED_HIGHLIGHTED_RANGE_DECORATION : e.NO_CONTROLS_COLLAPSED_RANGE_DECORATION : e.NO_CONTROLS_EXPANDED_RANGE_DECORATION : _ ? y ? this.showFoldingHighlights ? e.MANUALLY_COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION : e.MANUALLY_COLLAPSED_VISUAL_DECORATION : this.showFoldingHighlights ? e.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION : e.COLLAPSED_VISUAL_DECORATION : this.showFoldingControls === "mouseover" ? y ? e.MANUALLY_EXPANDED_AUTO_HIDE_VISUAL_DECORATION : e.EXPANDED_AUTO_HIDE_VISUAL_DECORATION : y ? e.MANUALLY_EXPANDED_VISUAL_DECORATION : e.EXPANDED_VISUAL_DECORATION;
	}
	changeDecorations(e) {
		return this.editor.changeDecorations(e);
	}
	removeDecorations(e) {
		this.editor.removeDecorations(e);
	}
}, foldingContext = {}, ID_SYNTAX_PROVIDER = "syntax", SyntaxRangeProvider = class {
	constructor(e, _, v, y, b) {
		this.editorModel = e, this.providers = _, this.handleFoldingRangesChange = v, this.foldingRangesLimit = y, this.fallbackRangeProvider = b, this.id = ID_SYNTAX_PROVIDER, this.disposables = new DisposableStore(), b && this.disposables.add(b);
		for (let e of _) typeof e.onDidChange == "function" && this.disposables.add(e.onDidChange(v));
	}
	compute(e) {
		return collectSyntaxRanges(this.providers, this.editorModel, e).then((_) => _ ? sanitizeRanges(_, this.foldingRangesLimit) : this.fallbackRangeProvider?.compute(e) ?? null);
	}
	dispose() {
		this.disposables.dispose();
	}
};
function collectSyntaxRanges(e, _, v) {
	let y = null, b = e.map((e, b) => Promise.resolve(e.provideFoldingRanges(_, foldingContext, v)).then((e) => {
		if (!v.isCancellationRequested && Array.isArray(e)) {
			Array.isArray(y) || (y = []);
			let v = _.getLineCount();
			for (let _ of e) _.start > 0 && _.end > _.start && _.end <= v && y.push({
				start: _.start,
				end: _.end,
				rank: b,
				kind: _.kind
			});
		}
	}, onUnexpectedExternalError));
	return Promise.all(b).then((e) => y);
}
var RangesCollector = class {
	constructor(e) {
		this._startIndexes = [], this._endIndexes = [], this._nestingLevels = [], this._nestingLevelCounts = [], this._types = [], this._length = 0, this._foldingRangesLimit = e;
	}
	add(e, _, v, y) {
		if (e > 16777215 || _ > 16777215) return;
		let b = this._length;
		this._startIndexes[b] = e, this._endIndexes[b] = _, this._nestingLevels[b] = y, this._types[b] = v, this._length++, y < 30 && (this._nestingLevelCounts[y] = (this._nestingLevelCounts[y] || 0) + 1);
	}
	toIndentRanges() {
		let e = this._foldingRangesLimit.limit;
		if (this._length <= e) {
			this._foldingRangesLimit.update(this._length, !1);
			let e = new Uint32Array(this._length), _ = new Uint32Array(this._length);
			for (let v = 0; v < this._length; v++) e[v] = this._startIndexes[v], _[v] = this._endIndexes[v];
			return new FoldingRegions(e, _, this._types);
		} else {
			this._foldingRangesLimit.update(this._length, e);
			let _ = 0, v = this._nestingLevelCounts.length;
			for (let y = 0; y < this._nestingLevelCounts.length; y++) {
				let b = this._nestingLevelCounts[y];
				if (b) {
					if (b + _ > e) {
						v = y;
						break;
					}
					_ += b;
				}
			}
			let y = new Uint32Array(e), b = new Uint32Array(e), x = [];
			for (let S = 0, C = 0; S < this._length; S++) {
				let w = this._nestingLevels[S];
				(w < v || w === v && _++ < e) && (y[C] = this._startIndexes[S], b[C] = this._endIndexes[S], x[C] = this._types[S], C++);
			}
			return new FoldingRegions(y, b, x);
		}
	}
};
function sanitizeRanges(e, _) {
	let v = e.sort((e, _) => {
		let v = e.start - _.start;
		return v === 0 && (v = e.rank - _.rank), v;
	}), y = new RangesCollector(_), b, x = [];
	for (let e of v) if (!b) b = e, y.add(e.start, e.end, e.kind && e.kind.value, x.length);
	else if (e.start > b.start) if (e.end <= b.end) x.push(b), b = e, y.add(e.start, e.end, e.kind && e.kind.value, x.length);
	else {
		if (e.start > b.end) {
			do
				b = x.pop();
			while (b && e.start > b.end);
			b && x.push(b), b = e;
		}
		y.add(e.start, e.end, e.kind && e.kind.value, x.length);
	}
	return y.toIndentRanges();
}
var __decorate$67 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$67 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, FoldingController_1, CONTEXT_FOLDING_ENABLED = new RawContextKey("foldingEnabled", !1), FoldingController = class extends Disposable {
	static {
		FoldingController_1 = this;
	}
	static {
		this.ID = "editor.contrib.folding";
	}
	static get(e) {
		return e.getContribution(FoldingController_1.ID);
	}
	static getFoldingRangeProviders(e, _) {
		let v = e.foldingRangeProvider.ordered(_);
		return FoldingController_1._foldingRangeSelector?.(v, _) ?? v;
	}
	constructor(e, _, v, y, b, x) {
		super(), this.contextKeyService = _, this.languageConfigurationService = v, this.languageFeaturesService = x, this.localToDispose = this._register(new DisposableStore()), this.editor = e, this._foldingLimitReporter = new RangesLimitReporter(e);
		let S = this.editor.getOptions();
		this._isEnabled = S.get(43), this._useFoldingProviders = S.get(44) !== "indentation", this._unfoldOnClickAfterEndOfLine = S.get(48), this._restoringViewState = !1, this._currentModelHasFoldedImports = !1, this._foldingImportsByDefault = S.get(46), this.updateDebounceInfo = b.for(x.foldingRangeProvider, "Folding", { min: 200 }), this.foldingModel = null, this.hiddenRangeModel = null, this.rangeProvider = null, this.foldingRegionPromise = null, this.foldingModelPromise = null, this.updateScheduler = null, this.cursorChangedScheduler = null, this.mouseDownInfo = null, this.foldingDecorationProvider = new FoldingDecorationProvider(e), this.foldingDecorationProvider.showFoldingControls = S.get(111), this.foldingDecorationProvider.showFoldingHighlights = S.get(45), this.foldingEnabled = CONTEXT_FOLDING_ENABLED.bindTo(this.contextKeyService), this.foldingEnabled.set(this._isEnabled), this._register(this.editor.onDidChangeModel(() => this.onModelChanged())), this._register(this.editor.onDidChangeConfiguration((e) => {
			if (e.hasChanged(43) && (this._isEnabled = this.editor.getOptions().get(43), this.foldingEnabled.set(this._isEnabled), this.onModelChanged()), e.hasChanged(47) && this.onModelChanged(), e.hasChanged(111) || e.hasChanged(45)) {
				let e = this.editor.getOptions();
				this.foldingDecorationProvider.showFoldingControls = e.get(111), this.foldingDecorationProvider.showFoldingHighlights = e.get(45), this.triggerFoldingModelChanged();
			}
			e.hasChanged(44) && (this._useFoldingProviders = this.editor.getOptions().get(44) !== "indentation", this.onFoldingStrategyChanged()), e.hasChanged(48) && (this._unfoldOnClickAfterEndOfLine = this.editor.getOptions().get(48)), e.hasChanged(46) && (this._foldingImportsByDefault = this.editor.getOptions().get(46));
		})), this.onModelChanged();
	}
	saveViewState() {
		let e = this.editor.getModel();
		if (!e || !this._isEnabled || e.isTooLargeForTokenization()) return {};
		if (this.foldingModel) {
			let _ = this.foldingModel.getMemento(), v = this.rangeProvider ? this.rangeProvider.id : void 0;
			return {
				collapsedRegions: _,
				lineCount: e.getLineCount(),
				provider: v,
				foldedImports: this._currentModelHasFoldedImports
			};
		}
	}
	restoreViewState(e) {
		let _ = this.editor.getModel();
		if (!(!_ || !this._isEnabled || _.isTooLargeForTokenization() || !this.hiddenRangeModel) && e && (this._currentModelHasFoldedImports = !!e.foldedImports, e.collapsedRegions && e.collapsedRegions.length > 0 && this.foldingModel)) {
			this._restoringViewState = !0;
			try {
				this.foldingModel.applyMemento(e.collapsedRegions);
			} finally {
				this._restoringViewState = !1;
			}
		}
	}
	onModelChanged() {
		this.localToDispose.clear();
		let e = this.editor.getModel();
		!this._isEnabled || !e || e.isTooLargeForTokenization() || (this._currentModelHasFoldedImports = !1, this.foldingModel = new FoldingModel(e, this.foldingDecorationProvider), this.localToDispose.add(this.foldingModel), this.hiddenRangeModel = new HiddenRangeModel(this.foldingModel), this.localToDispose.add(this.hiddenRangeModel), this.localToDispose.add(this.hiddenRangeModel.onDidChange((e) => this.onHiddenRangesChanges(e))), this.updateScheduler = new Delayer(this.updateDebounceInfo.get(e)), this.cursorChangedScheduler = new RunOnceScheduler(() => this.revealCursor(), 200), this.localToDispose.add(this.cursorChangedScheduler), this.localToDispose.add(this.languageFeaturesService.foldingRangeProvider.onDidChange(() => this.onFoldingStrategyChanged())), this.localToDispose.add(this.editor.onDidChangeModelLanguageConfiguration(() => this.onFoldingStrategyChanged())), this.localToDispose.add(this.editor.onDidChangeModelContent((e) => this.onDidChangeModelContent(e))), this.localToDispose.add(this.editor.onDidChangeCursorPosition(() => this.onCursorPositionChanged())), this.localToDispose.add(this.editor.onMouseDown((e) => this.onEditorMouseDown(e))), this.localToDispose.add(this.editor.onMouseUp((e) => this.onEditorMouseUp(e))), this.localToDispose.add({ dispose: () => {
			this.foldingRegionPromise &&= (this.foldingRegionPromise.cancel(), null), this.updateScheduler?.cancel(), this.updateScheduler = null, this.foldingModel = null, this.foldingModelPromise = null, this.hiddenRangeModel = null, this.cursorChangedScheduler = null, this.rangeProvider?.dispose(), this.rangeProvider = null;
		} }), this.triggerFoldingModelChanged());
	}
	onFoldingStrategyChanged() {
		this.rangeProvider?.dispose(), this.rangeProvider = null, this.triggerFoldingModelChanged();
	}
	getRangeProvider(e) {
		if (this.rangeProvider) return this.rangeProvider;
		let _ = new IndentRangeProvider(e, this.languageConfigurationService, this._foldingLimitReporter);
		if (this.rangeProvider = _, this._useFoldingProviders && this.foldingModel) {
			let v = FoldingController_1.getFoldingRangeProviders(this.languageFeaturesService, e);
			v.length > 0 && (this.rangeProvider = new SyntaxRangeProvider(e, v, () => this.triggerFoldingModelChanged(), this._foldingLimitReporter, _));
		}
		return this.rangeProvider;
	}
	getFoldingModel() {
		return this.foldingModelPromise;
	}
	onDidChangeModelContent(e) {
		this.hiddenRangeModel?.notifyChangeModelContent(e), this.triggerFoldingModelChanged();
	}
	triggerFoldingModelChanged() {
		this.updateScheduler && (this.foldingRegionPromise &&= (this.foldingRegionPromise.cancel(), null), this.foldingModelPromise = this.updateScheduler.trigger(() => {
			let e = this.foldingModel;
			if (!e) return null;
			let _ = new StopWatch(), v = this.getRangeProvider(e.textModel), y = this.foldingRegionPromise = createCancelablePromise((e) => v.compute(e));
			return y.then((v) => {
				if (v && y === this.foldingRegionPromise) {
					let y;
					if (this._foldingImportsByDefault && !this._currentModelHasFoldedImports) {
						let e = v.setCollapsedAllOfType(FoldingRangeKind.Imports.value, !0);
						e && (y = StableEditorScrollState.capture(this.editor), this._currentModelHasFoldedImports = e);
					}
					let b = this.editor.getSelections();
					e.update(v, toSelectedLines(b)), y?.restore(this.editor);
					let x = this.updateDebounceInfo.update(e.textModel, _.elapsed());
					this.updateScheduler && (this.updateScheduler.defaultDelay = x);
				}
				return e;
			});
		}).then(void 0, (e) => (onUnexpectedError(e), null)));
	}
	onHiddenRangesChanges(e) {
		if (this.hiddenRangeModel && e.length && !this._restoringViewState) {
			let e = this.editor.getSelections();
			e && this.hiddenRangeModel.adjustSelections(e) && this.editor.setSelections(e);
		}
		this.editor.setHiddenAreas(e, this);
	}
	onCursorPositionChanged() {
		this.hiddenRangeModel && this.hiddenRangeModel.hasRanges() && this.cursorChangedScheduler.schedule();
	}
	revealCursor() {
		let e = this.getFoldingModel();
		e && e.then((e) => {
			if (e) {
				let _ = this.editor.getSelections();
				if (_ && _.length > 0) {
					let v = [];
					for (let y of _) {
						let _ = y.selectionStartLineNumber;
						this.hiddenRangeModel && this.hiddenRangeModel.isHidden(_) && v.push(...e.getAllRegionsAtLine(_, (e) => e.isCollapsed && _ > e.startLineNumber));
					}
					v.length && (e.toggleCollapseState(v), this.reveal(_[0].getPosition()));
				}
			}
		}).then(void 0, onUnexpectedError);
	}
	onEditorMouseDown(e) {
		if (this.mouseDownInfo = null, !this.hiddenRangeModel || !e.target || !e.target.range || !e.event.leftButton && !e.event.middleButton) return;
		let _ = e.target.range, v = !1;
		switch (e.target.type) {
			case 4: {
				let _ = e.target.detail, y = e.target.element.offsetLeft;
				if (_.offsetX - y < 4) return;
				v = !0;
				break;
			}
			case 7:
				if (this._unfoldOnClickAfterEndOfLine && this.hiddenRangeModel.hasRanges() && !e.target.detail.isAfterLines) break;
				return;
			case 6:
				if (this.hiddenRangeModel.hasRanges()) {
					let e = this.editor.getModel();
					if (e && _.startColumn === e.getLineMaxColumn(_.startLineNumber)) break;
				}
				return;
			default: return;
		}
		this.mouseDownInfo = {
			lineNumber: _.startLineNumber,
			iconClicked: v
		};
	}
	onEditorMouseUp(e) {
		let _ = this.foldingModel;
		if (!_ || !this.mouseDownInfo || !e.target) return;
		let v = this.mouseDownInfo.lineNumber, y = this.mouseDownInfo.iconClicked, b = e.target.range;
		if (!b || b.startLineNumber !== v) return;
		if (y) {
			if (e.target.type !== 4) return;
		} else {
			let e = this.editor.getModel();
			if (!e || b.startColumn !== e.getLineMaxColumn(v)) return;
		}
		let x = _.getRegionAtLine(v);
		if (x && x.startLineNumber === v) {
			let b = x.isCollapsed;
			if (y || b) {
				let y = e.event.altKey, S = [];
				if (y) {
					let e = _.getRegionsInside(null, (e) => !e.containedBy(x) && !x.containedBy(e));
					for (let _ of e) _.isCollapsed && S.push(_);
					S.length === 0 && (S = e);
				} else {
					let v = e.event.middleButton || e.event.shiftKey;
					if (v) for (let e of _.getRegionsInside(x)) e.isCollapsed === b && S.push(e);
					(b || !v || S.length === 0) && S.push(x);
				}
				_.toggleCollapseState(S), this.reveal({
					lineNumber: v,
					column: 1
				});
			}
		}
	}
	reveal(e) {
		this.editor.revealPositionInCenterIfOutsideViewport(e, 0);
	}
};
FoldingController = FoldingController_1 = __decorate$67([
	__param$67(1, IContextKeyService),
	__param$67(2, ILanguageConfigurationService),
	__param$67(3, INotificationService),
	__param$67(4, ILanguageFeatureDebounceService),
	__param$67(5, ILanguageFeaturesService)
], FoldingController);
var RangesLimitReporter = class {
	constructor(e) {
		this.editor = e, this._onDidChange = new Emitter(), this._computed = 0, this._limited = !1;
	}
	get limit() {
		return this.editor.getOptions().get(47);
	}
	update(e, _) {
		(e !== this._computed || _ !== this._limited) && (this._computed = e, this._limited = _, this._onDidChange.fire());
	}
}, FoldingAction = class extends EditorAction {
	runEditorCommand(e, _, v) {
		let y = e.get(ILanguageConfigurationService), b = FoldingController.get(_);
		if (!b) return;
		let x = b.getFoldingModel();
		if (x) return this.reportTelemetry(e, _), x.then((e) => {
			if (e) {
				this.invoke(b, e, _, v, y);
				let x = _.getSelection();
				x && b.reveal(x.getStartPosition());
			}
		});
	}
	getSelectedLines(e) {
		let _ = e.getSelections();
		return _ ? _.map((e) => e.startLineNumber) : [];
	}
	getLineNumbers(e, _) {
		return e && e.selectionLines ? e.selectionLines.map((e) => e + 1) : this.getSelectedLines(_);
	}
	run(e, _) {}
};
function toSelectedLines(e) {
	return !e || e.length === 0 ? { startsInside: () => !1 } : { startsInside(_, v) {
		for (let y of e) {
			let e = y.startLineNumber;
			if (e >= _ && e <= v) return !0;
		}
		return !1;
	} };
}
function foldingArgumentsConstraint(e) {
	if (!isUndefined(e)) {
		if (!isObject(e)) return !1;
		let _ = e;
		if (!isUndefined(_.levels) && !isNumber(_.levels) || !isUndefined(_.direction) && !isString(_.direction) || !isUndefined(_.selectionLines) && (!Array.isArray(_.selectionLines) || !_.selectionLines.every(isNumber))) return !1;
	}
	return !0;
}
var UnfoldAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.unfold",
			label: localize("unfoldAction.label", "Unfold"),
			alias: "Unfold",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3166,
				mac: { primary: 2654 },
				weight: 100
			},
			metadata: {
				description: "Unfold the content in the editor",
				args: [{
					name: "Unfold editor argument",
					description: "Property-value pairs that can be passed through this argument:\n						* 'levels': Number of levels to unfold. If not set, defaults to 1.\n						* 'direction': If 'up', unfold given number of levels up otherwise unfolds down.\n						* 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the unfold action to. If not set, the active selection(s) will be used.\n						",
					constraint: foldingArgumentsConstraint,
					schema: {
						type: "object",
						properties: {
							levels: {
								type: "number",
								default: 1
							},
							direction: {
								type: "string",
								enum: ["up", "down"],
								default: "down"
							},
							selectionLines: {
								type: "array",
								items: { type: "number" }
							}
						}
					}
				}]
			}
		});
	}
	invoke(e, _, v, y) {
		let b = y && y.levels || 1, x = this.getLineNumbers(y, v);
		y && y.direction === "up" ? setCollapseStateLevelsUp(_, !1, b, x) : setCollapseStateLevelsDown(_, !1, b, x);
	}
}, UnFoldRecursivelyAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.unfoldRecursively",
			label: localize("unFoldRecursivelyAction.label", "Unfold Recursively"),
			alias: "Unfold Recursively",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2142),
				weight: 100
			}
		});
	}
	invoke(e, _, v, y) {
		setCollapseStateLevelsDown(_, !1, Number.MAX_VALUE, this.getSelectedLines(v));
	}
}, FoldAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.fold",
			label: localize("foldAction.label", "Fold"),
			alias: "Fold",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3164,
				mac: { primary: 2652 },
				weight: 100
			},
			metadata: {
				description: "Fold the content in the editor",
				args: [{
					name: "Fold editor argument",
					description: "Property-value pairs that can be passed through this argument:\n							* 'levels': Number of levels to fold.\n							* 'direction': If 'up', folds given number of levels up otherwise folds down.\n							* 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the fold action to. If not set, the active selection(s) will be used.\n							If no levels or direction is set, folds the region at the locations or if already collapsed, the first uncollapsed parent instead.\n						",
					constraint: foldingArgumentsConstraint,
					schema: {
						type: "object",
						properties: {
							levels: { type: "number" },
							direction: {
								type: "string",
								enum: ["up", "down"]
							},
							selectionLines: {
								type: "array",
								items: { type: "number" }
							}
						}
					}
				}]
			}
		});
	}
	invoke(e, _, v, y) {
		let b = this.getLineNumbers(y, v), x = y && y.levels, S = y && y.direction;
		typeof x != "number" && typeof S != "string" ? setCollapseStateUp(_, !0, b) : S === "up" ? setCollapseStateLevelsUp(_, !0, x || 1, b) : setCollapseStateLevelsDown(_, !0, x || 1, b);
	}
}, ToggleFoldAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.toggleFold",
			label: localize("toggleFoldAction.label", "Toggle Fold"),
			alias: "Toggle Fold",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2090),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		toggleCollapseState(_, 1, y);
	}
}, FoldRecursivelyAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.foldRecursively",
			label: localize("foldRecursivelyAction.label", "Fold Recursively"),
			alias: "Fold Recursively",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2140),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		setCollapseStateLevelsDown(_, !0, Number.MAX_VALUE, y);
	}
}, ToggleFoldRecursivelyAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.toggleFoldRecursively",
			label: localize("toggleFoldRecursivelyAction.label", "Toggle Fold Recursively"),
			alias: "Toggle Fold Recursively",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 3114),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		toggleCollapseState(_, Number.MAX_VALUE, y);
	}
}, FoldAllBlockCommentsAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.foldAllBlockComments",
			label: localize("foldAllBlockComments.label", "Fold All Block Comments"),
			alias: "Fold All Block Comments",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2138),
				weight: 100
			}
		});
	}
	invoke(e, _, v, y, b) {
		if (_.regions.hasTypes()) setCollapseStateForType(_, FoldingRangeKind.Comment.value, !0);
		else {
			let e = v.getModel();
			if (!e) return;
			let y = b.getLanguageConfiguration(e.getLanguageId()).comments;
			if (y && y.blockCommentStartToken) {
				let e = /* @__PURE__ */ RegExp("^\\s*" + escapeRegExpCharacters(y.blockCommentStartToken));
				setCollapseStateForMatchingLines(_, e, !0);
			}
		}
	}
}, FoldAllRegionsAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.foldAllMarkerRegions",
			label: localize("foldAllMarkerRegions.label", "Fold All Regions"),
			alias: "Fold All Regions",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2077),
				weight: 100
			}
		});
	}
	invoke(e, _, v, y, b) {
		if (_.regions.hasTypes()) setCollapseStateForType(_, FoldingRangeKind.Region.value, !0);
		else {
			let e = v.getModel();
			if (!e) return;
			let y = b.getLanguageConfiguration(e.getLanguageId()).foldingRules;
			if (y && y.markers && y.markers.start) {
				let e = new RegExp(y.markers.start);
				setCollapseStateForMatchingLines(_, e, !0);
			}
		}
	}
}, UnfoldAllRegionsAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.unfoldAllMarkerRegions",
			label: localize("unfoldAllMarkerRegions.label", "Unfold All Regions"),
			alias: "Unfold All Regions",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2078),
				weight: 100
			}
		});
	}
	invoke(e, _, v, y, b) {
		if (_.regions.hasTypes()) setCollapseStateForType(_, FoldingRangeKind.Region.value, !1);
		else {
			let e = v.getModel();
			if (!e) return;
			let y = b.getLanguageConfiguration(e.getLanguageId()).foldingRules;
			if (y && y.markers && y.markers.start) {
				let e = new RegExp(y.markers.start);
				setCollapseStateForMatchingLines(_, e, !1);
			}
		}
	}
}, FoldAllExceptAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.foldAllExcept",
			label: localize("foldAllExcept.label", "Fold All Except Selected"),
			alias: "Fold All Except Selected",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2136),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		setCollapseStateForRest(_, !0, y);
	}
}, UnfoldAllExceptAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.unfoldAllExcept",
			label: localize("unfoldAllExcept.label", "Unfold All Except Selected"),
			alias: "Unfold All Except Selected",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2134),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		setCollapseStateForRest(_, !1, y);
	}
}, FoldAllAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.foldAll",
			label: localize("foldAllAction.label", "Fold All"),
			alias: "Fold All",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2069),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		setCollapseStateLevelsDown(_, !0);
	}
}, UnfoldAllAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.unfoldAll",
			label: localize("unfoldAllAction.label", "Unfold All"),
			alias: "Unfold All",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2088),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		setCollapseStateLevelsDown(_, !1);
	}
}, FoldLevelAction = class e extends FoldingAction {
	static {
		this.ID_PREFIX = "editor.foldLevel";
	}
	static {
		this.ID = (_) => e.ID_PREFIX + _;
	}
	getFoldingLevel() {
		return parseInt(this.id.substr(e.ID_PREFIX.length));
	}
	invoke(e, _, v) {
		setCollapseStateAtLevel(_, this.getFoldingLevel(), !0, this.getSelectedLines(v));
	}
}, GotoParentFoldAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.gotoParentFold",
			label: localize("gotoParentFold.label", "Go to Parent Fold"),
			alias: "Go to Parent Fold",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		if (y.length > 0) {
			let e = getParentFoldLine(y[0], _);
			e !== null && v.setSelection({
				startLineNumber: e,
				startColumn: 1,
				endLineNumber: e,
				endColumn: 1
			});
		}
	}
}, GotoPreviousFoldAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.gotoPreviousFold",
			label: localize("gotoPreviousFold.label", "Go to Previous Folding Range"),
			alias: "Go to Previous Folding Range",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		if (y.length > 0) {
			let e = getPreviousFoldLine(y[0], _);
			e !== null && v.setSelection({
				startLineNumber: e,
				startColumn: 1,
				endLineNumber: e,
				endColumn: 1
			});
		}
	}
}, GotoNextFoldAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.gotoNextFold",
			label: localize("gotoNextFold.label", "Go to Next Folding Range"),
			alias: "Go to Next Folding Range",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = this.getSelectedLines(v);
		if (y.length > 0) {
			let e = getNextFoldLine(y[0], _);
			e !== null && v.setSelection({
				startLineNumber: e,
				startColumn: 1,
				endLineNumber: e,
				endColumn: 1
			});
		}
	}
}, FoldRangeFromSelectionAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.createFoldingRangeFromSelection",
			label: localize("createManualFoldRange.label", "Create Folding Range from Selection"),
			alias: "Create Folding Range from Selection",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2135),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = [], b = v.getSelections();
		if (b) {
			for (let e of b) {
				let _ = e.endLineNumber;
				e.endColumn === 1 && --_, _ > e.startLineNumber && (y.push({
					startLineNumber: e.startLineNumber,
					endLineNumber: _,
					type: void 0,
					isCollapsed: !0,
					source: 1
				}), v.setSelection({
					startLineNumber: e.startLineNumber,
					startColumn: 1,
					endLineNumber: e.startLineNumber,
					endColumn: 1
				}));
			}
			if (y.length > 0) {
				y.sort((e, _) => e.startLineNumber - _.startLineNumber);
				let e = FoldingRegions.sanitizeAndMerge(_.regions, y, v.getModel()?.getLineCount());
				_.updatePost(FoldingRegions.fromFoldRanges(e));
			}
		}
	}
}, RemoveFoldRangeFromSelectionAction = class extends FoldingAction {
	constructor() {
		super({
			id: "editor.removeManualFoldingRanges",
			label: localize("removeManualFoldingRanges.label", "Remove Manual Folding Ranges"),
			alias: "Remove Manual Folding Ranges",
			precondition: CONTEXT_FOLDING_ENABLED,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2137),
				weight: 100
			}
		});
	}
	invoke(e, _, v) {
		let y = v.getSelections();
		if (y) {
			let v = [];
			for (let e of y) {
				let { startLineNumber: _, endLineNumber: y } = e;
				v.push(y >= _ ? {
					startLineNumber: _,
					endLineNumber: y
				} : {
					endLineNumber: y,
					startLineNumber: _
				});
			}
			_.removeManualRanges(v), e.triggerFoldingModelChanged();
		}
	}
};
registerEditorContribution(FoldingController.ID, FoldingController, 0), registerEditorAction(UnfoldAction), registerEditorAction(UnFoldRecursivelyAction), registerEditorAction(FoldAction), registerEditorAction(FoldRecursivelyAction), registerEditorAction(ToggleFoldRecursivelyAction), registerEditorAction(FoldAllAction), registerEditorAction(UnfoldAllAction), registerEditorAction(FoldAllBlockCommentsAction), registerEditorAction(FoldAllRegionsAction), registerEditorAction(UnfoldAllRegionsAction), registerEditorAction(FoldAllExceptAction), registerEditorAction(UnfoldAllExceptAction), registerEditorAction(ToggleFoldAction), registerEditorAction(GotoParentFoldAction), registerEditorAction(GotoPreviousFoldAction), registerEditorAction(GotoNextFoldAction), registerEditorAction(FoldRangeFromSelectionAction), registerEditorAction(RemoveFoldRangeFromSelectionAction);
for (let e = 1; e <= 7; e++) registerInstantiatedEditorAction(new FoldLevelAction({
	id: FoldLevelAction.ID(e),
	label: localize("foldLevelAction.label", "Fold Level {0}", e),
	alias: `Fold Level ${e}`,
	precondition: CONTEXT_FOLDING_ENABLED,
	kbOpts: {
		kbExpr: EditorContextKeys.editorTextFocus,
		primary: KeyChord(2089, 2048 | 21 + e),
		weight: 100
	}
}));
CommandsRegistry.registerCommand("_executeFoldingRangeProvider", async function(e, ..._) {
	let [v] = _;
	if (!(v instanceof URI)) throw illegalArgument();
	let y = e.get(ILanguageFeaturesService), x = e.get(IModelService).getModel(v);
	if (!x) throw illegalArgument();
	let S = e.get(IConfigurationService);
	if (!S.getValue("editor.folding", { resource: v })) return [];
	let C = e.get(ILanguageConfigurationService), w = S.getValue("editor.foldingStrategy", { resource: v }), T = {
		get limit() {
			return S.getValue("editor.foldingMaximumRegions", { resource: v });
		},
		update: (e, _) => {}
	}, E = new IndentRangeProvider(x, C, T), D = E;
	if (w !== "indentation") {
		let e = FoldingController.getFoldingRangeProviders(y, x);
		e.length && (D = new SyntaxRangeProvider(x, e, () => {}, T, E));
	}
	let O = await D.compute(CancellationToken.None), k = [];
	try {
		if (O) for (let e = 0; e < O.length; e++) {
			let _ = O.getType(e);
			k.push({
				start: O.getStartLineNumber(e),
				end: O.getEndLineNumber(e),
				kind: _ ? FoldingRangeKind.fromValue(_) : void 0
			});
		}
		return k;
	} finally {
		D.dispose();
	}
});
var EditorFontZoomIn = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.fontZoomIn",
			label: localize("EditorFontZoomIn.label", "Increase Editor Font Size"),
			alias: "Increase Editor Font Size",
			precondition: void 0
		});
	}
	run(e, _) {
		EditorZoom.setZoomLevel(EditorZoom.getZoomLevel() + 1);
	}
}, EditorFontZoomOut = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.fontZoomOut",
			label: localize("EditorFontZoomOut.label", "Decrease Editor Font Size"),
			alias: "Decrease Editor Font Size",
			precondition: void 0
		});
	}
	run(e, _) {
		EditorZoom.setZoomLevel(EditorZoom.getZoomLevel() - 1);
	}
}, EditorFontZoomReset = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.fontZoomReset",
			label: localize("EditorFontZoomReset.label", "Reset Editor Font Size"),
			alias: "Reset Editor Font Size",
			precondition: void 0
		});
	}
	run(e, _) {
		EditorZoom.setZoomLevel(0);
	}
};
registerEditorAction(EditorFontZoomIn), registerEditorAction(EditorFontZoomOut), registerEditorAction(EditorFontZoomReset);
var __decorate$66 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$66 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, FormatOnType = class {
	static {
		this.ID = "editor.contrib.autoFormat";
	}
	constructor(e, _, v, y) {
		this._editor = e, this._languageFeaturesService = _, this._workerService = v, this._accessibilitySignalService = y, this._disposables = new DisposableStore(), this._sessionDisposables = new DisposableStore(), this._disposables.add(_.onTypeFormattingEditProvider.onDidChange(this._update, this)), this._disposables.add(e.onDidChangeModel(() => this._update())), this._disposables.add(e.onDidChangeModelLanguage(() => this._update())), this._disposables.add(e.onDidChangeConfiguration((e) => {
			e.hasChanged(56) && this._update();
		})), this._update();
	}
	dispose() {
		this._disposables.dispose(), this._sessionDisposables.dispose();
	}
	_update() {
		if (this._sessionDisposables.clear(), !this._editor.getOption(56) || !this._editor.hasModel()) return;
		let e = this._editor.getModel(), [_] = this._languageFeaturesService.onTypeFormattingEditProvider.ordered(e);
		if (!_ || !_.autoFormatTriggerCharacters) return;
		let v = new CharacterSet();
		for (let e of _.autoFormatTriggerCharacters) v.add(e.charCodeAt(0));
		this._sessionDisposables.add(this._editor.onDidType((e) => {
			let _ = e.charCodeAt(e.length - 1);
			v.has(_) && this._trigger(String.fromCharCode(_));
		}));
	}
	_trigger(e) {
		if (!this._editor.hasModel() || this._editor.getSelections().length > 1 || !this._editor.getSelection().isEmpty()) return;
		let _ = this._editor.getModel(), v = this._editor.getPosition(), y = new CancellationTokenSource(), b = this._editor.onDidChangeModelContent((e) => {
			if (e.isFlush) {
				y.cancel(), b.dispose();
				return;
			}
			for (let _ = 0, x = e.changes.length; _ < x; _++) if (e.changes[_].range.endLineNumber <= v.lineNumber) {
				y.cancel(), b.dispose();
				return;
			}
		});
		getOnTypeFormattingEdits(this._workerService, this._languageFeaturesService, _, v, e, _.getFormattingOptions(), y.token).then((e) => {
			y.token.isCancellationRequested || isNonEmptyArray(e) && (this._accessibilitySignalService.playSignal(AccessibilitySignal.format, { userGesture: !1 }), FormattingEdit.execute(this._editor, e, !0));
		}).finally(() => {
			b.dispose();
		});
	}
};
FormatOnType = __decorate$66([
	__param$66(1, ILanguageFeaturesService),
	__param$66(2, IEditorWorkerService),
	__param$66(3, IAccessibilitySignalService)
], FormatOnType);
var FormatOnPaste = class {
	static {
		this.ID = "editor.contrib.formatOnPaste";
	}
	constructor(e, _, v) {
		this.editor = e, this._languageFeaturesService = _, this._instantiationService = v, this._callOnDispose = new DisposableStore(), this._callOnModel = new DisposableStore(), this._callOnDispose.add(e.onDidChangeConfiguration(() => this._update())), this._callOnDispose.add(e.onDidChangeModel(() => this._update())), this._callOnDispose.add(e.onDidChangeModelLanguage(() => this._update())), this._callOnDispose.add(_.documentRangeFormattingEditProvider.onDidChange(this._update, this));
	}
	dispose() {
		this._callOnDispose.dispose(), this._callOnModel.dispose();
	}
	_update() {
		this._callOnModel.clear(), this.editor.getOption(55) && this.editor.hasModel() && this._languageFeaturesService.documentRangeFormattingEditProvider.has(this.editor.getModel()) && this._callOnModel.add(this.editor.onDidPaste(({ range: e }) => this._trigger(e)));
	}
	_trigger(e) {
		this.editor.hasModel() && (this.editor.getSelections().length > 1 || this._instantiationService.invokeFunction(formatDocumentRangesWithSelectedProvider, this.editor, e, 2, Progress.None, CancellationToken.None, !1).catch(onUnexpectedError));
	}
};
FormatOnPaste = __decorate$66([__param$66(1, ILanguageFeaturesService), __param$66(2, IInstantiationService)], FormatOnPaste);
var FormatDocumentAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.formatDocument",
			label: localize("formatDocument.label", "Format Document"),
			alias: "Format Document",
			precondition: ContextKeyExpr.and(EditorContextKeys.notInCompositeEditor, EditorContextKeys.writable, EditorContextKeys.hasDocumentFormattingProvider),
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1572,
				linux: { primary: 3111 },
				weight: 100
			},
			contextMenuOpts: {
				group: "1_modification",
				order: 1.3
			}
		});
	}
	async run(e, _) {
		if (_.hasModel()) {
			let v = e.get(IInstantiationService);
			await e.get(IEditorProgressService).showWhile(v.invokeFunction(formatDocumentWithSelectedProvider, _, 1, Progress.None, CancellationToken.None, !0), 250);
		}
	}
}, FormatSelectionAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.formatSelection",
			label: localize("formatSelection.label", "Format Selection"),
			alias: "Format Selection",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasDocumentSelectionFormattingProvider),
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2084),
				weight: 100
			},
			contextMenuOpts: {
				when: EditorContextKeys.hasNonEmptySelection,
				group: "1_modification",
				order: 1.31
			}
		});
	}
	async run(e, _) {
		if (!_.hasModel()) return;
		let v = e.get(IInstantiationService), y = _.getModel(), b = _.getSelections().map((e) => e.isEmpty() ? new Range(e.startLineNumber, 1, e.startLineNumber, y.getLineMaxColumn(e.startLineNumber)) : e);
		await e.get(IEditorProgressService).showWhile(v.invokeFunction(formatDocumentRangesWithSelectedProvider, _, b, 1, Progress.None, CancellationToken.None, !0), 250);
	}
};
registerEditorContribution(FormatOnType.ID, FormatOnType, 2), registerEditorContribution(FormatOnPaste.ID, FormatOnPaste, 2), registerEditorAction(FormatDocumentAction), registerEditorAction(FormatSelectionAction), CommandsRegistry.registerCommand("editor.action.format", async (e) => {
	let _ = e.get(ICodeEditorService).getFocusedCodeEditor();
	if (!_ || !_.hasModel()) return;
	let v = e.get(ICommandService);
	_.getSelection().isEmpty() ? await v.executeCommand("editor.action.formatDocument") : await v.executeCommand("editor.action.formatSelection");
});
var __decorate$65 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$65 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, TreeElement = class {
	remove() {
		this.parent?.children.delete(this.id);
	}
	static findId(e, _) {
		let v;
		typeof e == "string" ? v = `${_.id}/${e}` : (v = `${_.id}/${e.name}`, _.children.get(v) !== void 0 && (v = `${_.id}/${e.name}_${e.range.startLineNumber}_${e.range.startColumn}`));
		let y = v;
		for (let e = 0; _.children.get(y) !== void 0; e++) y = `${v}_${e}`;
		return y;
	}
	static empty(e) {
		return e.children.size === 0;
	}
}, OutlineElement = class extends TreeElement {
	constructor(e, _, v) {
		super(), this.id = e, this.parent = _, this.symbol = v, this.children = /* @__PURE__ */ new Map();
	}
}, OutlineGroup = class extends TreeElement {
	constructor(e, _, v, y) {
		super(), this.id = e, this.parent = _, this.label = v, this.order = y, this.children = /* @__PURE__ */ new Map();
	}
}, OutlineModel = class e extends TreeElement {
	static create(_, v, y) {
		let b = new CancellationTokenSource(y), x = new e(v.uri), S = _.ordered(v), C = S.map((_, y) => {
			let S = TreeElement.findId(`provider_${y}`, x), C = new OutlineGroup(S, x, _.displayName ?? "Unknown Outline Provider", y);
			return Promise.resolve(_.provideDocumentSymbols(v, b.token)).then((_) => {
				for (let v of _ || []) e._makeOutlineElement(v, C);
				return C;
			}, (e) => (onUnexpectedExternalError(e), C)).then((e) => {
				TreeElement.empty(e) ? e.remove() : x._groups.set(S, e);
			});
		}), w = _.onDidChange(() => {
			let e = _.ordered(v);
			equals(e, S) || b.cancel();
		});
		return Promise.all(C).then(() => b.token.isCancellationRequested && !y.isCancellationRequested ? e.create(_, v, y) : x._compact()).finally(() => {
			b.dispose(), w.dispose(), b.dispose();
		});
	}
	static _makeOutlineElement(_, v) {
		let y = TreeElement.findId(_, v), b = new OutlineElement(y, v, _);
		if (_.children) for (let v of _.children) e._makeOutlineElement(v, b);
		v.children.set(b.id, b);
	}
	constructor(e) {
		super(), this.uri = e, this.id = "root", this.parent = void 0, this._groups = /* @__PURE__ */ new Map(), this.children = /* @__PURE__ */ new Map(), this.id = "root", this.parent = void 0;
	}
	_compact() {
		let e = 0;
		for (let [_, v] of this._groups) v.children.size === 0 ? this._groups.delete(_) : e += 1;
		if (e !== 1) this.children = this._groups;
		else {
			let e = Iterable.first(this._groups.values());
			for (let [, _] of e.children) _.parent = this, this.children.set(_.id, _);
		}
		return this;
	}
	getTopLevelSymbols() {
		let e = [];
		for (let _ of this.children.values()) _ instanceof OutlineElement ? e.push(_.symbol) : e.push(...Iterable.map(_.children.values(), (e) => e.symbol));
		return e.sort((e, _) => Range.compareRangesUsingStarts(e.range, _.range));
	}
	asListOfDocumentSymbols() {
		let _ = this.getTopLevelSymbols(), v = [];
		return e._flattenDocumentSymbols(v, _, ""), v.sort((e, _) => Position.compare(Range.getStartPosition(e.range), Range.getStartPosition(_.range)) || Position.compare(Range.getEndPosition(_.range), Range.getEndPosition(e.range)));
	}
	static _flattenDocumentSymbols(_, v, y) {
		for (let b of v) _.push({
			kind: b.kind,
			tags: b.tags,
			name: b.name,
			detail: b.detail,
			containerName: b.containerName || y,
			range: b.range,
			selectionRange: b.selectionRange,
			children: void 0
		}), b.children && e._flattenDocumentSymbols(_, b.children, b.name);
	}
};
const IOutlineModelService = createDecorator("IOutlineModelService");
var OutlineModelService = class {
	constructor(e, _, v) {
		this._languageFeaturesService = e, this._disposables = new DisposableStore(), this._cache = new LRUCache(10, .7), this._debounceInformation = _.for(e.documentSymbolProvider, "DocumentSymbols", { min: 350 }), this._disposables.add(v.onModelRemoved((e) => {
			this._cache.delete(e.id);
		}));
	}
	dispose() {
		this._disposables.dispose();
	}
	async getOrCreate(e, _) {
		let v = this._languageFeaturesService.documentSymbolProvider, y = v.ordered(e), b = this._cache.get(e.id);
		if (!b || b.versionId !== e.getVersionId() || !equals(b.provider, y)) {
			let _ = new CancellationTokenSource();
			b = {
				versionId: e.getVersionId(),
				provider: y,
				promiseCnt: 0,
				source: _,
				promise: OutlineModel.create(v, e, _.token),
				model: void 0
			}, this._cache.set(e.id, b);
			let x = Date.now();
			b.promise.then((_) => {
				b.model = _, this._debounceInformation.update(e, Date.now() - x);
			}).catch((_) => {
				this._cache.delete(e.id);
			});
		}
		if (b.model) return b.model;
		b.promiseCnt += 1;
		let x = _.onCancellationRequested(() => {
			--b.promiseCnt === 0 && (b.source.cancel(), this._cache.delete(e.id));
		});
		try {
			return await b.promise;
		} finally {
			x.dispose();
		}
	}
};
OutlineModelService = __decorate$65([
	__param$65(0, ILanguageFeaturesService),
	__param$65(1, ILanguageFeatureDebounceService),
	__param$65(2, IModelService)
], OutlineModelService), registerSingleton(IOutlineModelService, OutlineModelService, 1), CommandsRegistry.registerCommand("_executeDocumentSymbolProvider", async function(e, ..._) {
	let [v] = _;
	assertType(URI.isUri(v));
	let y = e.get(IOutlineModelService), b = await e.get(ITextModelService).createModelReference(v);
	try {
		return (await y.getOrCreate(b.object.textEditorModel, CancellationToken.None)).getTopLevelSymbols();
	} finally {
		b.dispose();
	}
});
var InlineCompletionContextKeys = class e extends Disposable {
	static {
		this.inlineSuggestionVisible = new RawContextKey("inlineSuggestionVisible", !1, localize("inlineSuggestionVisible", "Whether an inline suggestion is visible"));
	}
	static {
		this.inlineSuggestionHasIndentation = new RawContextKey("inlineSuggestionHasIndentation", !1, localize("inlineSuggestionHasIndentation", "Whether the inline suggestion starts with whitespace"));
	}
	static {
		this.inlineSuggestionHasIndentationLessThanTabSize = new RawContextKey("inlineSuggestionHasIndentationLessThanTabSize", !0, localize("inlineSuggestionHasIndentationLessThanTabSize", "Whether the inline suggestion starts with whitespace that is less than what would be inserted by tab"));
	}
	static {
		this.suppressSuggestions = new RawContextKey("inlineSuggestionSuppressSuggestions", void 0, localize("suppressSuggestions", "Whether suggestions should be suppressed for the current suggestion"));
	}
	constructor(_, v) {
		super(), this.contextKeyService = _, this.model = v, this.inlineCompletionVisible = e.inlineSuggestionVisible.bindTo(this.contextKeyService), this.inlineCompletionSuggestsIndentation = e.inlineSuggestionHasIndentation.bindTo(this.contextKeyService), this.inlineCompletionSuggestsIndentationLessThanTabSize = e.inlineSuggestionHasIndentationLessThanTabSize.bindTo(this.contextKeyService), this.suppressSuggestions = e.suppressSuggestions.bindTo(this.contextKeyService), this._register(autorun((e) => {
			let _ = this.model.read(e)?.state.read(e), v = !!_?.inlineCompletion && _?.primaryGhostText !== void 0 && !_?.primaryGhostText.isEmpty();
			this.inlineCompletionVisible.set(v), _?.primaryGhostText && _?.inlineCompletion && this.suppressSuggestions.set(_.inlineCompletion.inlineCompletion.source.inlineCompletions.suppressSuggestions);
		})), this._register(autorun((e) => {
			let _ = this.model.read(e), v = !1, y = !0, b = _?.primaryGhostText.read(e);
			if (_?.selectedSuggestItem && b && b.parts.length > 0) {
				let { column: e, lines: x } = b.parts[0], S = x[0], C = _.textModel.getLineIndentColumn(b.lineNumber);
				if (e <= C) {
					let e = firstNonWhitespaceIndex(S);
					e === -1 && (e = S.length - 1), v = e > 0;
					let b = _.textModel.getOptions().tabSize;
					y = CursorColumns.visibleColumnFromColumn(S, e + 1, b) < b;
				}
			}
			this.inlineCompletionSuggestsIndentation.set(v), this.inlineCompletionSuggestsIndentationLessThanTabSize.set(y);
		}));
	}
};
function createStyleSheetFromObservable(e) {
	let _ = new DisposableStore(), v = _.add(createStyleSheet2());
	return _.add(autorun((_) => {
		v.setStyle(e.read(_));
	})), _;
}
var GhostText = class {
	constructor(e, _) {
		this.lineNumber = e, this.parts = _;
	}
	equals(e) {
		return this.lineNumber === e.lineNumber && this.parts.length === e.parts.length && this.parts.every((_, v) => _.equals(e.parts[v]));
	}
	renderForScreenReader(e) {
		if (this.parts.length === 0) return "";
		let _ = this.parts[this.parts.length - 1], v = e.substr(0, _.column - 1);
		return new TextEdit([...this.parts.map((e) => new SingleTextEdit(Range.fromPositions(new Position(1, e.column)), e.lines.join("\n")))]).applyToString(v).substring(this.parts[0].column - 1);
	}
	isEmpty() {
		return this.parts.every((e) => e.lines.length === 0);
	}
	get lineCount() {
		return 1 + this.parts.reduce((e, _) => e + _.lines.length - 1, 0);
	}
}, GhostTextPart = class {
	constructor(e, _, v) {
		this.column = e, this.text = _, this.preview = v, this.lines = splitLines(this.text);
	}
	equals(e) {
		return this.column === e.column && this.lines.length === e.lines.length && this.lines.every((_, v) => _ === e.lines[v]);
	}
}, GhostTextReplacement = class {
	constructor(e, _, v, y = 0) {
		this.lineNumber = e, this.columnRange = _, this.text = v, this.additionalReservedLineCount = y, this.parts = [new GhostTextPart(this.columnRange.endColumnExclusive, this.text, !1)], this.newLines = splitLines(this.text);
	}
	renderForScreenReader(e) {
		return this.newLines.join("\n");
	}
	get lineCount() {
		return this.newLines.length;
	}
	isEmpty() {
		return this.parts.every((e) => e.lines.length === 0);
	}
	equals(e) {
		return this.lineNumber === e.lineNumber && this.columnRange.equals(e.columnRange) && this.newLines.length === e.newLines.length && this.newLines.every((_, v) => _ === e.newLines[v]) && this.additionalReservedLineCount === e.additionalReservedLineCount;
	}
};
function ghostTextsOrReplacementsEqual(e, _) {
	return equals(e, _, ghostTextOrReplacementEquals);
}
function ghostTextOrReplacementEquals(e, _) {
	return e === _ ? !0 : !e || !_ ? !1 : e instanceof GhostText && _ instanceof GhostText || e instanceof GhostTextReplacement && _ instanceof GhostTextReplacement ? e.equals(_) : !1;
}
var array = [];
function getReadonlyEmptyArray() {
	return array;
}
var ColumnRange = class {
	constructor(e, _) {
		if (this.startColumn = e, this.endColumnExclusive = _, e > _) throw new BugIndicatingError(`startColumn ${e} cannot be after endColumnExclusive ${_}`);
	}
	toRange(e) {
		return new Range(e, this.startColumn, e, this.endColumnExclusive);
	}
	equals(e) {
		return this.startColumn === e.startColumn && this.endColumnExclusive === e.endColumnExclusive;
	}
};
function applyObservableDecorations(e, _) {
	let v = new DisposableStore(), y = e.createDecorationsCollection();
	return v.add(autorunOpts({ debugName: () => `Apply decorations from ${_.debugName}` }, (e) => {
		let v = _.read(e);
		y.set(v);
	})), v.add({ dispose: () => {
		y.clear();
	} }), v;
}
function addPositions(e, _) {
	return new Position(e.lineNumber + _.lineNumber - 1, _.lineNumber === 1 ? e.column + _.column - 1 : _.column);
}
function subtractPositions(e, _) {
	return new Position(e.lineNumber - _.lineNumber + 1, e.lineNumber - _.lineNumber === 0 ? e.column - _.column + 1 : e.column);
}
var __decorate$64 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$64 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const GHOST_TEXT_DESCRIPTION = "ghost-text";
var GhostTextView = class extends Disposable {
	constructor(e, _, v) {
		super(), this.editor = e, this.model = _, this.languageService = v, this.isDisposed = observableValue(this, !1), this.currentTextModel = observableFromEvent(this, this.editor.onDidChangeModel, () => this.editor.getModel()), this.uiState = derived(this, (e) => {
			if (this.isDisposed.read(e)) return;
			let _ = this.currentTextModel.read(e);
			if (_ !== this.model.targetTextModel.read(e)) return;
			let v = this.model.ghostText.read(e);
			if (!v) return;
			let y = v instanceof GhostTextReplacement ? v.columnRange : void 0, b = [], x = [];
			function S(e, _) {
				if (x.length > 0) {
					let v = x[x.length - 1];
					_ && v.decorations.push(new LineDecoration(v.content.length + 1, v.content.length + 1 + e[0].length, _, 0)), v.content += e[0], e = e.slice(1);
				}
				for (let v of e) x.push({
					content: v,
					decorations: _ ? [new LineDecoration(1, v.length + 1, _, 0)] : []
				});
			}
			let C = _.getLineContent(v.lineNumber), w, T = 0;
			for (let e of v.parts) {
				let _ = e.lines;
				w === void 0 ? (b.push({
					column: e.column,
					text: _[0],
					preview: e.preview
				}), _ = _.slice(1)) : S([C.substring(T, e.column - 1)], void 0), _.length > 0 && (S(_, GHOST_TEXT_DESCRIPTION), w === void 0 && e.column <= C.length && (w = e.column)), T = e.column - 1;
			}
			w !== void 0 && S([C.substring(T)], void 0);
			let E = w === void 0 ? void 0 : new ColumnRange(w, C.length + 1);
			return {
				replacedRange: y,
				inlineTexts: b,
				additionalLines: x,
				hiddenRange: E,
				lineNumber: v.lineNumber,
				additionalReservedLineCount: this.model.minReservedLineCount.read(e),
				targetTextModel: _
			};
		}), this.decorations = derived(this, (e) => {
			let _ = this.uiState.read(e);
			if (!_) return [];
			let v = [];
			_.replacedRange && v.push({
				range: _.replacedRange.toRange(_.lineNumber),
				options: {
					inlineClassName: "inline-completion-text-to-replace",
					description: "GhostTextReplacement"
				}
			}), _.hiddenRange && v.push({
				range: _.hiddenRange.toRange(_.lineNumber),
				options: {
					inlineClassName: "ghost-text-hidden",
					description: "ghost-text-hidden"
				}
			});
			for (let e of _.inlineTexts) v.push({
				range: Range.fromPositions(new Position(_.lineNumber, e.column)),
				options: {
					description: GHOST_TEXT_DESCRIPTION,
					after: {
						content: e.text,
						inlineClassName: e.preview ? "ghost-text-decoration-preview" : "ghost-text-decoration",
						cursorStops: InjectedTextCursorStops.Left
					},
					showIfCollapsed: !0
				}
			});
			return v;
		}), this.additionalLinesWidget = this._register(new AdditionalLinesWidget(this.editor, this.languageService.languageIdCodec, derived((e) => {
			let _ = this.uiState.read(e);
			return _ ? {
				lineNumber: _.lineNumber,
				additionalLines: _.additionalLines,
				minReservedLineCount: _.additionalReservedLineCount,
				targetTextModel: _.targetTextModel
			} : void 0;
		}))), this._register(toDisposable(() => {
			this.isDisposed.set(!0, void 0);
		})), this._register(applyObservableDecorations(this.editor, this.decorations));
	}
	ownsViewZone(e) {
		return this.additionalLinesWidget.viewZoneId === e;
	}
};
GhostTextView = __decorate$64([__param$64(2, ILanguageService)], GhostTextView);
var AdditionalLinesWidget = class extends Disposable {
	get viewZoneId() {
		return this._viewZoneId;
	}
	constructor(e, _, v) {
		super(), this.editor = e, this.languageIdCodec = _, this.lines = v, this._viewZoneId = void 0, this.editorOptionsChanged = observableSignalFromEvent("editorOptionChanged", Event.filter(this.editor.onDidChangeConfiguration, (e) => e.hasChanged(33) || e.hasChanged(118) || e.hasChanged(100) || e.hasChanged(95) || e.hasChanged(51) || e.hasChanged(50) || e.hasChanged(67))), this._register(autorun((e) => {
			let _ = this.lines.read(e);
			this.editorOptionsChanged.read(e), _ ? this.updateLines(_.lineNumber, _.additionalLines, _.minReservedLineCount) : this.clear();
		}));
	}
	dispose() {
		super.dispose(), this.clear();
	}
	clear() {
		this.editor.changeViewZones((e) => {
			this._viewZoneId &&= (e.removeZone(this._viewZoneId), void 0);
		});
	}
	updateLines(e, _, v) {
		let y = this.editor.getModel();
		if (!y) return;
		let { tabSize: b } = y.getOptions();
		this.editor.changeViewZones((y) => {
			this._viewZoneId &&= (y.removeZone(this._viewZoneId), void 0);
			let x = Math.max(_.length, v);
			if (x > 0) {
				let v = document.createElement("div");
				renderLines(v, b, _, this.editor.getOptions(), this.languageIdCodec), this._viewZoneId = y.addZone({
					afterLineNumber: e,
					heightInLines: x,
					domNode: v,
					afterColumnAffinity: 1
				});
			}
		});
	}
};
function renderLines(e, _, v, y, b) {
	let x = y.get(33), S = y.get(118), w = y.get(95), T = y.get(51), E = y.get(50), D = y.get(67), O = new StringBuilder(1e4);
	O.appendString("<div class=\"suggest-preview-text\">");
	for (let e = 0, y = v.length; e < y; e++) {
		let y = v[e], k = y.content;
		O.appendString("<div class=\"view-line"), O.appendString("\" style=\"top:"), O.appendString(String(e * D)), O.appendString("px;width:1000000px;\">");
		let A = isBasicASCII(k), j = containsRTL(k), M = LineTokens.createEmpty(k, b);
		renderViewLine(new RenderLineInput(E.isMonospace && !x, E.canUseHalfwidthRightwardsArrow, k, !1, A, j, 0, M, y.decorations, _, 0, E.spaceWidth, E.middotWidth, E.wsmiddotWidth, S, "none", w, T !== EditorFontLigatures.OFF, null), O), O.appendString("</div>");
	}
	O.appendString("</div>"), applyFontInfo(e, E);
	let k = O.build();
	e.innerHTML = ttPolicy ? ttPolicy.createHTML(k) : k;
}
const ttPolicy = createTrustedTypesPolicy("editorGhostText", { createHTML: (e) => e });
function fixBracketsInLine(e, _) {
	let v = new DenseKeyProvider(), y = new LanguageAgnosticBracketTokens(v, (e) => _.getLanguageConfiguration(e)), b = new TextBufferTokenizer(new StaticTokenizerSource([e]), y), x = parseDocument(b, [], void 0, !0), S = "", C = e.getLineContent();
	function w(e, _) {
		if (e.kind === 2) if (w(e.openingBracket, _), _ = lengthAdd(_, e.openingBracket.length), e.child && (w(e.child, _), _ = lengthAdd(_, e.child.length)), e.closingBracket) w(e.closingBracket, _), _ = lengthAdd(_, e.closingBracket.length);
		else {
			let _ = y.getSingleLanguageBracketTokens(e.openingBracket.languageId).findClosingTokenText(e.openingBracket.bracketIds);
			S += _;
		}
		else if (e.kind !== 3) {
			if (e.kind === 0 || e.kind === 1) S += C.substring(lengthGetColumnCountIfZeroLineCount(_), lengthGetColumnCountIfZeroLineCount(lengthAdd(_, e.length)));
			else if (e.kind === 4) for (let v of e.children) w(v, _), _ = lengthAdd(_, v.length);
		}
	}
	return w(x, 0), S;
}
var StaticTokenizerSource = class {
	constructor(e) {
		this.lines = e, this.tokenization = { getLineTokens: (e) => this.lines[e - 1] };
	}
	getLineCount() {
		return this.lines.length;
	}
	getLineLength(e) {
		return this.lines[e - 1].getLineContent().length;
	}
};
async function provideInlineCompletions(e, _, v, y, b = CancellationToken.None, x) {
	let S = _ instanceof Position ? getDefaultRange(_, v) : _, C = e.all(v), w = new SetMap();
	for (let e of C) e.groupId && w.add(e.groupId, e);
	function T(e) {
		if (!e.yieldsToGroupIds) return [];
		let _ = [];
		for (let v of e.yieldsToGroupIds || []) {
			let e = w.get(v);
			for (let v of e) _.push(v);
		}
		return _;
	}
	let E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set();
	function O(e, _) {
		if (_ = [..._, e], D.has(e)) return _;
		D.add(e);
		try {
			let v = T(e);
			for (let e of v) {
				let v = O(e, _);
				if (v) return v;
			}
		} finally {
			D.delete(e);
		}
	}
	function k(e) {
		let x = E.get(e);
		if (x) return x;
		let S = O(e, []);
		S && onUnexpectedExternalError(/* @__PURE__ */ Error(`Inline completions: cyclic yield-to dependency detected. Path: ${S.map((e) => e.toString ? e.toString() : "" + e).join(" -> ")}`));
		let C = new DeferredPromise();
		return E.set(e, C.p), (async () => {
			if (!S) {
				let _ = T(e);
				for (let e of _) {
					let _ = await k(e);
					if (_ && _.items.length > 0) return;
				}
			}
			try {
				return _ instanceof Position ? await e.provideInlineCompletions(v, _, y, b) : await e.provideInlineEdits?.(v, _, y, b);
			} catch (e) {
				onUnexpectedExternalError(e);
				return;
			}
		})().then((e) => C.complete(e), (e) => C.error(e)), C.p;
	}
	let A = await Promise.all(C.map(async (e) => ({
		provider: e,
		completions: await k(e)
	}))), j = /* @__PURE__ */ new Map(), M = [];
	for (let e of A) {
		let _ = e.completions;
		if (!_) continue;
		let y = new InlineCompletionList(_, e.provider);
		M.push(y);
		for (let e of _.items) {
			let _ = InlineCompletionItem.from(e, y, S, v, x);
			j.set(_.hash(), _);
		}
	}
	return new InlineCompletionProviderResult(Array.from(j.values()), new Set(j.keys()), M);
}
var InlineCompletionProviderResult = class {
	constructor(e, _, v) {
		this.completions = e, this.hashs = _, this.providerResults = v;
	}
	has(e) {
		return this.hashs.has(e.hash());
	}
	dispose() {
		for (let e of this.providerResults) e.removeRef();
	}
}, InlineCompletionList = class {
	constructor(e, _) {
		this.inlineCompletions = e, this.provider = _, this.refCount = 1;
	}
	addRef() {
		this.refCount++;
	}
	removeRef() {
		this.refCount--, this.refCount === 0 && this.provider.freeInlineCompletions(this.inlineCompletions);
	}
}, InlineCompletionItem = class e {
	static from(_, v, y, b, x) {
		let S, C, w = _.range ? Range.lift(_.range) : y;
		if (typeof _.insertText == "string") {
			if (S = _.insertText, x && _.completeBracketPairs) {
				S = closeBrackets(S, w.getStartPosition(), b, x);
				let e = S.length - _.insertText.length;
				e !== 0 && (w = new Range(w.startLineNumber, w.startColumn, w.endLineNumber, w.endColumn + e));
			}
			C = void 0;
		} else if ("snippet" in _.insertText) {
			let e = _.insertText.snippet.length;
			if (x && _.completeBracketPairs) {
				_.insertText.snippet = closeBrackets(_.insertText.snippet, w.getStartPosition(), b, x);
				let v = _.insertText.snippet.length - e;
				v !== 0 && (w = new Range(w.startLineNumber, w.startColumn, w.endLineNumber, w.endColumn + v));
			}
			let v = new SnippetParser().parse(_.insertText.snippet);
			v.children.length === 1 && v.children[0] instanceof Text ? (S = v.children[0].value, C = void 0) : (S = v.toString(), C = {
				snippet: _.insertText.snippet,
				range: w
			});
		} else assertNever(_.insertText);
		return new e(S, _.command, w, S, C, _.additionalTextEdits || getReadonlyEmptyArray(), _, v);
	}
	constructor(e, _, v, y, b, x, S, C) {
		this.filterText = e, this.command = _, this.range = v, this.insertText = y, this.snippetInfo = b, this.additionalTextEdits = x, this.sourceInlineCompletion = S, this.source = C, e = e.replace(/\r\n|\r/g, "\n"), y = e.replace(/\r\n|\r/g, "\n");
	}
	withRange(_) {
		return new e(this.filterText, this.command, _, this.insertText, this.snippetInfo, this.additionalTextEdits, this.sourceInlineCompletion, this.source);
	}
	hash() {
		return JSON.stringify({
			insertText: this.insertText,
			range: this.range.toString()
		});
	}
	toSingleTextEdit() {
		return new SingleTextEdit(this.range, this.insertText);
	}
};
function getDefaultRange(e, _) {
	let v = _.getWordAtPosition(e), y = _.getLineMaxColumn(e.lineNumber);
	return v ? new Range(e.lineNumber, v.startColumn, e.lineNumber, y) : Range.fromPositions(e, e.with(void 0, y));
}
function closeBrackets(e, _, v, y) {
	let b = v.getLineContent(_.lineNumber).substring(0, _.column - 1) + e, x = v.tokenization.tokenizeLineWithEdit(_, b.length - (_.column - 1), e)?.sliceAndInflate(_.column - 1, b.length, 0);
	return x ? fixBracketsInLine(x, y) : e;
}
function singleTextRemoveCommonPrefix(e, _, v) {
	let y = v ? e.range.intersectRanges(v) : e.range;
	if (!y) return e;
	let b = _.getValueInRange(y, 1), x = commonPrefixLength(b, e.text), S = TextLength.ofText(b.substring(0, x)).addToPosition(e.range.getStartPosition()), C = e.text.substring(x), w = Range.fromPositions(S, e.range.getEndPosition());
	return new SingleTextEdit(w, C);
}
function singleTextEditAugments(e, _) {
	return e.text.startsWith(_.text) && rangeExtends(e.range, _.range);
}
function computeGhostText(e, _, v, y, b = 0) {
	let x = singleTextRemoveCommonPrefix(e, _);
	if (x.range.endLineNumber !== x.range.startLineNumber) return;
	let S = _.getLineContent(x.range.startLineNumber), C = getLeadingWhitespace(S).length;
	if (x.range.startColumn - 1 <= C) {
		let e = getLeadingWhitespace(x.text).length, _ = S.substring(x.range.startColumn - 1, C), [v, y] = [x.range.getStartPosition(), x.range.getEndPosition()], b = v.column + _.length <= y.column ? v.delta(0, _.length) : y, w = Range.fromPositions(b, y), T = x.text.startsWith(_) ? x.text.substring(_.length) : x.text.substring(e);
		x = new SingleTextEdit(w, T);
	}
	let w = _.getValueInRange(x.range), T = cachingDiff(w, x.text);
	if (!T) return;
	let E = x.range.startLineNumber, D = [];
	if (v === "prefix") {
		let e = T.filter((e) => e.originalLength === 0);
		if (e.length > 1 || e.length === 1 && e[0].originalStart !== w.length) return;
	}
	let O = x.text.length - b;
	for (let e of T) {
		let _ = x.range.startColumn + e.originalStart + e.originalLength;
		if (v === "subwordSmart" && y && y.lineNumber === x.range.startLineNumber && _ < y.column || e.originalLength > 0) return;
		if (e.modifiedLength === 0) continue;
		let b = e.modifiedStart + e.modifiedLength, S = Math.max(e.modifiedStart, Math.min(b, O)), C = x.text.substring(e.modifiedStart, S), w = x.text.substring(S, Math.max(e.modifiedStart, b));
		C.length > 0 && D.push(new GhostTextPart(_, C, !1)), w.length > 0 && D.push(new GhostTextPart(_, w, !0));
	}
	return new GhostText(E, D);
}
function rangeExtends(e, _) {
	return _.getStartPosition().equals(e.getStartPosition()) && _.getEndPosition().isBeforeOrEqual(e.getEndPosition());
}
var lastRequest = void 0;
function cachingDiff(e, _) {
	if (lastRequest?.originalValue === e && lastRequest?.newValue === _) return lastRequest?.changes;
	{
		let v = smartDiff(e, _, !0);
		if (v) {
			let y = deletedCharacters(v);
			if (y > 0) {
				let b = smartDiff(e, _, !1);
				b && deletedCharacters(b) < y && (v = b);
			}
		}
		return lastRequest = {
			originalValue: e,
			newValue: _,
			changes: v
		}, v;
	}
}
function deletedCharacters(e) {
	let _ = 0;
	for (let v of e) _ += v.originalLength;
	return _;
}
function smartDiff(e, _, v) {
	if (e.length > 5e3 || _.length > 5e3) return;
	function y(e) {
		let _ = 0;
		for (let v = 0, y = e.length; v < y; v++) {
			let y = e.charCodeAt(v);
			y > _ && (_ = y);
		}
		return _;
	}
	let b = Math.max(y(e), y(_));
	function x(e) {
		if (e < 0) throw Error("unexpected");
		return b + e + 1;
	}
	function S(e) {
		let _ = 0, y = 0, b = new Int32Array(e.length);
		for (let S = 0, C = e.length; S < C; S++) if (v && e[S] === "(") {
			let e = y * 100 + _;
			b[S] = x(2 * e), _++;
		} else if (v && e[S] === ")") {
			_ = Math.max(_ - 1, 0);
			let e = y * 100 + _;
			b[S] = x(2 * e + 1), _ === 0 && y++;
		} else b[S] = e.charCodeAt(S);
		return b;
	}
	let C = S(e), w = S(_);
	return new LcsDiff({ getElements: () => C }, { getElements: () => w }).ComputeDiff(!1).changes;
}
var __decorate$63 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$63 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineCompletionsSource = class extends Disposable {
	constructor(e, _, v, y, b) {
		super(), this.textModel = e, this.versionId = _, this._debounceValue = v, this.languageFeaturesService = y, this.languageConfigurationService = b, this._updateOperation = this._register(new MutableDisposable()), this.inlineCompletions = disposableObservableValue("inlineCompletions", void 0), this.suggestWidgetInlineCompletions = disposableObservableValue("suggestWidgetInlineCompletions", void 0), this._register(this.textModel.onDidChangeContent(() => {
			this._updateOperation.clear();
		}));
	}
	fetch(e, _, v) {
		let y = new UpdateRequest(e, _, this.textModel.getVersionId()), b = _.selectedSuggestionInfo ? this.suggestWidgetInlineCompletions : this.inlineCompletions;
		if (this._updateOperation.value?.request.satisfies(y)) return this._updateOperation.value.promise;
		if (b.get()?.request.satisfies(y)) return Promise.resolve(!0);
		let x = !!this._updateOperation.value;
		this._updateOperation.clear();
		let S = new CancellationTokenSource(), C = (async () => {
			if ((x || _.triggerKind === InlineCompletionTriggerKind.Automatic) && await wait$1(this._debounceValue.get(this.textModel), S.token), S.token.isCancellationRequested || this._store.isDisposed || this.textModel.getVersionId() !== y.versionId) return !1;
			let C = /* @__PURE__ */ new Date(), w = await provideInlineCompletions(this.languageFeaturesService.inlineCompletionsProvider, e, this.textModel, _, S.token, this.languageConfigurationService);
			if (S.token.isCancellationRequested || this._store.isDisposed || this.textModel.getVersionId() !== y.versionId) return !1;
			let T = /* @__PURE__ */ new Date();
			this._debounceValue.update(this.textModel, T.getTime() - C.getTime());
			let E = new UpToDateInlineCompletions(w, y, this.textModel, this.versionId);
			if (v) {
				let _ = v.toInlineCompletion(void 0);
				v.canBeReused(this.textModel, e) && !w.has(_) && E.prepend(v.inlineCompletion, _.range, !0);
			}
			return this._updateOperation.clear(), transaction((e) => {
				b.set(E, e);
			}), !0;
		})(), w = new UpdateOperation(y, S, C);
		return this._updateOperation.value = w, C;
	}
	clear(e) {
		this._updateOperation.clear(), this.inlineCompletions.set(void 0, e), this.suggestWidgetInlineCompletions.set(void 0, e);
	}
	clearSuggestWidgetInlineCompletions(e) {
		this._updateOperation.value?.request.context.selectedSuggestionInfo && this._updateOperation.clear(), this.suggestWidgetInlineCompletions.set(void 0, e);
	}
	cancelUpdate() {
		this._updateOperation.clear();
	}
};
InlineCompletionsSource = __decorate$63([__param$63(3, ILanguageFeaturesService), __param$63(4, ILanguageConfigurationService)], InlineCompletionsSource);
function wait$1(e, _) {
	return new Promise((v) => {
		let y, b = setTimeout(() => {
			y && y.dispose(), v();
		}, e);
		_ && (y = _.onCancellationRequested(() => {
			clearTimeout(b), y && y.dispose(), v();
		}));
	});
}
var UpdateRequest = class {
	constructor(e, _, v) {
		this.position = e, this.context = _, this.versionId = v;
	}
	satisfies(e) {
		return this.position.equals(e.position) && equalsIfDefined(this.context.selectedSuggestionInfo, e.context.selectedSuggestionInfo, itemEquals()) && (e.context.triggerKind === InlineCompletionTriggerKind.Automatic || this.context.triggerKind === InlineCompletionTriggerKind.Explicit) && this.versionId === e.versionId;
	}
}, UpdateOperation = class {
	constructor(e, _, v) {
		this.request = e, this.cancellationTokenSource = _, this.promise = v;
	}
	dispose() {
		this.cancellationTokenSource.cancel();
	}
}, UpToDateInlineCompletions = class {
	get inlineCompletions() {
		return this._inlineCompletions;
	}
	constructor(e, _, v, y) {
		this.inlineCompletionProviderResult = e, this.request = _, this._textModel = v, this._versionId = y, this._refCount = 1, this._prependedInlineCompletionItems = [];
		let b = v.deltaDecorations([], e.completions.map((e) => ({
			range: e.range,
			options: { description: "inline-completion-tracking-range" }
		})));
		this._inlineCompletions = e.completions.map((e, _) => new InlineCompletionWithUpdatedRange(e, b[_], this._textModel, this._versionId));
	}
	clone() {
		return this._refCount++, this;
	}
	dispose() {
		if (this._refCount--, this._refCount === 0) {
			setTimeout(() => {
				this._textModel.isDisposed() || this._textModel.deltaDecorations(this._inlineCompletions.map((e) => e.decorationId), []);
			}, 0), this.inlineCompletionProviderResult.dispose();
			for (let e of this._prependedInlineCompletionItems) e.source.removeRef();
		}
	}
	prepend(e, _, v) {
		v && e.source.addRef();
		let y = this._textModel.deltaDecorations([], [{
			range: _,
			options: { description: "inline-completion-tracking-range" }
		}])[0];
		this._inlineCompletions.unshift(new InlineCompletionWithUpdatedRange(e, y, this._textModel, this._versionId)), this._prependedInlineCompletionItems.push(e);
	}
}, InlineCompletionWithUpdatedRange = class {
	get forwardStable() {
		return this.inlineCompletion.source.inlineCompletions.enableForwardStability ?? !1;
	}
	constructor(e, _, v, y) {
		this.inlineCompletion = e, this.decorationId = _, this._textModel = v, this._modelVersion = y, this.semanticId = JSON.stringify([
			this.inlineCompletion.filterText,
			this.inlineCompletion.insertText,
			this.inlineCompletion.range.getStartPosition().toString()
		]), this._updatedRange = derivedOpts({
			owner: this,
			equalsFn: Range.equalsRange
		}, (e) => (this._modelVersion.read(e), this._textModel.getDecorationRange(this.decorationId)));
	}
	toInlineCompletion(e) {
		return this.inlineCompletion.withRange(this._updatedRange.read(e) ?? emptyRange);
	}
	toSingleTextEdit(e) {
		return new SingleTextEdit(this._updatedRange.read(e) ?? emptyRange, this.inlineCompletion.insertText);
	}
	isVisible(e, _, v) {
		let y = singleTextRemoveCommonPrefix(this._toFilterTextReplacement(v), e), b = this._updatedRange.read(v);
		if (!b || !this.inlineCompletion.range.getStartPosition().equals(b.getStartPosition()) || _.lineNumber !== y.range.startLineNumber) return !1;
		let x = e.getValueInRange(y.range, 1), S = y.text, C = Math.max(0, _.column - y.range.startColumn), w = S.substring(0, C), T = S.substring(C), E = x.substring(0, C), D = x.substring(C), O = e.getLineIndentColumn(y.range.startLineNumber);
		return y.range.startColumn <= O && (E = E.trimStart(), E.length === 0 && (D = D.trimStart()), w = w.trimStart(), w.length === 0 && (T = T.trimStart())), w.startsWith(E) && !!matchesSubString(D, T);
	}
	canBeReused(e, _) {
		let v = this._updatedRange.read(void 0);
		return !!v && v.containsPosition(_) && this.isVisible(e, _, void 0) && TextLength.ofRange(v).isGreaterThanOrEqualTo(TextLength.ofRange(this.inlineCompletion.range));
	}
	_toFilterTextReplacement(e) {
		return new SingleTextEdit(this._updatedRange.read(e) ?? emptyRange, this.inlineCompletion.filterText);
	}
}, emptyRange = new Range(1, 1, 1, 1);
const Context$1 = {
	Visible: historyNavigationVisible,
	HasFocusedSuggestion: new RawContextKey("suggestWidgetHasFocusedSuggestion", !1, localize("suggestWidgetHasSelection", "Whether any suggestion is focused")),
	DetailsVisible: new RawContextKey("suggestWidgetDetailsVisible", !1, localize("suggestWidgetDetailsVisible", "Whether suggestion details are visible")),
	MultipleSuggestions: new RawContextKey("suggestWidgetMultipleSuggestions", !1, localize("suggestWidgetMultipleSuggestions", "Whether there are multiple suggestions to pick from")),
	MakesTextEdit: new RawContextKey("suggestionMakesTextEdit", !0, localize("suggestionMakesTextEdit", "Whether inserting the current suggestion yields in a change or has everything already been typed")),
	AcceptSuggestionsOnEnter: new RawContextKey("acceptSuggestionOnEnter", !0, localize("acceptSuggestionOnEnter", "Whether suggestions are inserted when pressing Enter")),
	HasInsertAndReplaceRange: new RawContextKey("suggestionHasInsertAndReplaceRange", !1, localize("suggestionHasInsertAndReplaceRange", "Whether the current suggestion has insert and replace behaviour")),
	InsertMode: new RawContextKey("suggestionInsertMode", void 0, {
		type: "string",
		description: localize("suggestionInsertMode", "Whether the default behaviour is to insert or replace")
	}),
	CanResolve: new RawContextKey("suggestionCanResolve", !1, localize("suggestionCanResolve", "Whether the current suggestion supports to resolve further details"))
}, suggestWidgetStatusbarMenu = new MenuId("suggestWidgetStatusBar");
var CompletionItem = class {
	constructor(e, _, v, y) {
		this.position = e, this.completion = _, this.container = v, this.provider = y, this.isInvalid = !1, this.score = FuzzyScore.Default, this.distance = 0, this.textLabel = typeof _.label == "string" ? _.label : _.label?.label, this.labelLow = this.textLabel.toLowerCase(), this.isInvalid = !this.textLabel, this.sortTextLow = _.sortText && _.sortText.toLowerCase(), this.filterTextLow = _.filterText && _.filterText.toLowerCase(), this.extensionId = _.extensionId, Range.isIRange(_.range) ? (this.editStart = new Position(_.range.startLineNumber, _.range.startColumn), this.editInsertEnd = new Position(_.range.endLineNumber, _.range.endColumn), this.editReplaceEnd = new Position(_.range.endLineNumber, _.range.endColumn), this.isInvalid = this.isInvalid || Range.spansMultipleLines(_.range) || _.range.startLineNumber !== e.lineNumber) : (this.editStart = new Position(_.range.insert.startLineNumber, _.range.insert.startColumn), this.editInsertEnd = new Position(_.range.insert.endLineNumber, _.range.insert.endColumn), this.editReplaceEnd = new Position(_.range.replace.endLineNumber, _.range.replace.endColumn), this.isInvalid = this.isInvalid || Range.spansMultipleLines(_.range.insert) || Range.spansMultipleLines(_.range.replace) || _.range.insert.startLineNumber !== e.lineNumber || _.range.replace.startLineNumber !== e.lineNumber || _.range.insert.startColumn !== _.range.replace.startColumn), typeof y.resolveCompletionItem != "function" && (this._resolveCache = Promise.resolve(), this._resolveDuration = 0);
	}
	get isResolved() {
		return this._resolveDuration !== void 0;
	}
	get resolveDuration() {
		return this._resolveDuration === void 0 ? -1 : this._resolveDuration;
	}
	async resolve(e) {
		if (!this._resolveCache) {
			let _ = e.onCancellationRequested(() => {
				this._resolveCache = void 0, this._resolveDuration = void 0;
			}), v = new StopWatch(!0);
			this._resolveCache = Promise.resolve(this.provider.resolveCompletionItem(this.completion, e)).then((e) => {
				Object.assign(this.completion, e), this._resolveDuration = v.elapsed();
			}, (e) => {
				isCancellationError(e) && (this._resolveCache = void 0, this._resolveDuration = void 0);
			}).finally(() => {
				_.dispose();
			});
		}
		return this._resolveCache;
	}
}, CompletionOptions = class e {
	static {
		this.default = new e();
	}
	constructor(e = 2, _ = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Map(), b = !0) {
		this.snippetSortOrder = e, this.kindFilter = _, this.providerFilter = v, this.providerItemsToReuse = y, this.showDeprecated = b;
	}
}, _snippetSuggestSupport;
function getSnippetSuggestSupport() {
	return _snippetSuggestSupport;
}
var CompletionItemModel = class {
	constructor(e, _, v, y) {
		this.items = e, this.needsClipboard = _, this.durations = v, this.disposable = y;
	}
};
async function provideSuggestionItems(e, _, v, y = CompletionOptions.default, b = { triggerKind: 0 }, x = CancellationToken.None) {
	let S = new StopWatch();
	v = v.clone();
	let C = _.getWordAtPosition(v), w = C ? new Range(v.lineNumber, C.startColumn, v.lineNumber, C.endColumn) : Range.fromPositions(v), T = {
		replace: w,
		insert: w.setEndPosition(v.lineNumber, v.column)
	}, E = [], D = new DisposableStore(), O = [], k = !1, A = (e, _, b) => {
		let x = !1;
		if (!_) return x;
		for (let b of _.suggestions) if (!y.kindFilter.has(b.kind)) {
			if (!y.showDeprecated && b?.tags?.includes(1)) continue;
			b.range ||= T, b.sortText ||= typeof b.label == "string" ? b.label : b.label.label, !k && b.insertTextRules && b.insertTextRules & 4 && (k = SnippetParser.guessNeedsClipboard(b.insertText)), E.push(new CompletionItem(v, b, _, e)), x = !0;
		}
		return isDisposable(_) && D.add(_), O.push({
			providerName: e._debugDisplayName ?? "unknown_provider",
			elapsedProvider: _.duration ?? -1,
			elapsedOverall: b.elapsed()
		}), x;
	}, j = (async () => {})();
	for (let S of e.orderedGroups(_)) {
		let e = !1;
		if (await Promise.all(S.map(async (S) => {
			if (y.providerItemsToReuse.has(S)) {
				let _ = y.providerItemsToReuse.get(S);
				_.forEach((e) => E.push(e)), e ||= _.length > 0;
				return;
			}
			if (!(y.providerFilter.size > 0 && !y.providerFilter.has(S))) try {
				let y = new StopWatch(), C = await S.provideCompletionItems(_, v, b, x);
				e = A(S, C, y) || e;
			} catch (e) {
				onUnexpectedExternalError(e);
			}
		})), e || x.isCancellationRequested) break;
	}
	return await j, x.isCancellationRequested ? (D.dispose(), Promise.reject(new CancellationError())) : new CompletionItemModel(E.sort(getSuggestionComparator(y.snippetSortOrder)), k, {
		entries: O,
		elapsed: S.elapsed()
	}, D);
}
function defaultComparator(e, _) {
	if (e.sortTextLow && _.sortTextLow) {
		if (e.sortTextLow < _.sortTextLow) return -1;
		if (e.sortTextLow > _.sortTextLow) return 1;
	}
	return e.textLabel < _.textLabel ? -1 : e.textLabel > _.textLabel ? 1 : e.completion.kind - _.completion.kind;
}
function snippetUpComparator(e, _) {
	if (e.completion.kind !== _.completion.kind) {
		if (e.completion.kind === 27) return -1;
		if (_.completion.kind === 27) return 1;
	}
	return defaultComparator(e, _);
}
function snippetDownComparator(e, _) {
	if (e.completion.kind !== _.completion.kind) {
		if (e.completion.kind === 27) return 1;
		if (_.completion.kind === 27) return -1;
	}
	return defaultComparator(e, _);
}
var _snippetComparators = /* @__PURE__ */ new Map();
_snippetComparators.set(0, snippetUpComparator), _snippetComparators.set(2, snippetDownComparator), _snippetComparators.set(1, defaultComparator);
function getSuggestionComparator(e) {
	return _snippetComparators.get(e);
}
CommandsRegistry.registerCommand("_executeCompletionItemProvider", async (e, ..._) => {
	let [v, y, b, x] = _;
	assertType(URI.isUri(v)), assertType(Position.isIPosition(y)), assertType(typeof b == "string" || !b), assertType(typeof x == "number" || !x);
	let { completionProvider: S } = e.get(ILanguageFeaturesService), C = await e.get(ITextModelService).createModelReference(v);
	try {
		let e = {
			incomplete: !1,
			suggestions: []
		}, _ = [], v = C.object.textEditorModel.validatePosition(y), w = await provideSuggestionItems(S, C.object.textEditorModel, v, void 0, {
			triggerCharacter: b ?? void 0,
			triggerKind: b ? 1 : 0
		});
		for (let v of w.items) _.length < (x ?? 0) && _.push(v.resolve(CancellationToken.None)), e.incomplete = e.incomplete || v.container.incomplete, e.suggestions.push(v.completion);
		try {
			return await Promise.all(_), e;
		} finally {
			setTimeout(() => w.disposable.dispose(), 100);
		}
	} finally {
		C.dispose();
	}
});
function showSimpleSuggestions(e, _) {
	e.getContribution("editor.contrib.suggestController")?.triggerSuggest((/* @__PURE__ */ new Set()).add(_), void 0, !0);
}
var QuickSuggestionsOptions = class {
	static isAllOff(e) {
		return e.other === "off" && e.comments === "off" && e.strings === "off";
	}
	static isAllOn(e) {
		return e.other === "on" && e.comments === "on" && e.strings === "on";
	}
	static valueFor(e, _) {
		switch (_) {
			case 1: return e.comments;
			case 2: return e.strings;
			default: return e.other;
		}
	}
};
function normalizeDriveLetter(e, _ = isWindows) {
	return hasDriveLetter(e, _) ? e.charAt(0).toUpperCase() + e.slice(1) : e;
}
var __decorate$62 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$62 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
Object.freeze({
	CURRENT_YEAR: !0,
	CURRENT_YEAR_SHORT: !0,
	CURRENT_MONTH: !0,
	CURRENT_DATE: !0,
	CURRENT_HOUR: !0,
	CURRENT_MINUTE: !0,
	CURRENT_SECOND: !0,
	CURRENT_DAY_NAME: !0,
	CURRENT_DAY_NAME_SHORT: !0,
	CURRENT_MONTH_NAME: !0,
	CURRENT_MONTH_NAME_SHORT: !0,
	CURRENT_SECONDS_UNIX: !0,
	CURRENT_TIMEZONE_OFFSET: !0,
	SELECTION: !0,
	CLIPBOARD: !0,
	TM_SELECTED_TEXT: !0,
	TM_CURRENT_LINE: !0,
	TM_CURRENT_WORD: !0,
	TM_LINE_INDEX: !0,
	TM_LINE_NUMBER: !0,
	TM_FILENAME: !0,
	TM_FILENAME_BASE: !0,
	TM_DIRECTORY: !0,
	TM_FILEPATH: !0,
	CURSOR_INDEX: !0,
	CURSOR_NUMBER: !0,
	RELATIVE_FILEPATH: !0,
	BLOCK_COMMENT_START: !0,
	BLOCK_COMMENT_END: !0,
	LINE_COMMENT: !0,
	WORKSPACE_NAME: !0,
	WORKSPACE_FOLDER: !0,
	RANDOM: !0,
	RANDOM_HEX: !0,
	UUID: !0
});
var CompositeSnippetVariableResolver = class {
	constructor(e) {
		this._delegates = e;
	}
	resolve(e) {
		for (let _ of this._delegates) {
			let v = _.resolve(e);
			if (v !== void 0) return v;
		}
	}
}, SelectionBasedVariableResolver = class {
	constructor(e, _, v, y) {
		this._model = e, this._selection = _, this._selectionIdx = v, this._overtypingCapturer = y;
	}
	resolve(e) {
		let { name: _ } = e;
		if (_ === "SELECTION" || _ === "TM_SELECTED_TEXT") {
			let _ = this._model.getValueInRange(this._selection) || void 0, v = this._selection.startLineNumber !== this._selection.endLineNumber;
			if (!_ && this._overtypingCapturer) {
				let e = this._overtypingCapturer.getLastOvertypedInfo(this._selectionIdx);
				e && (_ = e.value, v = e.multiline);
			}
			if (_ && v && e.snippet) {
				let v = this._model.getLineContent(this._selection.startLineNumber), y = getLeadingWhitespace(v, 0, this._selection.startColumn - 1), b = y;
				e.snippet.walk((_) => _ === e ? !1 : (_ instanceof Text && (b = getLeadingWhitespace(splitLines(_.value).pop())), !0));
				let x = commonPrefixLength(b, y);
				_ = _.replace(/(\r\n|\r|\n)(.*)/g, (e, _, v) => `${_}${b.substr(x)}${v}`);
			}
			return _;
		} else if (_ === "TM_CURRENT_LINE") return this._model.getLineContent(this._selection.positionLineNumber);
		else if (_ === "TM_CURRENT_WORD") {
			let e = this._model.getWordAtPosition({
				lineNumber: this._selection.positionLineNumber,
				column: this._selection.positionColumn
			});
			return e && e.word || void 0;
		} else if (_ === "TM_LINE_INDEX") return String(this._selection.positionLineNumber - 1);
		else if (_ === "TM_LINE_NUMBER") return String(this._selection.positionLineNumber);
		else if (_ === "CURSOR_INDEX") return String(this._selectionIdx);
		else if (_ === "CURSOR_NUMBER") return String(this._selectionIdx + 1);
	}
}, ModelBasedVariableResolver = class {
	constructor(e, _) {
		this._labelService = e, this._model = _;
	}
	resolve(e) {
		let { name: _ } = e;
		if (_ === "TM_FILENAME") return basename$1(this._model.uri.fsPath);
		if (_ === "TM_FILENAME_BASE") {
			let e = basename$1(this._model.uri.fsPath), _ = e.lastIndexOf(".");
			return _ <= 0 ? e : e.slice(0, _);
		} else if (_ === "TM_DIRECTORY") return dirname$1(this._model.uri.fsPath) === "." ? "" : this._labelService.getUriLabel(dirname(this._model.uri));
		else if (_ === "TM_FILEPATH") return this._labelService.getUriLabel(this._model.uri);
		else if (_ === "RELATIVE_FILEPATH") return this._labelService.getUriLabel(this._model.uri, {
			relative: !0,
			noPrefix: !0
		});
	}
}, ClipboardBasedVariableResolver = class {
	constructor(e, _, v, y) {
		this._readClipboardText = e, this._selectionIdx = _, this._selectionCount = v, this._spread = y;
	}
	resolve(e) {
		if (e.name !== "CLIPBOARD") return;
		let _ = this._readClipboardText();
		if (_) {
			if (this._spread) {
				let e = _.split(/\r\n|\n|\r/).filter((e) => !isFalsyOrWhitespace(e));
				if (e.length === this._selectionCount) return e[this._selectionIdx];
			}
			return _;
		}
	}
}, CommentBasedVariableResolver = class {
	constructor(e, _, v) {
		this._model = e, this._selection = _, this._languageConfigurationService = v;
	}
	resolve(e) {
		let { name: _ } = e, v = this._model.getLanguageIdAtPosition(this._selection.selectionStartLineNumber, this._selection.selectionStartColumn), y = this._languageConfigurationService.getLanguageConfiguration(v).comments;
		if (y) {
			if (_ === "LINE_COMMENT") return y.lineCommentToken || void 0;
			if (_ === "BLOCK_COMMENT_START") return y.blockCommentStartToken || void 0;
			if (_ === "BLOCK_COMMENT_END") return y.blockCommentEndToken || void 0;
		}
	}
};
CommentBasedVariableResolver = __decorate$62([__param$62(2, ILanguageConfigurationService)], CommentBasedVariableResolver);
var TimeBasedVariableResolver = class e {
	constructor() {
		this._date = /* @__PURE__ */ new Date();
	}
	static {
		this.dayNames = [
			localize("Sunday", "Sunday"),
			localize("Monday", "Monday"),
			localize("Tuesday", "Tuesday"),
			localize("Wednesday", "Wednesday"),
			localize("Thursday", "Thursday"),
			localize("Friday", "Friday"),
			localize("Saturday", "Saturday")
		];
	}
	static {
		this.dayNamesShort = [
			localize("SundayShort", "Sun"),
			localize("MondayShort", "Mon"),
			localize("TuesdayShort", "Tue"),
			localize("WednesdayShort", "Wed"),
			localize("ThursdayShort", "Thu"),
			localize("FridayShort", "Fri"),
			localize("SaturdayShort", "Sat")
		];
	}
	static {
		this.monthNames = [
			localize("January", "January"),
			localize("February", "February"),
			localize("March", "March"),
			localize("April", "April"),
			localize("May", "May"),
			localize("June", "June"),
			localize("July", "July"),
			localize("August", "August"),
			localize("September", "September"),
			localize("October", "October"),
			localize("November", "November"),
			localize("December", "December")
		];
	}
	static {
		this.monthNamesShort = [
			localize("JanuaryShort", "Jan"),
			localize("FebruaryShort", "Feb"),
			localize("MarchShort", "Mar"),
			localize("AprilShort", "Apr"),
			localize("MayShort", "May"),
			localize("JuneShort", "Jun"),
			localize("JulyShort", "Jul"),
			localize("AugustShort", "Aug"),
			localize("SeptemberShort", "Sep"),
			localize("OctoberShort", "Oct"),
			localize("NovemberShort", "Nov"),
			localize("DecemberShort", "Dec")
		];
	}
	resolve(_) {
		let { name: v } = _;
		if (v === "CURRENT_YEAR") return String(this._date.getFullYear());
		if (v === "CURRENT_YEAR_SHORT") return String(this._date.getFullYear()).slice(-2);
		if (v === "CURRENT_MONTH") return String(this._date.getMonth().valueOf() + 1).padStart(2, "0");
		if (v === "CURRENT_DATE") return String(this._date.getDate().valueOf()).padStart(2, "0");
		if (v === "CURRENT_HOUR") return String(this._date.getHours().valueOf()).padStart(2, "0");
		if (v === "CURRENT_MINUTE") return String(this._date.getMinutes().valueOf()).padStart(2, "0");
		if (v === "CURRENT_SECOND") return String(this._date.getSeconds().valueOf()).padStart(2, "0");
		if (v === "CURRENT_DAY_NAME") return e.dayNames[this._date.getDay()];
		if (v === "CURRENT_DAY_NAME_SHORT") return e.dayNamesShort[this._date.getDay()];
		if (v === "CURRENT_MONTH_NAME") return e.monthNames[this._date.getMonth()];
		if (v === "CURRENT_MONTH_NAME_SHORT") return e.monthNamesShort[this._date.getMonth()];
		if (v === "CURRENT_SECONDS_UNIX") return String(Math.floor(this._date.getTime() / 1e3));
		if (v === "CURRENT_TIMEZONE_OFFSET") {
			let e = this._date.getTimezoneOffset(), _ = e > 0 ? "-" : "+", v = Math.trunc(Math.abs(e / 60)), y = v < 10 ? "0" + v : v, b = Math.abs(e) - v * 60, x = b < 10 ? "0" + b : b;
			return _ + y + ":" + x;
		}
	}
}, WorkspaceBasedVariableResolver = class {
	constructor(e) {
		this._workspaceService = e;
	}
	resolve(e) {
		if (!this._workspaceService) return;
		let _ = toWorkspaceIdentifier(this._workspaceService.getWorkspace());
		if (!isEmptyWorkspaceIdentifier(_)) {
			if (e.name === "WORKSPACE_NAME") return this._resolveWorkspaceName(_);
			if (e.name === "WORKSPACE_FOLDER") return this._resoveWorkspacePath(_);
		}
	}
	_resolveWorkspaceName(e) {
		if (isSingleFolderWorkspaceIdentifier(e)) return basename$1(e.uri.path);
		let _ = basename$1(e.configPath.path);
		return _.endsWith("code-workspace") && (_ = _.substr(0, _.length - WORKSPACE_EXTENSION.length - 1)), _;
	}
	_resoveWorkspacePath(e) {
		if (isSingleFolderWorkspaceIdentifier(e)) return normalizeDriveLetter(e.uri.fsPath);
		let _ = basename$1(e.configPath.path), v = e.configPath.fsPath;
		return v.endsWith(_) && (v = v.substr(0, v.length - _.length - 1)), v ? normalizeDriveLetter(v) : "/";
	}
}, RandomBasedVariableResolver = class {
	resolve(e) {
		let { name: _ } = e;
		if (_ === "RANDOM") return Math.random().toString().slice(-6);
		if (_ === "RANDOM_HEX") return Math.random().toString(16).slice(-6);
		if (_ === "UUID") return generateUuid();
	}
}, __decorate$61 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$61 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SnippetSession_1, OneSnippet = class e {
	static {
		this._decor = {
			active: ModelDecorationOptions.register({
				description: "snippet-placeholder-1",
				stickiness: 0,
				className: "snippet-placeholder"
			}),
			inactive: ModelDecorationOptions.register({
				description: "snippet-placeholder-2",
				stickiness: 1,
				className: "snippet-placeholder"
			}),
			activeFinal: ModelDecorationOptions.register({
				description: "snippet-placeholder-3",
				stickiness: 1,
				className: "finish-snippet-placeholder"
			}),
			inactiveFinal: ModelDecorationOptions.register({
				description: "snippet-placeholder-4",
				stickiness: 1,
				className: "finish-snippet-placeholder"
			})
		};
	}
	constructor(e, _, v) {
		this._editor = e, this._snippet = _, this._snippetLineLeadingWhitespace = v, this._offset = -1, this._nestingLevel = 1, this._placeholderGroups = groupBy(_.placeholders, Placeholder.compareByIndex), this._placeholderGroupsIdx = -1;
	}
	initialize(e) {
		this._offset = e.newPosition;
	}
	dispose() {
		this._placeholderDecorations && this._editor.removeDecorations([...this._placeholderDecorations.values()]), this._placeholderGroups.length = 0;
	}
	_initDecorations() {
		if (this._offset === -1) throw Error("Snippet not initialized!");
		if (this._placeholderDecorations) return;
		this._placeholderDecorations = /* @__PURE__ */ new Map();
		let _ = this._editor.getModel();
		this._editor.changeDecorations((v) => {
			for (let y of this._snippet.placeholders) {
				let b = this._snippet.offset(y), x = this._snippet.fullLen(y), S = Range.fromPositions(_.getPositionAt(this._offset + b), _.getPositionAt(this._offset + b + x)), C = y.isFinalTabstop ? e._decor.inactiveFinal : e._decor.inactive, w = v.addDecoration(S, C);
				this._placeholderDecorations.set(y, w);
			}
		});
	}
	move(_) {
		if (!this._editor.hasModel()) return [];
		if (this._initDecorations(), this._placeholderGroupsIdx >= 0) {
			let e = [];
			for (let _ of this._placeholderGroups[this._placeholderGroupsIdx]) if (_.transform) {
				let v = this._placeholderDecorations.get(_), y = this._editor.getModel().getDecorationRange(v), b = this._editor.getModel().getValueInRange(y), x = _.transform.resolve(b).split(/\r\n|\r|\n/);
				for (let e = 1; e < x.length; e++) x[e] = this._editor.getModel().normalizeIndentation(this._snippetLineLeadingWhitespace + x[e]);
				e.push(EditOperation.replace(y, x.join(this._editor.getModel().getEOL())));
			}
			e.length > 0 && this._editor.executeEdits("snippet.placeholderTransform", e);
		}
		let v = !1;
		_ === !0 && this._placeholderGroupsIdx < this._placeholderGroups.length - 1 ? (this._placeholderGroupsIdx += 1, v = !0) : _ === !1 && this._placeholderGroupsIdx > 0 && (--this._placeholderGroupsIdx, v = !0);
		let y = this._editor.getModel().changeDecorations((_) => {
			let y = /* @__PURE__ */ new Set(), b = [];
			for (let x of this._placeholderGroups[this._placeholderGroupsIdx]) {
				let S = this._placeholderDecorations.get(x), C = this._editor.getModel().getDecorationRange(S);
				b.push(new Selection(C.startLineNumber, C.startColumn, C.endLineNumber, C.endColumn)), v &&= this._hasPlaceholderBeenCollapsed(x), _.changeDecorationOptions(S, x.isFinalTabstop ? e._decor.activeFinal : e._decor.active), y.add(x);
				for (let v of this._snippet.enclosingPlaceholders(x)) {
					let b = this._placeholderDecorations.get(v);
					_.changeDecorationOptions(b, v.isFinalTabstop ? e._decor.activeFinal : e._decor.active), y.add(v);
				}
			}
			for (let [v, b] of this._placeholderDecorations) y.has(v) || _.changeDecorationOptions(b, v.isFinalTabstop ? e._decor.inactiveFinal : e._decor.inactive);
			return b;
		});
		return v ? this.move(_) : y ?? [];
	}
	_hasPlaceholderBeenCollapsed(e) {
		let _ = e;
		for (; _;) {
			if (_ instanceof Placeholder) {
				let e = this._placeholderDecorations.get(_);
				if (this._editor.getModel().getDecorationRange(e).isEmpty() && _.toString().length > 0) return !0;
			}
			_ = _.parent;
		}
		return !1;
	}
	get isAtFirstPlaceholder() {
		return this._placeholderGroupsIdx <= 0 || this._placeholderGroups.length === 0;
	}
	get isAtLastPlaceholder() {
		return this._placeholderGroupsIdx === this._placeholderGroups.length - 1;
	}
	get hasPlaceholder() {
		return this._snippet.placeholders.length > 0;
	}
	get isTrivialSnippet() {
		if (this._snippet.placeholders.length === 0) return !0;
		if (this._snippet.placeholders.length === 1) {
			let [e] = this._snippet.placeholders;
			if (e.isFinalTabstop && this._snippet.rightMostDescendant === e) return !0;
		}
		return !1;
	}
	computePossibleSelections() {
		let e = /* @__PURE__ */ new Map();
		for (let _ of this._placeholderGroups) {
			let v;
			for (let y of _) {
				if (y.isFinalTabstop) break;
				v || (v = [], e.set(y.index, v));
				let _ = this._placeholderDecorations.get(y), b = this._editor.getModel().getDecorationRange(_);
				if (!b) {
					e.delete(y.index);
					break;
				}
				v.push(b);
			}
		}
		return e;
	}
	get activeChoice() {
		if (!this._placeholderDecorations) return;
		let e = this._placeholderGroups[this._placeholderGroupsIdx][0];
		if (!e?.choice) return;
		let _ = this._placeholderDecorations.get(e);
		if (!_) return;
		let v = this._editor.getModel().getDecorationRange(_);
		if (v) return {
			range: v,
			choice: e.choice
		};
	}
	get hasChoice() {
		let e = !1;
		return this._snippet.walk((_) => (e = _ instanceof Choice, !e)), e;
	}
	merge(_) {
		let v = this._editor.getModel();
		this._nestingLevel *= 10, this._editor.changeDecorations((y) => {
			for (let b of this._placeholderGroups[this._placeholderGroupsIdx]) {
				let x = _.shift();
				console.assert(x._offset !== -1), console.assert(!x._placeholderDecorations);
				let S = x._snippet.placeholderInfo.last.index;
				for (let e of x._snippet.placeholderInfo.all) e.isFinalTabstop ? e.index = b.index + (S + 1) / this._nestingLevel : e.index = b.index + e.index / this._nestingLevel;
				this._snippet.replace(b, x._snippet.children);
				let C = this._placeholderDecorations.get(b);
				y.removeDecoration(C), this._placeholderDecorations.delete(b);
				for (let _ of x._snippet.placeholders) {
					let b = x._snippet.offset(_), S = x._snippet.fullLen(_), C = Range.fromPositions(v.getPositionAt(x._offset + b), v.getPositionAt(x._offset + b + S)), w = y.addDecoration(C, e._decor.inactive);
					this._placeholderDecorations.set(_, w);
				}
			}
			this._placeholderGroups = groupBy(this._snippet.placeholders, Placeholder.compareByIndex);
		});
	}
}, _defaultOptions$1 = {
	overwriteBefore: 0,
	overwriteAfter: 0,
	adjustWhitespace: !0,
	clipboardText: void 0,
	overtypingCapturer: void 0
}, SnippetSession = SnippetSession_1 = class {
	static adjustWhitespace(e, _, v, y, b) {
		let x = e.getLineContent(_.lineNumber), S = getLeadingWhitespace(x, 0, _.column - 1), C;
		return y.walk((_) => {
			if (!(_ instanceof Text) || _.parent instanceof Choice || b && !b.has(_)) return !0;
			let x = _.value.split(/\r\n|\r|\n/);
			if (v) {
				let v = y.offset(_);
				if (v === 0) x[0] = e.normalizeIndentation(x[0]);
				else {
					C ??= y.toString();
					let _ = C.charCodeAt(v - 1);
					(_ === 10 || _ === 13) && (x[0] = e.normalizeIndentation(S + x[0]));
				}
				for (let _ = 1; _ < x.length; _++) x[_] = e.normalizeIndentation(S + x[_]);
			}
			let w = x.join(e.getEOL());
			return w !== _.value && (_.parent.replace(_, [new Text(w)]), C = void 0), !0;
		}), S;
	}
	static adjustSelection(e, _, v, y) {
		if (v !== 0 || y !== 0) {
			let { positionLineNumber: b, positionColumn: x } = _, S = x - v, C = x + y, w = e.validateRange({
				startLineNumber: b,
				startColumn: S,
				endLineNumber: b,
				endColumn: C
			});
			_ = Selection.createWithDirection(w.startLineNumber, w.startColumn, w.endLineNumber, w.endColumn, _.getDirection());
		}
		return _;
	}
	static createEditsAndSnippetsFromSelections(e, _, v, y, b, x, S, C, w) {
		let T = [], E = [];
		if (!e.hasModel()) return {
			edits: T,
			snippets: E
		};
		let D = e.getModel(), O = e.invokeWithinContext((e) => e.get(IWorkspaceContextService)), k = e.invokeWithinContext((e) => new ModelBasedVariableResolver(e.get(ILabelService), D)), A = () => S, j = D.getValueInRange(SnippetSession_1.adjustSelection(D, e.getSelection(), v, 0)), M = D.getValueInRange(SnippetSession_1.adjustSelection(D, e.getSelection(), 0, y)), N = D.getLineFirstNonWhitespaceColumn(e.getSelection().positionLineNumber), P = e.getSelections().map((e, _) => ({
			selection: e,
			idx: _
		})).sort((e, _) => Range.compareRangesUsingStarts(e.selection, _.selection));
		for (let { selection: S, idx: F } of P) {
			let I = SnippetSession_1.adjustSelection(D, S, v, 0), L = SnippetSession_1.adjustSelection(D, S, 0, y);
			j !== D.getValueInRange(I) && (I = S), M !== D.getValueInRange(L) && (L = S);
			let R = S.setStartPosition(I.startLineNumber, I.startColumn).setEndPosition(L.endLineNumber, L.endColumn), z = new SnippetParser().parse(_, !0, b), B = R.getStartPosition(), V = SnippetSession_1.adjustWhitespace(D, B, x || F > 0 && N !== D.getLineFirstNonWhitespaceColumn(S.positionLineNumber), z);
			z.resolveVariables(new CompositeSnippetVariableResolver([
				k,
				new ClipboardBasedVariableResolver(A, F, P.length, e.getOption(79) === "spread"),
				new SelectionBasedVariableResolver(D, S, F, C),
				new CommentBasedVariableResolver(D, S, w),
				new TimeBasedVariableResolver(),
				new WorkspaceBasedVariableResolver(O),
				new RandomBasedVariableResolver()
			])), T[F] = EditOperation.replace(R, z.toString()), T[F].identifier = {
				major: F,
				minor: 0
			}, T[F]._isTracked = !0, E[F] = new OneSnippet(e, z, V);
		}
		return {
			edits: T,
			snippets: E
		};
	}
	static createEditsAndSnippetsFromEdits(e, _, v, y, b, x, S) {
		if (!e.hasModel() || _.length === 0) return {
			edits: [],
			snippets: []
		};
		let C = [], w = e.getModel(), T = new SnippetParser(), E = new TextmateSnippet(), D = new CompositeSnippetVariableResolver([
			e.invokeWithinContext((e) => new ModelBasedVariableResolver(e.get(ILabelService), w)),
			new ClipboardBasedVariableResolver(() => b, 0, e.getSelections().length, e.getOption(79) === "spread"),
			new SelectionBasedVariableResolver(w, e.getSelection(), 0, x),
			new CommentBasedVariableResolver(w, e.getSelection(), S),
			new TimeBasedVariableResolver(),
			new WorkspaceBasedVariableResolver(e.invokeWithinContext((e) => e.get(IWorkspaceContextService))),
			new RandomBasedVariableResolver()
		]);
		_ = _.sort((e, _) => Range.compareRangesUsingStarts(e.range, _.range));
		let O = 0;
		for (let e = 0; e < _.length; e++) {
			let { range: v, template: y } = _[e];
			if (e > 0) {
				let y = _[e - 1].range, b = Range.fromPositions(y.getEndPosition(), v.getStartPosition()), x = new Text(w.getValueInRange(b));
				E.appendChild(x), O += x.value.length;
			}
			let b = T.parseFragment(y, E);
			SnippetSession_1.adjustWhitespace(w, v.getStartPosition(), !0, E, new Set(b)), E.resolveVariables(D);
			let x = E.toString(), S = x.slice(O);
			O = x.length;
			let k = EditOperation.replace(v, S);
			k.identifier = {
				major: e,
				minor: 0
			}, k._isTracked = !0, C.push(k);
		}
		return T.ensureFinalTabstop(E, v, !0), {
			edits: C,
			snippets: [new OneSnippet(e, E, "")]
		};
	}
	constructor(e, _, v = _defaultOptions$1, y) {
		this._editor = e, this._template = _, this._options = v, this._languageConfigurationService = y, this._templateMerges = [], this._snippets = [];
	}
	dispose() {
		dispose(this._snippets);
	}
	_logInfo() {
		return `template="${this._template}", merged_templates="${this._templateMerges.join(" -> ")}"`;
	}
	insert() {
		if (!this._editor.hasModel()) return;
		let { edits: e, snippets: _ } = typeof this._template == "string" ? SnippetSession_1.createEditsAndSnippetsFromSelections(this._editor, this._template, this._options.overwriteBefore, this._options.overwriteAfter, !1, this._options.adjustWhitespace, this._options.clipboardText, this._options.overtypingCapturer, this._languageConfigurationService) : SnippetSession_1.createEditsAndSnippetsFromEdits(this._editor, this._template, !1, this._options.adjustWhitespace, this._options.clipboardText, this._options.overtypingCapturer, this._languageConfigurationService);
		this._snippets = _, this._editor.executeEdits("snippet", e, (e) => {
			let v = e.filter((e) => !!e.identifier);
			for (let e = 0; e < _.length; e++) _[e].initialize(v[e].textChange);
			return this._snippets[0].hasPlaceholder ? this._move(!0) : v.map((e) => Selection.fromPositions(e.range.getEndPosition()));
		}), this._editor.revealRange(this._editor.getSelections()[0]);
	}
	merge(e, _ = _defaultOptions$1) {
		if (!this._editor.hasModel()) return;
		this._templateMerges.push([
			this._snippets[0]._nestingLevel,
			this._snippets[0]._placeholderGroupsIdx,
			e
		]);
		let { edits: v, snippets: y } = SnippetSession_1.createEditsAndSnippetsFromSelections(this._editor, e, _.overwriteBefore, _.overwriteAfter, !0, _.adjustWhitespace, _.clipboardText, _.overtypingCapturer, this._languageConfigurationService);
		this._editor.executeEdits("snippet", v, (e) => {
			let _ = e.filter((e) => !!e.identifier);
			for (let e = 0; e < y.length; e++) y[e].initialize(_[e].textChange);
			let v = y[0].isTrivialSnippet;
			if (!v) {
				for (let e of this._snippets) e.merge(y);
				console.assert(y.length === 0);
			}
			return this._snippets[0].hasPlaceholder && !v ? this._move(void 0) : _.map((e) => Selection.fromPositions(e.range.getEndPosition()));
		});
	}
	next() {
		let e = this._move(!0);
		this._editor.setSelections(e), this._editor.revealPositionInCenterIfOutsideViewport(e[0].getPosition());
	}
	prev() {
		let e = this._move(!1);
		this._editor.setSelections(e), this._editor.revealPositionInCenterIfOutsideViewport(e[0].getPosition());
	}
	_move(e) {
		let _ = [];
		for (let v of this._snippets) {
			let y = v.move(e);
			_.push(...y);
		}
		return _;
	}
	get isAtFirstPlaceholder() {
		return this._snippets[0].isAtFirstPlaceholder;
	}
	get isAtLastPlaceholder() {
		return this._snippets[0].isAtLastPlaceholder;
	}
	get hasPlaceholder() {
		return this._snippets[0].hasPlaceholder;
	}
	get hasChoice() {
		return this._snippets[0].hasChoice;
	}
	get activeChoice() {
		return this._snippets[0].activeChoice;
	}
	isSelectionWithinPlaceholders() {
		if (!this.hasPlaceholder) return !1;
		let e = this._editor.getSelections();
		if (e.length < this._snippets.length) return !1;
		let _ = /* @__PURE__ */ new Map();
		for (let v of this._snippets) {
			let y = v.computePossibleSelections();
			if (_.size === 0) for (let [v, b] of y) {
				b.sort(Range.compareRangesUsingStarts);
				for (let y of e) if (b[0].containsRange(y)) {
					_.set(v, []);
					break;
				}
			}
			if (_.size === 0) return !1;
			_.forEach((e, _) => {
				e.push(...y.get(_));
			});
		}
		e.sort(Range.compareRangesUsingStarts);
		for (let [v, y] of _) {
			if (y.length !== e.length) {
				_.delete(v);
				continue;
			}
			y.sort(Range.compareRangesUsingStarts);
			for (let b = 0; b < y.length; b++) if (!y[b].containsRange(e[b])) {
				_.delete(v);
				continue;
			}
		}
		return _.size > 0;
	}
};
SnippetSession = SnippetSession_1 = __decorate$61([__param$61(3, ILanguageConfigurationService)], SnippetSession);
var __decorate$60 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$60 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SnippetController2_1, _defaultOptions = {
	overwriteBefore: 0,
	overwriteAfter: 0,
	undoStopBefore: !0,
	undoStopAfter: !0,
	adjustWhitespace: !0,
	clipboardText: void 0,
	overtypingCapturer: void 0
}, SnippetController2 = class {
	static {
		SnippetController2_1 = this;
	}
	static {
		this.ID = "snippetController2";
	}
	static get(e) {
		return e.getContribution(SnippetController2_1.ID);
	}
	static {
		this.InSnippetMode = new RawContextKey("inSnippetMode", !1, localize("inSnippetMode", "Whether the editor in current in snippet mode"));
	}
	static {
		this.HasNextTabstop = new RawContextKey("hasNextTabstop", !1, localize("hasNextTabstop", "Whether there is a next tab stop when in snippet mode"));
	}
	static {
		this.HasPrevTabstop = new RawContextKey("hasPrevTabstop", !1, localize("hasPrevTabstop", "Whether there is a previous tab stop when in snippet mode"));
	}
	constructor(e, _, v, y, b) {
		this._editor = e, this._logService = _, this._languageFeaturesService = v, this._languageConfigurationService = b, this._snippetListener = new DisposableStore(), this._modelVersionId = -1, this._inSnippet = SnippetController2_1.InSnippetMode.bindTo(y), this._hasNextTabstop = SnippetController2_1.HasNextTabstop.bindTo(y), this._hasPrevTabstop = SnippetController2_1.HasPrevTabstop.bindTo(y);
	}
	dispose() {
		this._inSnippet.reset(), this._hasPrevTabstop.reset(), this._hasNextTabstop.reset(), this._session?.dispose(), this._snippetListener.dispose();
	}
	insert(e, _) {
		try {
			this._doInsert(e, _ === void 0 ? _defaultOptions : {
				..._defaultOptions,
				..._
			});
		} catch (_) {
			this.cancel(), this._logService.error(_), this._logService.error("snippet_error"), this._logService.error("insert_template=", e), this._logService.error("existing_template=", this._session ? this._session._logInfo() : "<no_session>");
		}
	}
	_doInsert(e, _) {
		if (this._editor.hasModel()) {
			if (this._snippetListener.clear(), _.undoStopBefore && this._editor.getModel().pushStackElement(), this._session && typeof e != "string" && this.cancel(), this._session ? (assertType(typeof e == "string"), this._session.merge(e, _)) : (this._modelVersionId = this._editor.getModel().getAlternativeVersionId(), this._session = new SnippetSession(this._editor, e, _, this._languageConfigurationService), this._session.insert()), _.undoStopAfter && this._editor.getModel().pushStackElement(), this._session?.hasChoice) {
				let e = {
					_debugDisplayName: "snippetChoiceCompletions",
					provideCompletionItems: (e, _) => {
						if (!this._session || e !== this._editor.getModel() || !Position.equals(this._editor.getPosition(), _)) return;
						let { activeChoice: v } = this._session;
						if (!v || v.choice.options.length === 0) return;
						let y = e.getValueInRange(v.range), b = !!v.choice.options.find((e) => e.value === y), x = [];
						for (let e = 0; e < v.choice.options.length; e++) {
							let _ = v.choice.options[e];
							x.push({
								kind: 13,
								label: _.value,
								insertText: _.value,
								sortText: "a".repeat(e + 1),
								range: v.range,
								filterText: b ? `${y}_${_.value}` : void 0,
								command: {
									id: "jumpToNextSnippetPlaceholder",
									title: localize("next", "Go to next placeholder...")
								}
							});
						}
						return { suggestions: x };
					}
				}, _ = this._editor.getModel(), v, y = !1;
				this._choiceCompletions = {
					provider: e,
					enable: () => {
						y ||= (v = this._languageFeaturesService.completionProvider.register({
							language: _.getLanguageId(),
							pattern: _.uri.fsPath,
							scheme: _.uri.scheme,
							exclusive: !0
						}, e), this._snippetListener.add(v), !0);
					},
					disable: () => {
						v?.dispose(), y = !1;
					}
				};
			}
			this._updateState(), this._snippetListener.add(this._editor.onDidChangeModelContent((e) => e.isFlush && this.cancel())), this._snippetListener.add(this._editor.onDidChangeModel(() => this.cancel())), this._snippetListener.add(this._editor.onDidChangeCursorSelection(() => this._updateState()));
		}
	}
	_updateState() {
		if (!(!this._session || !this._editor.hasModel())) {
			if (this._modelVersionId === this._editor.getModel().getAlternativeVersionId() || !this._session.hasPlaceholder) return this.cancel();
			if (this._session.isAtLastPlaceholder || !this._session.isSelectionWithinPlaceholders()) return this._editor.getModel().pushStackElement(), this.cancel();
			this._inSnippet.set(!0), this._hasPrevTabstop.set(!this._session.isAtFirstPlaceholder), this._hasNextTabstop.set(!this._session.isAtLastPlaceholder), this._handleChoice();
		}
	}
	_handleChoice() {
		if (!this._session || !this._editor.hasModel()) {
			this._currentChoice = void 0;
			return;
		}
		let { activeChoice: e } = this._session;
		if (!e || !this._choiceCompletions) {
			this._choiceCompletions?.disable(), this._currentChoice = void 0;
			return;
		}
		this._currentChoice !== e.choice && (this._currentChoice = e.choice, this._choiceCompletions.enable(), queueMicrotask(() => {
			showSimpleSuggestions(this._editor, this._choiceCompletions.provider);
		}));
	}
	finish() {
		for (; this._inSnippet.get();) this.next();
	}
	cancel(e = !1) {
		this._inSnippet.reset(), this._hasPrevTabstop.reset(), this._hasNextTabstop.reset(), this._snippetListener.clear(), this._currentChoice = void 0, this._session?.dispose(), this._session = void 0, this._modelVersionId = -1, e && this._editor.setSelections([this._editor.getSelection()]);
	}
	prev() {
		this._session?.prev(), this._updateState();
	}
	next() {
		this._session?.next(), this._updateState();
	}
	isInSnippet() {
		return !!this._inSnippet.get();
	}
};
SnippetController2 = SnippetController2_1 = __decorate$60([
	__param$60(1, ILogService),
	__param$60(2, ILanguageFeaturesService),
	__param$60(3, IContextKeyService),
	__param$60(4, ILanguageConfigurationService)
], SnippetController2), registerEditorContribution(SnippetController2.ID, SnippetController2, 4);
var CommandCtor = EditorCommand.bindToContribution(SnippetController2.get);
registerEditorCommand(new CommandCtor({
	id: "jumpToNextSnippetPlaceholder",
	precondition: ContextKeyExpr.and(SnippetController2.InSnippetMode, SnippetController2.HasNextTabstop),
	handler: (e) => e.next(),
	kbOpts: {
		weight: 130,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 2
	}
})), registerEditorCommand(new CommandCtor({
	id: "jumpToPrevSnippetPlaceholder",
	precondition: ContextKeyExpr.and(SnippetController2.InSnippetMode, SnippetController2.HasPrevTabstop),
	handler: (e) => e.prev(),
	kbOpts: {
		weight: 130,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 1026
	}
})), registerEditorCommand(new CommandCtor({
	id: "leaveSnippet",
	precondition: SnippetController2.InSnippetMode,
	handler: (e) => e.cancel(!0),
	kbOpts: {
		weight: 130,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 9,
		secondary: [1033]
	}
})), registerEditorCommand(new CommandCtor({
	id: "acceptSnippet",
	precondition: SnippetController2.InSnippetMode,
	handler: (e) => e.finish()
}));
var __decorate$59 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$59 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineCompletionsModel = class extends Disposable {
	get isAcceptingPartially() {
		return this._isAcceptingPartially;
	}
	constructor(e, _, v, y, b, x, S, C, w, T, E, D) {
		super(), this.textModel = e, this.selectedSuggestItem = _, this._textModelVersionId = v, this._positions = y, this._debounceValue = b, this._suggestPreviewEnabled = x, this._suggestPreviewMode = S, this._inlineSuggestMode = C, this._enabled = w, this._instantiationService = T, this._commandService = E, this._languageConfigurationService = D, this._source = this._register(this._instantiationService.createInstance(InlineCompletionsSource, this.textModel, this._textModelVersionId, this._debounceValue)), this._isActive = observableValue(this, !1), this._forceUpdateExplicitlySignal = observableSignal(this), this._selectedInlineCompletionId = observableValue(this, void 0), this._primaryPosition = derived(this, (e) => this._positions.read(e)[0] ?? new Position(1, 1)), this._isAcceptingPartially = !1, this._preserveCurrentCompletionReasons = new Set([
			VersionIdChangeReason.Redo,
			VersionIdChangeReason.Undo,
			VersionIdChangeReason.AcceptWord
		]), this._fetchInlineCompletionsPromise = derivedHandleChanges({
			owner: this,
			createEmptyChangeSummary: () => ({
				preserveCurrentCompletion: !1,
				inlineCompletionTriggerKind: InlineCompletionTriggerKind.Automatic
			}),
			handleChange: (e, _) => (e.didChange(this._textModelVersionId) && this._preserveCurrentCompletionReasons.has(this._getReason(e.change)) ? _.preserveCurrentCompletion = !0 : e.didChange(this._forceUpdateExplicitlySignal) && (_.inlineCompletionTriggerKind = InlineCompletionTriggerKind.Explicit), !0)
		}, (e, _) => {
			if (this._forceUpdateExplicitlySignal.read(e), !(this._enabled.read(e) && this.selectedSuggestItem.read(e) || this._isActive.read(e))) {
				this._source.cancelUpdate();
				return;
			}
			this._textModelVersionId.read(e);
			let v = this._source.suggestWidgetInlineCompletions.get(), y = this.selectedSuggestItem.read(e);
			if (v && !y) {
				let e = this._source.inlineCompletions.get();
				transaction((_) => {
					(!e || v.request.versionId > e.request.versionId) && this._source.inlineCompletions.set(v.clone(), _), this._source.clearSuggestWidgetInlineCompletions(_);
				});
			}
			let b = this._primaryPosition.read(e), x = {
				triggerKind: _.inlineCompletionTriggerKind,
				selectedSuggestionInfo: y?.toSelectedSuggestionInfo()
			}, S = this.selectedInlineCompletion.get(), C = _.preserveCurrentCompletion || S?.forwardStable ? S : void 0;
			return this._source.fetch(b, x, C);
		}), this._filteredInlineCompletionItems = derivedOpts({
			owner: this,
			equalsFn: itemsEquals()
		}, (e) => {
			let _ = this._source.inlineCompletions.read(e);
			if (!_) return [];
			let v = this._primaryPosition.read(e);
			return _.inlineCompletions.filter((_) => _.isVisible(this.textModel, v, e));
		}), this.selectedInlineCompletionIndex = derived(this, (e) => {
			let _ = this._selectedInlineCompletionId.read(e), v = this._filteredInlineCompletionItems.read(e), y = this._selectedInlineCompletionId === void 0 ? -1 : v.findIndex((e) => e.semanticId === _);
			return y === -1 ? (this._selectedInlineCompletionId.set(void 0, void 0), 0) : y;
		}), this.selectedInlineCompletion = derived(this, (e) => {
			let _ = this._filteredInlineCompletionItems.read(e), v = this.selectedInlineCompletionIndex.read(e);
			return _[v];
		}), this.activeCommands = derivedOpts({
			owner: this,
			equalsFn: itemsEquals()
		}, (e) => this.selectedInlineCompletion.read(e)?.inlineCompletion.source.inlineCompletions.commands ?? []), this.lastTriggerKind = this._source.inlineCompletions.map(this, (e) => e?.request.context.triggerKind), this.inlineCompletionsCount = derived(this, (e) => {
			if (this.lastTriggerKind.read(e) === InlineCompletionTriggerKind.Explicit) return this._filteredInlineCompletionItems.read(e).length;
		}), this.state = derivedOpts({
			owner: this,
			equalsFn: (e, _) => !e || !_ ? e === _ : ghostTextsOrReplacementsEqual(e.ghostTexts, _.ghostTexts) && e.inlineCompletion === _.inlineCompletion && e.suggestItem === _.suggestItem
		}, (e) => {
			let _ = this.textModel, v = this.selectedSuggestItem.read(e);
			if (v) {
				let y = singleTextRemoveCommonPrefix(v.toSingleTextEdit(), _), b = this._computeAugmentation(y, e);
				if (!this._suggestPreviewEnabled.read(e) && !b) return;
				let x = b?.edit ?? y, S = b ? b.edit.text.length - y.text.length : 0, C = this._suggestPreviewMode.read(e), w = this._positions.read(e), T = [x, ...getSecondaryEdits(this.textModel, w, x)], E = T.map((e, v) => computeGhostText(e, _, C, w[v], S)).filter(isDefined), D = E[0] ?? new GhostText(x.range.endLineNumber, []);
				return {
					edits: T,
					primaryGhostText: D,
					ghostTexts: E,
					inlineCompletion: b?.completion,
					suggestItem: v
				};
			} else {
				if (!this._isActive.read(e)) return;
				let v = this.selectedInlineCompletion.read(e);
				if (!v) return;
				let y = v.toSingleTextEdit(e), b = this._inlineSuggestMode.read(e), x = this._positions.read(e), S = [y, ...getSecondaryEdits(this.textModel, x, y)], C = S.map((e, v) => computeGhostText(e, _, b, x[v], 0)).filter(isDefined);
				return C[0] ? {
					edits: S,
					primaryGhostText: C[0],
					ghostTexts: C,
					inlineCompletion: v,
					suggestItem: void 0
				} : void 0;
			}
		}), this.ghostTexts = derivedOpts({
			owner: this,
			equalsFn: ghostTextsOrReplacementsEqual
		}, (e) => {
			let _ = this.state.read(e);
			if (_) return _.ghostTexts;
		}), this.primaryGhostText = derivedOpts({
			owner: this,
			equalsFn: ghostTextOrReplacementEquals
		}, (e) => {
			let _ = this.state.read(e);
			if (_) return _?.primaryGhostText;
		}), this._register(recomputeInitiallyAndOnChange(this._fetchInlineCompletionsPromise));
		let O;
		this._register(autorun((e) => {
			let _ = this.state.read(e)?.inlineCompletion;
			if (_?.semanticId !== O?.semanticId && (O = _, _)) {
				let e = _.inlineCompletion, v = e.source;
				v.provider.handleItemDidShow?.(v.inlineCompletions, e.sourceInlineCompletion, e.insertText);
			}
		}));
	}
	_getReason(e) {
		return e?.isUndoing ? VersionIdChangeReason.Undo : e?.isRedoing ? VersionIdChangeReason.Redo : this.isAcceptingPartially ? VersionIdChangeReason.AcceptWord : VersionIdChangeReason.Other;
	}
	async trigger(e) {
		this._isActive.set(!0, e), await this._fetchInlineCompletionsPromise.get();
	}
	async triggerExplicitly(e) {
		subtransaction(e, (e) => {
			this._isActive.set(!0, e), this._forceUpdateExplicitlySignal.trigger(e);
		}), await this._fetchInlineCompletionsPromise.get();
	}
	stop(e) {
		subtransaction(e, (e) => {
			this._isActive.set(!1, e), this._source.clear(e);
		});
	}
	_computeAugmentation(e, _) {
		let v = this.textModel, y = this._source.suggestWidgetInlineCompletions.read(_), b = y ? y.inlineCompletions : [this.selectedInlineCompletion.read(_)].filter(isDefined);
		return mapFindFirst(b, (y) => {
			let b = y.toSingleTextEdit(_);
			return b = singleTextRemoveCommonPrefix(b, v, Range.fromPositions(b.range.getStartPosition(), e.range.getEndPosition())), singleTextEditAugments(b, e) ? {
				completion: y,
				edit: b
			} : void 0;
		});
	}
	async _deltaSelectedInlineCompletionIndex(e) {
		await this.triggerExplicitly();
		let _ = this._filteredInlineCompletionItems.get() || [];
		if (_.length > 0) {
			let v = (this.selectedInlineCompletionIndex.get() + e + _.length) % _.length;
			this._selectedInlineCompletionId.set(_[v].semanticId, void 0);
		} else this._selectedInlineCompletionId.set(void 0, void 0);
	}
	async next() {
		await this._deltaSelectedInlineCompletionIndex(1);
	}
	async previous() {
		await this._deltaSelectedInlineCompletionIndex(-1);
	}
	async accept(e) {
		if (e.getModel() !== this.textModel) throw new BugIndicatingError();
		let _ = this.state.get();
		if (!_ || _.primaryGhostText.isEmpty() || !_.inlineCompletion) return;
		let v = _.inlineCompletion.toInlineCompletion(void 0);
		if (v.command && v.source.addRef(), e.pushUndoStop(), v.snippetInfo) e.executeEdits("inlineSuggestion.accept", [EditOperation.replace(v.range, ""), ...v.additionalTextEdits]), e.setPosition(v.snippetInfo.range.getStartPosition(), "inlineCompletionAccept"), SnippetController2.get(e)?.insert(v.snippetInfo.snippet, { undoStopBefore: !1 });
		else {
			let y = _.edits, b = getEndPositionsAfterApplying(y).map((e) => Selection.fromPositions(e));
			e.executeEdits("inlineSuggestion.accept", [...y.map((e) => EditOperation.replace(e.range, e.text)), ...v.additionalTextEdits]), e.setSelections(b, "inlineCompletionAccept");
		}
		this.stop(), v.command && (await this._commandService.executeCommand(v.command.id, ...v.command.arguments || []).then(void 0, onUnexpectedExternalError), v.source.removeRef());
	}
	async acceptNextWord(e) {
		await this._acceptNext(e, (e, _) => {
			let v = this.textModel.getLanguageIdAtPosition(e.lineNumber, e.column), y = this._languageConfigurationService.getLanguageConfiguration(v), b = new RegExp(y.wordDefinition.source, y.wordDefinition.flags.replace("g", "")), x = _.match(b), S = 0;
			S = x && x.index !== void 0 ? x.index === 0 ? x[0].length : x.index : _.length;
			let C = /\s+/g.exec(_);
			return C && C.index !== void 0 && C.index + C[0].length < S && (S = C.index + C[0].length), S;
		}, 0);
	}
	async acceptNextLine(e) {
		await this._acceptNext(e, (e, _) => {
			let v = _.match(/\n/);
			return v && v.index !== void 0 ? v.index + 1 : _.length;
		}, 1);
	}
	async _acceptNext(e, _, v) {
		if (e.getModel() !== this.textModel) throw new BugIndicatingError();
		let y = this.state.get();
		if (!y || y.primaryGhostText.isEmpty() || !y.inlineCompletion) return;
		let b = y.primaryGhostText, x = y.inlineCompletion.toInlineCompletion(void 0);
		if (x.snippetInfo || x.filterText !== x.insertText) {
			await this.accept(e);
			return;
		}
		let S = b.parts[0], C = new Position(b.lineNumber, S.column), w = S.text, T = _(C, w);
		if (T === w.length && b.parts.length === 1) {
			this.accept(e);
			return;
		}
		let E = w.substring(0, T), D = this._positions.get(), O = D[0];
		x.source.addRef();
		try {
			this._isAcceptingPartially = !0;
			try {
				e.pushUndoStop();
				let _ = Range.fromPositions(O, C), v = e.getModel().getValueInRange(_) + E, y = new SingleTextEdit(_, v), b = [y, ...getSecondaryEdits(this.textModel, D, y)], x = getEndPositionsAfterApplying(b).map((e) => Selection.fromPositions(e));
				e.executeEdits("inlineSuggestion.accept", b.map((e) => EditOperation.replace(e.range, e.text))), e.setSelections(x, "inlineCompletionPartialAccept"), e.revealPositionInCenterIfOutsideViewport(e.getPosition(), 1);
			} finally {
				this._isAcceptingPartially = !1;
			}
			if (x.source.provider.handlePartialAccept) {
				let _ = Range.fromPositions(x.range.getStartPosition(), TextLength.ofText(E).addToPosition(C)), y = e.getModel().getValueInRange(_, 1);
				x.source.provider.handlePartialAccept(x.source.inlineCompletions, x.sourceInlineCompletion, y.length, { kind: v });
			}
		} finally {
			x.source.removeRef();
		}
	}
	handleSuggestAccepted(e) {
		let _ = singleTextRemoveCommonPrefix(e.toSingleTextEdit(), this.textModel), v = this._computeAugmentation(_, void 0);
		if (!v) return;
		let y = v.completion.inlineCompletion;
		y.source.provider.handlePartialAccept?.(y.source.inlineCompletions, y.sourceInlineCompletion, _.text.length, { kind: 2 });
	}
};
InlineCompletionsModel = __decorate$59([
	__param$59(9, IInstantiationService),
	__param$59(10, ICommandService),
	__param$59(11, ILanguageConfigurationService)
], InlineCompletionsModel);
var VersionIdChangeReason;
(function(e) {
	e[e.Undo = 0] = "Undo", e[e.Redo = 1] = "Redo", e[e.AcceptWord = 2] = "AcceptWord", e[e.Other = 3] = "Other";
})(VersionIdChangeReason ||= {});
function getSecondaryEdits(e, _, v) {
	if (_.length === 1) return [];
	let y = _[0], b = _.slice(1), x = v.range.getStartPosition(), S = v.range.getEndPosition(), C = e.getValueInRange(Range.fromPositions(y, S)), w = subtractPositions(y, x);
	if (w.lineNumber < 1) return onUnexpectedError(new BugIndicatingError(`positionWithinTextEdit line number should be bigger than 0.
			Invalid subtraction between ${y.toString()} and ${x.toString()}`)), [];
	let T = substringPos(v.text, w);
	return b.map((_) => {
		let v = addPositions(subtractPositions(_, x), S), y = e.getValueInRange(Range.fromPositions(_, v)), b = commonPrefixLength(C, y), w = Range.fromPositions(_, _.delta(0, b));
		return new SingleTextEdit(w, T);
	});
}
function substringPos(e, _) {
	let v = "", y = splitLinesIncludeSeparators(e);
	for (let e = _.lineNumber - 1; e < y.length; e++) v += y[e].substring(e === _.lineNumber - 1 ? _.column - 1 : 0);
	return v;
}
function getEndPositionsAfterApplying(e) {
	let _ = Permutation.createSortPermutation(e, compareBy((e) => e.range, Range.compareRangesUsingStarts)), v = new TextEdit(_.apply(e)).getNewRanges();
	return _.inverse().apply(v).map((e) => e.getEndPosition());
}
var __decorate$58 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$58 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SuggestMemoryService_1, Memory = class {
	constructor(e) {
		this.name = e;
	}
	select(e, _, v) {
		if (v.length === 0) return 0;
		let y = v[0].score[0];
		for (let e = 0; e < v.length; e++) {
			let { score: _, completion: b } = v[e];
			if (_[0] !== y) break;
			if (b.preselect) return e;
		}
		return 0;
	}
}, NoMemory = class extends Memory {
	constructor() {
		super("first");
	}
	memorize(e, _, v) {}
	toJSON() {}
	fromJSON() {}
}, LRUMemory = class extends Memory {
	constructor() {
		super("recentlyUsed"), this._cache = new LRUCache(300, .66), this._seq = 0;
	}
	memorize(e, _, v) {
		let y = `${e.getLanguageId()}/${v.textLabel}`;
		this._cache.set(y, {
			touch: this._seq++,
			type: v.completion.kind,
			insertText: v.completion.insertText
		});
	}
	select(e, _, v) {
		if (v.length === 0) return 0;
		let y = e.getLineContent(_.lineNumber).substr(_.column - 10, _.column - 1);
		if (/\s$/.test(y)) return super.select(e, _, v);
		let b = v[0].score[0], x = -1, S = -1, C = -1;
		for (let _ = 0; _ < v.length && v[_].score[0] === b; _++) {
			let y = `${e.getLanguageId()}/${v[_].textLabel}`, b = this._cache.peek(y);
			if (b && b.touch > C && b.type === v[_].completion.kind && b.insertText === v[_].completion.insertText && (C = b.touch, S = _), v[_].completion.preselect && x === -1) return x = _;
		}
		return S === -1 ? x === -1 ? 0 : x : S;
	}
	toJSON() {
		return this._cache.toJSON();
	}
	fromJSON(e) {
		this._cache.clear();
		for (let [_, v] of e) v.touch = 0, v.type = typeof v.type == "number" ? v.type : CompletionItemKinds.fromString(v.type), this._cache.set(_, v);
		this._seq = this._cache.size;
	}
}, PrefixMemory = class extends Memory {
	constructor() {
		super("recentlyUsedByPrefix"), this._trie = TernarySearchTree.forStrings(), this._seq = 0;
	}
	memorize(e, _, v) {
		let { word: y } = e.getWordUntilPosition(_), b = `${e.getLanguageId()}/${y}`;
		this._trie.set(b, {
			type: v.completion.kind,
			insertText: v.completion.insertText,
			touch: this._seq++
		});
	}
	select(e, _, v) {
		let { word: y } = e.getWordUntilPosition(_);
		if (!y) return super.select(e, _, v);
		let b = `${e.getLanguageId()}/${y}`, x = this._trie.get(b);
		if (x ||= this._trie.findSubstr(b), x) for (let e = 0; e < v.length; e++) {
			let { kind: _, insertText: y } = v[e].completion;
			if (_ === x.type && y === x.insertText) return e;
		}
		return super.select(e, _, v);
	}
	toJSON() {
		let e = [];
		return this._trie.forEach((_, v) => e.push([v, _])), e.sort((e, _) => -(e[1].touch - _[1].touch)).forEach((e, _) => e[1].touch = _), e.slice(0, 200);
	}
	fromJSON(e) {
		if (this._trie.clear(), e.length > 0) {
			this._seq = e[0][1].touch + 1;
			for (let [_, v] of e) v.type = typeof v.type == "number" ? v.type : CompletionItemKinds.fromString(v.type), this._trie.set(_, v);
		}
	}
}, SuggestMemoryService = class {
	static {
		SuggestMemoryService_1 = this;
	}
	static {
		this._strategyCtors = new Map([
			["recentlyUsedByPrefix", PrefixMemory],
			["recentlyUsed", LRUMemory],
			["first", NoMemory]
		]);
	}
	static {
		this._storagePrefix = "suggest/memories";
	}
	constructor(e, _) {
		this._storageService = e, this._configService = _, this._disposables = new DisposableStore(), this._persistSoon = new RunOnceScheduler(() => this._saveState(), 500), this._disposables.add(e.onWillSaveState((e) => {
			e.reason === WillSaveStateReason.SHUTDOWN && this._saveState();
		}));
	}
	dispose() {
		this._disposables.dispose(), this._persistSoon.dispose();
	}
	memorize(e, _, v) {
		this._withStrategy(e, _).memorize(e, _, v), this._persistSoon.schedule();
	}
	select(e, _, v) {
		return this._withStrategy(e, _).select(e, _, v);
	}
	_withStrategy(e, _) {
		let v = this._configService.getValue("editor.suggestSelection", {
			overrideIdentifier: e.getLanguageIdAtPosition(_.lineNumber, _.column),
			resource: e.uri
		});
		if (this._strategy?.name !== v) {
			this._saveState(), this._strategy = new ((SuggestMemoryService_1._strategyCtors.get(v)) || NoMemory)();
			try {
				let e = this._configService.getValue("editor.suggest.shareSuggestSelections") ? 0 : 1, _ = this._storageService.get(`${SuggestMemoryService_1._storagePrefix}/${v}`, e);
				_ && this._strategy.fromJSON(JSON.parse(_));
			} catch {}
		}
		return this._strategy;
	}
	_saveState() {
		if (this._strategy) {
			let e = this._configService.getValue("editor.suggest.shareSuggestSelections") ? 0 : 1, _ = JSON.stringify(this._strategy);
			this._storageService.store(`${SuggestMemoryService_1._storagePrefix}/${this._strategy.name}`, _, e, 1);
		}
	}
};
SuggestMemoryService = SuggestMemoryService_1 = __decorate$58([__param$58(0, IStorageService), __param$58(1, IConfigurationService)], SuggestMemoryService);
const ISuggestMemoryService = createDecorator("ISuggestMemories");
registerSingleton(ISuggestMemoryService, SuggestMemoryService, 1);
var __decorate$57 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$57 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, WordContextKey_1, WordContextKey = class {
	static {
		WordContextKey_1 = this;
	}
	static {
		this.AtEnd = new RawContextKey("atEndOfWord", !1);
	}
	constructor(e, _) {
		this._editor = e, this._enabled = !1, this._ckAtEnd = WordContextKey_1.AtEnd.bindTo(_), this._configListener = this._editor.onDidChangeConfiguration((e) => e.hasChanged(124) && this._update()), this._update();
	}
	dispose() {
		this._configListener.dispose(), this._selectionListener?.dispose(), this._ckAtEnd.reset();
	}
	_update() {
		let e = this._editor.getOption(124) === "on";
		if (this._enabled !== e) if (this._enabled = e, this._enabled) {
			let e = () => {
				if (!this._editor.hasModel()) {
					this._ckAtEnd.set(!1);
					return;
				}
				let e = this._editor.getModel(), _ = this._editor.getSelection(), v = e.getWordAtPosition(_.getStartPosition());
				if (!v) {
					this._ckAtEnd.set(!1);
					return;
				}
				this._ckAtEnd.set(v.endColumn === _.getStartPosition().column);
			};
			this._selectionListener = this._editor.onDidChangeCursorSelection(e), e();
		} else this._selectionListener &&= (this._ckAtEnd.reset(), this._selectionListener.dispose(), void 0);
	}
};
WordContextKey = WordContextKey_1 = __decorate$57([__param$57(1, IContextKeyService)], WordContextKey);
var __decorate$56 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$56 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SuggestAlternatives_1, SuggestAlternatives = class {
	static {
		SuggestAlternatives_1 = this;
	}
	static {
		this.OtherSuggestions = new RawContextKey("hasOtherSuggestions", !1);
	}
	constructor(e, _) {
		this._editor = e, this._index = 0, this._ckOtherSuggestions = SuggestAlternatives_1.OtherSuggestions.bindTo(_);
	}
	dispose() {
		this.reset();
	}
	reset() {
		this._ckOtherSuggestions.reset(), this._listener?.dispose(), this._model = void 0, this._acceptNext = void 0, this._ignore = !1;
	}
	set({ model: e, index: _ }, v) {
		if (e.items.length === 0) {
			this.reset();
			return;
		}
		if (SuggestAlternatives_1._moveIndex(!0, e, _) === _) {
			this.reset();
			return;
		}
		this._acceptNext = v, this._model = e, this._index = _, this._listener = this._editor.onDidChangeCursorPosition(() => {
			this._ignore || this.reset();
		}), this._ckOtherSuggestions.set(!0);
	}
	static _moveIndex(e, _, v) {
		let y = v;
		for (let b = _.items.length; b > 0 && (y = (y + _.items.length + (e ? 1 : -1)) % _.items.length, !(y === v || !_.items[y].completion.additionalTextEdits)); b--);
		return y;
	}
	next() {
		this._move(!0);
	}
	prev() {
		this._move(!1);
	}
	_move(e) {
		if (this._model) try {
			this._ignore = !0, this._index = SuggestAlternatives_1._moveIndex(e, this._model, this._index), this._acceptNext({
				index: this._index,
				item: this._model.items[this._index],
				model: this._model
			});
		} finally {
			this._ignore = !1;
		}
	}
};
SuggestAlternatives = SuggestAlternatives_1 = __decorate$56([__param$56(1, IContextKeyService)], SuggestAlternatives);
var CommitCharacterController = class {
	constructor(e, _, v, y) {
		this._disposables = new DisposableStore(), this._disposables.add(v.onDidSuggest((e) => {
			e.completionModel.items.length === 0 && this.reset();
		})), this._disposables.add(v.onDidCancel((e) => {
			this.reset();
		})), this._disposables.add(_.onDidShow(() => this._onItem(_.getFocusedItem()))), this._disposables.add(_.onDidFocus(this._onItem, this)), this._disposables.add(_.onDidHide(this.reset, this)), this._disposables.add(e.onWillType((b) => {
			if (this._active && !_.isFrozen() && v.state !== 0) {
				let _ = b.charCodeAt(b.length - 1);
				this._active.acceptCharacters.has(_) && e.getOption(0) && y(this._active.item);
			}
		}));
	}
	_onItem(e) {
		if (!e || !isNonEmptyArray(e.item.completion.commitCharacters)) {
			this.reset();
			return;
		}
		if (this._active && this._active.item.item === e.item) return;
		let _ = new CharacterSet();
		for (let v of e.item.completion.commitCharacters) v.length > 0 && _.add(v.charCodeAt(0));
		this._active = {
			acceptCharacters: _,
			item: e
		};
	}
	reset() {
		this._active = void 0;
	}
	dispose() {
		this._disposables.dispose();
	}
}, BracketSelectionRangeProvider = class e {
	async provideSelectionRanges(_, v) {
		let y = [];
		for (let b of v) {
			let v = [];
			y.push(v);
			let x = /* @__PURE__ */ new Map();
			await new Promise((v) => e._bracketsRightYield(v, 0, _, b, x)), await new Promise((y) => e._bracketsLeftYield(y, 0, _, b, x, v));
		}
		return y;
	}
	static {
		this._maxDuration = 30;
	}
	static {
		this._maxRounds = 2;
	}
	static _bracketsRightYield(_, v, y, b, x) {
		let S = /* @__PURE__ */ new Map(), C = Date.now();
		for (;;) {
			if (v >= e._maxRounds) {
				_();
				break;
			}
			if (!b) {
				_();
				break;
			}
			let w = y.bracketPairs.findNextBracket(b);
			if (!w) {
				_();
				break;
			}
			if (Date.now() - C > e._maxDuration) {
				setTimeout(() => e._bracketsRightYield(_, v + 1, y, b, x));
				break;
			}
			if (w.bracketInfo.isOpeningBracket) {
				let e = w.bracketInfo.bracketText, _ = S.has(e) ? S.get(e) : 0;
				S.set(e, _ + 1);
			} else {
				let e = w.bracketInfo.getOpeningBrackets()[0].bracketText, _ = S.has(e) ? S.get(e) : 0;
				if (--_, S.set(e, Math.max(0, _)), _ < 0) {
					let _ = x.get(e);
					_ || (_ = new LinkedList(), x.set(e, _)), _.push(w.range);
				}
			}
			b = w.range.getEndPosition();
		}
	}
	static _bracketsLeftYield(_, v, y, b, x, S) {
		let C = /* @__PURE__ */ new Map(), w = Date.now();
		for (;;) {
			if (v >= e._maxRounds && x.size === 0) {
				_();
				break;
			}
			if (!b) {
				_();
				break;
			}
			let T = y.bracketPairs.findPrevBracket(b);
			if (!T) {
				_();
				break;
			}
			if (Date.now() - w > e._maxDuration) {
				setTimeout(() => e._bracketsLeftYield(_, v + 1, y, b, x, S));
				break;
			}
			if (T.bracketInfo.isOpeningBracket) {
				let _ = T.bracketInfo.bracketText, v = C.has(_) ? C.get(_) : 0;
				if (--v, C.set(_, Math.max(0, v)), v < 0) {
					let v = x.get(_);
					if (v) {
						let b = v.shift();
						v.size === 0 && x.delete(_);
						let C = Range.fromPositions(T.range.getEndPosition(), b.getStartPosition()), w = Range.fromPositions(T.range.getStartPosition(), b.getEndPosition());
						S.push({ range: C }), S.push({ range: w }), e._addBracketLeading(y, w, S);
					}
				}
			} else {
				let e = T.bracketInfo.getOpeningBrackets()[0].bracketText, _ = C.has(e) ? C.get(e) : 0;
				C.set(e, _ + 1);
			}
			b = T.range.getStartPosition();
		}
	}
	static _addBracketLeading(e, _, v) {
		if (_.startLineNumber === _.endLineNumber) return;
		let y = _.startLineNumber, b = e.getLineFirstNonWhitespaceColumn(y);
		b !== 0 && b !== _.startColumn && (v.push({ range: Range.fromPositions(new Position(y, b), _.getEndPosition()) }), v.push({ range: Range.fromPositions(new Position(y, 1), _.getEndPosition()) }));
		let x = y - 1;
		if (x > 0) {
			let y = e.getLineFirstNonWhitespaceColumn(x);
			y === _.startColumn && y !== e.getLineLastNonWhitespaceColumn(x) && (v.push({ range: Range.fromPositions(new Position(x, y), _.getEndPosition()) }), v.push({ range: Range.fromPositions(new Position(x, 1), _.getEndPosition()) }));
		}
	}
}, WordDistance = class e {
	static {
		this.None = new class extends e {
			distance() {
				return 0;
			}
		}();
	}
	static async create(_, v) {
		if (!v.getOption(119).localityBonus || !v.hasModel()) return e.None;
		let y = v.getModel(), b = v.getPosition();
		if (!_.canComputeWordRanges(y.uri)) return e.None;
		let [x] = await new BracketSelectionRangeProvider().provideSelectionRanges(y, [b]);
		if (x.length === 0) return e.None;
		let S = await _.computeWordRanges(y.uri, x[0].range);
		if (!S) return e.None;
		let C = y.getWordUntilPosition(b);
		return delete S[C.word], new class extends e {
			distance(e, _) {
				if (!b.equals(v.getPosition())) return 0;
				if (_.kind === 17) return 2 << 20;
				let y = typeof _.label == "string" ? _.label : _.label.label, C = S[y];
				if (isFalsyOrEmpty(C)) return 2 << 20;
				let w = binarySearch(C, Range.fromPositions(e), Range.compareRangesUsingStarts), T = w >= 0 ? C[w] : C[Math.max(0, ~w - 1)], E = x.length;
				for (let e of x) {
					if (!Range.containsRange(e.range, T)) break;
					--E;
				}
				return E;
			}
		}();
	}
}, LineContext = class {
	constructor(e, _) {
		this.leadingLineContent = e, this.characterCountDelta = _;
	}
}, CompletionModel = class e {
	constructor(_, v, y, b, x, S, C = FuzzyScoreOptions.default, w = void 0) {
		this.clipboardText = w, this._snippetCompareFn = e._compareCompletionItems, this._items = _, this._column = v, this._wordDistance = b, this._options = x, this._refilterKind = 1, this._lineContext = y, this._fuzzyScoreOptions = C, S === "top" ? this._snippetCompareFn = e._compareCompletionItemsSnippetsUp : S === "bottom" && (this._snippetCompareFn = e._compareCompletionItemsSnippetsDown);
	}
	get lineContext() {
		return this._lineContext;
	}
	set lineContext(e) {
		(this._lineContext.leadingLineContent !== e.leadingLineContent || this._lineContext.characterCountDelta !== e.characterCountDelta) && (this._refilterKind = this._lineContext.characterCountDelta < e.characterCountDelta && this._filteredItems ? 2 : 1, this._lineContext = e);
	}
	get items() {
		return this._ensureCachedState(), this._filteredItems;
	}
	getItemsByProvider() {
		return this._ensureCachedState(), this._itemsByProvider;
	}
	getIncompleteProvider() {
		this._ensureCachedState();
		let e = /* @__PURE__ */ new Set();
		for (let [_, v] of this.getItemsByProvider()) v.length > 0 && v[0].container.incomplete && e.add(_);
		return e;
	}
	get stats() {
		return this._ensureCachedState(), this._stats;
	}
	_ensureCachedState() {
		this._refilterKind !== 0 && this._createCachedState();
	}
	_createCachedState() {
		this._itemsByProvider = /* @__PURE__ */ new Map();
		let e = [], { leadingLineContent: _, characterCountDelta: v } = this._lineContext, y = "", b = "", x = this._refilterKind === 1 ? this._items : this._filteredItems, S = [], C = !this._options.filterGraceful || x.length > 2e3 ? fuzzyScore : fuzzyScoreGracefulAggressive;
		for (let w = 0; w < x.length; w++) {
			let T = x[w];
			if (T.isInvalid) continue;
			let E = this._itemsByProvider.get(T.provider);
			E ? E.push(T) : this._itemsByProvider.set(T.provider, [T]);
			let D = T.position.column - T.editStart.column, O = D + v - (T.position.column - this._column);
			if (y.length !== O && (y = O === 0 ? "" : _.slice(-O), b = y.toLowerCase()), T.word = y, O === 0) T.score = FuzzyScore.Default;
			else {
				let e = 0;
				for (; e < D;) {
					let _ = y.charCodeAt(e);
					if (_ === 32 || _ === 9) e += 1;
					else break;
				}
				if (e >= O) T.score = FuzzyScore.Default;
				else if (typeof T.completion.filterText == "string") {
					let _ = C(y, b, e, T.completion.filterText, T.filterTextLow, 0, this._fuzzyScoreOptions);
					if (!_) continue;
					compareIgnoreCase(T.completion.filterText, T.textLabel) === 0 ? T.score = _ : (T.score = anyScore(y, b, e, T.textLabel, T.labelLow, 0), T.score[0] = _[0]);
				} else {
					let _ = C(y, b, e, T.textLabel, T.labelLow, 0, this._fuzzyScoreOptions);
					if (!_) continue;
					T.score = _;
				}
			}
			T.idx = w, T.distance = this._wordDistance.distance(T.position, T.completion), S.push(T), e.push(T.textLabel.length);
		}
		this._filteredItems = S.sort(this._snippetCompareFn), this._refilterKind = 0, this._stats = { pLabelLen: e.length ? quickSelect(e.length - .85, e, (e, _) => e - _) : 0 };
	}
	static _compareCompletionItems(e, _) {
		return e.score[0] > _.score[0] ? -1 : e.score[0] < _.score[0] ? 1 : e.distance < _.distance ? -1 : e.distance > _.distance ? 1 : e.idx < _.idx ? -1 : e.idx > _.idx ? 1 : 0;
	}
	static _compareCompletionItemsSnippetsDown(_, v) {
		if (_.completion.kind !== v.completion.kind) {
			if (_.completion.kind === 27) return 1;
			if (v.completion.kind === 27) return -1;
		}
		return e._compareCompletionItems(_, v);
	}
	static _compareCompletionItemsSnippetsUp(_, v) {
		if (_.completion.kind !== v.completion.kind) {
			if (_.completion.kind === 27) return -1;
			if (v.completion.kind === 27) return 1;
		}
		return e._compareCompletionItems(_, v);
	}
}, __decorate$55 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$55 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SuggestModel_1, LineContext$1 = class {
	static shouldAutoTrigger(e) {
		if (!e.hasModel()) return !1;
		let _ = e.getModel(), v = e.getPosition();
		_.tokenization.tokenizeIfCheap(v.lineNumber);
		let y = _.getWordAtPosition(v);
		return !(!y || y.endColumn !== v.column && y.startColumn + 1 !== v.column || !isNaN(Number(y.word)));
	}
	constructor(e, _, v) {
		this.leadingLineContent = e.getLineContent(_.lineNumber).substr(0, _.column - 1), this.leadingWord = e.getWordUntilPosition(_), this.lineNumber = _.lineNumber, this.column = _.column, this.triggerOptions = v;
	}
};
function canShowQuickSuggest(e, _, v) {
	if (!_.getContextKeyValue(InlineCompletionContextKeys.inlineSuggestionVisible.key)) return !0;
	let y = _.getContextKeyValue(InlineCompletionContextKeys.suppressSuggestions.key);
	return y === void 0 ? !e.getOption(62).suppressSuggestions : !y;
}
function canShowSuggestOnTriggerCharacters(e, _, v) {
	if (!_.getContextKeyValue("inlineSuggestionVisible")) return !0;
	let y = _.getContextKeyValue(InlineCompletionContextKeys.suppressSuggestions.key);
	return y === void 0 ? !e.getOption(62).suppressSuggestions : !y;
}
var SuggestModel = SuggestModel_1 = class {
	constructor(e, _, v, y, b, x, S, C, w) {
		this._editor = e, this._editorWorkerService = _, this._clipboardService = v, this._telemetryService = y, this._logService = b, this._contextKeyService = x, this._configurationService = S, this._languageFeaturesService = C, this._envService = w, this._toDispose = new DisposableStore(), this._triggerCharacterListener = new DisposableStore(), this._triggerQuickSuggest = new TimeoutTimer(), this._triggerState = void 0, this._completionDisposables = new DisposableStore(), this._onDidCancel = new Emitter(), this._onDidTrigger = new Emitter(), this._onDidSuggest = new Emitter(), this.onDidCancel = this._onDidCancel.event, this.onDidTrigger = this._onDidTrigger.event, this.onDidSuggest = this._onDidSuggest.event, this._telemetryGate = 0, this._currentSelection = this._editor.getSelection() || new Selection(1, 1, 1, 1), this._toDispose.add(this._editor.onDidChangeModel(() => {
			this._updateTriggerCharacters(), this.cancel();
		})), this._toDispose.add(this._editor.onDidChangeModelLanguage(() => {
			this._updateTriggerCharacters(), this.cancel();
		})), this._toDispose.add(this._editor.onDidChangeConfiguration(() => {
			this._updateTriggerCharacters();
		})), this._toDispose.add(this._languageFeaturesService.completionProvider.onDidChange(() => {
			this._updateTriggerCharacters(), this._updateActiveSuggestSession();
		}));
		let T = !1;
		this._toDispose.add(this._editor.onDidCompositionStart(() => {
			T = !0;
		})), this._toDispose.add(this._editor.onDidCompositionEnd(() => {
			T = !1, this._onCompositionEnd();
		})), this._toDispose.add(this._editor.onDidChangeCursorSelection((e) => {
			T || this._onCursorChange(e);
		})), this._toDispose.add(this._editor.onDidChangeModelContent(() => {
			!T && this._triggerState !== void 0 && this._refilterCompletionItems();
		})), this._updateTriggerCharacters();
	}
	dispose() {
		dispose(this._triggerCharacterListener), dispose([
			this._onDidCancel,
			this._onDidSuggest,
			this._onDidTrigger,
			this._triggerQuickSuggest
		]), this._toDispose.dispose(), this._completionDisposables.dispose(), this.cancel();
	}
	_updateTriggerCharacters() {
		if (this._triggerCharacterListener.clear(), this._editor.getOption(92) || !this._editor.hasModel() || !this._editor.getOption(122)) return;
		let e = /* @__PURE__ */ new Map();
		for (let _ of this._languageFeaturesService.completionProvider.all(this._editor.getModel())) for (let v of _.triggerCharacters || []) {
			let y = e.get(v);
			if (!y) {
				y = /* @__PURE__ */ new Set();
				let _ = getSnippetSuggestSupport();
				_ && y.add(_), e.set(v, y);
			}
			y.add(_);
		}
		let _ = (_) => {
			if (!canShowSuggestOnTriggerCharacters(this._editor, this._contextKeyService, this._configurationService) || LineContext$1.shouldAutoTrigger(this._editor)) return;
			if (!_) {
				let e = this._editor.getPosition();
				_ = this._editor.getModel().getLineContent(e.lineNumber).substr(0, e.column - 1);
			}
			let v = "";
			isLowSurrogate(_.charCodeAt(_.length - 1)) ? isHighSurrogate(_.charCodeAt(_.length - 2)) && (v = _.substr(_.length - 2)) : v = _.charAt(_.length - 1);
			let y = e.get(v);
			if (y) {
				let e = /* @__PURE__ */ new Map();
				if (this._completionModel) for (let [_, v] of this._completionModel.getItemsByProvider()) y.has(_) || e.set(_, v);
				this.trigger({
					auto: !0,
					triggerKind: 1,
					triggerCharacter: v,
					retrigger: !!this._completionModel,
					clipboardText: this._completionModel?.clipboardText,
					completionOptions: {
						providerFilter: y,
						providerItemsToReuse: e
					}
				});
			}
		};
		this._triggerCharacterListener.add(this._editor.onDidType(_)), this._triggerCharacterListener.add(this._editor.onDidCompositionEnd(() => _()));
	}
	get state() {
		return this._triggerState ? this._triggerState.auto ? 2 : 1 : 0;
	}
	cancel(e = !1) {
		this._triggerState !== void 0 && (this._triggerQuickSuggest.cancel(), this._requestToken?.cancel(), this._requestToken = void 0, this._triggerState = void 0, this._completionModel = void 0, this._context = void 0, this._onDidCancel.fire({ retrigger: e }));
	}
	clear() {
		this._completionDisposables.clear();
	}
	_updateActiveSuggestSession() {
		this._triggerState !== void 0 && (!this._editor.hasModel() || !this._languageFeaturesService.completionProvider.has(this._editor.getModel()) ? this.cancel() : this.trigger({
			auto: this._triggerState.auto,
			retrigger: !0
		}));
	}
	_onCursorChange(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._currentSelection;
		if (this._currentSelection = this._editor.getSelection(), !e.selection.isEmpty() || e.reason !== 0 && e.reason !== 3 || e.source !== "keyboard" && e.source !== "deleteLeft") {
			this.cancel();
			return;
		}
		this._triggerState === void 0 && e.reason === 0 ? (_.containsRange(this._currentSelection) || _.getEndPosition().isBeforeOrEqual(this._currentSelection.getPosition())) && this._doTriggerQuickSuggest() : this._triggerState !== void 0 && e.reason === 3 && this._refilterCompletionItems();
	}
	_onCompositionEnd() {
		this._triggerState === void 0 ? this._doTriggerQuickSuggest() : this._refilterCompletionItems();
	}
	_doTriggerQuickSuggest() {
		QuickSuggestionsOptions.isAllOff(this._editor.getOption(90)) || this._editor.getOption(119).snippetsPreventQuickSuggestions && SnippetController2.get(this._editor)?.isInSnippet() || (this.cancel(), this._triggerQuickSuggest.cancelAndSet(() => {
			if (this._triggerState !== void 0 || !LineContext$1.shouldAutoTrigger(this._editor) || !this._editor.hasModel() || !this._editor.hasWidgetFocus()) return;
			let e = this._editor.getModel(), _ = this._editor.getPosition(), v = this._editor.getOption(90);
			if (!QuickSuggestionsOptions.isAllOff(v)) {
				if (!QuickSuggestionsOptions.isAllOn(v)) {
					e.tokenization.tokenizeIfCheap(_.lineNumber);
					let y = e.tokenization.getLineTokens(_.lineNumber), b = y.getStandardTokenType(y.findTokenIndexAtOffset(Math.max(_.column - 1 - 1, 0)));
					if (QuickSuggestionsOptions.valueFor(v, b) !== "on") return;
				}
				canShowQuickSuggest(this._editor, this._contextKeyService, this._configurationService) && this._languageFeaturesService.completionProvider.has(e) && this.trigger({ auto: !0 });
			}
		}, this._editor.getOption(91)));
	}
	_refilterCompletionItems() {
		assertType(this._editor.hasModel()), assertType(this._triggerState !== void 0);
		let e = this._editor.getModel(), _ = this._editor.getPosition(), v = new LineContext$1(e, _, {
			...this._triggerState,
			refilter: !0
		});
		this._onNewContext(v);
	}
	trigger(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._editor.getModel(), v = new LineContext$1(_, this._editor.getPosition(), e);
		this.cancel(e.retrigger), this._triggerState = e, this._onDidTrigger.fire({
			auto: e.auto,
			shy: e.shy ?? !1,
			position: this._editor.getPosition()
		}), this._context = v;
		let y = { triggerKind: e.triggerKind ?? 0 };
		e.triggerCharacter && (y = {
			triggerKind: 1,
			triggerCharacter: e.triggerCharacter
		}), this._requestToken = new CancellationTokenSource();
		let b = this._editor.getOption(113), x = 1;
		switch (b) {
			case "top":
				x = 0;
				break;
			case "bottom":
				x = 2;
				break;
		}
		let { itemKind: S, showDeprecated: C } = SuggestModel_1.createSuggestFilter(this._editor), w = new CompletionOptions(x, e.completionOptions?.kindFilter ?? S, e.completionOptions?.providerFilter, e.completionOptions?.providerItemsToReuse, C), T = WordDistance.create(this._editorWorkerService, this._editor), E = provideSuggestionItems(this._languageFeaturesService.completionProvider, _, this._editor.getPosition(), w, y, this._requestToken.token);
		Promise.all([E, T]).then(async ([_, v]) => {
			if (this._requestToken?.dispose(), !this._editor.hasModel()) return;
			let y = e?.clipboardText;
			if (!y && _.needsClipboard && (y = await this._clipboardService.readText()), this._triggerState === void 0) return;
			let b = this._editor.getModel(), x = new LineContext$1(b, this._editor.getPosition(), e), S = {
				...FuzzyScoreOptions.default,
				firstMatchCanBeWeak: !this._editor.getOption(119).matchOnWordStartOnly
			};
			if (this._completionModel = new CompletionModel(_.items, this._context.column, {
				leadingLineContent: x.leadingLineContent,
				characterCountDelta: x.column - this._context.column
			}, v, this._editor.getOption(119), this._editor.getOption(113), S, y), this._completionDisposables.add(_.disposable), this._onNewContext(x), this._reportDurationsTelemetry(_.durations), !this._envService.isBuilt || this._envService.isExtensionDevelopment) for (let e of _.items) e.isInvalid && this._logService.warn(`[suggest] did IGNORE invalid completion item from ${e.provider._debugDisplayName}`, e.completion);
		}).catch(onUnexpectedError);
	}
	_reportDurationsTelemetry(e) {
		this._telemetryGate++ % 230 == 0 && setTimeout(() => {
			this._telemetryService.publicLog2("suggest.durations.json", { data: JSON.stringify(e) }), this._logService.debug("suggest.durations.json", e);
		});
	}
	static createSuggestFilter(e) {
		let _ = /* @__PURE__ */ new Set();
		e.getOption(113) === "none" && _.add(27);
		let v = e.getOption(119);
		return v.showMethods || _.add(0), v.showFunctions || _.add(1), v.showConstructors || _.add(2), v.showFields || _.add(3), v.showVariables || _.add(4), v.showClasses || _.add(5), v.showStructs || _.add(6), v.showInterfaces || _.add(7), v.showModules || _.add(8), v.showProperties || _.add(9), v.showEvents || _.add(10), v.showOperators || _.add(11), v.showUnits || _.add(12), v.showValues || _.add(13), v.showConstants || _.add(14), v.showEnums || _.add(15), v.showEnumMembers || _.add(16), v.showKeywords || _.add(17), v.showWords || _.add(18), v.showColors || _.add(19), v.showFiles || _.add(20), v.showReferences || _.add(21), v.showColors || _.add(22), v.showFolders || _.add(23), v.showTypeParameters || _.add(24), v.showSnippets || _.add(27), v.showUsers || _.add(25), v.showIssues || _.add(26), {
			itemKind: _,
			showDeprecated: v.showDeprecated
		};
	}
	_onNewContext(e) {
		if (this._context) {
			if (e.lineNumber !== this._context.lineNumber) {
				this.cancel();
				return;
			}
			if (getLeadingWhitespace(e.leadingLineContent) !== getLeadingWhitespace(this._context.leadingLineContent)) {
				this.cancel();
				return;
			}
			if (e.column < this._context.column) {
				e.leadingWord.word ? this.trigger({
					auto: this._context.triggerOptions.auto,
					retrigger: !0
				}) : this.cancel();
				return;
			}
			if (this._completionModel) {
				if (e.leadingWord.word.length !== 0 && e.leadingWord.startColumn > this._context.leadingWord.startColumn) {
					if (LineContext$1.shouldAutoTrigger(this._editor) && this._context) {
						let e = this._completionModel.getItemsByProvider();
						this.trigger({
							auto: this._context.triggerOptions.auto,
							retrigger: !0,
							clipboardText: this._completionModel.clipboardText,
							completionOptions: { providerItemsToReuse: e }
						});
					}
					return;
				}
				if (e.column > this._context.column && this._completionModel.getIncompleteProvider().size > 0 && e.leadingWord.word.length !== 0) {
					let e = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Set();
					for (let [v, y] of this._completionModel.getItemsByProvider()) y.length > 0 && y[0].container.incomplete ? _.add(v) : e.set(v, y);
					this.trigger({
						auto: this._context.triggerOptions.auto,
						triggerKind: 2,
						retrigger: !0,
						clipboardText: this._completionModel.clipboardText,
						completionOptions: {
							providerFilter: _,
							providerItemsToReuse: e
						}
					});
				} else {
					let _ = this._completionModel.lineContext, v = !1;
					if (this._completionModel.lineContext = {
						leadingLineContent: e.leadingLineContent,
						characterCountDelta: e.column - this._context.column
					}, this._completionModel.items.length === 0) {
						let y = LineContext$1.shouldAutoTrigger(this._editor);
						if (!this._context) {
							this.cancel();
							return;
						}
						if (y && this._context.leadingWord.endColumn < e.leadingWord.startColumn) {
							this.trigger({
								auto: this._context.triggerOptions.auto,
								retrigger: !0
							});
							return;
						}
						if (this._context.triggerOptions.auto) {
							this.cancel();
							return;
						} else if (this._completionModel.lineContext = _, v = this._completionModel.items.length > 0, v && e.leadingWord.word.length === 0) {
							this.cancel();
							return;
						}
					}
					this._onDidSuggest.fire({
						completionModel: this._completionModel,
						triggerOptions: e.triggerOptions,
						isFrozen: v
					});
				}
			}
		}
	}
};
SuggestModel = SuggestModel_1 = __decorate$55([
	__param$55(1, IEditorWorkerService),
	__param$55(2, IClipboardService),
	__param$55(3, ITelemetryService),
	__param$55(4, ILogService),
	__param$55(5, IContextKeyService),
	__param$55(6, IConfigurationService),
	__param$55(7, ILanguageFeaturesService),
	__param$55(8, IEnvironmentService)
], SuggestModel);
var OvertypingCapturer = class e {
	static {
		this._maxSelectionLength = 51200;
	}
	constructor(_, v) {
		this._disposables = new DisposableStore(), this._lastOvertyped = [], this._locked = !1, this._disposables.add(_.onWillType(() => {
			if (this._locked || !_.hasModel()) return;
			let v = _.getSelections(), y = v.length, b = !1;
			for (let e = 0; e < y; e++) if (!v[e].isEmpty()) {
				b = !0;
				break;
			}
			if (!b) {
				this._lastOvertyped.length !== 0 && (this._lastOvertyped.length = 0);
				return;
			}
			this._lastOvertyped = [];
			let x = _.getModel();
			for (let _ = 0; _ < y; _++) {
				let y = v[_];
				if (x.getValueLengthInRange(y) > e._maxSelectionLength) return;
				this._lastOvertyped[_] = {
					value: x.getValueInRange(y),
					multiline: y.startLineNumber !== y.endLineNumber
				};
			}
		})), this._disposables.add(v.onDidTrigger((e) => {
			this._locked = !0;
		})), this._disposables.add(v.onDidCancel((e) => {
			this._locked = !1;
		}));
	}
	getLastOvertypedInfo(e) {
		if (e >= 0 && e < this._lastOvertyped.length) return this._lastOvertyped[e];
	}
	dispose() {
		this._disposables.dispose();
	}
}, __decorate$54 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$54 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SuggestWidgetStatus = class {
	constructor(e, _, v, y, b) {
		this._menuId = _, this._menuService = y, this._contextKeyService = b, this._menuDisposables = new DisposableStore(), this.element = append(e, $(".suggest-status-bar"));
		let x = ((e) => e instanceof MenuItemAction ? v.createInstance(TextOnlyMenuEntryActionViewItem, e, { useComma: !0 }) : void 0);
		this._leftActions = new ActionBar(this.element, { actionViewItemProvider: x }), this._rightActions = new ActionBar(this.element, { actionViewItemProvider: x }), this._leftActions.domNode.classList.add("left"), this._rightActions.domNode.classList.add("right");
	}
	dispose() {
		this._menuDisposables.dispose(), this._leftActions.dispose(), this._rightActions.dispose(), this.element.remove();
	}
	show() {
		let e = this._menuService.createMenu(this._menuId, this._contextKeyService), _ = () => {
			let _ = [], v = [];
			for (let [y, b] of e.getActions()) y === "left" ? _.push(...b) : v.push(...b);
			this._leftActions.clear(), this._leftActions.push(_), this._rightActions.clear(), this._rightActions.push(v);
		};
		this._menuDisposables.add(e.onDidChange(() => _())), this._menuDisposables.add(e);
	}
	hide() {
		this._menuDisposables.clear();
	}
};
SuggestWidgetStatus = __decorate$54([
	__param$54(2, IInstantiationService),
	__param$54(3, IMenuService),
	__param$54(4, IContextKeyService)
], SuggestWidgetStatus);
var __decorate$53 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$53 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
function canExpandCompletionItem(e) {
	return !!e && !!(e.completion.documentation || e.completion.detail && e.completion.detail !== e.completion.label);
}
var SuggestDetailsWidget = class {
	constructor(e, _) {
		this._editor = e, this._onDidClose = new Emitter(), this.onDidClose = this._onDidClose.event, this._onDidChangeContents = new Emitter(), this.onDidChangeContents = this._onDidChangeContents.event, this._disposables = new DisposableStore(), this._renderDisposeable = new DisposableStore(), this._borderWidth = 1, this._size = new Dimension(330, 0), this.domNode = $(".suggest-details"), this.domNode.classList.add("no-docs"), this._markdownRenderer = _.createInstance(MarkdownRenderer, { editor: e }), this._body = $(".body"), this._scrollbar = new DomScrollableElement(this._body, { alwaysConsumeMouseWheel: !0 }), append(this.domNode, this._scrollbar.getDomNode()), this._disposables.add(this._scrollbar), this._header = append(this._body, $(".header")), this._close = append(this._header, $("span" + ThemeIcon.asCSSSelector(Codicon.close))), this._close.title = localize("details.close", "Close"), this._type = append(this._header, $("p.type")), this._docs = append(this._body, $("p.docs")), this._configureFont(), this._disposables.add(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(50) && this._configureFont();
		}));
	}
	dispose() {
		this._disposables.dispose(), this._renderDisposeable.dispose();
	}
	_configureFont() {
		let e = this._editor.getOptions(), _ = e.get(50), v = _.getMassagedFontFamily(), y = e.get(120) || _.fontSize, b = e.get(121) || _.lineHeight, x = _.fontWeight, S = `${y}px`, C = `${b}px`;
		this.domNode.style.fontSize = S, this.domNode.style.lineHeight = `${b / y}`, this.domNode.style.fontWeight = x, this.domNode.style.fontFeatureSettings = _.fontFeatureSettings, this._type.style.fontFamily = v, this._close.style.height = C, this._close.style.width = C;
	}
	getLayoutInfo() {
		let e = this._editor.getOption(121) || this._editor.getOption(50).lineHeight, _ = this._borderWidth, v = _ * 2;
		return {
			lineHeight: e,
			borderWidth: _,
			borderHeight: v,
			verticalPadding: 22,
			horizontalPadding: 14
		};
	}
	renderLoading() {
		this._type.textContent = localize("loading", "Loading..."), this._docs.textContent = "", this.domNode.classList.remove("no-docs", "no-type"), this.layout(this.size.width, this.getLayoutInfo().lineHeight * 2), this._onDidChangeContents.fire(this);
	}
	renderItem(e, _) {
		this._renderDisposeable.clear();
		let { detail: v, documentation: y } = e.completion;
		if (_) {
			let _ = "";
			_ += `score: ${e.score[0]}\n`, _ += `prefix: ${e.word ?? "(no prefix)"}\n`, _ += `word: ${e.completion.filterText ? e.completion.filterText + " (filterText)" : e.textLabel}\n`, _ += `distance: ${e.distance} (localityBonus-setting)\n`, _ += `index: ${e.idx}, based on ${e.completion.sortText && `sortText: "${e.completion.sortText}"` || "label"}\n`, _ += `commit_chars: ${e.completion.commitCharacters?.join("")}\n`, y = new MarkdownString().appendCodeblock("empty", _), v = `Provider: ${e.provider._debugDisplayName}`;
		}
		if (!_ && !canExpandCompletionItem(e)) {
			this.clearContents();
			return;
		}
		if (this.domNode.classList.remove("no-docs", "no-type"), v) {
			let e = v.length > 1e5 ? `${v.substr(0, 1e5)}…` : v;
			this._type.textContent = e, this._type.title = e, show(this._type), this._type.classList.toggle("auto-wrap", !/\r?\n^\s+/gim.test(e));
		} else clearNode(this._type), this._type.title = "", hide(this._type), this.domNode.classList.add("no-type");
		if (clearNode(this._docs), typeof y == "string") this._docs.classList.remove("markdown-docs"), this._docs.textContent = y;
		else if (y) {
			this._docs.classList.add("markdown-docs"), clearNode(this._docs);
			let e = this._markdownRenderer.render(y);
			this._docs.appendChild(e.element), this._renderDisposeable.add(e), this._renderDisposeable.add(this._markdownRenderer.onDidRenderAsync(() => {
				this.layout(this._size.width, this._type.clientHeight + this._docs.clientHeight), this._onDidChangeContents.fire(this);
			}));
		}
		this.domNode.style.userSelect = "text", this.domNode.tabIndex = -1, this._close.onmousedown = (e) => {
			e.preventDefault(), e.stopPropagation();
		}, this._close.onclick = (e) => {
			e.preventDefault(), e.stopPropagation(), this._onDidClose.fire();
		}, this._body.scrollTop = 0, this.layout(this._size.width, this._type.clientHeight + this._docs.clientHeight), this._onDidChangeContents.fire(this);
	}
	clearContents() {
		this.domNode.classList.add("no-docs"), this._type.textContent = "", this._docs.textContent = "";
	}
	get isEmpty() {
		return this.domNode.classList.contains("no-docs");
	}
	get size() {
		return this._size;
	}
	layout(e, _) {
		let v = new Dimension(e, _);
		Dimension.equals(v, this._size) || (this._size = v, size(this.domNode, e, _)), this._scrollbar.scanDomNode();
	}
	scrollDown(e = 8) {
		this._body.scrollTop += e;
	}
	scrollUp(e = 8) {
		this._body.scrollTop -= e;
	}
	scrollTop() {
		this._body.scrollTop = 0;
	}
	scrollBottom() {
		this._body.scrollTop = this._body.scrollHeight;
	}
	pageDown() {
		this.scrollDown(80);
	}
	pageUp() {
		this.scrollUp(80);
	}
	set borderWidth(e) {
		this._borderWidth = e;
	}
	get borderWidth() {
		return this._borderWidth;
	}
};
SuggestDetailsWidget = __decorate$53([__param$53(1, IInstantiationService)], SuggestDetailsWidget);
var SuggestDetailsOverlay = class {
	constructor(e, _) {
		this.widget = e, this._editor = _, this.allowEditorOverflow = !0, this._disposables = new DisposableStore(), this._added = !1, this._preferAlignAtTop = !0, this._resizable = new ResizableHTMLElement(), this._resizable.domNode.classList.add("suggest-details-container"), this._resizable.domNode.appendChild(e.domNode), this._resizable.enableSashes(!1, !0, !0, !1);
		let v, y, b = 0, x = 0;
		this._disposables.add(this._resizable.onDidWillResize(() => {
			v = this._topLeft, y = this._resizable.size;
		})), this._disposables.add(this._resizable.onDidResize((e) => {
			if (v && y) {
				this.widget.layout(e.dimension.width, e.dimension.height);
				let _ = !1;
				e.west && (x = y.width - e.dimension.width, _ = !0), e.north && (b = y.height - e.dimension.height, _ = !0), _ && this._applyTopLeft({
					top: v.top + b,
					left: v.left + x
				});
			}
			e.done && (v = void 0, y = void 0, b = 0, x = 0, this._userSize = e.dimension);
		})), this._disposables.add(this.widget.onDidChangeContents(() => {
			this._anchorBox && this._placeAtAnchor(this._anchorBox, this._userSize ?? this.widget.size, this._preferAlignAtTop);
		}));
	}
	dispose() {
		this._resizable.dispose(), this._disposables.dispose(), this.hide();
	}
	getId() {
		return "suggest.details";
	}
	getDomNode() {
		return this._resizable.domNode;
	}
	getPosition() {
		return this._topLeft ? { preference: this._topLeft } : null;
	}
	show() {
		this._added ||= (this._editor.addOverlayWidget(this), !0);
	}
	hide(e = !1) {
		this._resizable.clearSashHoverState(), this._added && (this._editor.removeOverlayWidget(this), this._added = !1, this._anchorBox = void 0, this._topLeft = void 0), e && (this._userSize = void 0, this.widget.clearContents());
	}
	placeAtAnchor(e, _) {
		this._anchorBox = e.getBoundingClientRect(), this._preferAlignAtTop = _, this._placeAtAnchor(this._anchorBox, this._userSize ?? this.widget.size, _);
	}
	_placeAtAnchor(e, _, v) {
		let y = getClientArea(this.getDomNode().ownerDocument.body), b = this.widget.getLayoutInfo(), x = new Dimension(220, 2 * b.lineHeight), S = e.top, C = (function() {
			let v = y.width - (e.left + e.width + b.borderWidth + b.horizontalPadding), C = -b.borderWidth + e.left + e.width, w = new Dimension(v, y.height - e.top - b.borderHeight - b.verticalPadding), T = w.with(void 0, e.top + e.height - b.borderHeight - b.verticalPadding);
			return {
				top: S,
				left: C,
				fit: v - _.width,
				maxSizeTop: w,
				maxSizeBottom: T,
				minSize: x.with(Math.min(v, x.width))
			};
		})(), w = (function() {
			let v = e.left - b.borderWidth - b.horizontalPadding, C = Math.max(b.horizontalPadding, e.left - _.width - b.borderWidth), w = new Dimension(v, y.height - e.top - b.borderHeight - b.verticalPadding), T = w.with(void 0, e.top + e.height - b.borderHeight - b.verticalPadding);
			return {
				top: S,
				left: C,
				fit: v - _.width,
				maxSizeTop: w,
				maxSizeBottom: T,
				minSize: x.with(Math.min(v, x.width))
			};
		})(), T = (function() {
			let v = e.left, S = -b.borderWidth + e.top + e.height, C = new Dimension(e.width - b.borderHeight, y.height - e.top - e.height - b.verticalPadding);
			return {
				top: S,
				left: v,
				fit: C.height - _.height,
				maxSizeBottom: C,
				maxSizeTop: C,
				minSize: x.with(C.width)
			};
		})(), E = [
			C,
			w,
			T
		], D = E.find((e) => e.fit >= 0) ?? E.sort((e, _) => _.fit - e.fit)[0], O = e.top + e.height - b.borderHeight, k, A = _.height, j = Math.max(D.maxSizeTop.height, D.maxSizeBottom.height);
		A > j && (A = j);
		let M;
		v ? A <= D.maxSizeTop.height ? (k = !0, M = D.maxSizeTop) : (k = !1, M = D.maxSizeBottom) : A <= D.maxSizeBottom.height ? (k = !1, M = D.maxSizeBottom) : (k = !0, M = D.maxSizeTop);
		let { top: N, left: P } = D;
		!k && A > e.height && (N = O - A);
		let F = this._editor.getDomNode();
		if (F) {
			let e = F.getBoundingClientRect();
			N -= e.top, P -= e.left;
		}
		this._applyTopLeft({
			left: P,
			top: N
		}), this._resizable.enableSashes(!k, D === C, k, D !== C), this._resizable.minSize = D.minSize, this._resizable.maxSize = M, this._resizable.layout(A, Math.min(M.width, _.width)), this.widget.layout(this._resizable.size.width, this._resizable.size.height);
	}
	_applyTopLeft(e) {
		this._topLeft = e, this._editor.layoutOverlayWidget(this);
	}
}, FileKind;
(function(e) {
	e[e.FILE = 0] = "FILE", e[e.FOLDER = 1] = "FOLDER", e[e.ROOT_FOLDER = 2] = "ROOT_FOLDER";
})(FileKind ||= {});
var fileIconDirectoryRegex = /(?:\/|^)(?:([^\/]+)\/)?([^\/]+)$/;
function getIconClasses(e, _, v, y, b) {
	if (ThemeIcon.isThemeIcon(b)) return [`codicon-${b.id}`, "predefined-file-icon"];
	if (URI.isUri(b)) return [];
	let x = y === FileKind.ROOT_FOLDER ? ["rootfolder-icon"] : y === FileKind.FOLDER ? ["folder-icon"] : ["file-icon"];
	if (v) {
		let b;
		if (v.scheme === Schemas.data) b = DataUri.parseMetaData(v).get(DataUri.META_DATA_LABEL);
		else {
			let e = v.path.match(fileIconDirectoryRegex);
			e ? (b = cssEscape(e[2].toLowerCase()), e[1] && x.push(`${cssEscape(e[1].toLowerCase())}-name-dir-icon`)) : b = cssEscape(v.authority.toLowerCase());
		}
		if (y === FileKind.ROOT_FOLDER) x.push(`${b}-root-name-folder-icon`);
		else if (y === FileKind.FOLDER) x.push(`${b}-name-folder-icon`);
		else {
			if (b) {
				if (x.push(`${b}-name-file-icon`), x.push("name-file-icon"), b.length <= 255) {
					let e = b.split(".");
					for (let _ = 1; _ < e.length; _++) x.push(`${e.slice(_).join(".")}-ext-file-icon`);
				}
				x.push("ext-file-icon");
			}
			let y = detectLanguageId(e, _, v);
			y && x.push(`${cssEscape(y)}-lang-file-icon`);
		}
	}
	return x;
}
function detectLanguageId(e, _, v) {
	if (!v) return null;
	let y = null;
	if (v.scheme === Schemas.data) {
		let e = DataUri.parseMetaData(v).get(DataUri.META_DATA_MIME);
		e && (y = _.getLanguageIdByMimeType(e));
	} else {
		let _ = e.getModel(v);
		_ && (y = _.getLanguageId());
	}
	return y && y !== "plaintext" ? y : _.guessLanguageIdByFilepathOrFirstLine(v);
}
function cssEscape(e) {
	return e.replace(/[\s]/g, "/");
}
var __decorate$52 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$52 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
function getAriaId(e) {
	return `suggest-aria-id:${e}`;
}
var suggestMoreInfoIcon = registerIcon("suggest-more-info", Codicon.chevronRight, localize("suggestMoreInfoIcon", "Icon for more information in the suggest widget.")), _completionItemColor = new class e {
	static {
		this._regexRelaxed = /(#([\da-fA-F]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))/;
	}
	static {
		this._regexStrict = RegExp(`^${e._regexRelaxed.source}$`, "i");
	}
	extract(_, v) {
		if (_.textLabel.match(e._regexStrict)) return v[0] = _.textLabel, !0;
		if (_.completion.detail && _.completion.detail.match(e._regexStrict)) return v[0] = _.completion.detail, !0;
		if (_.completion.documentation) {
			let y = typeof _.completion.documentation == "string" ? _.completion.documentation : _.completion.documentation.value, b = e._regexRelaxed.exec(y);
			if (b && (b.index === 0 || b.index + b[0].length === y.length)) return v[0] = b[0], !0;
		}
		return !1;
	}
}(), ItemRenderer = class {
	constructor(e, _, v, y) {
		this._editor = e, this._modelService = _, this._languageService = v, this._themeService = y, this._onDidToggleDetails = new Emitter(), this.onDidToggleDetails = this._onDidToggleDetails.event, this.templateId = "suggestion";
	}
	dispose() {
		this._onDidToggleDetails.dispose();
	}
	renderTemplate(e) {
		let _ = new DisposableStore(), v = e;
		v.classList.add("show-file-icons");
		let y = append(e, $(".icon")), b = append(y, $("span.colorspan")), x = append(e, $(".contents")), S = append(x, $(".main")), C = append(S, $(".icon-label.codicon")), w = append(S, $("span.left")), T = append(S, $("span.right")), E = new IconLabel(w, {
			supportHighlights: !0,
			supportIcons: !0
		});
		_.add(E);
		let D = append(w, $("span.signature-label")), O = append(w, $("span.qualifier-label")), k = append(T, $("span.details-label")), A = append(T, $("span.readMore" + ThemeIcon.asCSSSelector(suggestMoreInfoIcon)));
		return A.title = localize("readMore", "Read More"), {
			root: v,
			left: w,
			right: T,
			icon: y,
			colorspan: b,
			iconLabel: E,
			iconContainer: C,
			parametersLabel: D,
			qualifierLabel: O,
			detailsLabel: k,
			readMore: A,
			disposables: _,
			configureFont: () => {
				let e = this._editor.getOptions(), _ = e.get(50), b = _.getMassagedFontFamily(), x = _.fontFeatureSettings, C = e.get(120) || _.fontSize, w = e.get(121) || _.lineHeight, T = _.fontWeight, E = _.letterSpacing, D = `${C}px`, O = `${w}px`, k = `${E}px`;
				v.style.fontSize = D, v.style.fontWeight = T, v.style.letterSpacing = k, S.style.fontFamily = b, S.style.fontFeatureSettings = x, S.style.lineHeight = O, y.style.height = O, y.style.width = O, A.style.height = O, A.style.width = O;
			}
		};
	}
	renderElement(e, _, v) {
		v.configureFont();
		let { completion: y } = e;
		v.root.id = getAriaId(_), v.colorspan.style.backgroundColor = "";
		let b = {
			labelEscapeNewLines: !0,
			matches: createMatches(e.score)
		}, x = [];
		if (y.kind === 19 && _completionItemColor.extract(e, x)) v.icon.className = "icon customcolor", v.iconContainer.className = "icon hide", v.colorspan.style.backgroundColor = x[0];
		else if (y.kind === 20 && this._themeService.getFileIconTheme().hasFileIcons) {
			v.icon.className = "icon hide", v.iconContainer.className = "icon hide";
			let _ = getIconClasses(this._modelService, this._languageService, URI.from({
				scheme: "fake",
				path: e.textLabel
			}), FileKind.FILE), x = getIconClasses(this._modelService, this._languageService, URI.from({
				scheme: "fake",
				path: y.detail
			}), FileKind.FILE);
			b.extraClasses = _.length > x.length ? _ : x;
		} else y.kind === 23 && this._themeService.getFileIconTheme().hasFolderIcons ? (v.icon.className = "icon hide", v.iconContainer.className = "icon hide", b.extraClasses = [getIconClasses(this._modelService, this._languageService, URI.from({
			scheme: "fake",
			path: e.textLabel
		}), FileKind.FOLDER), getIconClasses(this._modelService, this._languageService, URI.from({
			scheme: "fake",
			path: y.detail
		}), FileKind.FOLDER)].flat()) : (v.icon.className = "icon hide", v.iconContainer.className = "", v.iconContainer.classList.add("suggest-icon", ...ThemeIcon.asClassNameArray(CompletionItemKinds.toIcon(y.kind))));
		y.tags && y.tags.indexOf(1) >= 0 && (b.extraClasses = (b.extraClasses || []).concat(["deprecated"]), b.matches = []), v.iconLabel.setLabel(e.textLabel, void 0, b), typeof y.label == "string" ? (v.parametersLabel.textContent = "", v.detailsLabel.textContent = stripNewLines(y.detail || ""), v.root.classList.add("string-label")) : (v.parametersLabel.textContent = stripNewLines(y.label.detail || ""), v.detailsLabel.textContent = stripNewLines(y.label.description || ""), v.root.classList.remove("string-label")), this._editor.getOption(119).showInlineDetails ? show(v.detailsLabel) : hide(v.detailsLabel), canExpandCompletionItem(e) ? (v.right.classList.add("can-expand-details"), show(v.readMore), v.readMore.onmousedown = (e) => {
			e.stopPropagation(), e.preventDefault();
		}, v.readMore.onclick = (e) => {
			e.stopPropagation(), e.preventDefault(), this._onDidToggleDetails.fire();
		}) : (v.right.classList.remove("can-expand-details"), hide(v.readMore), v.readMore.onmousedown = null, v.readMore.onclick = null);
	}
	disposeTemplate(e) {
		e.disposables.dispose();
	}
};
ItemRenderer = __decorate$52([
	__param$52(1, IModelService),
	__param$52(2, ILanguageService),
	__param$52(3, IThemeService)
], ItemRenderer);
function stripNewLines(e) {
	return e.replace(/\r\n|\r|\n/g, "");
}
var __decorate$51 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$51 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SuggestWidget_1;
registerColor("editorSuggestWidget.background", editorWidgetBackground, localize("editorSuggestWidgetBackground", "Background color of the suggest widget.")), registerColor("editorSuggestWidget.border", editorWidgetBorder, localize("editorSuggestWidgetBorder", "Border color of the suggest widget."));
var editorSuggestWidgetForeground = registerColor("editorSuggestWidget.foreground", editorForeground, localize("editorSuggestWidgetForeground", "Foreground color of the suggest widget."));
registerColor("editorSuggestWidget.selectedForeground", quickInputListFocusForeground, localize("editorSuggestWidgetSelectedForeground", "Foreground color of the selected entry in the suggest widget.")), registerColor("editorSuggestWidget.selectedIconForeground", quickInputListFocusIconForeground, localize("editorSuggestWidgetSelectedIconForeground", "Icon foreground color of the selected entry in the suggest widget."));
const editorSuggestWidgetSelectedBackground = registerColor("editorSuggestWidget.selectedBackground", quickInputListFocusBackground, localize("editorSuggestWidgetSelectedBackground", "Background color of the selected entry in the suggest widget."));
registerColor("editorSuggestWidget.highlightForeground", listHighlightForeground, localize("editorSuggestWidgetHighlightForeground", "Color of the match highlights in the suggest widget.")), registerColor("editorSuggestWidget.focusHighlightForeground", listFocusHighlightForeground, localize("editorSuggestWidgetFocusHighlightForeground", "Color of the match highlights in the suggest widget when an item is focused.")), registerColor("editorSuggestWidgetStatus.foreground", transparent(editorSuggestWidgetForeground, .5), localize("editorSuggestWidgetStatusForeground", "Foreground color of the suggest widget status."));
var PersistedWidgetSize = class {
	constructor(e, _) {
		this._service = e, this._key = `suggestWidget.size/${_.getEditorType()}/${_ instanceof EmbeddedCodeEditorWidget}`;
	}
	restore() {
		let e = this._service.get(this._key, 0) ?? "";
		try {
			let _ = JSON.parse(e);
			if (Dimension.is(_)) return Dimension.lift(_);
		} catch {}
	}
	store(e) {
		this._service.store(this._key, JSON.stringify(e), 0, 1);
	}
	reset() {
		this._service.remove(this._key, 0);
	}
}, SuggestWidget = class {
	static {
		SuggestWidget_1 = this;
	}
	static {
		this.LOADING_MESSAGE = localize("suggestWidget.loading", "Loading...");
	}
	static {
		this.NO_SUGGESTIONS_MESSAGE = localize("suggestWidget.noSuggestions", "No suggestions.");
	}
	constructor(e, _, v, y, b) {
		this.editor = e, this._storageService = _, this._state = 0, this._isAuto = !1, this._pendingLayout = new MutableDisposable(), this._pendingShowDetails = new MutableDisposable(), this._ignoreFocusEvents = !1, this._forceRenderingAbove = !1, this._explainMode = !1, this._showTimeout = new TimeoutTimer(), this._disposables = new DisposableStore(), this._onDidSelect = new PauseableEmitter(), this._onDidFocus = new PauseableEmitter(), this._onDidHide = new Emitter(), this._onDidShow = new Emitter(), this.onDidSelect = this._onDidSelect.event, this.onDidFocus = this._onDidFocus.event, this.onDidHide = this._onDidHide.event, this.onDidShow = this._onDidShow.event, this._onDetailsKeydown = new Emitter(), this.onDetailsKeyDown = this._onDetailsKeydown.event, this.element = new ResizableHTMLElement(), this.element.domNode.classList.add("editor-widget", "suggest-widget"), this._contentWidget = new SuggestContentWidget(this, e), this._persistedSize = new PersistedWidgetSize(_, e);
		class x {
			constructor(e, _, v = !1, y = !1) {
				this.persistedSize = e, this.currentSize = _, this.persistHeight = v, this.persistWidth = y;
			}
		}
		let S;
		this._disposables.add(this.element.onDidWillResize(() => {
			this._contentWidget.lockPreference(), S = new x(this._persistedSize.restore(), this.element.size);
		})), this._disposables.add(this.element.onDidResize((e) => {
			if (this._resize(e.dimension.width, e.dimension.height), S && (S.persistHeight = S.persistHeight || !!e.north || !!e.south, S.persistWidth = S.persistWidth || !!e.east || !!e.west), e.done) {
				if (S) {
					let { itemHeight: e, defaultSize: _ } = this.getLayoutInfo(), v = Math.round(e / 2), { width: y, height: b } = this.element.size;
					(!S.persistHeight || Math.abs(S.currentSize.height - b) <= v) && (b = S.persistedSize?.height ?? _.height), (!S.persistWidth || Math.abs(S.currentSize.width - y) <= v) && (y = S.persistedSize?.width ?? _.width), this._persistedSize.store(new Dimension(y, b));
				}
				this._contentWidget.unlockPreference(), S = void 0;
			}
		})), this._messageElement = append(this.element.domNode, $(".message")), this._listElement = append(this.element.domNode, $(".tree"));
		let C = this._disposables.add(b.createInstance(SuggestDetailsWidget, this.editor));
		C.onDidClose(this.toggleDetails, this, this._disposables), this._details = new SuggestDetailsOverlay(C, this.editor);
		let w = () => this.element.domNode.classList.toggle("no-icons", !this.editor.getOption(119).showIcons);
		w();
		let T = b.createInstance(ItemRenderer, this.editor);
		this._disposables.add(T), this._disposables.add(T.onDidToggleDetails(() => this.toggleDetails())), this._list = new List("SuggestWidget", this._listElement, {
			getHeight: (e) => this.getLayoutInfo().itemHeight,
			getTemplateId: (e) => "suggestion"
		}, [T], {
			alwaysConsumeMouseWheel: !0,
			useShadows: !1,
			mouseSupport: !1,
			multipleSelectionSupport: !1,
			accessibilityProvider: {
				getRole: () => "option",
				getWidgetAriaLabel: () => localize("suggest", "Suggest"),
				getWidgetRole: () => "listbox",
				getAriaLabel: (e) => {
					let _ = e.textLabel;
					if (typeof e.completion.label != "string") {
						let { detail: v, description: y } = e.completion.label;
						v && y ? _ = localize("label.full", "{0} {1}, {2}", _, v, y) : v ? _ = localize("label.detail", "{0} {1}", _, v) : y && (_ = localize("label.desc", "{0}, {1}", _, y));
					}
					if (!e.isResolved || !this._isDetailsVisible()) return _;
					let { documentation: v, detail: y } = e.completion, b = format("{0}{1}", y || "", v ? typeof v == "string" ? v : v.value : "");
					return localize("ariaCurrenttSuggestionReadDetails", "{0}, docs: {1}", _, b);
				}
			}
		}), this._list.style(getListStyles({
			listInactiveFocusBackground: editorSuggestWidgetSelectedBackground,
			listInactiveFocusOutline: activeContrastBorder
		})), this._status = b.createInstance(SuggestWidgetStatus, this.element.domNode, suggestWidgetStatusbarMenu);
		let E = () => this.element.domNode.classList.toggle("with-status-bar", this.editor.getOption(119).showStatusBar);
		E(), this._disposables.add(y.onDidColorThemeChange((e) => this._onThemeChange(e))), this._onThemeChange(y.getColorTheme()), this._disposables.add(this._list.onMouseDown((e) => this._onListMouseDownOrTap(e))), this._disposables.add(this._list.onTap((e) => this._onListMouseDownOrTap(e))), this._disposables.add(this._list.onDidChangeSelection((e) => this._onListSelection(e))), this._disposables.add(this._list.onDidChangeFocus((e) => this._onListFocus(e))), this._disposables.add(this.editor.onDidChangeCursorSelection(() => this._onCursorSelectionChanged())), this._disposables.add(this.editor.onDidChangeConfiguration((e) => {
			e.hasChanged(119) && (E(), w()), this._completionModel && (e.hasChanged(50) || e.hasChanged(120) || e.hasChanged(121)) && this._list.splice(0, this._list.length, this._completionModel.items);
		})), this._ctxSuggestWidgetVisible = Context$1.Visible.bindTo(v), this._ctxSuggestWidgetDetailsVisible = Context$1.DetailsVisible.bindTo(v), this._ctxSuggestWidgetMultipleSuggestions = Context$1.MultipleSuggestions.bindTo(v), this._ctxSuggestWidgetHasFocusedSuggestion = Context$1.HasFocusedSuggestion.bindTo(v), this._disposables.add(addStandardDisposableListener(this._details.widget.domNode, "keydown", (e) => {
			this._onDetailsKeydown.fire(e);
		})), this._disposables.add(this.editor.onMouseDown((e) => this._onEditorMouseDown(e)));
	}
	dispose() {
		this._details.widget.dispose(), this._details.dispose(), this._list.dispose(), this._status.dispose(), this._disposables.dispose(), this._loadingTimeout?.dispose(), this._pendingLayout.dispose(), this._pendingShowDetails.dispose(), this._showTimeout.dispose(), this._contentWidget.dispose(), this.element.dispose();
	}
	_onEditorMouseDown(e) {
		this._details.widget.domNode.contains(e.target.element) ? this._details.widget.domNode.focus() : this.element.domNode.contains(e.target.element) && this.editor.focus();
	}
	_onCursorSelectionChanged() {
		this._state !== 0 && this._contentWidget.layout();
	}
	_onListMouseDownOrTap(e) {
		e.element === void 0 || e.index === void 0 || (e.browserEvent.preventDefault(), e.browserEvent.stopPropagation(), this._select(e.element, e.index));
	}
	_onListSelection(e) {
		e.elements.length && this._select(e.elements[0], e.indexes[0]);
	}
	_select(e, _) {
		let v = this._completionModel;
		v && (this._onDidSelect.fire({
			item: e,
			index: _,
			model: v
		}), this.editor.focus());
	}
	_onThemeChange(e) {
		this._details.widget.borderWidth = isHighContrast(e.type) ? 2 : 1;
	}
	_onListFocus(e) {
		if (this._ignoreFocusEvents) return;
		if (!e.elements.length) {
			this._currentSuggestionDetails && (this._currentSuggestionDetails.cancel(), this._currentSuggestionDetails = void 0, this._focusedItem = void 0), this.editor.setAriaOptions({ activeDescendant: void 0 }), this._ctxSuggestWidgetHasFocusedSuggestion.set(!1);
			return;
		}
		if (!this._completionModel) return;
		this._ctxSuggestWidgetHasFocusedSuggestion.set(!0);
		let _ = e.elements[0], v = e.indexes[0];
		_ !== this._focusedItem && (this._currentSuggestionDetails?.cancel(), this._currentSuggestionDetails = void 0, this._focusedItem = _, this._list.reveal(v), this._currentSuggestionDetails = createCancelablePromise(async (e) => {
			let v = disposableTimeout(() => {
				this._isDetailsVisible() && this.showDetails(!0);
			}, 250), y = e.onCancellationRequested(() => v.dispose());
			try {
				return await _.resolve(e);
			} finally {
				v.dispose(), y.dispose();
			}
		}), this._currentSuggestionDetails.then(() => {
			v >= this._list.length || _ !== this._list.element(v) || (this._ignoreFocusEvents = !0, this._list.splice(v, 1, [_]), this._list.setFocus([v]), this._ignoreFocusEvents = !1, this._isDetailsVisible() ? this.showDetails(!1) : this.element.domNode.classList.remove("docs-side"), this.editor.setAriaOptions({ activeDescendant: getAriaId(v) }));
		}).catch(onUnexpectedError)), this._onDidFocus.fire({
			item: _,
			index: v,
			model: this._completionModel
		});
	}
	_setState(e) {
		if (this._state !== e) switch (this._state = e, this.element.domNode.classList.toggle("frozen", e === 4), this.element.domNode.classList.remove("message"), e) {
			case 0:
				hide(this._messageElement, this._listElement, this._status.element), this._details.hide(!0), this._status.hide(), this._contentWidget.hide(), this._ctxSuggestWidgetVisible.reset(), this._ctxSuggestWidgetMultipleSuggestions.reset(), this._ctxSuggestWidgetHasFocusedSuggestion.reset(), this._showTimeout.cancel(), this.element.domNode.classList.remove("visible"), this._list.splice(0, this._list.length), this._focusedItem = void 0, this._cappedHeight = void 0, this._explainMode = !1;
				break;
			case 1:
				this.element.domNode.classList.add("message"), this._messageElement.textContent = SuggestWidget_1.LOADING_MESSAGE, hide(this._listElement, this._status.element), show(this._messageElement), this._details.hide(), this._show(), this._focusedItem = void 0, status(SuggestWidget_1.LOADING_MESSAGE);
				break;
			case 2:
				this.element.domNode.classList.add("message"), this._messageElement.textContent = SuggestWidget_1.NO_SUGGESTIONS_MESSAGE, hide(this._listElement, this._status.element), show(this._messageElement), this._details.hide(), this._show(), this._focusedItem = void 0, status(SuggestWidget_1.NO_SUGGESTIONS_MESSAGE);
				break;
			case 3:
				hide(this._messageElement), show(this._listElement, this._status.element), this._show();
				break;
			case 4:
				hide(this._messageElement), show(this._listElement, this._status.element), this._show();
				break;
			case 5:
				hide(this._messageElement), show(this._listElement, this._status.element), this._details.show(), this._show();
				break;
		}
	}
	_show() {
		this._status.show(), this._contentWidget.show(), this._layout(this._persistedSize.restore()), this._ctxSuggestWidgetVisible.set(!0), this._showTimeout.cancelAndSet(() => {
			this.element.domNode.classList.add("visible"), this._onDidShow.fire(this);
		}, 100);
	}
	showTriggered(e, _) {
		this._state === 0 && (this._contentWidget.setPosition(this.editor.getPosition()), this._isAuto = !!e, this._isAuto || (this._loadingTimeout = disposableTimeout(() => this._setState(1), _)));
	}
	showSuggestions(e, _, v, y, b) {
		if (this._contentWidget.setPosition(this.editor.getPosition()), this._loadingTimeout?.dispose(), this._currentSuggestionDetails?.cancel(), this._currentSuggestionDetails = void 0, this._completionModel !== e && (this._completionModel = e), v && this._state !== 2 && this._state !== 0) {
			this._setState(4);
			return;
		}
		let x = this._completionModel.items.length, S = x === 0;
		if (this._ctxSuggestWidgetMultipleSuggestions.set(x > 1), S) {
			this._setState(y ? 0 : 2), this._completionModel = void 0;
			return;
		}
		this._focusedItem = void 0, this._onDidFocus.pause(), this._onDidSelect.pause();
		try {
			this._list.splice(0, this._list.length, this._completionModel.items), this._setState(v ? 4 : 3), this._list.reveal(_, 0), this._list.setFocus(b ? [] : [_]);
		} finally {
			this._onDidFocus.resume(), this._onDidSelect.resume();
		}
		this._pendingLayout.value = runAtThisOrScheduleAtNextAnimationFrame(getWindow(this.element.domNode), () => {
			this._pendingLayout.clear(), this._layout(this.element.size), this._details.widget.domNode.classList.remove("focused");
		});
	}
	focusSelected() {
		this._list.length > 0 && this._list.setFocus([0]);
	}
	selectNextPage() {
		switch (this._state) {
			case 0: return !1;
			case 5: return this._details.widget.pageDown(), !0;
			case 1: return !this._isAuto;
			default: return this._list.focusNextPage(), !0;
		}
	}
	selectNext() {
		switch (this._state) {
			case 0: return !1;
			case 1: return !this._isAuto;
			default: return this._list.focusNext(1, !0), !0;
		}
	}
	selectLast() {
		switch (this._state) {
			case 0: return !1;
			case 5: return this._details.widget.scrollBottom(), !0;
			case 1: return !this._isAuto;
			default: return this._list.focusLast(), !0;
		}
	}
	selectPreviousPage() {
		switch (this._state) {
			case 0: return !1;
			case 5: return this._details.widget.pageUp(), !0;
			case 1: return !this._isAuto;
			default: return this._list.focusPreviousPage(), !0;
		}
	}
	selectPrevious() {
		switch (this._state) {
			case 0: return !1;
			case 1: return !this._isAuto;
			default: return this._list.focusPrevious(1, !0), !1;
		}
	}
	selectFirst() {
		switch (this._state) {
			case 0: return !1;
			case 5: return this._details.widget.scrollTop(), !0;
			case 1: return !this._isAuto;
			default: return this._list.focusFirst(), !0;
		}
	}
	getFocusedItem() {
		if (this._state !== 0 && this._state !== 2 && this._state !== 1 && this._completionModel && this._list.getFocus().length > 0) return {
			item: this._list.getFocusedElements()[0],
			index: this._list.getFocus()[0],
			model: this._completionModel
		};
	}
	toggleDetailsFocus() {
		this._state === 5 ? (this._setState(3), this._details.widget.domNode.classList.remove("focused")) : this._state === 3 && this._isDetailsVisible() && (this._setState(5), this._details.widget.domNode.classList.add("focused"));
	}
	toggleDetails() {
		this._isDetailsVisible() ? (this._pendingShowDetails.clear(), this._ctxSuggestWidgetDetailsVisible.set(!1), this._setDetailsVisible(!1), this._details.hide(), this.element.domNode.classList.remove("shows-details")) : (canExpandCompletionItem(this._list.getFocusedElements()[0]) || this._explainMode) && (this._state === 3 || this._state === 5 || this._state === 4) && (this._ctxSuggestWidgetDetailsVisible.set(!0), this._setDetailsVisible(!0), this.showDetails(!1));
	}
	showDetails(e) {
		this._pendingShowDetails.value = runAtThisOrScheduleAtNextAnimationFrame(getWindow(this.element.domNode), () => {
			this._pendingShowDetails.clear(), this._details.show(), e ? this._details.widget.renderLoading() : this._details.widget.renderItem(this._list.getFocusedElements()[0], this._explainMode), this._details.widget.isEmpty ? this._details.hide() : (this._positionDetails(), this.element.domNode.classList.add("shows-details")), this.editor.focus();
		});
	}
	toggleExplainMode() {
		this._list.getFocusedElements()[0] && (this._explainMode = !this._explainMode, this._isDetailsVisible() ? this.showDetails(!1) : this.toggleDetails());
	}
	resetPersistedSize() {
		this._persistedSize.reset();
	}
	hideWidget() {
		this._pendingLayout.clear(), this._pendingShowDetails.clear(), this._loadingTimeout?.dispose(), this._setState(0), this._onDidHide.fire(this), this.element.clearSashHoverState();
		let e = this._persistedSize.restore(), _ = Math.ceil(this.getLayoutInfo().itemHeight * 4.3);
		e && e.height < _ && this._persistedSize.store(e.with(void 0, _));
	}
	isFrozen() {
		return this._state === 4;
	}
	_afterRender(e) {
		if (e === null) {
			this._isDetailsVisible() && this._details.hide();
			return;
		}
		this._state === 2 || this._state === 1 || (this._isDetailsVisible() && !this._details.widget.isEmpty && this._details.show(), this._positionDetails());
	}
	_layout(e) {
		if (!this.editor.hasModel() || !this.editor.getDomNode()) return;
		let _ = getClientArea(this.element.domNode.ownerDocument.body), v = this.getLayoutInfo();
		e ||= v.defaultSize;
		let y = e.height, b = e.width;
		if (this._status.element.style.height = `${v.itemHeight}px`, this._state === 2 || this._state === 1) y = v.itemHeight + v.borderHeight, b = v.defaultSize.width / 2, this.element.enableSashes(!1, !1, !1, !1), this.element.minSize = this.element.maxSize = new Dimension(b, y), this._contentWidget.setPreference(2);
		else {
			let x = _.width - v.borderHeight - 2 * v.horizontalPadding;
			b > x && (b = x);
			let S = this._completionModel ? this._completionModel.stats.pLabelLen * v.typicalHalfwidthCharacterWidth : b, C = v.statusBarHeight + this._list.contentHeight + v.borderHeight, T = v.itemHeight + v.statusBarHeight, E = getDomNodePagePosition(this.editor.getDomNode()), D = this.editor.getScrolledVisiblePosition(this.editor.getPosition()), O = E.top + D.top + D.height, k = Math.min(_.height - O - v.verticalPadding, C), A = E.top + D.top - v.verticalPadding, j = Math.min(A, C), M = Math.min(Math.max(j, k) + v.borderHeight, C);
			y === this._cappedHeight?.capped && (y = this._cappedHeight.wanted), y < T && (y = T), y > M && (y = M), y > k || this._forceRenderingAbove && A > 150 ? (this._contentWidget.setPreference(1), this.element.enableSashes(!0, !0, !1, !1), M = j) : (this._contentWidget.setPreference(2), this.element.enableSashes(!1, !0, !0, !1), M = k), this.element.preferredSize = new Dimension(S, v.defaultSize.height), this.element.maxSize = new Dimension(x, M), this.element.minSize = new Dimension(220, T), this._cappedHeight = y === C ? {
				wanted: this._cappedHeight?.wanted ?? e.height,
				capped: y
			} : void 0;
		}
		this._resize(b, y);
	}
	_resize(e, _) {
		let { width: v, height: y } = this.element.maxSize;
		e = Math.min(v, e), _ = Math.min(y, _);
		let { statusBarHeight: b } = this.getLayoutInfo();
		this._list.layout(_ - b, e), this._listElement.style.height = `${_ - b}px`, this.element.layout(_, e), this._contentWidget.layout(), this._positionDetails();
	}
	_positionDetails() {
		this._isDetailsVisible() && this._details.placeAtAnchor(this.element.domNode, this._contentWidget.getPosition()?.preference[0] === 2);
	}
	getLayoutInfo() {
		let e = this.editor.getOption(50), _ = clamp(this.editor.getOption(121) || e.lineHeight, 8, 1e3), v = !this.editor.getOption(119).showStatusBar || this._state === 2 || this._state === 1 ? 0 : _, y = this._details.widget.borderWidth, b = 2 * y;
		return {
			itemHeight: _,
			statusBarHeight: v,
			borderWidth: y,
			borderHeight: b,
			typicalHalfwidthCharacterWidth: e.typicalHalfwidthCharacterWidth,
			verticalPadding: 22,
			horizontalPadding: 14,
			defaultSize: new Dimension(430, v + 12 * _ + b)
		};
	}
	_isDetailsVisible() {
		return this._storageService.getBoolean("expandSuggestionDocs", 0, !1);
	}
	_setDetailsVisible(e) {
		this._storageService.store("expandSuggestionDocs", e, 0, 0);
	}
	forceRenderingAbove() {
		this._forceRenderingAbove || (this._forceRenderingAbove = !0, this._layout(this._persistedSize.restore()));
	}
	stopForceRenderingAbove() {
		this._forceRenderingAbove = !1;
	}
};
SuggestWidget = SuggestWidget_1 = __decorate$51([
	__param$51(1, IStorageService),
	__param$51(2, IContextKeyService),
	__param$51(3, IThemeService),
	__param$51(4, IInstantiationService)
], SuggestWidget);
var SuggestContentWidget = class {
	constructor(e, _) {
		this._widget = e, this._editor = _, this.allowEditorOverflow = !0, this.suppressMouseDown = !1, this._preferenceLocked = !1, this._added = !1, this._hidden = !1;
	}
	dispose() {
		this._added && (this._added = !1, this._editor.removeContentWidget(this));
	}
	getId() {
		return "editor.widget.suggestWidget";
	}
	getDomNode() {
		return this._widget.element.domNode;
	}
	show() {
		this._hidden = !1, this._added || (this._added = !0, this._editor.addContentWidget(this));
	}
	hide() {
		this._hidden || (this._hidden = !0, this.layout());
	}
	layout() {
		this._editor.layoutContentWidget(this);
	}
	getPosition() {
		return this._hidden || !this._position || !this._preference ? null : {
			position: this._position,
			preference: [this._preference]
		};
	}
	beforeRender() {
		let { height: e, width: _ } = this._widget.element.size, { borderWidth: v, horizontalPadding: y } = this._widget.getLayoutInfo();
		return new Dimension(_ + 2 * v + y, e + 2 * v);
	}
	afterRender(e) {
		this._widget._afterRender(e);
	}
	setPreference(e) {
		this._preferenceLocked || (this._preference = e);
	}
	lockPreference() {
		this._preferenceLocked = !0;
	}
	unlockPreference() {
		this._preferenceLocked = !1;
	}
	setPosition(e) {
		this._position = e;
	}
}, __decorate$50 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$50 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SuggestController_1, LineSuffix = class {
	constructor(e, _) {
		if (this._model = e, this._position = _, this._decorationOptions = ModelDecorationOptions.register({
			description: "suggest-line-suffix",
			stickiness: 1
		}), e.getLineMaxColumn(_.lineNumber) !== _.column) {
			let v = e.getOffsetAt(_), y = e.getPositionAt(v + 1);
			e.changeDecorations((e) => {
				this._marker && e.removeDecoration(this._marker), this._marker = e.addDecoration(Range.fromPositions(_, y), this._decorationOptions);
			});
		}
	}
	dispose() {
		this._marker && !this._model.isDisposed() && this._model.changeDecorations((e) => {
			e.removeDecoration(this._marker), this._marker = void 0;
		});
	}
	delta(e) {
		if (this._model.isDisposed() || this._position.lineNumber !== e.lineNumber) return 0;
		if (this._marker) {
			let _ = this._model.getDecorationRange(this._marker);
			return this._model.getOffsetAt(_.getStartPosition()) - this._model.getOffsetAt(e);
		} else return this._model.getLineMaxColumn(e.lineNumber) - e.column;
	}
}, SuggestController = class {
	static {
		SuggestController_1 = this;
	}
	static {
		this.ID = "editor.contrib.suggestController";
	}
	static get(e) {
		return e.getContribution(SuggestController_1.ID);
	}
	constructor(e, _, v, y, b, x, S) {
		this._memoryService = _, this._commandService = v, this._contextKeyService = y, this._instantiationService = b, this._logService = x, this._telemetryService = S, this._lineSuffix = new MutableDisposable(), this._toDispose = new DisposableStore(), this._selectors = new PriorityRegistry((e) => e.priority), this._onWillInsertSuggestItem = new Emitter(), this.onWillInsertSuggestItem = this._onWillInsertSuggestItem.event, this.editor = e, this.model = b.createInstance(SuggestModel, this.editor), this._selectors.register({
			priority: 0,
			select: (e, _, v) => this._memoryService.select(e, _, v)
		});
		let C = Context$1.InsertMode.bindTo(y);
		C.set(e.getOption(119).insertMode), this._toDispose.add(this.model.onDidTrigger(() => C.set(e.getOption(119).insertMode))), this.widget = this._toDispose.add(new WindowIdleValue(getWindow(e.getDomNode()), () => {
			let e = this._instantiationService.createInstance(SuggestWidget, this.editor);
			this._toDispose.add(e), this._toDispose.add(e.onDidSelect((e) => this._insertSuggestion(e, 0), this));
			let _ = new CommitCharacterController(this.editor, e, this.model, (e) => this._insertSuggestion(e, 2));
			this._toDispose.add(_);
			let v = Context$1.MakesTextEdit.bindTo(this._contextKeyService), y = Context$1.HasInsertAndReplaceRange.bindTo(this._contextKeyService), b = Context$1.CanResolve.bindTo(this._contextKeyService);
			return this._toDispose.add(toDisposable(() => {
				v.reset(), y.reset(), b.reset();
			})), this._toDispose.add(e.onDidFocus(({ item: e }) => {
				let _ = this.editor.getPosition(), x = e.editStart.column, S = _.column, C = !0;
				this.editor.getOption(1) === "smart" && this.model.state === 2 && !e.completion.additionalTextEdits && !(e.completion.insertTextRules & 4) && S - x === e.completion.insertText.length && (C = this.editor.getModel().getValueInRange({
					startLineNumber: _.lineNumber,
					startColumn: x,
					endLineNumber: _.lineNumber,
					endColumn: S
				}) !== e.completion.insertText), v.set(C), y.set(!Position.equals(e.editInsertEnd, e.editReplaceEnd)), b.set(!!e.provider.resolveCompletionItem || !!e.completion.documentation || e.completion.detail !== e.completion.label);
			})), this._toDispose.add(e.onDetailsKeyDown((e) => {
				if (e.toKeyCodeChord().equals(new KeyCodeChord(!0, !1, !1, !1, 33)) || isMacintosh && e.toKeyCodeChord().equals(new KeyCodeChord(!1, !1, !1, !0, 33))) {
					e.stopPropagation();
					return;
				}
				e.toKeyCodeChord().isModifierKey() || this.editor.focus();
			})), e;
		})), this._overtypingCapturer = this._toDispose.add(new WindowIdleValue(getWindow(e.getDomNode()), () => this._toDispose.add(new OvertypingCapturer(this.editor, this.model)))), this._alternatives = this._toDispose.add(new WindowIdleValue(getWindow(e.getDomNode()), () => this._toDispose.add(new SuggestAlternatives(this.editor, this._contextKeyService)))), this._toDispose.add(b.createInstance(WordContextKey, e)), this._toDispose.add(this.model.onDidTrigger((e) => {
			this.widget.value.showTriggered(e.auto, e.shy ? 250 : 50), this._lineSuffix.value = new LineSuffix(this.editor.getModel(), e.position);
		})), this._toDispose.add(this.model.onDidSuggest((e) => {
			if (e.triggerOptions.shy) return;
			let _ = -1;
			for (let v of this._selectors.itemsOrderedByPriorityDesc) if (_ = v.select(this.editor.getModel(), this.editor.getPosition(), e.completionModel.items), _ !== -1) break;
			if (_ === -1 && (_ = 0), this.model.state === 0) return;
			let v = !1;
			if (e.triggerOptions.auto) {
				let _ = this.editor.getOption(119);
				_.selectionMode === "never" || _.selectionMode === "always" ? v = _.selectionMode === "never" : _.selectionMode === "whenTriggerCharacter" ? v = e.triggerOptions.triggerKind !== 1 : _.selectionMode === "whenQuickSuggestion" && (v = e.triggerOptions.triggerKind === 1 && !e.triggerOptions.refilter);
			}
			this.widget.value.showSuggestions(e.completionModel, _, e.isFrozen, e.triggerOptions.auto, v);
		})), this._toDispose.add(this.model.onDidCancel((e) => {
			e.retrigger || this.widget.value.hideWidget();
		})), this._toDispose.add(this.editor.onDidBlurEditorWidget(() => {
			this.model.cancel(), this.model.clear();
		}));
		let w = Context$1.AcceptSuggestionsOnEnter.bindTo(y), T = () => {
			let e = this.editor.getOption(1);
			w.set(e === "on" || e === "smart");
		};
		this._toDispose.add(this.editor.onDidChangeConfiguration(() => T())), T();
	}
	dispose() {
		this._alternatives.dispose(), this._toDispose.dispose(), this.widget.dispose(), this.model.dispose(), this._lineSuffix.dispose(), this._onWillInsertSuggestItem.dispose();
	}
	_insertSuggestion(e, _) {
		if (!e || !e.item) {
			this._alternatives.value.reset(), this.model.cancel(), this.model.clear();
			return;
		}
		if (!this.editor.hasModel()) return;
		let v = SnippetController2.get(this.editor);
		if (!v) return;
		this._onWillInsertSuggestItem.fire({ item: e.item });
		let y = this.editor.getModel(), b = y.getAlternativeVersionId(), { item: x } = e, S = [], C = new CancellationTokenSource();
		_ & 1 || this.editor.pushUndoStop();
		let w = this.getOverwriteInfo(x, !!(_ & 8));
		this._memoryService.memorize(y, this.editor.getPosition(), x);
		let T = x.isResolved, E = -1, D = -1;
		if (Array.isArray(x.completion.additionalTextEdits)) {
			this.model.cancel();
			let e = StableEditorScrollState.capture(this.editor);
			this.editor.executeEdits("suggestController.additionalTextEdits.sync", x.completion.additionalTextEdits.map((e) => {
				let _ = Range.lift(e.range);
				if (_.startLineNumber === x.position.lineNumber && _.startColumn > x.position.column) {
					let e = this.editor.getPosition().column - x.position.column, v = e, y = Range.spansMultipleLines(_) ? 0 : e;
					_ = new Range(_.startLineNumber, _.startColumn + v, _.endLineNumber, _.endColumn + y);
				}
				return EditOperation.replaceMove(_, e.text);
			})), e.restoreRelativeVerticalPositionOfCursor(this.editor);
		} else if (!T) {
			let e = new StopWatch(), v, b = y.onDidChangeContent((e) => {
				if (e.isFlush) {
					C.cancel(), b.dispose();
					return;
				}
				for (let _ of e.changes) {
					let e = Range.getEndPosition(_.range);
					(!v || Position.isBefore(e, v)) && (v = e);
				}
			}), w = _;
			_ |= 2;
			let T = !1, E = this.editor.onWillType(() => {
				E.dispose(), T = !0, w & 2 || this.editor.pushUndoStop();
			});
			S.push(x.resolve(C.token).then(() => {
				if (!x.completion.additionalTextEdits || C.token.isCancellationRequested) return;
				if (v && x.completion.additionalTextEdits.some((e) => Position.isBefore(v, Range.getStartPosition(e.range)))) return !1;
				T && this.editor.pushUndoStop();
				let e = StableEditorScrollState.capture(this.editor);
				return this.editor.executeEdits("suggestController.additionalTextEdits.async", x.completion.additionalTextEdits.map((e) => EditOperation.replaceMove(Range.lift(e.range), e.text))), e.restoreRelativeVerticalPositionOfCursor(this.editor), (T || !(w & 2)) && this.editor.pushUndoStop(), !0;
			}).then((_) => {
				this._logService.trace("[suggest] async resolving of edits DONE (ms, applied?)", e.elapsed(), _), D = _ === !0 ? 1 : _ === !1 ? 0 : -2;
			}).finally(() => {
				b.dispose(), E.dispose();
			}));
		}
		let { insertText: O } = x.completion;
		if (x.completion.insertTextRules & 4 || (O = SnippetParser.escape(O)), this.model.cancel(), v.insert(O, {
			overwriteBefore: w.overwriteBefore,
			overwriteAfter: w.overwriteAfter,
			undoStopBefore: !1,
			undoStopAfter: !1,
			adjustWhitespace: !(x.completion.insertTextRules & 1),
			clipboardText: e.model.clipboardText,
			overtypingCapturer: this._overtypingCapturer.value
		}), _ & 2 || this.editor.pushUndoStop(), x.completion.command) if (x.completion.command.id === TriggerSuggestAction.id) this.model.trigger({
			auto: !0,
			retrigger: !0
		});
		else {
			let e = new StopWatch();
			S.push(this._commandService.executeCommand(x.completion.command.id, ...x.completion.command.arguments ? [...x.completion.command.arguments] : []).catch((e) => {
				x.completion.extensionId ? onUnexpectedExternalError(e) : onUnexpectedError(e);
			}).finally(() => {
				E = e.elapsed();
			}));
		}
		_ & 4 && this._alternatives.value.set(e, (e) => {
			for (C.cancel(); y.canUndo();) {
				b !== y.getAlternativeVersionId() && y.undo(), this._insertSuggestion(e, 3 | (_ & 8 ? 8 : 0));
				break;
			}
		}), this._alertCompletionItem(x), Promise.all(S).finally(() => {
			this._reportSuggestionAcceptedTelemetry(x, y, T, E, D, e.index, e.model.items), this.model.clear(), C.dispose();
		});
	}
	_reportSuggestionAcceptedTelemetry(e, _, v, y, b, x, S) {
		if (Math.floor(Math.random() * 100) === 0) return;
		let C = /* @__PURE__ */ new Map();
		for (let e = 0; e < Math.min(30, S.length); e++) {
			let _ = S[e].textLabel;
			C.has(_) ? C.get(_).push(e) : C.set(_, [e]);
		}
		let w = C.get(e.textLabel), T = w && w.length > 1 ? w[0] : -1;
		this._telemetryService.publicLog2("suggest.acceptedSuggestion", {
			extensionId: e.extensionId?.value ?? "unknown",
			providerId: e.provider._debugDisplayName ?? "unknown",
			kind: e.completion.kind,
			basenameHash: hash(basename(_.uri)).toString(16),
			languageId: _.getLanguageId(),
			fileExtension: extname(_.uri),
			resolveInfo: e.provider.resolveCompletionItem ? v ? 1 : 0 : -1,
			resolveDuration: e.resolveDuration,
			commandDuration: y,
			additionalEditsAsync: b,
			index: x,
			firstIndex: T
		});
	}
	getOverwriteInfo(e, _) {
		assertType(this.editor.hasModel());
		let v = this.editor.getOption(119).insertMode === "replace";
		_ && (v = !v);
		let y = e.position.column - e.editStart.column, b = (v ? e.editReplaceEnd.column : e.editInsertEnd.column) - e.position.column, x = this.editor.getPosition().column - e.position.column, S = this._lineSuffix.value ? this._lineSuffix.value.delta(this.editor.getPosition()) : 0;
		return {
			overwriteBefore: y + x,
			overwriteAfter: b + S
		};
	}
	_alertCompletionItem(e) {
		if (isNonEmptyArray(e.completion.additionalTextEdits)) {
			let _ = localize("aria.alert.snippet", "Accepting '{0}' made {1} additional edits", e.textLabel, e.completion.additionalTextEdits.length);
			alert(_);
		}
	}
	triggerSuggest(e, _, v) {
		this.editor.hasModel() && (this.model.trigger({
			auto: _ ?? !1,
			completionOptions: {
				providerFilter: e,
				kindFilter: v ? /* @__PURE__ */ new Set() : void 0
			}
		}), this.editor.revealPosition(this.editor.getPosition(), 0), this.editor.focus());
	}
	triggerSuggestAndAcceptBest(e) {
		if (!this.editor.hasModel()) return;
		let _ = this.editor.getPosition(), v = () => {
			_.equals(this.editor.getPosition()) && this._commandService.executeCommand(e.fallback);
		}, y = (e) => {
			if (e.completion.insertTextRules & 4 || e.completion.additionalTextEdits) return !0;
			let _ = this.editor.getPosition(), v = e.editStart.column, y = _.column;
			return y - v === e.completion.insertText.length ? this.editor.getModel().getValueInRange({
				startLineNumber: _.lineNumber,
				startColumn: v,
				endLineNumber: _.lineNumber,
				endColumn: y
			}) !== e.completion.insertText : !0;
		};
		Event.once(this.model.onDidTrigger)((e) => {
			let _ = [];
			Event.any(this.model.onDidTrigger, this.model.onDidCancel)(() => {
				dispose(_), v();
			}, void 0, _), this.model.onDidSuggest(({ completionModel: e }) => {
				if (dispose(_), e.items.length === 0) {
					v();
					return;
				}
				let b = this._memoryService.select(this.editor.getModel(), this.editor.getPosition(), e.items), x = e.items[b];
				if (!y(x)) {
					v();
					return;
				}
				this.editor.pushUndoStop(), this._insertSuggestion({
					index: b,
					item: x,
					model: e
				}, 7);
			}, void 0, _);
		}), this.model.trigger({
			auto: !1,
			shy: !0
		}), this.editor.revealPosition(_, 0), this.editor.focus();
	}
	acceptSelectedSuggestion(e, _) {
		let v = this.widget.value.getFocusedItem(), y = 0;
		e && (y |= 4), _ && (y |= 8), this._insertSuggestion(v, y);
	}
	acceptNextSuggestion() {
		this._alternatives.value.next();
	}
	acceptPrevSuggestion() {
		this._alternatives.value.prev();
	}
	cancelSuggestWidget() {
		this.model.cancel(), this.model.clear(), this.widget.value.hideWidget();
	}
	focusSuggestion() {
		this.widget.value.focusSelected();
	}
	selectNextSuggestion() {
		this.widget.value.selectNext();
	}
	selectNextPageSuggestion() {
		this.widget.value.selectNextPage();
	}
	selectLastSuggestion() {
		this.widget.value.selectLast();
	}
	selectPrevSuggestion() {
		this.widget.value.selectPrevious();
	}
	selectPrevPageSuggestion() {
		this.widget.value.selectPreviousPage();
	}
	selectFirstSuggestion() {
		this.widget.value.selectFirst();
	}
	toggleSuggestionDetails() {
		this.widget.value.toggleDetails();
	}
	toggleExplainMode() {
		this.widget.value.toggleExplainMode();
	}
	toggleSuggestionFocus() {
		this.widget.value.toggleDetailsFocus();
	}
	resetWidgetSize() {
		this.widget.value.resetPersistedSize();
	}
	forceRenderingAbove() {
		this.widget.value.forceRenderingAbove();
	}
	stopForceRenderingAbove() {
		this.widget.isInitialized && this.widget.value.stopForceRenderingAbove();
	}
	registerSelector(e) {
		return this._selectors.register(e);
	}
};
SuggestController = SuggestController_1 = __decorate$50([
	__param$50(1, ISuggestMemoryService),
	__param$50(2, ICommandService),
	__param$50(3, IContextKeyService),
	__param$50(4, IInstantiationService),
	__param$50(5, ILogService),
	__param$50(6, ITelemetryService)
], SuggestController);
var PriorityRegistry = class {
	constructor(e) {
		this.prioritySelector = e, this._items = [];
	}
	register(e) {
		if (this._items.indexOf(e) !== -1) throw Error("Value is already registered");
		return this._items.push(e), this._items.sort((e, _) => this.prioritySelector(_) - this.prioritySelector(e)), { dispose: () => {
			let _ = this._items.indexOf(e);
			_ >= 0 && this._items.splice(_, 1);
		} };
	}
	get itemsOrderedByPriorityDesc() {
		return this._items;
	}
}, TriggerSuggestAction = class e extends EditorAction {
	static {
		this.id = "editor.action.triggerSuggest";
	}
	constructor() {
		super({
			id: e.id,
			label: localize("suggest.trigger.label", "Trigger Suggest"),
			alias: "Trigger Suggest",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCompletionItemProvider, Context$1.Visible.toNegated()),
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 2058,
				secondary: [2087],
				mac: {
					primary: 266,
					secondary: [521, 2087]
				},
				weight: 100
			}
		});
	}
	run(e, _, v) {
		let y = SuggestController.get(_);
		if (!y) return;
		let b;
		v && typeof v == "object" && v.auto === !0 && (b = !0), y.triggerSuggest(void 0, b, void 0);
	}
};
registerEditorContribution(SuggestController.ID, SuggestController, 2), registerEditorAction(TriggerSuggestAction);
var weight$2 = 190, SuggestCommand = EditorCommand.bindToContribution(SuggestController.get);
registerEditorCommand(new SuggestCommand({
	id: "acceptSelectedSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, Context$1.HasFocusedSuggestion),
	handler(e) {
		e.acceptSelectedSuggestion(!0, !1);
	},
	kbOpts: [{
		primary: 2,
		kbExpr: ContextKeyExpr.and(Context$1.Visible, EditorContextKeys.textInputFocus),
		weight: weight$2
	}, {
		primary: 3,
		kbExpr: ContextKeyExpr.and(Context$1.Visible, EditorContextKeys.textInputFocus, Context$1.AcceptSuggestionsOnEnter, Context$1.MakesTextEdit),
		weight: weight$2
	}],
	menuOpts: [
		{
			menuId: suggestWidgetStatusbarMenu,
			title: localize("accept.insert", "Insert"),
			group: "left",
			order: 1,
			when: Context$1.HasInsertAndReplaceRange.toNegated()
		},
		{
			menuId: suggestWidgetStatusbarMenu,
			title: localize("accept.insert", "Insert"),
			group: "left",
			order: 1,
			when: ContextKeyExpr.and(Context$1.HasInsertAndReplaceRange, Context$1.InsertMode.isEqualTo("insert"))
		},
		{
			menuId: suggestWidgetStatusbarMenu,
			title: localize("accept.replace", "Replace"),
			group: "left",
			order: 1,
			when: ContextKeyExpr.and(Context$1.HasInsertAndReplaceRange, Context$1.InsertMode.isEqualTo("replace"))
		}
	]
})), registerEditorCommand(new SuggestCommand({
	id: "acceptAlternativeSelectedSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, EditorContextKeys.textInputFocus, Context$1.HasFocusedSuggestion),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 1027,
		secondary: [1026]
	},
	handler(e) {
		e.acceptSelectedSuggestion(!1, !0);
	},
	menuOpts: [{
		menuId: suggestWidgetStatusbarMenu,
		group: "left",
		order: 2,
		when: ContextKeyExpr.and(Context$1.HasInsertAndReplaceRange, Context$1.InsertMode.isEqualTo("insert")),
		title: localize("accept.replace", "Replace")
	}, {
		menuId: suggestWidgetStatusbarMenu,
		group: "left",
		order: 2,
		when: ContextKeyExpr.and(Context$1.HasInsertAndReplaceRange, Context$1.InsertMode.isEqualTo("replace")),
		title: localize("accept.insert", "Insert")
	}]
})), CommandsRegistry.registerCommandAlias("acceptSelectedSuggestionOnEnter", "acceptSelectedSuggestion"), registerEditorCommand(new SuggestCommand({
	id: "hideSuggestWidget",
	precondition: Context$1.Visible,
	handler: (e) => e.cancelSuggestWidget(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 9,
		secondary: [1033]
	}
})), registerEditorCommand(new SuggestCommand({
	id: "selectNextSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, ContextKeyExpr.or(Context$1.MultipleSuggestions, Context$1.HasFocusedSuggestion.negate())),
	handler: (e) => e.selectNextSuggestion(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 18,
		secondary: [2066],
		mac: {
			primary: 18,
			secondary: [2066, 300]
		}
	}
})), registerEditorCommand(new SuggestCommand({
	id: "selectNextPageSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, ContextKeyExpr.or(Context$1.MultipleSuggestions, Context$1.HasFocusedSuggestion.negate())),
	handler: (e) => e.selectNextPageSuggestion(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 12,
		secondary: [2060]
	}
})), registerEditorCommand(new SuggestCommand({
	id: "selectLastSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, ContextKeyExpr.or(Context$1.MultipleSuggestions, Context$1.HasFocusedSuggestion.negate())),
	handler: (e) => e.selectLastSuggestion()
})), registerEditorCommand(new SuggestCommand({
	id: "selectPrevSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, ContextKeyExpr.or(Context$1.MultipleSuggestions, Context$1.HasFocusedSuggestion.negate())),
	handler: (e) => e.selectPrevSuggestion(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 16,
		secondary: [2064],
		mac: {
			primary: 16,
			secondary: [2064, 302]
		}
	}
})), registerEditorCommand(new SuggestCommand({
	id: "selectPrevPageSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, ContextKeyExpr.or(Context$1.MultipleSuggestions, Context$1.HasFocusedSuggestion.negate())),
	handler: (e) => e.selectPrevPageSuggestion(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 11,
		secondary: [2059]
	}
})), registerEditorCommand(new SuggestCommand({
	id: "selectFirstSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, ContextKeyExpr.or(Context$1.MultipleSuggestions, Context$1.HasFocusedSuggestion.negate())),
	handler: (e) => e.selectFirstSuggestion()
})), registerEditorCommand(new SuggestCommand({
	id: "focusSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, Context$1.HasFocusedSuggestion.negate()),
	handler: (e) => e.focusSuggestion(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 2058,
		secondary: [2087],
		mac: {
			primary: 266,
			secondary: [2087]
		}
	}
})), registerEditorCommand(new SuggestCommand({
	id: "focusAndAcceptSuggestion",
	precondition: ContextKeyExpr.and(Context$1.Visible, Context$1.HasFocusedSuggestion.negate()),
	handler: (e) => {
		e.focusSuggestion(), e.acceptSelectedSuggestion(!0, !1);
	}
})), registerEditorCommand(new SuggestCommand({
	id: "toggleSuggestionDetails",
	precondition: ContextKeyExpr.and(Context$1.Visible, Context$1.HasFocusedSuggestion),
	handler: (e) => e.toggleSuggestionDetails(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 2058,
		secondary: [2087],
		mac: {
			primary: 266,
			secondary: [2087]
		}
	},
	menuOpts: [{
		menuId: suggestWidgetStatusbarMenu,
		group: "right",
		order: 1,
		when: ContextKeyExpr.and(Context$1.DetailsVisible, Context$1.CanResolve),
		title: localize("detail.more", "Show Less")
	}, {
		menuId: suggestWidgetStatusbarMenu,
		group: "right",
		order: 1,
		when: ContextKeyExpr.and(Context$1.DetailsVisible.toNegated(), Context$1.CanResolve),
		title: localize("detail.less", "Show More")
	}]
})), registerEditorCommand(new SuggestCommand({
	id: "toggleExplainMode",
	precondition: Context$1.Visible,
	handler: (e) => e.toggleExplainMode(),
	kbOpts: {
		weight: 100,
		primary: 2138
	}
})), registerEditorCommand(new SuggestCommand({
	id: "toggleSuggestionFocus",
	precondition: Context$1.Visible,
	handler: (e) => e.toggleSuggestionFocus(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 2570,
		mac: { primary: 778 }
	}
})), registerEditorCommand(new SuggestCommand({
	id: "insertBestCompletion",
	precondition: ContextKeyExpr.and(EditorContextKeys.textInputFocus, ContextKeyExpr.equals("config.editor.tabCompletion", "on"), WordContextKey.AtEnd, Context$1.Visible.toNegated(), SuggestAlternatives.OtherSuggestions.toNegated(), SnippetController2.InSnippetMode.toNegated()),
	handler: (e, _) => {
		e.triggerSuggestAndAcceptBest(isObject(_) ? {
			fallback: "tab",
			..._
		} : { fallback: "tab" });
	},
	kbOpts: {
		weight: weight$2,
		primary: 2
	}
})), registerEditorCommand(new SuggestCommand({
	id: "insertNextSuggestion",
	precondition: ContextKeyExpr.and(EditorContextKeys.textInputFocus, ContextKeyExpr.equals("config.editor.tabCompletion", "on"), SuggestAlternatives.OtherSuggestions, Context$1.Visible.toNegated(), SnippetController2.InSnippetMode.toNegated()),
	handler: (e) => e.acceptNextSuggestion(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 2
	}
})), registerEditorCommand(new SuggestCommand({
	id: "insertPrevSuggestion",
	precondition: ContextKeyExpr.and(EditorContextKeys.textInputFocus, ContextKeyExpr.equals("config.editor.tabCompletion", "on"), SuggestAlternatives.OtherSuggestions, Context$1.Visible.toNegated(), SnippetController2.InSnippetMode.toNegated()),
	handler: (e) => e.acceptPrevSuggestion(),
	kbOpts: {
		weight: weight$2,
		kbExpr: EditorContextKeys.textInputFocus,
		primary: 1026
	}
})), registerEditorAction(class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.resetSuggestSize",
			label: localize("suggest.reset.label", "Reset Suggest Widget Size"),
			alias: "Reset Suggest Widget Size",
			precondition: void 0
		});
	}
	run(e, _) {
		SuggestController.get(_)?.resetWidgetSize();
	}
});
var SuggestWidgetAdaptor = class extends Disposable {
	get selectedItem() {
		return this._currentSuggestItemInfo;
	}
	constructor(e, _, v) {
		super(), this.editor = e, this.suggestControllerPreselector = _, this.onWillAccept = v, this.isSuggestWidgetVisible = !1, this.isShiftKeyPressed = !1, this._isActive = !1, this._currentSuggestItemInfo = void 0, this._onDidSelectedItemChange = this._register(new Emitter()), this.onDidSelectedItemChange = this._onDidSelectedItemChange.event, this._register(e.onKeyDown((e) => {
			e.shiftKey && !this.isShiftKeyPressed && (this.isShiftKeyPressed = !0, this.update(this._isActive));
		})), this._register(e.onKeyUp((e) => {
			e.shiftKey && this.isShiftKeyPressed && (this.isShiftKeyPressed = !1, this.update(this._isActive));
		}));
		let y = SuggestController.get(this.editor);
		if (y) {
			this._register(y.registerSelector({
				priority: 100,
				select: (e, _, v) => {
					let b = this.editor.getModel();
					if (!b) return -1;
					let x = this.suggestControllerPreselector(), S = x ? singleTextRemoveCommonPrefix(x, b) : void 0;
					if (!S) return -1;
					let C = Position.lift(_), w = v.map((e, _) => {
						let v = SuggestItemInfo.fromSuggestion(y, b, C, e, this.isShiftKeyPressed), x = singleTextRemoveCommonPrefix(v.toSingleTextEdit(), b), w = singleTextEditAugments(S, x);
						return {
							index: _,
							valid: w,
							prefixLength: x.text.length,
							suggestItem: e
						};
					}).filter((e) => e && e.valid && e.prefixLength > 0), T = findFirstMax(w, compareBy((e) => e.prefixLength, numberComparator));
					return T ? T.index : -1;
				}
			}));
			let e = !1, _ = () => {
				e || (e = !0, this._register(y.widget.value.onDidShow(() => {
					this.isSuggestWidgetVisible = !0, this.update(!0);
				})), this._register(y.widget.value.onDidHide(() => {
					this.isSuggestWidgetVisible = !1, this.update(!1);
				})), this._register(y.widget.value.onDidFocus(() => {
					this.isSuggestWidgetVisible = !0, this.update(!0);
				})));
			};
			this._register(Event.once(y.model.onDidTrigger)((e) => {
				_();
			})), this._register(y.onWillInsertSuggestItem((e) => {
				let _ = this.editor.getPosition(), v = this.editor.getModel();
				if (!_ || !v) return;
				let b = SuggestItemInfo.fromSuggestion(y, v, _, e.item, this.isShiftKeyPressed);
				this.onWillAccept(b);
			}));
		}
		this.update(this._isActive);
	}
	update(e) {
		let _ = this.getSuggestItemInfo();
		(this._isActive !== e || !suggestItemInfoEquals(this._currentSuggestItemInfo, _)) && (this._isActive = e, this._currentSuggestItemInfo = _, this._onDidSelectedItemChange.fire());
	}
	getSuggestItemInfo() {
		let e = SuggestController.get(this.editor);
		if (!e || !this.isSuggestWidgetVisible) return;
		let _ = e.widget.value.getFocusedItem(), v = this.editor.getPosition(), y = this.editor.getModel();
		if (!(!_ || !v || !y)) return SuggestItemInfo.fromSuggestion(e, y, v, _.item, this.isShiftKeyPressed);
	}
	stopForceRenderingAbove() {
		SuggestController.get(this.editor)?.stopForceRenderingAbove();
	}
	forceRenderingAbove() {
		SuggestController.get(this.editor)?.forceRenderingAbove();
	}
}, SuggestItemInfo = class e {
	static fromSuggestion(_, v, y, b, x) {
		let { insertText: S } = b.completion, C = !1;
		if (b.completion.insertTextRules & 4) {
			let e = new SnippetParser().parse(S);
			e.children.length < 100 && SnippetSession.adjustWhitespace(v, y, !0, e), S = e.toString(), C = !0;
		}
		let w = _.getOverwriteInfo(b, x);
		return new e(Range.fromPositions(y.delta(0, -w.overwriteBefore), y.delta(0, Math.max(w.overwriteAfter, 0))), S, b.completion.kind, C);
	}
	constructor(e, _, v, y) {
		this.range = e, this.insertText = _, this.completionItemKind = v, this.isSnippetText = y;
	}
	equals(e) {
		return this.range.equalsRange(e.range) && this.insertText === e.insertText && this.completionItemKind === e.completionItemKind && this.isSnippetText === e.isSnippetText;
	}
	toSelectedSuggestionInfo() {
		return new SelectedSuggestionInfo(this.range, this.insertText, this.completionItemKind, this.isSnippetText);
	}
	toSingleTextEdit() {
		return new SingleTextEdit(this.range, this.insertText);
	}
};
function suggestItemInfoEquals(e, _) {
	return e === _ ? !0 : !e || !_ ? !1 : e.equals(_);
}
var __decorate$49 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$49 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineCompletionsController_1, InlineCompletionsController = class extends Disposable {
	static {
		InlineCompletionsController_1 = this;
	}
	static {
		this.ID = "editor.contrib.inlineCompletionsController";
	}
	static get(e) {
		return e.getContribution(InlineCompletionsController_1.ID);
	}
	constructor(e, _, v, y, b, S, C, w, T, D) {
		super(), this.editor = e, this._instantiationService = _, this._contextKeyService = v, this._configurationService = y, this._commandService = b, this._debounceService = S, this._languageFeaturesService = C, this._accessibilitySignalService = w, this._keybindingService = T, this._accessibilityService = D, this._editorObs = observableCodeEditor(this.editor), this._positions = derived(this, (e) => this._editorObs.selections.read(e)?.map((e) => e.getEndPosition()) ?? [new Position(1, 1)]), this._suggestWidgetAdaptor = this._register(new SuggestWidgetAdaptor(this.editor, () => (this._editorObs.forceUpdate(), this.model.get()?.selectedInlineCompletion.get()?.toSingleTextEdit(void 0)), (e) => this._editorObs.forceUpdate((_) => {
			this.model.get()?.handleSuggestAccepted(e);
		}))), this._suggestWidgetSelectedItem = observableFromEvent(this, (e) => this._suggestWidgetAdaptor.onDidSelectedItemChange(() => {
			this._editorObs.forceUpdate((_) => e(void 0));
		}), () => this._suggestWidgetAdaptor.selectedItem), this._enabledInConfig = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(62).enabled), this._isScreenReaderEnabled = observableFromEvent(this, this._accessibilityService.onDidChangeScreenReaderOptimized, () => this._accessibilityService.isScreenReaderOptimized()), this._editorDictationInProgress = observableFromEvent(this, this._contextKeyService.onDidChangeContext, () => this._contextKeyService.getContext(this.editor.getDomNode()).getValue("editorDictation.inProgress") === !0), this._enabled = derived(this, (e) => this._enabledInConfig.read(e) && (!this._isScreenReaderEnabled.read(e) || !this._editorDictationInProgress.read(e))), this._debounceValue = this._debounceService.for(this._languageFeaturesService.inlineCompletionsProvider, "InlineCompletionsDebounce", {
			min: 50,
			max: 50
		}), this.model = derivedDisposable(this, (e) => {
			if (this._editorObs.isReadonly.read(e)) return;
			let _ = this._editorObs.model.read(e);
			if (_) return this._instantiationService.createInstance(InlineCompletionsModel, _, this._suggestWidgetSelectedItem, this._editorObs.versionId, this._positions, this._debounceValue, observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(119).preview), observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(119).previewMode), observableFromEvent(this.editor.onDidChangeConfiguration, () => this.editor.getOption(62).mode), this._enabled);
		}).recomputeInitiallyAndOnChange(this._store), this._ghostTexts = derived(this, (e) => this.model.read(e)?.ghostTexts.read(e) ?? []), this._stablizedGhostTexts = convertItemsToStableObservables(this._ghostTexts, this._store), this._ghostTextWidgets = mapObservableArrayCached(this, this._stablizedGhostTexts, (e, _) => _.add(this._instantiationService.createInstance(GhostTextView, this.editor, {
			ghostText: e,
			minReservedLineCount: constObservable(0),
			targetTextModel: this.model.map((e) => e?.textModel)
		}))).recomputeInitiallyAndOnChange(this._store), this._playAccessibilitySignal = observableSignal(this), this._fontFamily = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(62).fontFamily), this._register(new InlineCompletionContextKeys(this._contextKeyService, this.model)), this._register(reactToChange(this._editorObs.onDidType, (e, _) => {
			this._enabled.get() && this.model.get()?.trigger();
		})), this._register(this._commandService.onDidExecuteCommand((_) => {
			new Set([
				CoreEditingCommands.Tab.id,
				CoreEditingCommands.DeleteLeft.id,
				CoreEditingCommands.DeleteRight.id,
				"editor.action.inlineSuggest.commit",
				"acceptSelectedSuggestion"
			]).has(_.commandId) && e.hasTextFocus() && this._enabled.get() && this._editorObs.forceUpdate((e) => {
				this.model.get()?.trigger(e);
			});
		})), this._register(reactToChange(this._editorObs.selections, (e, _) => {
			_.some((e) => e.reason === 3 || e.source === "api") && this.model.get()?.stop();
		})), this._register(this.editor.onDidBlurEditorWidget(() => {
			this._contextKeyService.getContextKeyValue("accessibleViewIsShown") || this._configurationService.getValue("editor.inlineSuggest.keepOnBlur") || e.getOption(62).keepOnBlur || InlineSuggestionHintsContentWidget.dropDownVisible || transaction((e) => {
				this.model.get()?.stop(e);
			});
		})), this._register(autorun((e) => {
			let _ = this.model.read(e)?.state.read(e);
			_?.suggestItem ? _.primaryGhostText.lineCount >= 2 && this._suggestWidgetAdaptor.forceRenderingAbove() : this._suggestWidgetAdaptor.stopForceRenderingAbove();
		})), this._register(toDisposable(() => {
			this._suggestWidgetAdaptor.stopForceRenderingAbove();
		}));
		let O = derivedObservableWithCache(this, (e, _) => {
			let v = this.model.read(e)?.state.read(e);
			return this._suggestWidgetSelectedItem.get() ? _ : v?.inlineCompletion?.semanticId;
		});
		this._register(reactToChangeWithStore(derived((e) => (this._playAccessibilitySignal.read(e), O.read(e), {})), async (e, _, v) => {
			let y = this.model.get(), b = y?.state.get();
			if (!b || !y) return;
			let x = y.textModel.getLineContent(b.primaryGhostText.lineNumber);
			await timeout(50, cancelOnDispose(v)), await waitForState(this._suggestWidgetSelectedItem, isUndefined, () => !1, cancelOnDispose(v)), await this._accessibilitySignalService.playSignal(AccessibilitySignal.inlineSuggestion), this.editor.getOption(8) && this._provideScreenReaderUpdate(b.primaryGhostText.renderForScreenReader(x));
		})), this._register(new InlineCompletionsHintsWidget(this.editor, this.model, this._instantiationService)), this._register(createStyleSheetFromObservable(derived((e) => {
			let _ = this._fontFamily.read(e);
			return _ === "" || _ === "default" ? "" : `
.monaco-editor .ghost-text-decoration,
.monaco-editor .ghost-text-decoration-preview,
.monaco-editor .ghost-text {
	font-family: ${_};
}`;
		}))), this._register(this._configurationService.onDidChangeConfiguration((e) => {
			e.affectsConfiguration("accessibility.verbosity.inlineCompletions") && this.editor.updateOptions({ inlineCompletionsAccessibilityVerbose: this._configurationService.getValue("accessibility.verbosity.inlineCompletions") });
		})), this.editor.updateOptions({ inlineCompletionsAccessibilityVerbose: this._configurationService.getValue("accessibility.verbosity.inlineCompletions") });
	}
	playAccessibilitySignal(e) {
		this._playAccessibilitySignal.trigger(e);
	}
	_provideScreenReaderUpdate(e) {
		let _ = this._contextKeyService.getContextKeyValue("accessibleViewIsShown"), v = this._keybindingService.lookupKeybinding("editor.action.accessibleView"), y;
		!_ && v && this.editor.getOption(150) && (y = localize("showAccessibleViewHint", "Inspect this in the accessible view ({0})", v.getAriaLabel())), alert(y ? e + ", " + y : e);
	}
	shouldShowHoverAt(e) {
		let _ = this.model.get()?.primaryGhostText.get();
		return _ ? _.parts.some((v) => e.containsPosition(new Position(_.lineNumber, v.column))) : !1;
	}
	shouldShowHoverAtViewZone(e) {
		return this._ghostTextWidgets.get()[0]?.ownsViewZone(e) ?? !1;
	}
};
InlineCompletionsController = InlineCompletionsController_1 = __decorate$49([
	__param$49(1, IInstantiationService),
	__param$49(2, IContextKeyService),
	__param$49(3, IConfigurationService),
	__param$49(4, ICommandService),
	__param$49(5, ILanguageFeatureDebounceService),
	__param$49(6, ILanguageFeaturesService),
	__param$49(7, IAccessibilitySignalService),
	__param$49(8, IKeybindingService),
	__param$49(9, IAccessibilityService)
], InlineCompletionsController);
function convertItemsToStableObservables(e, _) {
	let v = observableValue("result", []), y = [];
	return _.add(autorun((_) => {
		let b = e.read(_);
		transaction((e) => {
			if (b.length !== y.length) {
				y.length = b.length;
				for (let e = 0; e < y.length; e++) y[e] || (y[e] = observableValue("item", b[e]));
				v.set([...y], e);
			}
			y.forEach((_, v) => _.set(b[v], e));
		});
	})), v;
}
var ShowNextInlineSuggestionAction = class e extends EditorAction {
	static {
		this.ID = showNextInlineSuggestionActionId;
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("action.inlineSuggest.showNext", "Show Next Inline Suggestion"),
			alias: "Show Next Inline Suggestion",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
			kbOpts: {
				weight: 100,
				primary: 606
			}
		});
	}
	async run(e, _) {
		InlineCompletionsController.get(_)?.model.get()?.next();
	}
}, ShowPreviousInlineSuggestionAction = class e extends EditorAction {
	static {
		this.ID = showPreviousInlineSuggestionActionId;
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("action.inlineSuggest.showPrevious", "Show Previous Inline Suggestion"),
			alias: "Show Previous Inline Suggestion",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
			kbOpts: {
				weight: 100,
				primary: 604
			}
		});
	}
	async run(e, _) {
		InlineCompletionsController.get(_)?.model.get()?.previous();
	}
}, TriggerInlineSuggestionAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inlineSuggest.trigger",
			label: localize("action.inlineSuggest.trigger", "Trigger Inline Suggestion"),
			alias: "Trigger Inline Suggestion",
			precondition: EditorContextKeys.writable
		});
	}
	async run(e, _) {
		let v = InlineCompletionsController.get(_);
		await asyncTransaction(async (e) => {
			await v?.model.get()?.triggerExplicitly(e), v?.playAccessibilitySignal(e);
		});
	}
}, AcceptNextWordOfInlineCompletion = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inlineSuggest.acceptNextWord",
			label: localize("action.inlineSuggest.acceptNextWord", "Accept Next Word Of Inline Suggestion"),
			alias: "Accept Next Word Of Inline Suggestion",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
			kbOpts: {
				weight: 101,
				primary: 2065,
				kbExpr: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible)
			},
			menuOpts: [{
				menuId: MenuId.InlineSuggestionToolbar,
				title: localize("acceptWord", "Accept Word"),
				group: "primary",
				order: 2
			}]
		});
	}
	async run(e, _) {
		let v = InlineCompletionsController.get(_);
		await v?.model.get()?.acceptNextWord(v.editor);
	}
}, AcceptNextLineOfInlineCompletion = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inlineSuggest.acceptNextLine",
			label: localize("action.inlineSuggest.acceptNextLine", "Accept Next Line Of Inline Suggestion"),
			alias: "Accept Next Line Of Inline Suggestion",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineCompletionContextKeys.inlineSuggestionVisible),
			kbOpts: { weight: 101 },
			menuOpts: [{
				menuId: MenuId.InlineSuggestionToolbar,
				title: localize("acceptLine", "Accept Line"),
				group: "secondary",
				order: 2
			}]
		});
	}
	async run(e, _) {
		let v = InlineCompletionsController.get(_);
		await v?.model.get()?.acceptNextLine(v.editor);
	}
}, AcceptInlineCompletion = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inlineSuggest.commit",
			label: localize("action.inlineSuggest.accept", "Accept Inline Suggestion"),
			alias: "Accept Inline Suggestion",
			precondition: InlineCompletionContextKeys.inlineSuggestionVisible,
			menuOpts: [{
				menuId: MenuId.InlineSuggestionToolbar,
				title: localize("accept", "Accept"),
				group: "primary",
				order: 1
			}],
			kbOpts: {
				primary: 2,
				weight: 200,
				kbExpr: ContextKeyExpr.and(InlineCompletionContextKeys.inlineSuggestionVisible, EditorContextKeys.tabMovesFocus.toNegated(), InlineCompletionContextKeys.inlineSuggestionHasIndentationLessThanTabSize, Context$1.Visible.toNegated(), EditorContextKeys.hoverFocused.toNegated())
			}
		});
	}
	async run(e, _) {
		let v = InlineCompletionsController.get(_);
		v && (v.model.get()?.accept(v.editor), v.editor.focus());
	}
}, HideInlineCompletion = class e extends EditorAction {
	static {
		this.ID = "editor.action.inlineSuggest.hide";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("action.inlineSuggest.hide", "Hide Inline Suggestion"),
			alias: "Hide Inline Suggestion",
			precondition: InlineCompletionContextKeys.inlineSuggestionVisible,
			kbOpts: {
				weight: 100,
				primary: 9
			}
		});
	}
	async run(e, _) {
		let v = InlineCompletionsController.get(_);
		transaction((e) => {
			v?.model.get()?.stop(e);
		});
	}
}, ToggleAlwaysShowInlineSuggestionToolbar = class e extends Action2 {
	static {
		this.ID = "editor.action.inlineSuggest.toggleAlwaysShowToolbar";
	}
	constructor() {
		super({
			id: e.ID,
			title: localize("action.inlineSuggest.alwaysShowToolbar", "Always Show Toolbar"),
			f1: !1,
			precondition: void 0,
			menu: [{
				id: MenuId.InlineSuggestionToolbar,
				group: "secondary",
				order: 10
			}],
			toggled: ContextKeyExpr.equals("config.editor.inlineSuggest.showToolbar", "always")
		});
	}
	async run(e, _) {
		let v = e.get(IConfigurationService), y = v.getValue("editor.inlineSuggest.showToolbar") === "always" ? "onHover" : "always";
		v.updateValue("editor.inlineSuggest.showToolbar", y);
	}
}, __decorate$48 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$48 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineCompletionsHover = class {
	constructor(e, _, v) {
		this.owner = e, this.range = _, this.controller = v;
	}
	isValidForHoverAnchor(e) {
		return e.type === 1 && this.range.startColumn <= e.range.startColumn && this.range.endColumn >= e.range.endColumn;
	}
}, InlineCompletionsHoverParticipant = class {
	constructor(e, _, v, y, b, x) {
		this._editor = e, this._languageService = _, this._openerService = v, this.accessibilityService = y, this._instantiationService = b, this._telemetryService = x, this.hoverOrdinal = 4;
	}
	suggestHoverAnchor(e) {
		let _ = InlineCompletionsController.get(this._editor);
		if (!_) return null;
		let v = e.target;
		if (v.type === 8) {
			let y = v.detail;
			if (_.shouldShowHoverAtViewZone(y.viewZoneId)) return new HoverForeignElementAnchor(1e3, this, Range.fromPositions(this._editor.getModel().validatePosition(y.positionBefore || y.position)), e.event.posx, e.event.posy, !1);
		}
		return v.type === 7 && _.shouldShowHoverAt(v.range) || v.type === 6 && v.detail.mightBeForeignElement && _.shouldShowHoverAt(v.range) ? new HoverForeignElementAnchor(1e3, this, v.range, e.event.posx, e.event.posy, !1) : null;
	}
	computeSync(e, _) {
		if (this._editor.getOption(62).showToolbar !== "onHover") return [];
		let v = InlineCompletionsController.get(this._editor);
		return v && v.shouldShowHoverAt(e.range) ? [new InlineCompletionsHover(this, e.range, v)] : [];
	}
	renderHoverParts(e, _) {
		let v = new DisposableStore(), y = _[0];
		this._telemetryService.publicLog2("inlineCompletionHover.shown"), this.accessibilityService.isScreenReaderOptimized() && !this._editor.getOption(8) && v.add(this.renderScreenReaderText(e, y));
		let b = y.controller.model.get(), x = this._instantiationService.createInstance(InlineSuggestionHintsContentWidget, this._editor, !1, constObservable(null), b.selectedInlineCompletionIndex, b.inlineCompletionsCount, b.activeCommands), S = x.getDomNode();
		return e.fragment.appendChild(S), b.triggerExplicitly(), v.add(x), new RenderedHoverParts([{
			hoverPart: y,
			hoverElement: S,
			dispose() {
				v.dispose();
			}
		}]);
	}
	renderScreenReaderText(e, _) {
		let v = new DisposableStore(), y = $, b = y("div.hover-row.markdown-hover"), x = append(b, y("div.hover-contents", { "aria-live": "assertive" })), S = v.add(new MarkdownRenderer({ editor: this._editor }, this._languageService, this._openerService)), C = (_) => {
			v.add(S.onDidRenderAsync(() => {
				x.className = "hover-contents code-hover-contents", e.onContentsChanged();
			}));
			let y = localize("inlineSuggestionFollows", "Suggestion:"), b = v.add(S.render(new MarkdownString().appendText(y).appendCodeblock("text", _)));
			x.replaceChildren(b.element);
		};
		return v.add(autorun((e) => {
			let v = _.controller.model.read(e)?.primaryGhostText.read(e);
			if (v) {
				let e = this._editor.getModel().getLineContent(v.lineNumber);
				C(v.renderForScreenReader(e));
			} else reset(x);
		})), e.fragment.appendChild(b), v;
	}
};
InlineCompletionsHoverParticipant = __decorate$48([
	__param$48(1, ILanguageService),
	__param$48(2, IOpenerService),
	__param$48(3, IAccessibilityService),
	__param$48(4, IInstantiationService),
	__param$48(5, ITelemetryService)
], InlineCompletionsHoverParticipant);
var InlineCompletionsAccessibleView = class {};
const AccessibleViewRegistry = new class {
	constructor() {
		this._implementations = [];
	}
	register(e) {
		return this._implementations.push(e), { dispose: () => {
			let _ = this._implementations.indexOf(e);
			_ !== -1 && this._implementations.splice(_, 1);
		} };
	}
	getImplementations() {
		return this._implementations;
	}
}();
registerEditorContribution(InlineCompletionsController.ID, InlineCompletionsController, 3), registerEditorAction(TriggerInlineSuggestionAction), registerEditorAction(ShowNextInlineSuggestionAction), registerEditorAction(ShowPreviousInlineSuggestionAction), registerEditorAction(AcceptNextWordOfInlineCompletion), registerEditorAction(AcceptNextLineOfInlineCompletion), registerEditorAction(AcceptInlineCompletion), registerEditorAction(HideInlineCompletion), registerAction2(ToggleAlwaysShowInlineSuggestionToolbar), HoverParticipantRegistry.register(InlineCompletionsHoverParticipant), AccessibleViewRegistry.register(new InlineCompletionsAccessibleView());
var __decorate$47 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$47 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, GotoDefinitionAtPositionEditorContribution_1, GotoDefinitionAtPositionEditorContribution = class {
	static {
		GotoDefinitionAtPositionEditorContribution_1 = this;
	}
	static {
		this.ID = "editor.contrib.gotodefinitionatposition";
	}
	static {
		this.MAX_SOURCE_PREVIEW_LINES = 8;
	}
	constructor(e, _, v, y) {
		this.textModelResolverService = _, this.languageService = v, this.languageFeaturesService = y, this.toUnhook = new DisposableStore(), this.toUnhookForKeyboard = new DisposableStore(), this.currentWordAtPosition = null, this.previousPromise = null, this.editor = e, this.linkDecorations = this.editor.createDecorationsCollection();
		let b = new ClickLinkGesture(e);
		this.toUnhook.add(b), this.toUnhook.add(b.onMouseMoveOrRelevantKeyDown(([e, _]) => {
			this.startFindDefinitionFromMouse(e, _ ?? void 0);
		})), this.toUnhook.add(b.onExecute((e) => {
			this.isEnabled(e) && this.gotoDefinition(e.target.position, e.hasSideBySideModifier).catch((e) => {
				onUnexpectedError(e);
			}).finally(() => {
				this.removeLinkDecorations();
			});
		})), this.toUnhook.add(b.onCancel(() => {
			this.removeLinkDecorations(), this.currentWordAtPosition = null;
		}));
	}
	static get(e) {
		return e.getContribution(GotoDefinitionAtPositionEditorContribution_1.ID);
	}
	async startFindDefinitionFromCursor(e) {
		await this.startFindDefinition(e), this.toUnhookForKeyboard.add(this.editor.onDidChangeCursorPosition(() => {
			this.currentWordAtPosition = null, this.removeLinkDecorations(), this.toUnhookForKeyboard.clear();
		})), this.toUnhookForKeyboard.add(this.editor.onKeyDown((e) => {
			e && (this.currentWordAtPosition = null, this.removeLinkDecorations(), this.toUnhookForKeyboard.clear());
		}));
	}
	startFindDefinitionFromMouse(e, _) {
		if (e.target.type === 9 && this.linkDecorations.length > 0) return;
		if (!this.editor.hasModel() || !this.isEnabled(e, _)) {
			this.currentWordAtPosition = null, this.removeLinkDecorations();
			return;
		}
		let v = e.target.position;
		this.startFindDefinition(v);
	}
	async startFindDefinition(e) {
		this.toUnhookForKeyboard.clear();
		let _ = e ? this.editor.getModel()?.getWordAtPosition(e) : null;
		if (!_) {
			this.currentWordAtPosition = null, this.removeLinkDecorations();
			return;
		}
		if (this.currentWordAtPosition && this.currentWordAtPosition.startColumn === _.startColumn && this.currentWordAtPosition.endColumn === _.endColumn && this.currentWordAtPosition.word === _.word) return;
		this.currentWordAtPosition = _;
		let v = new EditorState(this.editor, 15);
		this.previousPromise &&= (this.previousPromise.cancel(), null), this.previousPromise = createCancelablePromise((_) => this.findDefinition(e, _));
		let y;
		try {
			y = await this.previousPromise;
		} catch (e) {
			onUnexpectedError(e);
			return;
		}
		if (!y || !y.length || !v.validate(this.editor)) {
			this.removeLinkDecorations();
			return;
		}
		let b = y[0].originSelectionRange ? Range.lift(y[0].originSelectionRange) : new Range(e.lineNumber, _.startColumn, e.lineNumber, _.endColumn);
		if (y.length > 1) {
			let e = b;
			for (let { originSelectionRange: _ } of y) _ && (e = Range.plusRange(e, _));
			this.addDecoration(e, new MarkdownString().appendText(localize("multipleResults", "Click to show {0} definitions.", y.length)));
		} else {
			let e = y[0];
			if (!e.uri) return;
			this.textModelResolverService.createModelReference(e.uri).then((_) => {
				if (!_.object || !_.object.textEditorModel) {
					_.dispose();
					return;
				}
				let { object: { textEditorModel: v } } = _, { startLineNumber: y } = e.range;
				if (y < 1 || y > v.getLineCount()) {
					_.dispose();
					return;
				}
				let x = this.getPreviewValue(v, y, e), S = this.languageService.guessLanguageIdByFilepathOrFirstLine(v.uri);
				this.addDecoration(b, x ? new MarkdownString().appendCodeblock(S || "", x) : void 0), _.dispose();
			});
		}
	}
	getPreviewValue(e, _, v) {
		let y = v.range;
		return y.endLineNumber - y.startLineNumber >= GotoDefinitionAtPositionEditorContribution_1.MAX_SOURCE_PREVIEW_LINES && (y = this.getPreviewRangeBasedOnIndentation(e, _)), this.stripIndentationFromPreviewRange(e, _, y);
	}
	stripIndentationFromPreviewRange(e, _, v) {
		let y = e.getLineFirstNonWhitespaceColumn(_);
		for (let b = _ + 1; b < v.endLineNumber; b++) {
			let _ = e.getLineFirstNonWhitespaceColumn(b);
			y = Math.min(y, _);
		}
		return e.getValueInRange(v).replace(RegExp(`^\\s{${y - 1}}`, "gm"), "").trim();
	}
	getPreviewRangeBasedOnIndentation(e, _) {
		let v = e.getLineFirstNonWhitespaceColumn(_), y = Math.min(e.getLineCount(), _ + GotoDefinitionAtPositionEditorContribution_1.MAX_SOURCE_PREVIEW_LINES), b = _ + 1;
		for (; b < y; b++) {
			let _ = e.getLineFirstNonWhitespaceColumn(b);
			if (v === _) break;
		}
		return new Range(_, 1, b + 1, 1);
	}
	addDecoration(e, _) {
		let v = {
			range: e,
			options: {
				description: "goto-definition-link",
				inlineClassName: "goto-definition-link",
				hoverMessage: _
			}
		};
		this.linkDecorations.set([v]);
	}
	removeLinkDecorations() {
		this.linkDecorations.clear();
	}
	isEnabled(e, _) {
		return this.editor.hasModel() && e.isLeftClick && e.isNoneOrSingleMouseDown && e.target.type === 6 && !(e.target.detail.injectedText?.options instanceof ModelDecorationInjectedTextOptions) && (e.hasTriggerModifier || (_ ? _.keyCodeIsTriggerKey : !1)) && this.languageFeaturesService.definitionProvider.has(this.editor.getModel());
	}
	findDefinition(e, _) {
		let v = this.editor.getModel();
		return v ? getDefinitionsAtPosition(this.languageFeaturesService.definitionProvider, v, e, !1, _) : Promise.resolve(null);
	}
	gotoDefinition(e, _) {
		return this.editor.setPosition(e), this.editor.invokeWithinContext((e) => {
			let v = !_ && this.editor.getOption(89) && !this.isInPeekEditor(e);
			return new DefinitionAction({
				openToSide: _,
				openInPeek: v,
				muteMessage: !0
			}, {
				title: {
					value: "",
					original: ""
				},
				id: "",
				precondition: void 0
			}).run(e);
		});
	}
	isInPeekEditor(e) {
		let _ = e.get(IContextKeyService);
		return PeekContext.inPeekEditor.getValue(_);
	}
	dispose() {
		this.toUnhook.dispose(), this.toUnhookForKeyboard.dispose();
	}
};
GotoDefinitionAtPositionEditorContribution = GotoDefinitionAtPositionEditorContribution_1 = __decorate$47([
	__param$47(1, ITextModelService),
	__param$47(2, ILanguageService),
	__param$47(3, ILanguageFeaturesService)
], GotoDefinitionAtPositionEditorContribution), registerEditorContribution(GotoDefinitionAtPositionEditorContribution.ID, GotoDefinitionAtPositionEditorContribution, 2);
var __decorate$46 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$46 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, MarkerCoordinate = class {
	constructor(e, _, v) {
		this.marker = e, this.index = _, this.total = v;
	}
}, MarkerList = class {
	constructor(e, _, v) {
		this._markerService = _, this._configService = v, this._onDidChange = new Emitter(), this.onDidChange = this._onDidChange.event, this._dispoables = new DisposableStore(), this._markers = [], this._nextIdx = -1, URI.isUri(e) ? this._resourceFilter = (_) => _.toString() === e.toString() : e && (this._resourceFilter = e);
		let y = this._configService.getValue("problems.sortOrder"), b = (e, _) => {
			let v = compare(e.resource.toString(), _.resource.toString());
			return v === 0 && (v = y === "position" ? Range.compareRangesUsingStarts(e, _) || MarkerSeverity.compare(e.severity, _.severity) : MarkerSeverity.compare(e.severity, _.severity) || Range.compareRangesUsingStarts(e, _)), v;
		}, x = () => {
			this._markers = this._markerService.read({
				resource: URI.isUri(e) ? e : void 0,
				severities: MarkerSeverity.Error | MarkerSeverity.Warning | MarkerSeverity.Info
			}), typeof e == "function" && (this._markers = this._markers.filter((e) => this._resourceFilter(e.resource))), this._markers.sort(b);
		};
		x(), this._dispoables.add(_.onMarkerChanged((e) => {
			(!this._resourceFilter || e.some((e) => this._resourceFilter(e))) && (x(), this._nextIdx = -1, this._onDidChange.fire());
		}));
	}
	dispose() {
		this._dispoables.dispose(), this._onDidChange.dispose();
	}
	matches(e) {
		return !this._resourceFilter && !e ? !0 : !this._resourceFilter || !e ? !1 : this._resourceFilter(e);
	}
	get selected() {
		let e = this._markers[this._nextIdx];
		return e && new MarkerCoordinate(e, this._nextIdx + 1, this._markers.length);
	}
	_initIdx(e, _, v) {
		let y = !1, b = this._markers.findIndex((_) => _.resource.toString() === e.uri.toString());
		b < 0 && (b = binarySearch(this._markers, { resource: e.uri }, (e, _) => compare(e.resource.toString(), _.resource.toString())), b < 0 && (b = ~b));
		for (let v = b; v < this._markers.length; v++) {
			let b = Range.lift(this._markers[v]);
			if (b.isEmpty()) {
				let _ = e.getWordAtPosition(b.getStartPosition());
				_ && (b = new Range(b.startLineNumber, _.startColumn, b.startLineNumber, _.endColumn));
			}
			if (_ && (b.containsPosition(_) || _.isBeforeOrEqual(b.getStartPosition()))) {
				this._nextIdx = v, y = !0;
				break;
			}
			if (this._markers[v].resource.toString() !== e.uri.toString()) break;
		}
		y || (this._nextIdx = v ? 0 : this._markers.length - 1), this._nextIdx < 0 && (this._nextIdx = this._markers.length - 1);
	}
	resetIndex() {
		this._nextIdx = -1;
	}
	move(e, _, v) {
		if (this._markers.length === 0) return !1;
		let y = this._nextIdx;
		return this._nextIdx === -1 ? this._initIdx(_, v, e) : e ? this._nextIdx = (this._nextIdx + 1) % this._markers.length : e || (this._nextIdx = (this._nextIdx - 1 + this._markers.length) % this._markers.length), y !== this._nextIdx;
	}
	find(e, _) {
		let v = this._markers.findIndex((_) => _.resource.toString() === e.toString());
		if (!(v < 0)) {
			for (; v < this._markers.length; v++) if (Range.containsPosition(this._markers[v], _)) return new MarkerCoordinate(this._markers[v], v + 1, this._markers.length);
		}
	}
};
MarkerList = __decorate$46([__param$46(1, IMarkerService), __param$46(2, IConfigurationService)], MarkerList);
const IMarkerNavigationService = createDecorator("IMarkerNavigationService");
var MarkerNavigationService = class {
	constructor(e, _) {
		this._markerService = e, this._configService = _, this._provider = new LinkedList();
	}
	getMarkerList(e) {
		for (let _ of this._provider) {
			let v = _.getMarkerList(e);
			if (v) return v;
		}
		return new MarkerList(e, this._markerService, this._configService);
	}
};
MarkerNavigationService = __decorate$46([__param$46(0, IMarkerService), __param$46(1, IConfigurationService)], MarkerNavigationService), registerSingleton(IMarkerNavigationService, MarkerNavigationService, 1);
var SeverityIcon;
(function(e) {
	function _(e) {
		switch (e) {
			case severity_default.Ignore: return "severity-ignore " + ThemeIcon.asClassName(Codicon.info);
			case severity_default.Info: return ThemeIcon.asClassName(Codicon.info);
			case severity_default.Warning: return ThemeIcon.asClassName(Codicon.warning);
			case severity_default.Error: return ThemeIcon.asClassName(Codicon.error);
			default: return "";
		}
	}
	e.className = _;
})(SeverityIcon ||= {});
var __decorate$45 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$45 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, MarkerNavigationWidget_1, MessageWidget = class {
	constructor(e, _, v, y, b) {
		this._openerService = y, this._labelService = b, this._lines = 0, this._longestLineLength = 0, this._relatedDiagnostics = /* @__PURE__ */ new WeakMap(), this._disposables = new DisposableStore(), this._editor = _;
		let x = document.createElement("div");
		x.className = "descriptioncontainer", this._messageBlock = document.createElement("div"), this._messageBlock.classList.add("message"), this._messageBlock.setAttribute("aria-live", "assertive"), this._messageBlock.setAttribute("role", "alert"), x.appendChild(this._messageBlock), this._relatedBlock = document.createElement("div"), x.appendChild(this._relatedBlock), this._disposables.add(addStandardDisposableListener(this._relatedBlock, "click", (e) => {
			e.preventDefault();
			let _ = this._relatedDiagnostics.get(e.target);
			_ && v(_);
		})), this._scrollable = new ScrollableElement(x, {
			horizontal: 1,
			vertical: 1,
			useShadows: !1,
			horizontalScrollbarSize: 6,
			verticalScrollbarSize: 6
		}), e.appendChild(this._scrollable.getDomNode()), this._disposables.add(this._scrollable.onScroll((e) => {
			x.style.left = `-${e.scrollLeft}px`, x.style.top = `-${e.scrollTop}px`;
		})), this._disposables.add(this._scrollable);
	}
	dispose() {
		dispose(this._disposables);
	}
	update(e) {
		let { source: _, message: v, relatedInformation: y, code: b } = e, x = (_?.length || 0) + 2;
		b && (typeof b == "string" ? x += b.length : x += b.value.length);
		let S = splitLines(v);
		this._lines = S.length, this._longestLineLength = 0;
		for (let e of S) this._longestLineLength = Math.max(e.length + x, this._longestLineLength);
		clearNode(this._messageBlock), this._messageBlock.setAttribute("aria-label", this.getAriaLabel(e)), this._editor.applyFontInfo(this._messageBlock);
		let C = this._messageBlock;
		for (let e of S) C = document.createElement("div"), C.innerText = e, e === "" && (C.style.height = this._messageBlock.style.lineHeight), this._messageBlock.appendChild(C);
		if (_ || b) {
			let e = document.createElement("span");
			if (e.classList.add("details"), C.appendChild(e), _) {
				let v = document.createElement("span");
				v.innerText = _, v.classList.add("source"), e.appendChild(v);
			}
			if (b) if (typeof b == "string") {
				let _ = document.createElement("span");
				_.innerText = `(${b})`, _.classList.add("code"), e.appendChild(_);
			} else {
				this._codeLink = $("a.code-link"), this._codeLink.setAttribute("href", `${b.target.toString()}`), this._codeLink.onclick = (e) => {
					this._openerService.open(b.target, { allowCommands: !0 }), e.preventDefault(), e.stopPropagation();
				};
				let _ = append(this._codeLink, $("span"));
				_.innerText = b.value, e.appendChild(this._codeLink);
			}
		}
		if (clearNode(this._relatedBlock), this._editor.applyFontInfo(this._relatedBlock), isNonEmptyArray(y)) {
			let e = this._relatedBlock.appendChild(document.createElement("div"));
			e.style.paddingTop = `${Math.floor(this._editor.getOption(67) * .66)}px`, this._lines += 1;
			for (let _ of y) {
				let v = document.createElement("div"), y = document.createElement("a");
				y.classList.add("filename"), y.innerText = `${this._labelService.getUriBasenameLabel(_.resource)}(${_.startLineNumber}, ${_.startColumn}): `, y.title = this._labelService.getUriLabel(_.resource), this._relatedDiagnostics.set(y, _);
				let b = document.createElement("span");
				b.innerText = _.message, v.appendChild(y), v.appendChild(b), this._lines += 1, e.appendChild(v);
			}
		}
		let w = this._editor.getOption(50), T = Math.ceil(w.typicalFullwidthCharacterWidth * this._longestLineLength * .75), E = w.lineHeight * this._lines;
		this._scrollable.setScrollDimensions({
			scrollWidth: T,
			scrollHeight: E
		});
	}
	layout(e, _) {
		this._scrollable.getDomNode().style.height = `${e}px`, this._scrollable.getDomNode().style.width = `${_}px`, this._scrollable.setScrollDimensions({
			width: _,
			height: e
		});
	}
	getHeightInLines() {
		return Math.min(17, this._lines);
	}
	getAriaLabel(e) {
		let _ = "";
		switch (e.severity) {
			case MarkerSeverity.Error:
				_ = localize("Error", "Error");
				break;
			case MarkerSeverity.Warning:
				_ = localize("Warning", "Warning");
				break;
			case MarkerSeverity.Info:
				_ = localize("Info", "Info");
				break;
			case MarkerSeverity.Hint:
				_ = localize("Hint", "Hint");
				break;
		}
		let v = localize("marker aria", "{0} at {1}. ", _, e.startLineNumber + ":" + e.startColumn), y = this._editor.getModel();
		return y && e.startLineNumber <= y.getLineCount() && e.startLineNumber >= 1 && (v = `${y.getLineContent(e.startLineNumber)}, ${v}`), v;
	}
}, MarkerNavigationWidget = class extends PeekViewWidget {
	static {
		MarkerNavigationWidget_1 = this;
	}
	static {
		this.TitleMenu = new MenuId("gotoErrorTitleMenu");
	}
	constructor(e, _, v, y, b, x, S) {
		super(e, {
			showArrow: !0,
			showFrame: !0,
			isAccessible: !0,
			frameWidth: 1
		}, b), this._themeService = _, this._openerService = v, this._menuService = y, this._contextKeyService = x, this._labelService = S, this._callOnDispose = new DisposableStore(), this._onDidSelectRelatedInformation = new Emitter(), this.onDidSelectRelatedInformation = this._onDidSelectRelatedInformation.event, this._severity = MarkerSeverity.Warning, this._backgroundColor = Color.white, this._applyTheme(_.getColorTheme()), this._callOnDispose.add(_.onDidColorThemeChange(this._applyTheme.bind(this))), this.create();
	}
	_applyTheme(e) {
		this._backgroundColor = e.getColor(editorMarkerNavigationBackground);
		let _ = editorMarkerNavigationError, v = editorMarkerNavigationErrorHeader;
		this._severity === MarkerSeverity.Warning ? (_ = editorMarkerNavigationWarning, v = editorMarkerNavigationWarningHeader) : this._severity === MarkerSeverity.Info && (_ = editorMarkerNavigationInfo, v = editorMarkerNavigationInfoHeader);
		let y = e.getColor(_), b = e.getColor(v);
		this.style({
			arrowColor: y,
			frameColor: y,
			headerBackgroundColor: b,
			primaryHeadingColor: e.getColor(peekViewTitleForeground),
			secondaryHeadingColor: e.getColor(peekViewTitleInfoForeground)
		});
	}
	_applyStyles() {
		this._parentContainer && (this._parentContainer.style.backgroundColor = this._backgroundColor ? this._backgroundColor.toString() : ""), super._applyStyles();
	}
	dispose() {
		this._callOnDispose.dispose(), super.dispose();
	}
	_fillHead(e) {
		super._fillHead(e), this._disposables.add(this._actionbarWidget.actionRunner.onWillRun((e) => this.editor.focus()));
		let _ = [], v = this._menuService.getMenuActions(MarkerNavigationWidget_1.TitleMenu, this._contextKeyService);
		createAndFillInActionBarActions(v, _), this._actionbarWidget.push(_, {
			label: !1,
			icon: !0,
			index: 0
		});
	}
	_fillTitleIcon(e) {
		this._icon = append(e, $(""));
	}
	_fillBody(e) {
		this._parentContainer = e, e.classList.add("marker-widget"), this._parentContainer.tabIndex = 0, this._parentContainer.setAttribute("role", "tooltip"), this._container = document.createElement("div"), e.appendChild(this._container), this._message = new MessageWidget(this._container, this.editor, (e) => this._onDidSelectRelatedInformation.fire(e), this._openerService, this._labelService), this._disposables.add(this._message);
	}
	show() {
		throw Error("call showAtMarker");
	}
	showAtMarker(e, _, v) {
		this._container.classList.remove("stale"), this._message.update(e), this._severity = e.severity, this._applyTheme(this._themeService.getColorTheme());
		let y = Range.lift(e), b = this.editor.getPosition(), x = b && y.containsPosition(b) ? b : y.getStartPosition();
		super.show(x, this.computeRequiredHeight());
		let S = this.editor.getModel();
		if (S) {
			let e = v > 1 ? localize("problems", "{0} of {1} problems", _, v) : localize("change", "{0} of {1} problem", _, v);
			this.setTitle(basename(S.uri), e);
		}
		this._icon.className = `codicon ${SeverityIcon.className(MarkerSeverity.toSeverity(this._severity))}`, this.editor.revealPositionNearTop(x, 0), this.editor.focus();
	}
	updateMarker(e) {
		this._container.classList.remove("stale"), this._message.update(e);
	}
	showStale() {
		this._container.classList.add("stale"), this._relayout();
	}
	_doLayoutBody(e, _) {
		super._doLayoutBody(e, _), this._heightInPixel = e, this._message.layout(e, _), this._container.style.height = `${e}px`;
	}
	_onWidth(e) {
		this._message.layout(this._heightInPixel, e);
	}
	_relayout() {
		super._relayout(this.computeRequiredHeight());
	}
	computeRequiredHeight() {
		return 3 + this._message.getHeightInLines();
	}
};
MarkerNavigationWidget = MarkerNavigationWidget_1 = __decorate$45([
	__param$45(1, IThemeService),
	__param$45(2, IOpenerService),
	__param$45(3, IMenuService),
	__param$45(4, IInstantiationService),
	__param$45(5, IContextKeyService),
	__param$45(6, ILabelService)
], MarkerNavigationWidget);
var errorDefault = oneOf(editorErrorForeground, editorErrorBorder), warningDefault = oneOf(editorWarningForeground, editorWarningBorder), infoDefault = oneOf(editorInfoForeground, editorInfoBorder), editorMarkerNavigationError = registerColor("editorMarkerNavigationError.background", {
	dark: errorDefault,
	light: errorDefault,
	hcDark: contrastBorder,
	hcLight: contrastBorder
}, localize("editorMarkerNavigationError", "Editor marker navigation widget error color.")), editorMarkerNavigationErrorHeader = registerColor("editorMarkerNavigationError.headerBackground", {
	dark: transparent(editorMarkerNavigationError, .1),
	light: transparent(editorMarkerNavigationError, .1),
	hcDark: null,
	hcLight: null
}, localize("editorMarkerNavigationErrorHeaderBackground", "Editor marker navigation widget error heading background.")), editorMarkerNavigationWarning = registerColor("editorMarkerNavigationWarning.background", {
	dark: warningDefault,
	light: warningDefault,
	hcDark: contrastBorder,
	hcLight: contrastBorder
}, localize("editorMarkerNavigationWarning", "Editor marker navigation widget warning color.")), editorMarkerNavigationWarningHeader = registerColor("editorMarkerNavigationWarning.headerBackground", {
	dark: transparent(editorMarkerNavigationWarning, .1),
	light: transparent(editorMarkerNavigationWarning, .1),
	hcDark: "#0C141F",
	hcLight: transparent(editorMarkerNavigationWarning, .2)
}, localize("editorMarkerNavigationWarningBackground", "Editor marker navigation widget warning heading background.")), editorMarkerNavigationInfo = registerColor("editorMarkerNavigationInfo.background", {
	dark: infoDefault,
	light: infoDefault,
	hcDark: contrastBorder,
	hcLight: contrastBorder
}, localize("editorMarkerNavigationInfo", "Editor marker navigation widget info color.")), editorMarkerNavigationInfoHeader = registerColor("editorMarkerNavigationInfo.headerBackground", {
	dark: transparent(editorMarkerNavigationInfo, .1),
	light: transparent(editorMarkerNavigationInfo, .1),
	hcDark: null,
	hcLight: null
}, localize("editorMarkerNavigationInfoHeaderBackground", "Editor marker navigation widget info heading background.")), editorMarkerNavigationBackground = registerColor("editorMarkerNavigation.background", editorBackground, localize("editorMarkerNavigationBackground", "Editor marker navigation widget background.")), __decorate$44 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$44 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, MarkerController_1, MarkerController = class {
	static {
		MarkerController_1 = this;
	}
	static {
		this.ID = "editor.contrib.markerController";
	}
	static get(e) {
		return e.getContribution(MarkerController_1.ID);
	}
	constructor(e, _, v, y, b) {
		this._markerNavigationService = _, this._contextKeyService = v, this._editorService = y, this._instantiationService = b, this._sessionDispoables = new DisposableStore(), this._editor = e, this._widgetVisible = CONTEXT_MARKERS_NAVIGATION_VISIBLE.bindTo(this._contextKeyService);
	}
	dispose() {
		this._cleanUp(), this._sessionDispoables.dispose();
	}
	_cleanUp() {
		this._widgetVisible.reset(), this._sessionDispoables.clear(), this._widget = void 0, this._model = void 0;
	}
	_getOrCreateModel(e) {
		if (this._model && this._model.matches(e)) return this._model;
		let _ = !1;
		return this._model && (_ = !0, this._cleanUp()), this._model = this._markerNavigationService.getMarkerList(e), _ && this._model.move(!0, this._editor.getModel(), this._editor.getPosition()), this._widget = this._instantiationService.createInstance(MarkerNavigationWidget, this._editor), this._widget.onDidClose(() => this.close(), this, this._sessionDispoables), this._widgetVisible.set(!0), this._sessionDispoables.add(this._model), this._sessionDispoables.add(this._widget), this._sessionDispoables.add(this._editor.onDidChangeCursorPosition((e) => {
			(!this._model?.selected || !Range.containsPosition(this._model?.selected.marker, e.position)) && this._model?.resetIndex();
		})), this._sessionDispoables.add(this._model.onDidChange(() => {
			if (!this._widget || !this._widget.position || !this._model) return;
			let e = this._model.find(this._editor.getModel().uri, this._widget.position);
			e ? this._widget.updateMarker(e.marker) : this._widget.showStale();
		})), this._sessionDispoables.add(this._widget.onDidSelectRelatedInformation((e) => {
			this._editorService.openCodeEditor({
				resource: e.resource,
				options: {
					pinned: !0,
					revealIfOpened: !0,
					selection: Range.lift(e).collapseToStart()
				}
			}, this._editor), this.close(!1);
		})), this._sessionDispoables.add(this._editor.onDidChangeModel(() => this._cleanUp())), this._model;
	}
	close(e = !0) {
		this._cleanUp(), e && this._editor.focus();
	}
	showAtMarker(e) {
		if (this._editor.hasModel()) {
			let _ = this._getOrCreateModel(this._editor.getModel().uri);
			_.resetIndex(), _.move(!0, this._editor.getModel(), new Position(e.startLineNumber, e.startColumn)), _.selected && this._widget.showAtMarker(_.selected.marker, _.selected.index, _.selected.total);
		}
	}
	async nagivate(e, _) {
		if (this._editor.hasModel()) {
			let v = this._getOrCreateModel(_ ? void 0 : this._editor.getModel().uri);
			if (v.move(e, this._editor.getModel(), this._editor.getPosition()), !v.selected) return;
			if (v.selected.marker.resource.toString() !== this._editor.getModel().uri.toString()) {
				this._cleanUp();
				let y = await this._editorService.openCodeEditor({
					resource: v.selected.marker.resource,
					options: {
						pinned: !1,
						revealIfOpened: !0,
						selectionRevealType: 2,
						selection: v.selected.marker
					}
				}, this._editor);
				y && (MarkerController_1.get(y)?.close(), MarkerController_1.get(y)?.nagivate(e, _));
			} else this._widget.showAtMarker(v.selected.marker, v.selected.index, v.selected.total);
		}
	}
};
MarkerController = MarkerController_1 = __decorate$44([
	__param$44(1, IMarkerNavigationService),
	__param$44(2, IContextKeyService),
	__param$44(3, ICodeEditorService),
	__param$44(4, IInstantiationService)
], MarkerController);
var MarkerNavigationAction = class extends EditorAction {
	constructor(e, _, v) {
		super(v), this._next = e, this._multiFile = _;
	}
	async run(e, _) {
		_.hasModel() && MarkerController.get(_)?.nagivate(this._next, this._multiFile);
	}
}, NextMarkerAction = class e extends MarkerNavigationAction {
	static {
		this.ID = "editor.action.marker.next";
	}
	static {
		this.LABEL = localize("markerAction.next.label", "Go to Next Problem (Error, Warning, Info)");
	}
	constructor() {
		super(!0, !1, {
			id: e.ID,
			label: e.LABEL,
			alias: "Go to Next Problem (Error, Warning, Info)",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 578,
				weight: 100
			},
			menuOpts: {
				menuId: MarkerNavigationWidget.TitleMenu,
				title: e.LABEL,
				icon: registerIcon("marker-navigation-next", Codicon.arrowDown, localize("nextMarkerIcon", "Icon for goto next marker.")),
				group: "navigation",
				order: 1
			}
		});
	}
}, PrevMarkerAction = class e extends MarkerNavigationAction {
	static {
		this.ID = "editor.action.marker.prev";
	}
	static {
		this.LABEL = localize("markerAction.previous.label", "Go to Previous Problem (Error, Warning, Info)");
	}
	constructor() {
		super(!1, !1, {
			id: e.ID,
			label: e.LABEL,
			alias: "Go to Previous Problem (Error, Warning, Info)",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 1602,
				weight: 100
			},
			menuOpts: {
				menuId: MarkerNavigationWidget.TitleMenu,
				title: e.LABEL,
				icon: registerIcon("marker-navigation-previous", Codicon.arrowUp, localize("previousMarkerIcon", "Icon for goto previous marker.")),
				group: "navigation",
				order: 2
			}
		});
	}
}, NextMarkerInFilesAction = class extends MarkerNavigationAction {
	constructor() {
		super(!0, !0, {
			id: "editor.action.marker.nextInFiles",
			label: localize("markerAction.nextInFiles.label", "Go to Next Problem in Files (Error, Warning, Info)"),
			alias: "Go to Next Problem in Files (Error, Warning, Info)",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 66,
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarGoMenu,
				title: localize({
					key: "miGotoNextProblem",
					comment: ["&& denotes a mnemonic"]
				}, "Next &&Problem"),
				group: "6_problem_nav",
				order: 1
			}
		});
	}
}, PrevMarkerInFilesAction = class extends MarkerNavigationAction {
	constructor() {
		super(!1, !0, {
			id: "editor.action.marker.prevInFiles",
			label: localize("markerAction.previousInFiles.label", "Go to Previous Problem in Files (Error, Warning, Info)"),
			alias: "Go to Previous Problem in Files (Error, Warning, Info)",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 1090,
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarGoMenu,
				title: localize({
					key: "miGotoPreviousProblem",
					comment: ["&& denotes a mnemonic"]
				}, "Previous &&Problem"),
				group: "6_problem_nav",
				order: 2
			}
		});
	}
};
registerEditorContribution(MarkerController.ID, MarkerController, 4), registerEditorAction(NextMarkerAction), registerEditorAction(PrevMarkerAction), registerEditorAction(NextMarkerInFilesAction), registerEditorAction(PrevMarkerInFilesAction);
var CONTEXT_MARKERS_NAVIGATION_VISIBLE = new RawContextKey("markersNavigationVisible", !1), MarkerCommand = EditorCommand.bindToContribution(MarkerController.get);
registerEditorCommand(new MarkerCommand({
	id: "closeMarkersNavigation",
	precondition: CONTEXT_MARKERS_NAVIGATION_VISIBLE,
	handler: (e) => e.close(),
	kbOpts: {
		weight: 150,
		kbExpr: EditorContextKeys.focus,
		primary: 9,
		secondary: [1033]
	}
}));
var HoverFocusBehavior;
(function(e) {
	e.NoAutoFocus = "noAutoFocus", e.FocusIfVisible = "focusIfVisible", e.AutoFocusImmediately = "autoFocusImmediately";
})(HoverFocusBehavior ||= {});
var ShowOrFocusHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.showHover",
			label: localize({
				key: "showOrFocusHover",
				comment: [
					"Label for action that will trigger the showing/focusing of a hover in the editor.",
					"If the hover is not visible, it will show the hover.",
					"This allows for users to show the hover without using the mouse."
				]
			}, "Show or Focus Hover"),
			metadata: {
				description: localize2("showOrFocusHoverDescription", "Show or focus the editor hover which shows documentation, references, and other content for a symbol at the current cursor position."),
				args: [{
					name: "args",
					schema: {
						type: "object",
						properties: { focus: {
							description: "Controls if and when the hover should take focus upon being triggered by this action.",
							enum: [
								HoverFocusBehavior.NoAutoFocus,
								HoverFocusBehavior.FocusIfVisible,
								HoverFocusBehavior.AutoFocusImmediately
							],
							enumDescriptions: [
								localize("showOrFocusHover.focus.noAutoFocus", "The hover will not automatically take focus."),
								localize("showOrFocusHover.focus.focusIfVisible", "The hover will take focus only if it is already visible."),
								localize("showOrFocusHover.focus.autoFocusImmediately", "The hover will automatically take focus when it appears.")
							],
							default: HoverFocusBehavior.FocusIfVisible
						} }
					}
				}]
			},
			alias: "Show or Focus Hover",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2087),
				weight: 100
			}
		});
	}
	run(e, _, v) {
		if (!_.hasModel()) return;
		let y = ContentHoverController.get(_);
		if (!y) return;
		let b = v?.focus, x = HoverFocusBehavior.FocusIfVisible;
		Object.values(HoverFocusBehavior).includes(b) ? x = b : typeof b == "boolean" && b && (x = HoverFocusBehavior.AutoFocusImmediately);
		let S = (e) => {
			let v = _.getPosition(), b = new Range(v.lineNumber, v.column, v.lineNumber, v.column);
			y.showContentHover(b, 1, 1, e);
		}, C = _.getOption(2) === 2;
		y.isHoverVisible ? x === HoverFocusBehavior.NoAutoFocus ? S(C) : y.focus() : S(C || x === HoverFocusBehavior.AutoFocusImmediately);
	}
}, ShowDefinitionPreviewHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.showDefinitionPreviewHover",
			label: localize({
				key: "showDefinitionPreviewHover",
				comment: ["Label for action that will trigger the showing of definition preview hover in the editor.", "This allows for users to show the definition preview hover without using the mouse."]
			}, "Show Definition Preview Hover"),
			alias: "Show Definition Preview Hover",
			precondition: void 0,
			metadata: { description: localize2("showDefinitionPreviewHoverDescription", "Show the definition preview hover in the editor.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		if (!v) return;
		let y = _.getPosition();
		if (!y) return;
		let b = new Range(y.lineNumber, y.column, y.lineNumber, y.column), x = GotoDefinitionAtPositionEditorContribution.get(_);
		x && x.startFindDefinitionFromCursor(y).then(() => {
			v.showContentHover(b, 1, 1, !0);
		});
	}
}, ScrollUpHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.scrollUpHover",
			label: localize({
				key: "scrollUpHover",
				comment: ["Action that allows to scroll up in the hover widget with the up arrow when the hover widget is focused."]
			}, "Scroll Up Hover"),
			alias: "Scroll Up Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 16,
				weight: 100
			},
			metadata: { description: localize2("scrollUpHoverDescription", "Scroll up the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.scrollUp();
	}
}, ScrollDownHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.scrollDownHover",
			label: localize({
				key: "scrollDownHover",
				comment: ["Action that allows to scroll down in the hover widget with the up arrow when the hover widget is focused."]
			}, "Scroll Down Hover"),
			alias: "Scroll Down Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 18,
				weight: 100
			},
			metadata: { description: localize2("scrollDownHoverDescription", "Scroll down the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.scrollDown();
	}
}, ScrollLeftHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.scrollLeftHover",
			label: localize({
				key: "scrollLeftHover",
				comment: ["Action that allows to scroll left in the hover widget with the left arrow when the hover widget is focused."]
			}, "Scroll Left Hover"),
			alias: "Scroll Left Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 15,
				weight: 100
			},
			metadata: { description: localize2("scrollLeftHoverDescription", "Scroll left the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.scrollLeft();
	}
}, ScrollRightHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.scrollRightHover",
			label: localize({
				key: "scrollRightHover",
				comment: ["Action that allows to scroll right in the hover widget with the right arrow when the hover widget is focused."]
			}, "Scroll Right Hover"),
			alias: "Scroll Right Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 17,
				weight: 100
			},
			metadata: { description: localize2("scrollRightHoverDescription", "Scroll right the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.scrollRight();
	}
}, PageUpHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.pageUpHover",
			label: localize({
				key: "pageUpHover",
				comment: ["Action that allows to page up in the hover widget with the page up command when the hover widget is focused."]
			}, "Page Up Hover"),
			alias: "Page Up Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 11,
				secondary: [528],
				weight: 100
			},
			metadata: { description: localize2("pageUpHoverDescription", "Page up the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.pageUp();
	}
}, PageDownHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.pageDownHover",
			label: localize({
				key: "pageDownHover",
				comment: ["Action that allows to page down in the hover widget with the page down command when the hover widget is focused."]
			}, "Page Down Hover"),
			alias: "Page Down Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 12,
				secondary: [530],
				weight: 100
			},
			metadata: { description: localize2("pageDownHoverDescription", "Page down the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.pageDown();
	}
}, GoToTopHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.goToTopHover",
			label: localize({
				key: "goToTopHover",
				comment: ["Action that allows to go to the top of the hover widget with the home command when the hover widget is focused."]
			}, "Go To Top Hover"),
			alias: "Go To Bottom Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 14,
				secondary: [2064],
				weight: 100
			},
			metadata: { description: localize2("goToTopHoverDescription", "Go to the top of the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.goToTop();
	}
}, GoToBottomHoverAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.goToBottomHover",
			label: localize({
				key: "goToBottomHover",
				comment: ["Action that allows to go to the bottom in the hover widget with the end command when the hover widget is focused."]
			}, "Go To Bottom Hover"),
			alias: "Go To Bottom Hover",
			precondition: EditorContextKeys.hoverFocused,
			kbOpts: {
				kbExpr: EditorContextKeys.hoverFocused,
				primary: 13,
				secondary: [2066],
				weight: 100
			},
			metadata: { description: localize2("goToBottomHoverDescription", "Go to the bottom of the editor hover.") }
		});
	}
	run(e, _) {
		let v = ContentHoverController.get(_);
		v && v.goToBottom();
	}
}, IncreaseHoverVerbosityLevel = class extends EditorAction {
	constructor() {
		super({
			id: INCREASE_HOVER_VERBOSITY_ACTION_ID,
			label: INCREASE_HOVER_VERBOSITY_ACTION_LABEL,
			alias: "Increase Hover Verbosity Level",
			precondition: EditorContextKeys.hoverVisible
		});
	}
	run(e, _, v) {
		let y = ContentHoverController.get(_);
		if (!y) return;
		let b = v?.index === void 0 ? y.focusedHoverPartIndex() : v.index;
		y.updateHoverVerbosityLevel(HoverVerbosityAction.Increase, b, v?.focus);
	}
}, DecreaseHoverVerbosityLevel = class extends EditorAction {
	constructor() {
		super({
			id: DECREASE_HOVER_VERBOSITY_ACTION_ID,
			label: DECREASE_HOVER_VERBOSITY_ACTION_LABEL,
			alias: "Decrease Hover Verbosity Level",
			precondition: EditorContextKeys.hoverVisible
		});
	}
	run(e, _, v) {
		let y = ContentHoverController.get(_);
		if (!y) return;
		let b = v?.index === void 0 ? y.focusedHoverPartIndex() : v.index;
		ContentHoverController.get(_)?.updateHoverVerbosityLevel(HoverVerbosityAction.Decrease, b, v?.focus);
	}
}, __decorate$43 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$43 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, $$3 = $, MarkerHover = class {
	constructor(e, _, v) {
		this.owner = e, this.range = _, this.marker = v;
	}
	isValidForHoverAnchor(e) {
		return e.type === 1 && this.range.startColumn <= e.range.startColumn && this.range.endColumn >= e.range.endColumn;
	}
}, markerCodeActionTrigger = {
	type: 1,
	filter: { include: CodeActionKind.QuickFix },
	triggerAction: CodeActionTriggerSource.QuickFixHover
}, MarkerHoverParticipant = class {
	constructor(e, _, v, y) {
		this._editor = e, this._markerDecorationsService = _, this._openerService = v, this._languageFeaturesService = y, this.hoverOrdinal = 1, this.recentMarkerCodeActionsInfo = void 0;
	}
	computeSync(e, _) {
		if (!this._editor.hasModel() || e.type !== 1 && !e.supportsMarkerHover) return [];
		let v = this._editor.getModel(), y = e.range.startLineNumber, b = v.getLineMaxColumn(y), x = [];
		for (let S of _) {
			let _ = S.range.startLineNumber === y ? S.range.startColumn : 1, C = S.range.endLineNumber === y ? S.range.endColumn : b, w = this._markerDecorationsService.getMarker(v.uri, S);
			if (!w) continue;
			let T = new Range(e.range.startLineNumber, _, e.range.startLineNumber, C);
			x.push(new MarkerHover(this, T, w));
		}
		return x;
	}
	renderHoverParts(e, _) {
		if (!_.length) return new RenderedHoverParts([]);
		let v = new DisposableStore(), y = [];
		_.forEach((_) => {
			let v = this._renderMarkerHover(_);
			e.fragment.appendChild(v.hoverElement), y.push(v);
		});
		let b = _.length === 1 ? _[0] : _.sort((e, _) => MarkerSeverity.compare(e.marker.severity, _.marker.severity))[0];
		return this.renderMarkerStatusbar(e, b, v), new RenderedHoverParts(y);
	}
	_renderMarkerHover(e) {
		let _ = new DisposableStore(), v = $$3("div.hover-row"), y = append(v, $$3("div.marker.hover-contents")), { source: b, message: x, code: S, relatedInformation: C } = e.marker;
		this._editor.applyFontInfo(y);
		let w = append(y, $$3("span"));
		if (w.style.whiteSpace = "pre-wrap", w.innerText = x, b || S) if (S && typeof S != "string") {
			let e = $$3("span");
			if (b) {
				let _ = append(e, $$3("span"));
				_.innerText = b;
			}
			let v = append(e, $$3("a.code-link"));
			v.setAttribute("href", S.target.toString()), _.add(addDisposableListener(v, "click", (e) => {
				this._openerService.open(S.target, { allowCommands: !0 }), e.preventDefault(), e.stopPropagation();
			}));
			let x = append(v, $$3("span"));
			x.innerText = S.value;
			let C = append(y, e);
			C.style.opacity = "0.6", C.style.paddingLeft = "6px";
		} else {
			let e = append(y, $$3("span"));
			e.style.opacity = "0.6", e.style.paddingLeft = "6px", e.innerText = b && S ? `${b}(${S})` : b || `(${S})`;
		}
		if (isNonEmptyArray(C)) for (let { message: e, resource: v, startLineNumber: b, startColumn: x } of C) {
			let S = append(y, $$3("div"));
			S.style.marginTop = "8px";
			let C = append(S, $$3("a"));
			C.innerText = `${basename(v)}(${b}, ${x}): `, C.style.cursor = "pointer", _.add(addDisposableListener(C, "click", (e) => {
				if (e.stopPropagation(), e.preventDefault(), this._openerService) {
					let e = { selection: {
						startLineNumber: b,
						startColumn: x
					} };
					this._openerService.open(v, {
						fromUserGesture: !0,
						editorOptions: e
					}).catch(onUnexpectedError);
				}
			}));
			let w = append(S, $$3("span"));
			w.innerText = e, this._editor.applyFontInfo(w);
		}
		return {
			hoverPart: e,
			hoverElement: v,
			dispose: () => _.dispose()
		};
	}
	renderMarkerStatusbar(e, _, v) {
		if (_.marker.severity === MarkerSeverity.Error || _.marker.severity === MarkerSeverity.Warning || _.marker.severity === MarkerSeverity.Info) {
			let v = MarkerController.get(this._editor);
			v && e.statusBar.addAction({
				label: localize("view problem", "View Problem"),
				commandId: NextMarkerAction.ID,
				run: () => {
					e.hide(), v.showAtMarker(_.marker), this._editor.focus();
				}
			});
		}
		if (!this._editor.getOption(92)) {
			let y = e.statusBar.append($$3("div"));
			this.recentMarkerCodeActionsInfo && (IMarkerData.makeKey(this.recentMarkerCodeActionsInfo.marker) === IMarkerData.makeKey(_.marker) ? this.recentMarkerCodeActionsInfo.hasCodeActions || (y.textContent = localize("noQuickFixes", "No quick fixes available")) : this.recentMarkerCodeActionsInfo = void 0);
			let b = this.recentMarkerCodeActionsInfo && !this.recentMarkerCodeActionsInfo.hasCodeActions ? Disposable.None : disposableTimeout(() => y.textContent = localize("checkingForQuickFixes", "Checking for quick fixes..."), 200, v);
			y.textContent ||= "\xA0";
			let x = this.getCodeActions(_.marker);
			v.add(toDisposable(() => x.cancel())), x.then((x) => {
				if (b.dispose(), this.recentMarkerCodeActionsInfo = {
					marker: _.marker,
					hasCodeActions: x.validActions.length > 0
				}, !this.recentMarkerCodeActionsInfo.hasCodeActions) {
					x.dispose(), y.textContent = localize("noQuickFixes", "No quick fixes available");
					return;
				}
				y.style.display = "none";
				let S = !1;
				v.add(toDisposable(() => {
					S || x.dispose();
				})), e.statusBar.addAction({
					label: localize("quick fixes", "Quick Fix..."),
					commandId: quickFixCommandId,
					run: (_) => {
						S = !0;
						let v = CodeActionController.get(this._editor), y = getDomNodePagePosition(_);
						e.hide(), v?.showCodeActions(markerCodeActionTrigger, x, {
							x: y.left,
							y: y.top,
							width: y.width,
							height: y.height
						});
					}
				});
			}, onUnexpectedError);
		}
	}
	getCodeActions(e) {
		return createCancelablePromise((_) => getCodeActions(this._languageFeaturesService.codeActionProvider, this._editor.getModel(), new Range(e.startLineNumber, e.startColumn, e.endLineNumber, e.endColumn), markerCodeActionTrigger, Progress.None, _));
	}
};
MarkerHoverParticipant = __decorate$43([
	__param$43(1, IMarkerDecorationsService),
	__param$43(2, IOpenerService),
	__param$43(3, ILanguageFeaturesService)
], MarkerHoverParticipant);
var MarginHoverComputer = class {
	get lineNumber() {
		return this._lineNumber;
	}
	set lineNumber(e) {
		this._lineNumber = e;
	}
	get lane() {
		return this._laneOrLine;
	}
	set lane(e) {
		this._laneOrLine = e;
	}
	constructor(e) {
		this._editor = e, this._lineNumber = -1, this._laneOrLine = GlyphMarginLane.Center;
	}
	computeSync() {
		let e = (e) => ({ value: e }), _ = this._editor.getLineDecorations(this._lineNumber), v = [], y = this._laneOrLine === "lineNo";
		if (!_) return v;
		for (let b of _) {
			let _ = b.options.glyphMargin?.position ?? GlyphMarginLane.Center;
			if (!y && _ !== this._laneOrLine) continue;
			let x = y ? b.options.lineNumberHoverMessage : b.options.glyphMarginHoverMessage;
			!x || isEmptyMarkdownString(x) || v.push(...asArray(x).map(e));
		}
		return v;
	}
}, __decorate$42 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$42 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, MarginHoverWidget_1, $$2 = $, MarginHoverWidget = class extends Disposable {
	static {
		MarginHoverWidget_1 = this;
	}
	static {
		this.ID = "editor.contrib.modesGlyphHoverWidget";
	}
	constructor(e, _, v) {
		super(), this._renderDisposeables = this._register(new DisposableStore()), this._editor = e, this._isVisible = !1, this._messages = [], this._hover = this._register(new HoverWidget()), this._hover.containerDomNode.classList.toggle("hidden", !this._isVisible), this._markdownRenderer = this._register(new MarkdownRenderer({ editor: this._editor }, _, v)), this._computer = new MarginHoverComputer(this._editor), this._hoverOperation = this._register(new HoverOperation(this._editor, this._computer)), this._register(this._hoverOperation.onResult((e) => {
			this._withResult(e.value);
		})), this._register(this._editor.onDidChangeModelDecorations(() => this._onModelDecorationsChanged())), this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(50) && this._updateFont();
		})), this._register(addStandardDisposableListener(this._hover.containerDomNode, "mouseleave", (e) => {
			this._onMouseLeave(e);
		})), this._editor.addOverlayWidget(this);
	}
	dispose() {
		this._editor.removeOverlayWidget(this), super.dispose();
	}
	getId() {
		return MarginHoverWidget_1.ID;
	}
	getDomNode() {
		return this._hover.containerDomNode;
	}
	getPosition() {
		return null;
	}
	_updateFont() {
		Array.prototype.slice.call(this._hover.contentsDomNode.getElementsByClassName("code")).forEach((e) => this._editor.applyFontInfo(e));
	}
	_onModelDecorationsChanged() {
		this._isVisible && (this._hoverOperation.cancel(), this._hoverOperation.start(0));
	}
	showsOrWillShow(e) {
		let _ = e.target;
		return _.type === 2 && _.detail.glyphMarginLane ? (this._startShowingAt(_.position.lineNumber, _.detail.glyphMarginLane), !0) : _.type === 3 ? (this._startShowingAt(_.position.lineNumber, "lineNo"), !0) : !1;
	}
	_startShowingAt(e, _) {
		this._computer.lineNumber === e && this._computer.lane === _ || (this._hoverOperation.cancel(), this.hide(), this._computer.lineNumber = e, this._computer.lane = _, this._hoverOperation.start(0));
	}
	hide() {
		this._computer.lineNumber = -1, this._hoverOperation.cancel(), this._isVisible && (this._isVisible = !1, this._hover.containerDomNode.classList.toggle("hidden", !this._isVisible));
	}
	_withResult(e) {
		this._messages = e, this._messages.length > 0 ? this._renderMessages(this._computer.lineNumber, this._messages) : this.hide();
	}
	_renderMessages(e, _) {
		this._renderDisposeables.clear();
		let v = document.createDocumentFragment();
		for (let e of _) {
			let _ = $$2("div.hover-row.markdown-hover"), y = append(_, $$2("div.hover-contents")), b = this._renderDisposeables.add(this._markdownRenderer.render(e.value));
			y.appendChild(b.element), v.appendChild(_);
		}
		this._updateContents(v), this._showAt(e);
	}
	_updateContents(e) {
		this._hover.contentsDomNode.textContent = "", this._hover.contentsDomNode.appendChild(e), this._updateFont();
	}
	_showAt(e) {
		this._isVisible || (this._isVisible = !0, this._hover.containerDomNode.classList.toggle("hidden", !this._isVisible));
		let _ = this._editor.getLayoutInfo(), v = this._editor.getTopForLineNumber(e), y = this._editor.getScrollTop(), b = this._editor.getOption(67), x = this._hover.containerDomNode.clientHeight, S = v - y - (x - b) / 2, C = _.glyphMarginLeft + _.glyphMarginWidth + (this._computer.lane === "lineNo" ? _.lineNumbersWidth : 0);
		this._hover.containerDomNode.style.left = `${C}px`, this._hover.containerDomNode.style.top = `${Math.max(Math.round(S), 0)}px`;
	}
	_onMouseLeave(e) {
		let _ = this._editor.getDomNode();
		(!_ || !isMousePositionWithinElement(_, e.x, e.y)) && this.hide();
	}
};
MarginHoverWidget = MarginHoverWidget_1 = __decorate$42([__param$42(1, ILanguageService), __param$42(2, IOpenerService)], MarginHoverWidget);
var __decorate$41 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$41 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, MarginHoverController = class extends Disposable {
	static {
		this.ID = "editor.contrib.marginHover";
	}
	constructor(e, _) {
		super(), this._editor = e, this._instantiationService = _, this.shouldKeepOpenOnEditorMouseMoveOrLeave = !1, this._listenersStore = new DisposableStore(), this._hoverState = { mouseDown: !1 }, this._reactToEditorMouseMoveRunner = this._register(new RunOnceScheduler(() => this._reactToEditorMouseMove(this._mouseMoveEvent), 0)), this._hookListeners(), this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(60) && (this._unhookListeners(), this._hookListeners());
		}));
	}
	_hookListeners() {
		let e = this._editor.getOption(60);
		this._hoverSettings = {
			enabled: e.enabled,
			sticky: e.sticky,
			hidingDelay: e.hidingDelay
		}, e.enabled ? (this._listenersStore.add(this._editor.onMouseDown((e) => this._onEditorMouseDown(e))), this._listenersStore.add(this._editor.onMouseUp(() => this._onEditorMouseUp())), this._listenersStore.add(this._editor.onMouseMove((e) => this._onEditorMouseMove(e))), this._listenersStore.add(this._editor.onKeyDown((e) => this._onKeyDown(e)))) : (this._listenersStore.add(this._editor.onMouseMove((e) => this._onEditorMouseMove(e))), this._listenersStore.add(this._editor.onKeyDown((e) => this._onKeyDown(e)))), this._listenersStore.add(this._editor.onMouseLeave((e) => this._onEditorMouseLeave(e))), this._listenersStore.add(this._editor.onDidChangeModel(() => {
			this._cancelScheduler(), this._hideWidgets();
		})), this._listenersStore.add(this._editor.onDidChangeModelContent(() => this._cancelScheduler())), this._listenersStore.add(this._editor.onDidScrollChange((e) => this._onEditorScrollChanged(e)));
	}
	_unhookListeners() {
		this._listenersStore.clear();
	}
	_cancelScheduler() {
		this._mouseMoveEvent = void 0, this._reactToEditorMouseMoveRunner.cancel();
	}
	_onEditorScrollChanged(e) {
		(e.scrollTopChanged || e.scrollLeftChanged) && this._hideWidgets();
	}
	_onEditorMouseDown(e) {
		this._hoverState.mouseDown = !0, !this._isMouseOnMarginHoverWidget(e) && this._hideWidgets();
	}
	_isMouseOnMarginHoverWidget(e) {
		let _ = this._glyphWidget?.getDomNode();
		return _ ? isMousePositionWithinElement(_, e.event.posx, e.event.posy) : !1;
	}
	_onEditorMouseUp() {
		this._hoverState.mouseDown = !1;
	}
	_onEditorMouseLeave(e) {
		this.shouldKeepOpenOnEditorMouseMoveOrLeave || (this._cancelScheduler(), !this._isMouseOnMarginHoverWidget(e) && this._hideWidgets());
	}
	_shouldNotRecomputeCurrentHoverWidget(e) {
		let _ = this._hoverSettings.sticky, v = this._isMouseOnMarginHoverWidget(e);
		return _ && v;
	}
	_onEditorMouseMove(e) {
		if (!this.shouldKeepOpenOnEditorMouseMoveOrLeave) {
			if (this._mouseMoveEvent = e, this._shouldNotRecomputeCurrentHoverWidget(e)) {
				this._reactToEditorMouseMoveRunner.cancel();
				return;
			}
			this._reactToEditorMouseMove(e);
		}
	}
	_reactToEditorMouseMove(e) {
		e && (this._tryShowHoverWidget(e) || this._hideWidgets());
	}
	_tryShowHoverWidget(e) {
		return this._getOrCreateGlyphWidget().showsOrWillShow(e);
	}
	_onKeyDown(e) {
		this._editor.hasModel() && (e.keyCode === 5 || e.keyCode === 6 || e.keyCode === 57 || e.keyCode === 4 || this._hideWidgets());
	}
	_hideWidgets() {
		this._glyphWidget?.hide();
	}
	_getOrCreateGlyphWidget() {
		return this._glyphWidget ||= this._instantiationService.createInstance(MarginHoverWidget, this._editor), this._glyphWidget;
	}
	dispose() {
		super.dispose(), this._unhookListeners(), this._listenersStore.dispose(), this._glyphWidget?.dispose();
	}
};
MarginHoverController = __decorate$41([__param$41(1, IInstantiationService)], MarginHoverController);
var HoverAccessibleView = class {}, HoverAccessibilityHelp = class {}, ExtHoverAccessibleView = class {};
registerEditorContribution(ContentHoverController.ID, ContentHoverController, 2), registerEditorContribution(MarginHoverController.ID, MarginHoverController, 2), registerEditorAction(ShowOrFocusHoverAction), registerEditorAction(ShowDefinitionPreviewHoverAction), registerEditorAction(ScrollUpHoverAction), registerEditorAction(ScrollDownHoverAction), registerEditorAction(ScrollLeftHoverAction), registerEditorAction(ScrollRightHoverAction), registerEditorAction(PageUpHoverAction), registerEditorAction(PageDownHoverAction), registerEditorAction(GoToTopHoverAction), registerEditorAction(GoToBottomHoverAction), registerEditorAction(IncreaseHoverVerbosityLevel), registerEditorAction(DecreaseHoverVerbosityLevel), HoverParticipantRegistry.register(MarkdownHoverParticipant), HoverParticipantRegistry.register(MarkerHoverParticipant), registerThemingParticipant((e, _) => {
	let v = e.getColor(editorHoverBorder);
	v && (_.addRule(`.monaco-editor .monaco-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid ${v.transparent(.5)}; }`), _.addRule(`.monaco-editor .monaco-hover hr { border-top: 1px solid ${v.transparent(.5)}; }`), _.addRule(`.monaco-editor .monaco-hover hr { border-bottom: 0px solid ${v.transparent(.5)}; }`));
}), AccessibleViewRegistry.register(new HoverAccessibleView()), AccessibleViewRegistry.register(new HoverAccessibilityHelp()), AccessibleViewRegistry.register(new ExtHoverAccessibleView());
function getSpaceCnt(e, _) {
	let v = 0;
	for (let y = 0; y < e.length; y++) e.charAt(y) === "	" ? v += _ : v++;
	return v;
}
function generateIndent(e, _, v) {
	e = e < 0 ? 0 : e;
	let y = "";
	if (!v) {
		let v = Math.floor(e / _);
		e %= _;
		for (let e = 0; e < v; e++) y += "	";
	}
	for (let _ = 0; _ < e; _++) y += " ";
	return y;
}
function getReindentEditOperations(e, _, v, y) {
	if (e.getLineCount() === 1 && e.getLineMaxColumn(1) === 1) return [];
	let b = _.getLanguageConfiguration(e.getLanguageId()).indentRulesSupport;
	if (!b) return [];
	let x = new ProcessedIndentRulesSupport(e, b, _);
	for (y = Math.min(y, e.getLineCount()); v <= y && x.shouldIgnore(v);) v++;
	if (v > y - 1) return [];
	let { tabSize: S, indentSize: C, insertSpaces: w } = e.getOptions(), T = (e, _) => (_ ||= 1, ShiftCommand.shiftIndent(e, e.length + _, S, C, w)), E = (e, _) => (_ ||= 1, ShiftCommand.unshiftIndent(e, e.length + _, S, C, w)), D = [], O = e.getLineContent(v), k = getLeadingWhitespace(O), A = k;
	x.shouldIncrease(v) ? (A = T(A), k = T(k)) : x.shouldIndentNextLine(v) && (A = T(A)), v++;
	for (let _ = v; _ <= y; _++) {
		if (doesLineStartWithString(e, _)) continue;
		let v = e.getLineContent(_), y = getLeadingWhitespace(v), b = A;
		x.shouldDecrease(_, b) && (A = E(A), k = E(k)), y !== A && D.push(EditOperation.replaceMove(new Selection(_, 1, _, y.length + 1), normalizeIndentation(A, C, w))), !x.shouldIgnore(_) && (x.shouldIncrease(_, b) ? (k = T(k), A = k) : A = x.shouldIndentNextLine(_, b) ? T(A) : k);
	}
	return D;
}
function doesLineStartWithString(e, _) {
	return e.tokenization.isCheapToTokenize(_) ? e.tokenization.getLineTokens(_).getStandardTokenType(0) === 2 : !1;
}
var __decorate$40 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$40 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, IndentationToSpacesAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.indentationToSpaces";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("indentationToSpaces", "Convert Indentation to Spaces"),
			alias: "Convert Indentation to Spaces",
			precondition: EditorContextKeys.writable,
			metadata: { description: localize2("indentationToSpacesDescription", "Convert the tab indentation to spaces.") }
		});
	}
	run(e, _) {
		let v = _.getModel();
		if (!v) return;
		let y = v.getOptions(), b = _.getSelection();
		if (!b) return;
		let x = new IndentationToSpacesCommand(b, y.tabSize);
		_.pushUndoStop(), _.executeCommands(this.id, [x]), _.pushUndoStop(), v.updateOptions({ insertSpaces: !0 });
	}
}, IndentationToTabsAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.indentationToTabs";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("indentationToTabs", "Convert Indentation to Tabs"),
			alias: "Convert Indentation to Tabs",
			precondition: EditorContextKeys.writable,
			metadata: { description: localize2("indentationToTabsDescription", "Convert the spaces indentation to tabs.") }
		});
	}
	run(e, _) {
		let v = _.getModel();
		if (!v) return;
		let y = v.getOptions(), b = _.getSelection();
		if (!b) return;
		let x = new IndentationToTabsCommand(b, y.tabSize);
		_.pushUndoStop(), _.executeCommands(this.id, [x]), _.pushUndoStop(), v.updateOptions({ insertSpaces: !1 });
	}
}, ChangeIndentationSizeAction = class extends EditorAction {
	constructor(e, _, v) {
		super(v), this.insertSpaces = e, this.displaySizeOnly = _;
	}
	run(e, _) {
		let v = e.get(IQuickInputService), y = e.get(IModelService), b = _.getModel();
		if (!b) return;
		let x = y.getCreationOptions(b.getLanguageId(), b.uri, b.isForSimpleWidget), S = b.getOptions(), C = [
			1,
			2,
			3,
			4,
			5,
			6,
			7,
			8
		].map((e) => ({
			id: e.toString(),
			label: e.toString(),
			description: e === x.tabSize && e === S.tabSize ? localize("configuredTabSize", "Configured Tab Size") : e === x.tabSize ? localize("defaultTabSize", "Default Tab Size") : e === S.tabSize ? localize("currentTabSize", "Current Tab Size") : void 0
		})), w = Math.min(b.getOptions().tabSize - 1, 7);
		setTimeout(() => {
			v.pick(C, {
				placeHolder: localize({
					key: "selectTabWidth",
					comment: ["Tab corresponds to the tab key"]
				}, "Select Tab Size for Current File"),
				activeItem: C[w]
			}).then((e) => {
				if (e && b && !b.isDisposed()) {
					let _ = parseInt(e.label, 10);
					this.displaySizeOnly ? b.updateOptions({ tabSize: _ }) : b.updateOptions({
						tabSize: _,
						indentSize: _,
						insertSpaces: this.insertSpaces
					});
				}
			});
		}, 50);
	}
}, IndentUsingTabs = class e extends ChangeIndentationSizeAction {
	static {
		this.ID = "editor.action.indentUsingTabs";
	}
	constructor() {
		super(!1, !1, {
			id: e.ID,
			label: localize("indentUsingTabs", "Indent Using Tabs"),
			alias: "Indent Using Tabs",
			precondition: void 0,
			metadata: { description: localize2("indentUsingTabsDescription", "Use indentation with tabs.") }
		});
	}
}, IndentUsingSpaces = class e extends ChangeIndentationSizeAction {
	static {
		this.ID = "editor.action.indentUsingSpaces";
	}
	constructor() {
		super(!0, !1, {
			id: e.ID,
			label: localize("indentUsingSpaces", "Indent Using Spaces"),
			alias: "Indent Using Spaces",
			precondition: void 0,
			metadata: { description: localize2("indentUsingSpacesDescription", "Use indentation with spaces.") }
		});
	}
}, ChangeTabDisplaySize = class e extends ChangeIndentationSizeAction {
	static {
		this.ID = "editor.action.changeTabDisplaySize";
	}
	constructor() {
		super(!0, !0, {
			id: e.ID,
			label: localize("changeTabDisplaySize", "Change Tab Display Size"),
			alias: "Change Tab Display Size",
			precondition: void 0,
			metadata: { description: localize2("changeTabDisplaySizeDescription", "Change the space size equivalent of the tab.") }
		});
	}
}, DetectIndentation = class e extends EditorAction {
	static {
		this.ID = "editor.action.detectIndentation";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("detectIndentation", "Detect Indentation from Content"),
			alias: "Detect Indentation from Content",
			precondition: void 0,
			metadata: { description: localize2("detectIndentationDescription", "Detect the indentation from content.") }
		});
	}
	run(e, _) {
		let v = e.get(IModelService), y = _.getModel();
		if (!y) return;
		let b = v.getCreationOptions(y.getLanguageId(), y.uri, y.isForSimpleWidget);
		y.detectIndentation(b.insertSpaces, b.tabSize);
	}
}, ReindentLinesAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.reindentlines",
			label: localize("editor.reindentlines", "Reindent Lines"),
			alias: "Reindent Lines",
			precondition: EditorContextKeys.writable,
			metadata: { description: localize2("editor.reindentlinesDescription", "Reindent the lines of the editor.") }
		});
	}
	run(e, _) {
		let v = e.get(ILanguageConfigurationService), y = _.getModel();
		if (!y) return;
		let b = getReindentEditOperations(y, v, 1, y.getLineCount());
		b.length > 0 && (_.pushUndoStop(), _.executeEdits(this.id, b), _.pushUndoStop());
	}
}, ReindentSelectedLinesAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.reindentselectedlines",
			label: localize("editor.reindentselectedlines", "Reindent Selected Lines"),
			alias: "Reindent Selected Lines",
			precondition: EditorContextKeys.writable,
			metadata: { description: localize2("editor.reindentselectedlinesDescription", "Reindent the selected lines of the editor.") }
		});
	}
	run(e, _) {
		let v = e.get(ILanguageConfigurationService), y = _.getModel();
		if (!y) return;
		let b = _.getSelections();
		if (b === null) return;
		let x = [];
		for (let e of b) {
			let _ = e.startLineNumber, b = e.endLineNumber;
			if (_ !== b && e.endColumn === 1 && b--, _ === 1) {
				if (_ === b) continue;
			} else _--;
			let S = getReindentEditOperations(y, v, _, b);
			x.push(...S);
		}
		x.length > 0 && (_.pushUndoStop(), _.executeEdits(this.id, x), _.pushUndoStop());
	}
}, AutoIndentOnPasteCommand = class {
	constructor(e, _) {
		this._initialSelection = _, this._edits = [], this._selectionId = null;
		for (let _ of e) _.range && typeof _.text == "string" && this._edits.push(_);
	}
	getEditOperations(e, _) {
		for (let e of this._edits) _.addEditOperation(Range.lift(e.range), e.text);
		let v = !1;
		Array.isArray(this._edits) && this._edits.length === 1 && this._initialSelection.isEmpty() && (this._edits[0].range.startColumn === this._initialSelection.endColumn && this._edits[0].range.startLineNumber === this._initialSelection.endLineNumber ? (v = !0, this._selectionId = _.trackSelection(this._initialSelection, !0)) : this._edits[0].range.endColumn === this._initialSelection.startColumn && this._edits[0].range.endLineNumber === this._initialSelection.startLineNumber && (v = !0, this._selectionId = _.trackSelection(this._initialSelection, !1))), v || (this._selectionId = _.trackSelection(this._initialSelection));
	}
	computeCursorState(e, _) {
		return _.getTrackedSelection(this._selectionId);
	}
}, AutoIndentOnPaste = class {
	static {
		this.ID = "editor.contrib.autoIndentOnPaste";
	}
	constructor(e, _) {
		this.editor = e, this._languageConfigurationService = _, this.callOnDispose = new DisposableStore(), this.callOnModel = new DisposableStore(), this.callOnDispose.add(e.onDidChangeConfiguration(() => this.update())), this.callOnDispose.add(e.onDidChangeModel(() => this.update())), this.callOnDispose.add(e.onDidChangeModelLanguage(() => this.update()));
	}
	update() {
		this.callOnModel.clear(), !(this.editor.getOption(12) < 4 || this.editor.getOption(55)) && this.editor.hasModel() && this.callOnModel.add(this.editor.onDidPaste(({ range: e }) => {
			this.trigger(e);
		}));
	}
	trigger(e) {
		let _ = this.editor.getSelections();
		if (_ === null || _.length > 1) return;
		let v = this.editor.getModel();
		if (!v || this.rangeContainsOnlyWhitespaceCharacters(v, e) || isStartOrEndInString(v, e) || !v.tokenization.isCheapToTokenize(e.getStartPosition().lineNumber)) return;
		let y = this.editor.getOption(12), { tabSize: b, indentSize: x, insertSpaces: S } = v.getOptions(), C = [], w = {
			shiftIndent: (e) => ShiftCommand.shiftIndent(e, e.length + 1, b, x, S),
			unshiftIndent: (e) => ShiftCommand.unshiftIndent(e, e.length + 1, b, x, S)
		}, T = e.startLineNumber;
		for (; T <= e.endLineNumber;) {
			if (this.shouldIgnoreLine(v, T)) {
				T++;
				continue;
			}
			break;
		}
		if (T > e.endLineNumber) return;
		let E = v.getLineContent(T);
		if (!/\S/.test(E.substring(0, e.startColumn - 1))) {
			let e = getGoodIndentForLine(y, v, v.getLanguageId(), T, w, this._languageConfigurationService);
			if (e !== null) {
				let _ = getLeadingWhitespace(E), y = getSpaceCnt(e, b), x = getSpaceCnt(_, b);
				if (y !== x) {
					let e = generateIndent(y, b, S);
					C.push({
						range: new Range(T, 1, T, _.length + 1),
						text: e
					}), E = e + E.substring(_.length);
				} else {
					let e = getIndentMetadata(v, T, this._languageConfigurationService);
					if (e === 0 || e === 8) return;
				}
			}
		}
		let D = T;
		for (; T < e.endLineNumber;) {
			if (!/\S/.test(v.getLineContent(T + 1))) {
				T++;
				continue;
			}
			break;
		}
		if (T !== e.endLineNumber) {
			let _ = getGoodIndentForLine(y, {
				tokenization: {
					getLineTokens: (e) => v.tokenization.getLineTokens(e),
					getLanguageId: () => v.getLanguageId(),
					getLanguageIdAtPosition: (e, _) => v.getLanguageIdAtPosition(e, _)
				},
				getLineContent: (e) => e === D ? E : v.getLineContent(e)
			}, v.getLanguageId(), T + 1, w, this._languageConfigurationService);
			if (_ !== null) {
				let y = getSpaceCnt(_, b), x = getSpaceCnt(getLeadingWhitespace(v.getLineContent(T + 1)), b);
				if (y !== x) {
					let _ = y - x;
					for (let y = T + 1; y <= e.endLineNumber; y++) {
						let e = v.getLineContent(y), x = getLeadingWhitespace(e), w = getSpaceCnt(x, b) + _, T = generateIndent(w, b, S);
						T !== x && C.push({
							range: new Range(y, 1, y, x.length + 1),
							text: T
						});
					}
				}
			}
		}
		if (C.length > 0) {
			this.editor.pushUndoStop();
			let e = new AutoIndentOnPasteCommand(C, this.editor.getSelection());
			this.editor.executeCommand("autoIndentOnPaste", e), this.editor.pushUndoStop();
		}
	}
	rangeContainsOnlyWhitespaceCharacters(e, _) {
		let v = (e) => e.trim().length === 0, y = !0;
		if (_.startLineNumber === _.endLineNumber) {
			let b = e.getLineContent(_.startLineNumber).substring(_.startColumn - 1, _.endColumn - 1);
			y = v(b);
		} else for (let b = _.startLineNumber; b <= _.endLineNumber; b++) {
			let x = e.getLineContent(b);
			if (b === _.startLineNumber) {
				let e = x.substring(_.startColumn - 1);
				y = v(e);
			} else if (b === _.endLineNumber) {
				let e = x.substring(0, _.endColumn - 1);
				y = v(e);
			} else y = e.getLineFirstNonWhitespaceColumn(b) === 0;
			if (!y) break;
		}
		return y;
	}
	shouldIgnoreLine(e, _) {
		e.tokenization.forceTokenization(_);
		let v = e.getLineFirstNonWhitespaceColumn(_);
		if (v === 0) return !0;
		let y = e.tokenization.getLineTokens(_);
		if (y.getCount() > 0) {
			let e = y.findTokenIndexAtOffset(v);
			if (e >= 0 && y.getStandardTokenType(e) === 1) return !0;
		}
		return !1;
	}
	dispose() {
		this.callOnDispose.dispose(), this.callOnModel.dispose();
	}
};
AutoIndentOnPaste = __decorate$40([__param$40(1, ILanguageConfigurationService)], AutoIndentOnPaste);
function isStartOrEndInString(e, _) {
	let v = (_) => getStandardTokenTypeAtPosition(e, _) === 2;
	return v(_.getStartPosition()) || v(_.getEndPosition());
}
function getIndentationEditOperations(e, _, v, y) {
	if (e.getLineCount() === 1 && e.getLineMaxColumn(1) === 1) return;
	let b = "";
	for (let e = 0; e < v; e++) b += " ";
	let x = new RegExp(b, "gi");
	for (let v = 1, S = e.getLineCount(); v <= S; v++) {
		let S = e.getLineFirstNonWhitespaceColumn(v);
		if (S === 0 && (S = e.getLineMaxColumn(v)), S === 1) continue;
		let C = new Range(v, 1, v, S), w = e.getValueInRange(C), T = y ? w.replace(/\t/gi, b) : w.replace(x, "	");
		_.addEditOperation(C, T);
	}
}
var IndentationToSpacesCommand = class {
	constructor(e, _) {
		this.selection = e, this.tabSize = _, this.selectionId = null;
	}
	getEditOperations(e, _) {
		this.selectionId = _.trackSelection(this.selection), getIndentationEditOperations(e, _, this.tabSize, !0);
	}
	computeCursorState(e, _) {
		return _.getTrackedSelection(this.selectionId);
	}
}, IndentationToTabsCommand = class {
	constructor(e, _) {
		this.selection = e, this.tabSize = _, this.selectionId = null;
	}
	getEditOperations(e, _) {
		this.selectionId = _.trackSelection(this.selection), getIndentationEditOperations(e, _, this.tabSize, !1);
	}
	computeCursorState(e, _) {
		return _.getTrackedSelection(this.selectionId);
	}
};
registerEditorContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste, 2), registerEditorAction(IndentationToSpacesAction), registerEditorAction(IndentationToTabsAction), registerEditorAction(IndentUsingTabs), registerEditorAction(IndentUsingSpaces), registerEditorAction(ChangeTabDisplaySize), registerEditorAction(DetectIndentation), registerEditorAction(ReindentLinesAction), registerEditorAction(ReindentSelectedLinesAction), registerEditorContribution(InlayHintsController.ID, InlayHintsController, 1), HoverParticipantRegistry.register(InlayHintsHover);
var InPlaceReplaceCommand = class {
	constructor(e, _, v) {
		this._editRange = e, this._originalSelection = _, this._text = v;
	}
	getEditOperations(e, _) {
		_.addTrackedEditOperation(this._editRange, this._text);
	}
	computeCursorState(e, _) {
		let v = _.getInverseEditOperations()[0].range;
		return this._originalSelection.isEmpty() ? new Selection(v.endLineNumber, Math.min(this._originalSelection.positionColumn, v.endColumn), v.endLineNumber, Math.min(this._originalSelection.positionColumn, v.endColumn)) : new Selection(v.endLineNumber, v.endColumn - this._text.length, v.endLineNumber, v.endColumn);
	}
}, __decorate$39 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$39 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InPlaceReplaceController_1, InPlaceReplaceController = class {
	static {
		InPlaceReplaceController_1 = this;
	}
	static {
		this.ID = "editor.contrib.inPlaceReplaceController";
	}
	static get(e) {
		return e.getContribution(InPlaceReplaceController_1.ID);
	}
	static {
		this.DECORATION = ModelDecorationOptions.register({
			description: "in-place-replace",
			className: "valueSetReplacement"
		});
	}
	constructor(e, _) {
		this.editor = e, this.editorWorkerService = _, this.decorations = this.editor.createDecorationsCollection();
	}
	dispose() {}
	run(e, _) {
		this.currentRequest?.cancel();
		let v = this.editor.getSelection(), y = this.editor.getModel();
		if (!y || !v) return;
		let b = v;
		if (b.startLineNumber !== b.endLineNumber) return;
		let x = new EditorState(this.editor, 5), S = y.uri;
		return this.editorWorkerService.canNavigateValueSet(S) ? (this.currentRequest = createCancelablePromise((e) => this.editorWorkerService.navigateValueSet(S, b, _)), this.currentRequest.then((_) => {
			if (!_ || !_.range || !_.value || !x.validate(this.editor)) return;
			let v = Range.lift(_.range), y = _.range, S = _.value.length - (b.endColumn - b.startColumn);
			y = {
				startLineNumber: y.startLineNumber,
				startColumn: y.startColumn,
				endLineNumber: y.endLineNumber,
				endColumn: y.startColumn + _.value.length
			}, S > 1 && (b = new Selection(b.startLineNumber, b.startColumn, b.endLineNumber, b.endColumn + S - 1));
			let C = new InPlaceReplaceCommand(v, b, _.value);
			this.editor.pushUndoStop(), this.editor.executeCommand(e, C), this.editor.pushUndoStop(), this.decorations.set([{
				range: y,
				options: InPlaceReplaceController_1.DECORATION
			}]), this.decorationRemover?.cancel(), this.decorationRemover = timeout(350), this.decorationRemover.then(() => this.decorations.clear()).catch(onUnexpectedError);
		}).catch(onUnexpectedError)) : Promise.resolve(void 0);
	}
};
InPlaceReplaceController = InPlaceReplaceController_1 = __decorate$39([__param$39(1, IEditorWorkerService)], InPlaceReplaceController);
var InPlaceReplaceUp = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inPlaceReplace.up",
			label: localize("InPlaceReplaceAction.previous.label", "Replace with Previous Value"),
			alias: "Replace with Previous Value",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3159,
				weight: 100
			}
		});
	}
	run(e, _) {
		let v = InPlaceReplaceController.get(_);
		return v ? v.run(this.id, !1) : Promise.resolve(void 0);
	}
}, InPlaceReplaceDown = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inPlaceReplace.down",
			label: localize("InPlaceReplaceAction.next.label", "Replace with Next Value"),
			alias: "Replace with Next Value",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3161,
				weight: 100
			}
		});
	}
	run(e, _) {
		let v = InPlaceReplaceController.get(_);
		return v ? v.run(this.id, !0) : Promise.resolve(void 0);
	}
};
registerEditorContribution(InPlaceReplaceController.ID, InPlaceReplaceController, 4), registerEditorAction(InPlaceReplaceUp), registerEditorAction(InPlaceReplaceDown), registerEditorAction(class extends EditorAction {
	constructor() {
		super({
			id: "expandLineSelection",
			label: localize("expandLineSelection", "Expand Line Selection"),
			alias: "Expand Line Selection",
			precondition: void 0,
			kbOpts: {
				weight: 0,
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 2090
			}
		});
	}
	run(e, _, v) {
		if (v ||= {}, !_.hasModel()) return;
		let y = _._getViewModel();
		y.model.pushStackElement(), y.setCursorStates(v.source, 3, CursorMoveCommands.expandLineSelection(y, y.getCursorStates())), y.revealAllCursors(v.source, !0);
	}
});
var TrimTrailingWhitespaceCommand = class {
	constructor(e, _, v) {
		this._selection = e, this._cursors = _, this._selectionId = null, this._trimInRegexesAndStrings = v;
	}
	getEditOperations(e, _) {
		let v = trimTrailingWhitespace(e, this._cursors, this._trimInRegexesAndStrings);
		for (let e = 0, y = v.length; e < y; e++) {
			let y = v[e];
			_.addEditOperation(y.range, y.text);
		}
		this._selectionId = _.trackSelection(this._selection);
	}
	computeCursorState(e, _) {
		return _.getTrackedSelection(this._selectionId);
	}
};
function trimTrailingWhitespace(e, _, v) {
	_.sort((e, _) => e.lineNumber === _.lineNumber ? e.column - _.column : e.lineNumber - _.lineNumber);
	for (let e = _.length - 2; e >= 0; e--) _[e].lineNumber === _[e + 1].lineNumber && _.splice(e, 1);
	let y = [], b = 0, x = 0, S = _.length;
	for (let C = 1, w = e.getLineCount(); C <= w; C++) {
		let w = e.getLineContent(C), T = w.length + 1, E = 0;
		if (x < S && _[x].lineNumber === C && (E = _[x].column, x++, E === T) || w.length === 0) continue;
		let D = lastNonWhitespaceIndex(w), O = 0;
		if (D === -1) O = 1;
		else if (D !== w.length - 1) O = D + 2;
		else continue;
		if (!v) {
			if (!e.tokenization.hasAccurateTokensForLine(C)) continue;
			let _ = e.tokenization.getLineTokens(C), v = _.getStandardTokenType(_.findTokenIndexAtOffset(O));
			if (v === 2 || v === 3) continue;
		}
		O = Math.max(E, O), y[b++] = EditOperation.delete(new Range(C, O, C, T));
	}
	return y;
}
var CopyLinesCommand = class {
	constructor(e, _, v) {
		this._selection = e, this._isCopyingDown = _, this._noop = v || !1, this._selectionDirection = 0, this._selectionId = null, this._startLineNumberDelta = 0, this._endLineNumberDelta = 0;
	}
	getEditOperations(e, _) {
		let v = this._selection;
		this._startLineNumberDelta = 0, this._endLineNumberDelta = 0, v.startLineNumber < v.endLineNumber && v.endColumn === 1 && (this._endLineNumberDelta = 1, v = v.setEndPosition(v.endLineNumber - 1, e.getLineMaxColumn(v.endLineNumber - 1)));
		let y = [];
		for (let _ = v.startLineNumber; _ <= v.endLineNumber; _++) y.push(e.getLineContent(_));
		let b = y.join("\n");
		b === "" && this._isCopyingDown && (this._startLineNumberDelta++, this._endLineNumberDelta++), this._noop ? _.addEditOperation(new Range(v.endLineNumber, e.getLineMaxColumn(v.endLineNumber), v.endLineNumber + 1, 1), v.endLineNumber === e.getLineCount() ? "" : "\n") : this._isCopyingDown ? _.addEditOperation(new Range(v.startLineNumber, 1, v.startLineNumber, 1), b + "\n") : _.addEditOperation(new Range(v.endLineNumber, e.getLineMaxColumn(v.endLineNumber), v.endLineNumber, e.getLineMaxColumn(v.endLineNumber)), "\n" + b), this._selectionId = _.trackSelection(v), this._selectionDirection = this._selection.getDirection();
	}
	computeCursorState(e, _) {
		let v = _.getTrackedSelection(this._selectionId);
		if (this._startLineNumberDelta !== 0 || this._endLineNumberDelta !== 0) {
			let e = v.startLineNumber, _ = v.startColumn, y = v.endLineNumber, b = v.endColumn;
			this._startLineNumberDelta !== 0 && (e += this._startLineNumberDelta, _ = 1), this._endLineNumberDelta !== 0 && (y += this._endLineNumberDelta, b = 1), v = Selection.createWithDirection(e, _, y, b, this._selectionDirection);
		}
		return v;
	}
}, __decorate$38 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$38 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, MoveLinesCommand = class {
	constructor(e, _, v, y) {
		this._languageConfigurationService = y, this._selection = e, this._isMovingDown = _, this._autoIndent = v, this._selectionId = null, this._moveEndLineSelectionShrink = !1;
	}
	getEditOperations(e, _) {
		let v = () => e.getLanguageId(), y = (_, v) => e.getLanguageIdAtPosition(_, v), b = e.getLineCount();
		if (this._isMovingDown && this._selection.endLineNumber === b) {
			this._selectionId = _.trackSelection(this._selection);
			return;
		}
		if (!this._isMovingDown && this._selection.startLineNumber === 1) {
			this._selectionId = _.trackSelection(this._selection);
			return;
		}
		this._moveEndPositionDown = !1;
		let x = this._selection;
		x.startLineNumber < x.endLineNumber && x.endColumn === 1 && (this._moveEndPositionDown = !0, x = x.setEndPosition(x.endLineNumber - 1, e.getLineMaxColumn(x.endLineNumber - 1)));
		let { tabSize: S, indentSize: C, insertSpaces: w } = e.getOptions(), T = this.buildIndentConverter(S, C, w);
		if (x.startLineNumber === x.endLineNumber && e.getLineMaxColumn(x.startLineNumber) === 1) {
			let v = x.startLineNumber, y = this._isMovingDown ? v + 1 : v - 1;
			e.getLineMaxColumn(y) === 1 ? _.addEditOperation(new Range(1, 1, 1, 1), null) : (_.addEditOperation(new Range(v, 1, v, 1), e.getLineContent(y)), _.addEditOperation(new Range(y, 1, y, e.getLineMaxColumn(y)), null)), x = new Selection(y, 1, y, 1);
		} else {
			let b, C;
			if (this._isMovingDown) {
				b = x.endLineNumber + 1, C = e.getLineContent(b), _.addEditOperation(new Range(b - 1, e.getLineMaxColumn(b - 1), b, e.getLineMaxColumn(b)), null);
				let E = C;
				if (this.shouldAutoIndent(e, x)) {
					let D = this.matchEnterRule(e, T, S, b, x.startLineNumber - 1);
					if (D !== null) {
						let _ = getLeadingWhitespace(e.getLineContent(b)), v = D + getSpaceCnt(_, S);
						E = generateIndent(v, S, w) + this.trimStart(C);
					} else {
						let _ = {
							tokenization: {
								getLineTokens: (_) => _ === x.startLineNumber ? e.tokenization.getLineTokens(b) : e.tokenization.getLineTokens(_),
								getLanguageId: v,
								getLanguageIdAtPosition: y
							},
							getLineContent: (_) => _ === x.startLineNumber ? e.getLineContent(b) : e.getLineContent(_)
						}, D = getGoodIndentForLine(this._autoIndent, _, e.getLanguageIdAtPosition(b, 1), x.startLineNumber, T, this._languageConfigurationService);
						if (D !== null) {
							let _ = getLeadingWhitespace(e.getLineContent(b)), v = getSpaceCnt(D, S), y = getSpaceCnt(_, S);
							v !== y && (E = generateIndent(v, S, w) + this.trimStart(C));
						}
					}
					_.addEditOperation(new Range(x.startLineNumber, 1, x.startLineNumber, 1), E + "\n");
					let O = this.matchEnterRuleMovingDown(e, T, S, x.startLineNumber, b, E);
					if (O !== null) O !== 0 && this.getIndentEditsOfMovingBlock(e, _, x, S, w, O);
					else {
						let C = {
							tokenization: {
								getLineTokens: (_) => _ === x.startLineNumber ? e.tokenization.getLineTokens(b) : _ >= x.startLineNumber + 1 && _ <= x.endLineNumber + 1 ? e.tokenization.getLineTokens(_ - 1) : e.tokenization.getLineTokens(_),
								getLanguageId: v,
								getLanguageIdAtPosition: y
							},
							getLineContent: (_) => _ === x.startLineNumber ? E : _ >= x.startLineNumber + 1 && _ <= x.endLineNumber + 1 ? e.getLineContent(_ - 1) : e.getLineContent(_)
						}, D = getGoodIndentForLine(this._autoIndent, C, e.getLanguageIdAtPosition(b, 1), x.startLineNumber + 1, T, this._languageConfigurationService);
						if (D !== null) {
							let v = getLeadingWhitespace(e.getLineContent(x.startLineNumber)), y = getSpaceCnt(D, S), b = getSpaceCnt(v, S);
							if (y !== b) {
								let v = y - b;
								this.getIndentEditsOfMovingBlock(e, _, x, S, w, v);
							}
						}
					}
				} else _.addEditOperation(new Range(x.startLineNumber, 1, x.startLineNumber, 1), E + "\n");
			} else if (b = x.startLineNumber - 1, C = e.getLineContent(b), _.addEditOperation(new Range(b, 1, b + 1, 1), null), _.addEditOperation(new Range(x.endLineNumber, e.getLineMaxColumn(x.endLineNumber), x.endLineNumber, e.getLineMaxColumn(x.endLineNumber)), "\n" + C), this.shouldAutoIndent(e, x)) {
				let C = {
					tokenization: {
						getLineTokens: (_) => _ === b ? e.tokenization.getLineTokens(x.startLineNumber) : e.tokenization.getLineTokens(_),
						getLanguageId: v,
						getLanguageIdAtPosition: y
					},
					getLineContent: (_) => _ === b ? e.getLineContent(x.startLineNumber) : e.getLineContent(_)
				}, E = this.matchEnterRule(e, T, S, x.startLineNumber, x.startLineNumber - 2);
				if (E !== null) E !== 0 && this.getIndentEditsOfMovingBlock(e, _, x, S, w, E);
				else {
					let v = getGoodIndentForLine(this._autoIndent, C, e.getLanguageIdAtPosition(x.startLineNumber, 1), b, T, this._languageConfigurationService);
					if (v !== null) {
						let y = getLeadingWhitespace(e.getLineContent(x.startLineNumber)), b = getSpaceCnt(v, S), C = getSpaceCnt(y, S);
						if (b !== C) {
							let v = b - C;
							this.getIndentEditsOfMovingBlock(e, _, x, S, w, v);
						}
					}
				}
			}
		}
		this._selectionId = _.trackSelection(x);
	}
	buildIndentConverter(e, _, v) {
		return {
			shiftIndent: (y) => ShiftCommand.shiftIndent(y, y.length + 1, e, _, v),
			unshiftIndent: (y) => ShiftCommand.unshiftIndent(y, y.length + 1, e, _, v)
		};
	}
	parseEnterResult(e, _, v, y, b) {
		if (b) {
			let x = b.indentation;
			b.indentAction === IndentAction.None || b.indentAction === IndentAction.Indent ? x = b.indentation + b.appendText : b.indentAction === IndentAction.IndentOutdent ? x = b.indentation : b.indentAction === IndentAction.Outdent && (x = _.unshiftIndent(b.indentation) + b.appendText);
			let S = e.getLineContent(y);
			if (this.trimStart(S).indexOf(this.trimStart(x)) >= 0) {
				let b = getLeadingWhitespace(e.getLineContent(y)), S = getLeadingWhitespace(x), C = getIndentMetadata(e, y, this._languageConfigurationService);
				C !== null && C & 2 && (S = _.unshiftIndent(S));
				let w = getSpaceCnt(S, v), T = getSpaceCnt(b, v);
				return w - T;
			}
		}
		return null;
	}
	matchEnterRuleMovingDown(e, _, v, y, b, x) {
		if (lastNonWhitespaceIndex(x) >= 0) {
			let x = e.getLineMaxColumn(b), S = getEnterAction(this._autoIndent, e, new Range(b, x, b, x), this._languageConfigurationService);
			return this.parseEnterResult(e, _, v, y, S);
		} else {
			let b = y - 1;
			for (; b >= 1;) {
				let _ = e.getLineContent(b);
				if (lastNonWhitespaceIndex(_) >= 0) break;
				b--;
			}
			if (b < 1 || y > e.getLineCount()) return null;
			let x = e.getLineMaxColumn(b), S = getEnterAction(this._autoIndent, e, new Range(b, x, b, x), this._languageConfigurationService);
			return this.parseEnterResult(e, _, v, y, S);
		}
	}
	matchEnterRule(e, _, v, y, b, x) {
		let S = b;
		for (; S >= 1;) {
			let _;
			if (_ = S === b && x !== void 0 ? x : e.getLineContent(S), lastNonWhitespaceIndex(_) >= 0) break;
			S--;
		}
		if (S < 1 || y > e.getLineCount()) return null;
		let C = e.getLineMaxColumn(S), w = getEnterAction(this._autoIndent, e, new Range(S, C, S, C), this._languageConfigurationService);
		return this.parseEnterResult(e, _, v, y, w);
	}
	trimStart(e) {
		return e.replace(/^\s+/, "");
	}
	shouldAutoIndent(e, _) {
		if (this._autoIndent < 4 || !e.tokenization.isCheapToTokenize(_.startLineNumber)) return !1;
		let v = e.getLanguageIdAtPosition(_.startLineNumber, 1), y = e.getLanguageIdAtPosition(_.endLineNumber, 1);
		return !(v !== y || this._languageConfigurationService.getLanguageConfiguration(v).indentRulesSupport === null);
	}
	getIndentEditsOfMovingBlock(e, _, v, y, b, x) {
		for (let S = v.startLineNumber; S <= v.endLineNumber; S++) {
			let C = e.getLineContent(S), w = getLeadingWhitespace(C), T = getSpaceCnt(w, y) + x, E = generateIndent(T, y, b);
			E !== w && (_.addEditOperation(new Range(S, 1, S, w.length + 1), E), S === v.endLineNumber && v.endColumn <= w.length + 1 && E === "" && (this._moveEndLineSelectionShrink = !0));
		}
	}
	computeCursorState(e, _) {
		let v = _.getTrackedSelection(this._selectionId);
		return this._moveEndPositionDown && (v = v.setEndPosition(v.endLineNumber + 1, 1)), this._moveEndLineSelectionShrink && v.startLineNumber < v.endLineNumber && (v = v.setEndPosition(v.endLineNumber, 2)), v;
	}
};
MoveLinesCommand = __decorate$38([__param$38(3, ILanguageConfigurationService)], MoveLinesCommand);
var SortLinesCommand = class e {
	static {
		this._COLLATOR = null;
	}
	static getCollator() {
		return e._COLLATOR ||= new Intl.Collator(), e._COLLATOR;
	}
	constructor(e, _) {
		this.selection = e, this.descending = _, this.selectionId = null;
	}
	getEditOperations(e, _) {
		let v = sortLines(e, this.selection, this.descending);
		v && _.addEditOperation(v.range, v.text), this.selectionId = _.trackSelection(this.selection);
	}
	computeCursorState(e, _) {
		return _.getTrackedSelection(this.selectionId);
	}
	static canRun(e, _, v) {
		if (e === null) return !1;
		let y = getSortData(e, _, v);
		if (!y) return !1;
		for (let e = 0, _ = y.before.length; e < _; e++) if (y.before[e] !== y.after[e]) return !0;
		return !1;
	}
};
function getSortData(e, _, v) {
	let y = _.startLineNumber, b = _.endLineNumber;
	if (_.endColumn === 1 && b--, y >= b) return null;
	let x = [];
	for (let _ = y; _ <= b; _++) x.push(e.getLineContent(_));
	let S = x.slice(0);
	return S.sort(SortLinesCommand.getCollator().compare), v === !0 && (S = S.reverse()), {
		startLineNumber: y,
		endLineNumber: b,
		before: x,
		after: S
	};
}
function sortLines(e, _, v) {
	let y = getSortData(e, _, v);
	return y ? EditOperation.replace(new Range(y.startLineNumber, 1, y.endLineNumber, e.getLineMaxColumn(y.endLineNumber)), y.after.join("\n")) : null;
}
var AbstractCopyLinesAction = class extends EditorAction {
	constructor(e, _) {
		super(_), this.down = e;
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getSelections().map((e, _) => ({
			selection: e,
			index: _,
			ignore: !1
		}));
		v.sort((e, _) => Range.compareRangesUsingStarts(e.selection, _.selection));
		let y = v[0];
		for (let e = 1; e < v.length; e++) {
			let _ = v[e];
			y.selection.endLineNumber === _.selection.startLineNumber && (y.index < _.index ? _.ignore = !0 : (y.ignore = !0, y = _));
		}
		let b = [];
		for (let e of v) b.push(new CopyLinesCommand(e.selection, this.down, e.ignore));
		_.pushUndoStop(), _.executeCommands(this.id, b), _.pushUndoStop();
	}
}, CopyLinesUpAction = class extends AbstractCopyLinesAction {
	constructor() {
		super(!1, {
			id: "editor.action.copyLinesUpAction",
			label: localize("lines.copyUp", "Copy Line Up"),
			alias: "Copy Line Up",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1552,
				linux: { primary: 3600 },
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "2_line",
				title: localize({
					key: "miCopyLinesUp",
					comment: ["&& denotes a mnemonic"]
				}, "&&Copy Line Up"),
				order: 1
			}
		});
	}
}, CopyLinesDownAction = class extends AbstractCopyLinesAction {
	constructor() {
		super(!0, {
			id: "editor.action.copyLinesDownAction",
			label: localize("lines.copyDown", "Copy Line Down"),
			alias: "Copy Line Down",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1554,
				linux: { primary: 3602 },
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "2_line",
				title: localize({
					key: "miCopyLinesDown",
					comment: ["&& denotes a mnemonic"]
				}, "Co&&py Line Down"),
				order: 2
			}
		});
	}
}, DuplicateSelectionAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.duplicateSelection",
			label: localize("duplicateSelection", "Duplicate Selection"),
			alias: "Duplicate Selection",
			precondition: EditorContextKeys.writable,
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "2_line",
				title: localize({
					key: "miDuplicateSelection",
					comment: ["&& denotes a mnemonic"]
				}, "&&Duplicate Selection"),
				order: 5
			}
		});
	}
	run(e, _, v) {
		if (!_.hasModel()) return;
		let y = [], b = _.getSelections(), x = _.getModel();
		for (let e of b) if (e.isEmpty()) y.push(new CopyLinesCommand(e, !0));
		else {
			let _ = new Selection(e.endLineNumber, e.endColumn, e.endLineNumber, e.endColumn);
			y.push(new ReplaceCommandThatSelectsText(_, x.getValueInRange(e)));
		}
		_.pushUndoStop(), _.executeCommands(this.id, y), _.pushUndoStop();
	}
}, AbstractMoveLinesAction = class extends EditorAction {
	constructor(e, _) {
		super(_), this.down = e;
	}
	run(e, _) {
		let v = e.get(ILanguageConfigurationService), y = [], b = _.getSelections() || [], x = _.getOption(12);
		for (let e of b) y.push(new MoveLinesCommand(e, this.down, x, v));
		_.pushUndoStop(), _.executeCommands(this.id, y), _.pushUndoStop();
	}
}, MoveLinesUpAction = class extends AbstractMoveLinesAction {
	constructor() {
		super(!1, {
			id: "editor.action.moveLinesUpAction",
			label: localize("lines.moveUp", "Move Line Up"),
			alias: "Move Line Up",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 528,
				linux: { primary: 528 },
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "2_line",
				title: localize({
					key: "miMoveLinesUp",
					comment: ["&& denotes a mnemonic"]
				}, "Mo&&ve Line Up"),
				order: 3
			}
		});
	}
}, MoveLinesDownAction = class extends AbstractMoveLinesAction {
	constructor() {
		super(!0, {
			id: "editor.action.moveLinesDownAction",
			label: localize("lines.moveDown", "Move Line Down"),
			alias: "Move Line Down",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 530,
				linux: { primary: 530 },
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "2_line",
				title: localize({
					key: "miMoveLinesDown",
					comment: ["&& denotes a mnemonic"]
				}, "Move &&Line Down"),
				order: 4
			}
		});
	}
}, AbstractSortLinesAction = class extends EditorAction {
	constructor(e, _) {
		super(_), this.descending = e;
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getModel(), y = _.getSelections();
		y.length === 1 && y[0].isEmpty() && (y = [new Selection(1, 1, v.getLineCount(), v.getLineMaxColumn(v.getLineCount()))]);
		for (let e of y) if (!SortLinesCommand.canRun(_.getModel(), e, this.descending)) return;
		let b = [];
		for (let e = 0, _ = y.length; e < _; e++) b[e] = new SortLinesCommand(y[e], this.descending);
		_.pushUndoStop(), _.executeCommands(this.id, b), _.pushUndoStop();
	}
}, SortLinesAscendingAction = class extends AbstractSortLinesAction {
	constructor() {
		super(!1, {
			id: "editor.action.sortLinesAscending",
			label: localize("lines.sortAscending", "Sort Lines Ascending"),
			alias: "Sort Lines Ascending",
			precondition: EditorContextKeys.writable
		});
	}
}, SortLinesDescendingAction = class extends AbstractSortLinesAction {
	constructor() {
		super(!0, {
			id: "editor.action.sortLinesDescending",
			label: localize("lines.sortDescending", "Sort Lines Descending"),
			alias: "Sort Lines Descending",
			precondition: EditorContextKeys.writable
		});
	}
}, DeleteDuplicateLinesAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.removeDuplicateLines",
			label: localize("lines.deleteDuplicates", "Delete Duplicate Lines"),
			alias: "Delete Duplicate Lines",
			precondition: EditorContextKeys.writable
		});
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getModel();
		if (v.getLineCount() === 1 && v.getLineMaxColumn(1) === 1) return;
		let y = [], b = [], x = 0, S = !0, C = _.getSelections();
		C.length === 1 && C[0].isEmpty() && (C = [new Selection(1, 1, v.getLineCount(), v.getLineMaxColumn(v.getLineCount()))], S = !1);
		for (let e of C) {
			let _ = /* @__PURE__ */ new Set(), S = [];
			for (let y = e.startLineNumber; y <= e.endLineNumber; y++) {
				let e = v.getLineContent(y);
				_.has(e) || (S.push(e), _.add(e));
			}
			let C = new Selection(e.startLineNumber, 1, e.endLineNumber, v.getLineMaxColumn(e.endLineNumber)), w = e.startLineNumber - x, T = new Selection(w, 1, w + S.length - 1, S[S.length - 1].length);
			y.push(EditOperation.replace(C, S.join("\n"))), b.push(T), x += e.endLineNumber - e.startLineNumber + 1 - S.length;
		}
		_.pushUndoStop(), _.executeEdits(this.id, y, S ? b : void 0), _.pushUndoStop();
	}
}, TrimTrailingWhitespaceAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.trimTrailingWhitespace";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("lines.trimTrailingWhitespace", "Trim Trailing Whitespace"),
			alias: "Trim Trailing Whitespace",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: KeyChord(2089, 2102),
				weight: 100
			}
		});
	}
	run(e, _, v) {
		let y = [];
		v.reason === "auto-save" && (y = (_.getSelections() || []).map((e) => new Position(e.positionLineNumber, e.positionColumn)));
		let b = _.getSelection();
		if (b === null) return;
		let x = e.get(IConfigurationService), S = _.getModel(), C = x.getValue("files.trimTrailingWhitespaceInRegexAndStrings", {
			overrideIdentifier: S?.getLanguageId(),
			resource: S?.uri
		}), w = new TrimTrailingWhitespaceCommand(b, y, C);
		_.pushUndoStop(), _.executeCommands(this.id, [w]), _.pushUndoStop();
	}
}, DeleteLinesAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.deleteLines",
			label: localize("lines.delete", "Delete Line"),
			alias: "Delete Line",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 3113,
				weight: 100
			}
		});
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = this._getLinesToRemove(_), y = _.getModel();
		if (y.getLineCount() === 1 && y.getLineMaxColumn(1) === 1) return;
		let b = 0, x = [], S = [];
		for (let e = 0, _ = v.length; e < _; e++) {
			let _ = v[e], C = _.startLineNumber, w = _.endLineNumber, T = 1, E = y.getLineMaxColumn(w);
			w < y.getLineCount() ? (w += 1, E = 1) : C > 1 && (--C, T = y.getLineMaxColumn(C)), x.push(EditOperation.replace(new Selection(C, T, w, E), "")), S.push(new Selection(C - b, _.positionColumn, C - b, _.positionColumn)), b += _.endLineNumber - _.startLineNumber + 1;
		}
		_.pushUndoStop(), _.executeEdits(this.id, x, S), _.pushUndoStop();
	}
	_getLinesToRemove(e) {
		let _ = e.getSelections().map((e) => {
			let _ = e.endLineNumber;
			return e.startLineNumber < e.endLineNumber && e.endColumn === 1 && --_, {
				startLineNumber: e.startLineNumber,
				selectionStartColumn: e.selectionStartColumn,
				endLineNumber: _,
				positionColumn: e.positionColumn
			};
		});
		_.sort((e, _) => e.startLineNumber === _.startLineNumber ? e.endLineNumber - _.endLineNumber : e.startLineNumber - _.startLineNumber);
		let v = [], y = _[0];
		for (let e = 1; e < _.length; e++) y.endLineNumber + 1 >= _[e].startLineNumber ? y.endLineNumber = _[e].endLineNumber : (v.push(y), y = _[e]);
		return v.push(y), v;
	}
}, IndentLinesAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.indentLines",
			label: localize("lines.indent", "Indent Line"),
			alias: "Indent Line",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2142,
				weight: 100
			}
		});
	}
	run(e, _) {
		let v = _._getViewModel();
		v && (_.pushUndoStop(), _.executeCommands(this.id, TypeOperations.indent(v.cursorConfig, _.getModel(), _.getSelections())), _.pushUndoStop());
	}
}, OutdentLinesAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.outdentLines",
			label: localize("lines.outdent", "Outdent Line"),
			alias: "Outdent Line",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2140,
				weight: 100
			}
		});
	}
	run(e, _) {
		CoreEditingCommands.Outdent.runEditorCommand(e, _, null);
	}
}, InsertLineBeforeAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.insertLineBefore",
			label: localize("lines.insertBefore", "Insert Line Above"),
			alias: "Insert Line Above",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3075,
				weight: 100
			}
		});
	}
	run(e, _) {
		let v = _._getViewModel();
		v && (_.pushUndoStop(), _.executeCommands(this.id, EnterOperation.lineInsertBefore(v.cursorConfig, _.getModel(), _.getSelections())));
	}
}, InsertLineAfterAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.insertLineAfter",
			label: localize("lines.insertAfter", "Insert Line Below"),
			alias: "Insert Line Below",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2051,
				weight: 100
			}
		});
	}
	run(e, _) {
		let v = _._getViewModel();
		v && (_.pushUndoStop(), _.executeCommands(this.id, EnterOperation.lineInsertAfter(v.cursorConfig, _.getModel(), _.getSelections())));
	}
}, AbstractDeleteAllToBoundaryAction = class extends EditorAction {
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getSelection(), y = this._getRangesToDelete(_), b = [];
		for (let e = 0, _ = y.length - 1; e < _; e++) {
			let _ = y[e], v = y[e + 1];
			Range.intersectRanges(_, v) === null ? b.push(_) : y[e + 1] = Range.plusRange(_, v);
		}
		b.push(y[y.length - 1]);
		let x = this._getEndCursorState(v, b), S = b.map((e) => EditOperation.replace(e, ""));
		_.pushUndoStop(), _.executeEdits(this.id, S, x), _.pushUndoStop();
	}
}, DeleteAllLeftAction = class extends AbstractDeleteAllToBoundaryAction {
	constructor() {
		super({
			id: "deleteAllLeft",
			label: localize("lines.deleteAllLeft", "Delete All Left"),
			alias: "Delete All Left",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 2049 },
				weight: 100
			}
		});
	}
	_getEndCursorState(e, _) {
		let v = null, y = [], b = 0;
		return _.forEach((_) => {
			let x;
			if (_.endColumn === 1 && b > 0) {
				let e = _.startLineNumber - b;
				x = new Selection(e, _.startColumn, e, _.startColumn);
			} else x = new Selection(_.startLineNumber, _.startColumn, _.startLineNumber, _.startColumn);
			b += _.endLineNumber - _.startLineNumber, _.intersectRanges(e) ? v = x : y.push(x);
		}), v && y.unshift(v), y;
	}
	_getRangesToDelete(e) {
		let _ = e.getSelections();
		if (_ === null) return [];
		let v = _, y = e.getModel();
		return y === null ? [] : (v.sort(Range.compareRangesUsingStarts), v = v.map((e) => {
			if (e.isEmpty()) if (e.startColumn === 1) {
				let _ = Math.max(1, e.startLineNumber - 1), v = e.startLineNumber === 1 ? 1 : y.getLineLength(_) + 1;
				return new Range(_, v, e.startLineNumber, 1);
			} else return new Range(e.startLineNumber, 1, e.startLineNumber, e.startColumn);
			else return new Range(e.startLineNumber, 1, e.endLineNumber, e.endColumn);
		}), v);
	}
}, DeleteAllRightAction = class extends AbstractDeleteAllToBoundaryAction {
	constructor() {
		super({
			id: "deleteAllRight",
			label: localize("lines.deleteAllRight", "Delete All Right"),
			alias: "Delete All Right",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: {
					primary: 297,
					secondary: [2068]
				},
				weight: 100
			}
		});
	}
	_getEndCursorState(e, _) {
		let v = null, y = [];
		for (let b = 0, x = _.length; b < x; b++) {
			let x = _[b], S = new Selection(x.startLineNumber - 0, x.startColumn, x.startLineNumber - 0, x.startColumn);
			x.intersectRanges(e) ? v = S : y.push(S);
		}
		return v && y.unshift(v), y;
	}
	_getRangesToDelete(e) {
		let _ = e.getModel();
		if (_ === null) return [];
		let v = e.getSelections();
		if (v === null) return [];
		let y = v.map((e) => {
			if (e.isEmpty()) {
				let v = _.getLineMaxColumn(e.startLineNumber);
				return e.startColumn === v ? new Range(e.startLineNumber, e.startColumn, e.startLineNumber + 1, 1) : new Range(e.startLineNumber, e.startColumn, e.startLineNumber, v);
			}
			return e;
		});
		return y.sort(Range.compareRangesUsingStarts), y;
	}
}, JoinLinesAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.joinLines",
			label: localize("lines.joinLines", "Join Lines"),
			alias: "Join Lines",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 0,
				mac: { primary: 296 },
				weight: 100
			}
		});
	}
	run(e, _) {
		let v = _.getSelections();
		if (v === null) return;
		let y = _.getSelection();
		if (y === null) return;
		v.sort(Range.compareRangesUsingStarts);
		let b = [], x = v.reduce((e, _) => e.isEmpty() ? e.endLineNumber === _.startLineNumber ? (y.equalsSelection(e) && (y = _), _) : _.startLineNumber > e.endLineNumber + 1 ? (b.push(e), _) : new Selection(e.startLineNumber, e.startColumn, _.endLineNumber, _.endColumn) : _.startLineNumber > e.endLineNumber ? (b.push(e), _) : new Selection(e.startLineNumber, e.startColumn, _.endLineNumber, _.endColumn));
		b.push(x);
		let S = _.getModel();
		if (S === null) return;
		let C = [], w = [], T = y, E = 0;
		for (let e = 0, _ = b.length; e < _; e++) {
			let _ = b[e], v = _.startLineNumber, x = 0, D, O, k = S.getLineLength(_.endLineNumber) - _.endColumn;
			if (_.isEmpty() || _.startLineNumber === _.endLineNumber) {
				let e = _.getStartPosition();
				e.lineNumber < S.getLineCount() ? (D = v + 1, O = S.getLineMaxColumn(D)) : (D = e.lineNumber, O = S.getLineMaxColumn(e.lineNumber));
			} else D = _.endLineNumber, O = S.getLineMaxColumn(D);
			let A = S.getLineContent(v);
			for (let e = v + 1; e <= D; e++) {
				let _ = S.getLineContent(e), v = S.getLineFirstNonWhitespaceColumn(e);
				if (v >= 1) {
					let e = !0;
					A === "" && (e = !1), e && (A.charAt(A.length - 1) === " " || A.charAt(A.length - 1) === "	") && (e = !1, A = A.replace(/[\s\uFEFF\xA0]+$/g, " "));
					let y = _.substr(v - 1);
					A += (e ? " " : "") + y, x = e ? y.length + 1 : y.length;
				} else x = 0;
			}
			let j = new Range(v, 1, D, O);
			if (!j.isEmpty()) {
				let e;
				_.isEmpty() ? (C.push(EditOperation.replace(j, A)), e = new Selection(j.startLineNumber - E, A.length - x + 1, v - E, A.length - x + 1)) : _.startLineNumber === _.endLineNumber ? (C.push(EditOperation.replace(j, A)), e = new Selection(_.startLineNumber - E, _.startColumn, _.endLineNumber - E, _.endColumn)) : (C.push(EditOperation.replace(j, A)), e = new Selection(_.startLineNumber - E, _.startColumn, _.startLineNumber - E, A.length - k)), Range.intersectRanges(j, y) === null ? w.push(e) : T = e;
			}
			E += j.endLineNumber - j.startLineNumber;
		}
		w.unshift(T), _.pushUndoStop(), _.executeEdits(this.id, C, w), _.pushUndoStop();
	}
}, TransposeAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.transpose",
			label: localize("editor.transpose", "Transpose Characters around the Cursor"),
			alias: "Transpose Characters around the Cursor",
			precondition: EditorContextKeys.writable
		});
	}
	run(e, _) {
		let v = _.getSelections();
		if (v === null) return;
		let y = _.getModel();
		if (y === null) return;
		let b = [];
		for (let e = 0, _ = v.length; e < _; e++) {
			let _ = v[e];
			if (!_.isEmpty()) continue;
			let x = _.getStartPosition(), S = y.getLineMaxColumn(x.lineNumber);
			if (x.column >= S) {
				if (x.lineNumber === y.getLineCount()) continue;
				let e = new Range(x.lineNumber, Math.max(1, x.column - 1), x.lineNumber + 1, 1), _ = y.getValueInRange(e).split("").reverse().join("");
				b.push(new ReplaceCommand(new Selection(x.lineNumber, Math.max(1, x.column - 1), x.lineNumber + 1, 1), _));
			} else {
				let e = new Range(x.lineNumber, Math.max(1, x.column - 1), x.lineNumber, x.column + 1), _ = y.getValueInRange(e).split("").reverse().join("");
				b.push(new ReplaceCommandThatPreservesSelection(e, _, new Selection(x.lineNumber, x.column + 1, x.lineNumber, x.column + 1)));
			}
		}
		_.pushUndoStop(), _.executeCommands(this.id, b), _.pushUndoStop();
	}
}, AbstractCaseAction = class extends EditorAction {
	run(e, _) {
		let v = _.getSelections();
		if (v === null) return;
		let y = _.getModel();
		if (y === null) return;
		let b = _.getOption(132), x = [];
		for (let e of v) if (e.isEmpty()) {
			let v = e.getStartPosition(), S = _.getConfiguredWordAtPosition(v);
			if (!S) continue;
			let C = new Range(v.lineNumber, S.startColumn, v.lineNumber, S.endColumn), w = y.getValueInRange(C);
			x.push(EditOperation.replace(C, this._modifyText(w, b)));
		} else {
			let _ = y.getValueInRange(e);
			x.push(EditOperation.replace(e, this._modifyText(_, b)));
		}
		_.pushUndoStop(), _.executeEdits(this.id, x), _.pushUndoStop();
	}
}, UpperCaseAction = class extends AbstractCaseAction {
	constructor() {
		super({
			id: "editor.action.transformToUppercase",
			label: localize("editor.transformToUppercase", "Transform to Uppercase"),
			alias: "Transform to Uppercase",
			precondition: EditorContextKeys.writable
		});
	}
	_modifyText(e, _) {
		return e.toLocaleUpperCase();
	}
}, LowerCaseAction = class extends AbstractCaseAction {
	constructor() {
		super({
			id: "editor.action.transformToLowercase",
			label: localize("editor.transformToLowercase", "Transform to Lowercase"),
			alias: "Transform to Lowercase",
			precondition: EditorContextKeys.writable
		});
	}
	_modifyText(e, _) {
		return e.toLocaleLowerCase();
	}
}, BackwardsCompatibleRegExp = class {
	constructor(e, _) {
		this._pattern = e, this._flags = _, this._actual = null, this._evaluated = !1;
	}
	get() {
		if (!this._evaluated) {
			this._evaluated = !0;
			try {
				this._actual = new RegExp(this._pattern, this._flags);
			} catch {}
		}
		return this._actual;
	}
	isSupported() {
		return this.get() !== null;
	}
}, TitleCaseAction = class e extends AbstractCaseAction {
	static {
		this.titleBoundary = new BackwardsCompatibleRegExp("(^|[^\\p{L}\\p{N}']|((^|\\P{L})'))\\p{L}", "gmu");
	}
	constructor() {
		super({
			id: "editor.action.transformToTitlecase",
			label: localize("editor.transformToTitlecase", "Transform to Title Case"),
			alias: "Transform to Title Case",
			precondition: EditorContextKeys.writable
		});
	}
	_modifyText(_, v) {
		let y = e.titleBoundary.get();
		return y ? _.toLocaleLowerCase().replace(y, (e) => e.toLocaleUpperCase()) : _;
	}
}, SnakeCaseAction = class e extends AbstractCaseAction {
	static {
		this.caseBoundary = new BackwardsCompatibleRegExp("(\\p{Ll})(\\p{Lu})", "gmu");
	}
	static {
		this.singleLetters = new BackwardsCompatibleRegExp("(\\p{Lu}|\\p{N})(\\p{Lu})(\\p{Ll})", "gmu");
	}
	constructor() {
		super({
			id: "editor.action.transformToSnakecase",
			label: localize("editor.transformToSnakecase", "Transform to Snake Case"),
			alias: "Transform to Snake Case",
			precondition: EditorContextKeys.writable
		});
	}
	_modifyText(_, v) {
		let y = e.caseBoundary.get(), b = e.singleLetters.get();
		return !y || !b ? _ : _.replace(y, "$1_$2").replace(b, "$1_$2$3").toLocaleLowerCase();
	}
}, CamelCaseAction = class e extends AbstractCaseAction {
	static {
		this.wordBoundary = new BackwardsCompatibleRegExp("[_\\s-]", "gm");
	}
	constructor() {
		super({
			id: "editor.action.transformToCamelcase",
			label: localize("editor.transformToCamelcase", "Transform to Camel Case"),
			alias: "Transform to Camel Case",
			precondition: EditorContextKeys.writable
		});
	}
	_modifyText(_, v) {
		let y = e.wordBoundary.get();
		if (!y) return _;
		let b = _.split(y);
		return b.shift() + b.map((e) => e.substring(0, 1).toLocaleUpperCase() + e.substring(1)).join("");
	}
}, PascalCaseAction = class e extends AbstractCaseAction {
	static {
		this.wordBoundary = new BackwardsCompatibleRegExp("[_\\s-]", "gm");
	}
	static {
		this.wordBoundaryToMaintain = new BackwardsCompatibleRegExp("(?<=\\.)", "gm");
	}
	constructor() {
		super({
			id: "editor.action.transformToPascalcase",
			label: localize("editor.transformToPascalcase", "Transform to Pascal Case"),
			alias: "Transform to Pascal Case",
			precondition: EditorContextKeys.writable
		});
	}
	_modifyText(_, v) {
		let y = e.wordBoundary.get(), b = e.wordBoundaryToMaintain.get();
		return !y || !b ? _ : _.split(b).map((e) => e.split(y)).flat().map((e) => e.substring(0, 1).toLocaleUpperCase() + e.substring(1)).join("");
	}
}, KebabCaseAction = class e extends AbstractCaseAction {
	static isSupported() {
		return [
			this.caseBoundary,
			this.singleLetters,
			this.underscoreBoundary
		].every((e) => e.isSupported());
	}
	static {
		this.caseBoundary = new BackwardsCompatibleRegExp("(\\p{Ll})(\\p{Lu})", "gmu");
	}
	static {
		this.singleLetters = new BackwardsCompatibleRegExp("(\\p{Lu}|\\p{N})(\\p{Lu}\\p{Ll})", "gmu");
	}
	static {
		this.underscoreBoundary = new BackwardsCompatibleRegExp("(\\S)(_)(\\S)", "gm");
	}
	constructor() {
		super({
			id: "editor.action.transformToKebabcase",
			label: localize("editor.transformToKebabcase", "Transform to Kebab Case"),
			alias: "Transform to Kebab Case",
			precondition: EditorContextKeys.writable
		});
	}
	_modifyText(_, v) {
		let y = e.caseBoundary.get(), b = e.singleLetters.get(), x = e.underscoreBoundary.get();
		return !y || !b || !x ? _ : _.replace(x, "$1-$3").replace(y, "$1-$2").replace(b, "$1-$2").toLocaleLowerCase();
	}
};
registerEditorAction(CopyLinesUpAction), registerEditorAction(CopyLinesDownAction), registerEditorAction(DuplicateSelectionAction), registerEditorAction(MoveLinesUpAction), registerEditorAction(MoveLinesDownAction), registerEditorAction(SortLinesAscendingAction), registerEditorAction(SortLinesDescendingAction), registerEditorAction(DeleteDuplicateLinesAction), registerEditorAction(TrimTrailingWhitespaceAction), registerEditorAction(DeleteLinesAction), registerEditorAction(IndentLinesAction), registerEditorAction(OutdentLinesAction), registerEditorAction(InsertLineBeforeAction), registerEditorAction(InsertLineAfterAction), registerEditorAction(DeleteAllLeftAction), registerEditorAction(DeleteAllRightAction), registerEditorAction(JoinLinesAction), registerEditorAction(TransposeAction), registerEditorAction(UpperCaseAction), registerEditorAction(LowerCaseAction), SnakeCaseAction.caseBoundary.isSupported() && SnakeCaseAction.singleLetters.isSupported() && registerEditorAction(SnakeCaseAction), CamelCaseAction.wordBoundary.isSupported() && registerEditorAction(CamelCaseAction), PascalCaseAction.wordBoundary.isSupported() && registerEditorAction(PascalCaseAction), TitleCaseAction.titleBoundary.isSupported() && registerEditorAction(TitleCaseAction), KebabCaseAction.isSupported() && registerEditorAction(KebabCaseAction);
var __decorate$37 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$37 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, LinkedEditingContribution_1;
const CONTEXT_ONTYPE_RENAME_INPUT_VISIBLE = new RawContextKey("LinkedEditingInputVisible", !1);
var DECORATION_CLASS_NAME = "linked-editing-decoration", LinkedEditingContribution = class extends Disposable {
	static {
		LinkedEditingContribution_1 = this;
	}
	static {
		this.ID = "editor.contrib.linkedEditing";
	}
	static {
		this.DECORATION = ModelDecorationOptions.register({
			description: "linked-editing",
			stickiness: 0,
			className: DECORATION_CLASS_NAME
		});
	}
	static get(e) {
		return e.getContribution(LinkedEditingContribution_1.ID);
	}
	constructor(e, _, v, y, b) {
		super(), this.languageConfigurationService = y, this._syncRangesToken = 0, this._localToDispose = this._register(new DisposableStore()), this._editor = e, this._providers = v.linkedEditingRangeProvider, this._enabled = !1, this._visibleContextKey = CONTEXT_ONTYPE_RENAME_INPUT_VISIBLE.bindTo(_), this._debounceInformation = b.for(this._providers, "Linked Editing", { max: 200 }), this._currentDecorations = this._editor.createDecorationsCollection(), this._languageWordPattern = null, this._currentWordPattern = null, this._ignoreChangeEvent = !1, this._localToDispose = this._register(new DisposableStore()), this._rangeUpdateTriggerPromise = null, this._rangeSyncTriggerPromise = null, this._currentRequestCts = null, this._currentRequestPosition = null, this._currentRequestModelVersion = null, this._register(this._editor.onDidChangeModel(() => this.reinitialize(!0))), this._register(this._editor.onDidChangeConfiguration((e) => {
			(e.hasChanged(70) || e.hasChanged(94)) && this.reinitialize(!1);
		})), this._register(this._providers.onDidChange(() => this.reinitialize(!1))), this._register(this._editor.onDidChangeModelLanguage(() => this.reinitialize(!0))), this.reinitialize(!0);
	}
	reinitialize(e) {
		let _ = this._editor.getModel(), v = _ !== null && (this._editor.getOption(70) || this._editor.getOption(94)) && this._providers.has(_);
		if (v === this._enabled && !e || (this._enabled = v, this.clearRanges(), this._localToDispose.clear(), !v || _ === null)) return;
		this._localToDispose.add(Event.runAndSubscribe(_.onDidChangeLanguageConfiguration, () => {
			this._languageWordPattern = this.languageConfigurationService.getLanguageConfiguration(_.getLanguageId()).getWordDefinition();
		}));
		let y = new Delayer(this._debounceInformation.get(_)), b = () => {
			this._rangeUpdateTriggerPromise = y.trigger(() => this.updateRanges(), this._debounceDuration ?? this._debounceInformation.get(_));
		}, x = new Delayer(0), S = (e) => {
			this._rangeSyncTriggerPromise = x.trigger(() => this._syncRanges(e));
		};
		this._localToDispose.add(this._editor.onDidChangeCursorPosition(() => {
			b();
		})), this._localToDispose.add(this._editor.onDidChangeModelContent((e) => {
			if (!this._ignoreChangeEvent && this._currentDecorations.length > 0) {
				let _ = this._currentDecorations.getRange(0);
				if (_ && e.changes.every((e) => _.intersectRanges(e.range))) {
					S(this._syncRangesToken);
					return;
				}
			}
			b();
		})), this._localToDispose.add({ dispose: () => {
			y.dispose(), x.dispose();
		} }), this.updateRanges();
	}
	_syncRanges(e) {
		if (!this._editor.hasModel() || e !== this._syncRangesToken || this._currentDecorations.length === 0) return;
		let _ = this._editor.getModel(), v = this._currentDecorations.getRange(0);
		if (!v || v.startLineNumber !== v.endLineNumber) return this.clearRanges();
		let y = _.getValueInRange(v);
		if (this._currentWordPattern) {
			let e = y.match(this._currentWordPattern);
			if ((e ? e[0].length : 0) !== y.length) return this.clearRanges();
		}
		let b = [];
		for (let e = 1, v = this._currentDecorations.length; e < v; e++) {
			let v = this._currentDecorations.getRange(e);
			if (v) if (v.startLineNumber !== v.endLineNumber) b.push({
				range: v,
				text: y
			});
			else {
				let e = _.getValueInRange(v), x = y, S = v.startColumn, C = v.endColumn, w = commonPrefixLength(e, x);
				S += w, e = e.substr(w), x = x.substr(w);
				let T = commonSuffixLength(e, x);
				C -= T, e = e.substr(0, e.length - T), x = x.substr(0, x.length - T), (S !== C || x.length !== 0) && b.push({
					range: new Range(v.startLineNumber, S, v.endLineNumber, C),
					text: x
				});
			}
		}
		if (b.length !== 0) try {
			this._editor.popUndoStop(), this._ignoreChangeEvent = !0;
			let e = this._editor._getViewModel().getPrevEditOperationType();
			this._editor.executeEdits("linkedEditing", b), this._editor._getViewModel().setPrevEditOperationType(e);
		} finally {
			this._ignoreChangeEvent = !1;
		}
	}
	dispose() {
		this.clearRanges(), super.dispose();
	}
	clearRanges() {
		this._visibleContextKey.set(!1), this._currentDecorations.clear(), this._currentRequestCts && (this._currentRequestCts.cancel(), this._currentRequestCts = null, this._currentRequestPosition = null);
	}
	async updateRanges(e = !1) {
		if (!this._editor.hasModel()) {
			this.clearRanges();
			return;
		}
		let _ = this._editor.getPosition();
		if (!this._enabled && !e || this._editor.getSelections().length > 1) {
			this.clearRanges();
			return;
		}
		let v = this._editor.getModel(), y = v.getVersionId();
		if (this._currentRequestPosition && this._currentRequestModelVersion === y) {
			if (_.equals(this._currentRequestPosition)) return;
			if (this._currentDecorations.length > 0) {
				let e = this._currentDecorations.getRange(0);
				if (e && e.containsPosition(_)) return;
			}
		}
		this.clearRanges(), this._currentRequestPosition = _, this._currentRequestModelVersion = y;
		let b = this._currentRequestCts = new CancellationTokenSource();
		try {
			let e = new StopWatch(!1), x = await getLinkedEditingRanges(this._providers, v, _, b.token);
			if (this._debounceInformation.update(v, e.elapsed()), b !== this._currentRequestCts || (this._currentRequestCts = null, y !== v.getVersionId())) return;
			let S = [];
			x?.ranges && (S = x.ranges), this._currentWordPattern = x?.wordPattern || this._languageWordPattern;
			let C = !1;
			for (let e = 0, v = S.length; e < v; e++) if (Range.containsPosition(S[e], _)) {
				if (C = !0, e !== 0) {
					let _ = S[e];
					S.splice(e, 1), S.unshift(_);
				}
				break;
			}
			if (!C) {
				this.clearRanges();
				return;
			}
			let w = S.map((e) => ({
				range: e,
				options: LinkedEditingContribution_1.DECORATION
			}));
			this._visibleContextKey.set(!0), this._currentDecorations.set(w), this._syncRangesToken++;
		} catch (e) {
			isCancellationError(e) || onUnexpectedError(e), (this._currentRequestCts === b || !this._currentRequestCts) && this.clearRanges();
		}
	}
};
LinkedEditingContribution = LinkedEditingContribution_1 = __decorate$37([
	__param$37(1, IContextKeyService),
	__param$37(2, ILanguageFeaturesService),
	__param$37(3, ILanguageConfigurationService),
	__param$37(4, ILanguageFeatureDebounceService)
], LinkedEditingContribution);
var LinkedEditingAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.linkedEditing",
			label: localize("linkedEditing.label", "Start Linked Editing"),
			alias: "Start Linked Editing",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasRenameProvider),
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3132,
				weight: 100
			}
		});
	}
	runCommand(e, _) {
		let v = e.get(ICodeEditorService), [y, b] = Array.isArray(_) && _ || [void 0, void 0];
		return URI.isUri(y) && Position.isIPosition(b) ? v.openCodeEditor({ resource: y }, v.getActiveCodeEditor()).then((e) => {
			e && (e.setPosition(b), e.invokeWithinContext((_) => (this.reportTelemetry(_, e), this.run(_, e))));
		}, onUnexpectedError) : super.runCommand(e, _);
	}
	run(e, _) {
		let v = LinkedEditingContribution.get(_);
		return v ? Promise.resolve(v.updateRanges(!0)) : Promise.resolve();
	}
}, LinkedEditingCommand = EditorCommand.bindToContribution(LinkedEditingContribution.get);
registerEditorCommand(new LinkedEditingCommand({
	id: "cancelLinkedEditingInput",
	precondition: CONTEXT_ONTYPE_RENAME_INPUT_VISIBLE,
	handler: (e) => e.clearRanges(),
	kbOpts: {
		kbExpr: EditorContextKeys.editorTextFocus,
		weight: 199,
		primary: 9,
		secondary: [1033]
	}
}));
function getLinkedEditingRanges(e, _, v, y) {
	let b = e.ordered(_);
	return first(b.map((e) => async () => {
		try {
			return await e.provideLinkedEditingRanges(_, v, y);
		} catch (e) {
			onUnexpectedExternalError(e);
			return;
		}
	}), (e) => !!e && isNonEmptyArray(e?.ranges));
}
registerColor("editor.linkedEditingBackground", {
	dark: Color.fromHex("#f00").transparent(.3),
	light: Color.fromHex("#f00").transparent(.3),
	hcDark: Color.fromHex("#f00").transparent(.3),
	hcLight: Color.white
}, localize("editorLinkedEditingBackground", "Background color when the editor auto renames on type.")), registerModelAndPositionCommand("_executeLinkedEditingProvider", (e, _, v) => {
	let { linkedEditingRangeProvider: y } = e.get(ILanguageFeaturesService);
	return getLinkedEditingRanges(y, _, v, CancellationToken.None);
}), registerEditorContribution(LinkedEditingContribution.ID, LinkedEditingContribution, 1), registerEditorAction(LinkedEditingAction);
var Link$1 = class {
	constructor(e, _) {
		this._link = e, this._provider = _;
	}
	toJSON() {
		return {
			range: this.range,
			url: this.url,
			tooltip: this.tooltip
		};
	}
	get range() {
		return this._link.range;
	}
	get url() {
		return this._link.url;
	}
	get tooltip() {
		return this._link.tooltip;
	}
	async resolve(e) {
		return this._link.url ? this._link.url : typeof this._provider.resolveLink == "function" ? Promise.resolve(this._provider.resolveLink(this._link, e)).then((_) => (this._link = _ || this._link, this._link.url ? this.resolve(e) : Promise.reject(/* @__PURE__ */ Error("missing")))) : Promise.reject(/* @__PURE__ */ Error("missing"));
	}
}, LinksList = class e {
	constructor(_) {
		this._disposables = new DisposableStore();
		let v = [];
		for (let [y, b] of _) {
			let _ = y.links.map((e) => new Link$1(e, b));
			v = e._union(v, _), isDisposable(y) && this._disposables.add(y);
		}
		this.links = v;
	}
	dispose() {
		this._disposables.dispose(), this.links.length = 0;
	}
	static _union(e, _) {
		let v = [], y, b, x, S;
		for (y = 0, x = 0, b = e.length, S = _.length; y < b && x < S;) {
			let b = e[y], S = _[x];
			if (Range.areIntersectingOrTouching(b.range, S.range)) {
				y++;
				continue;
			}
			Range.compareRangesUsingStarts(b.range, S.range) < 0 ? (v.push(b), y++) : (v.push(S), x++);
		}
		for (; y < b; y++) v.push(e[y]);
		for (; x < S; x++) v.push(_[x]);
		return v;
	}
};
function getLinks(e, _, v) {
	let y = [], b = e.ordered(_).reverse().map((e, b) => Promise.resolve(e.provideLinks(_, v)).then((_) => {
		_ && (y[b] = [_, e]);
	}, onUnexpectedExternalError));
	return Promise.all(b).then(() => {
		let e = new LinksList(coalesce(y));
		return v.isCancellationRequested ? (e.dispose(), new LinksList([])) : e;
	});
}
CommandsRegistry.registerCommand("_executeLinkProvider", async (e, ..._) => {
	let [v, y] = _;
	assertType(v instanceof URI), typeof y != "number" && (y = 0);
	let { linkProvider: b } = e.get(ILanguageFeaturesService), x = e.get(IModelService).getModel(v);
	if (!x) return [];
	let S = await getLinks(b, x, CancellationToken.None);
	if (!S) return [];
	for (let e = 0; e < Math.min(y, S.links.length); e++) await S.links[e].resolve(CancellationToken.None);
	let C = S.links.slice(0);
	return S.dispose(), C;
});
var __decorate$36 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$36 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, LinkDetector_1, LinkDetector = class extends Disposable {
	static {
		LinkDetector_1 = this;
	}
	static {
		this.ID = "editor.linkDetector";
	}
	static get(e) {
		return e.getContribution(LinkDetector_1.ID);
	}
	constructor(e, _, v, y, b) {
		super(), this.editor = e, this.openerService = _, this.notificationService = v, this.languageFeaturesService = y, this.providers = this.languageFeaturesService.linkProvider, this.debounceInformation = b.for(this.providers, "Links", {
			min: 1e3,
			max: 4e3
		}), this.computeLinks = this._register(new RunOnceScheduler(() => this.computeLinksNow(), 1e3)), this.computePromise = null, this.activeLinksList = null, this.currentOccurrences = {}, this.activeLinkDecorationId = null;
		let x = this._register(new ClickLinkGesture(e));
		this._register(x.onMouseMoveOrRelevantKeyDown(([e, _]) => {
			this._onEditorMouseMove(e, _);
		})), this._register(x.onExecute((e) => {
			this.onEditorMouseUp(e);
		})), this._register(x.onCancel((e) => {
			this.cleanUpActiveLinkDecoration();
		})), this._register(e.onDidChangeConfiguration((e) => {
			e.hasChanged(71) && (this.updateDecorations([]), this.stop(), this.computeLinks.schedule(0));
		})), this._register(e.onDidChangeModelContent((e) => {
			this.editor.hasModel() && this.computeLinks.schedule(this.debounceInformation.get(this.editor.getModel()));
		})), this._register(e.onDidChangeModel((e) => {
			this.currentOccurrences = {}, this.activeLinkDecorationId = null, this.stop(), this.computeLinks.schedule(0);
		})), this._register(e.onDidChangeModelLanguage((e) => {
			this.stop(), this.computeLinks.schedule(0);
		})), this._register(this.providers.onDidChange((e) => {
			this.stop(), this.computeLinks.schedule(0);
		})), this.computeLinks.schedule(0);
	}
	async computeLinksNow() {
		if (!this.editor.hasModel() || !this.editor.getOption(71)) return;
		let e = this.editor.getModel();
		if (!e.isTooLargeForSyncing() && this.providers.has(e)) {
			this.activeLinksList &&= (this.activeLinksList.dispose(), null), this.computePromise = createCancelablePromise((_) => getLinks(this.providers, e, _));
			try {
				let _ = new StopWatch(!1);
				if (this.activeLinksList = await this.computePromise, this.debounceInformation.update(e, _.elapsed()), e.isDisposed()) return;
				this.updateDecorations(this.activeLinksList.links);
			} catch (e) {
				onUnexpectedError(e);
			} finally {
				this.computePromise = null;
			}
		}
	}
	updateDecorations(e) {
		let _ = this.editor.getOption(78) === "altKey", v = [], y = Object.keys(this.currentOccurrences);
		for (let e of y) {
			let _ = this.currentOccurrences[e];
			v.push(_.decorationId);
		}
		let b = [];
		if (e) for (let v of e) b.push(LinkOccurrence.decoration(v, _));
		this.editor.changeDecorations((_) => {
			let y = _.deltaDecorations(v, b);
			this.currentOccurrences = {}, this.activeLinkDecorationId = null;
			for (let _ = 0, v = y.length; _ < v; _++) {
				let v = new LinkOccurrence(e[_], y[_]);
				this.currentOccurrences[v.decorationId] = v;
			}
		});
	}
	_onEditorMouseMove(e, _) {
		let v = this.editor.getOption(78) === "altKey";
		if (this.isEnabled(e, _)) {
			this.cleanUpActiveLinkDecoration();
			let _ = this.getLinkOccurrence(e.target.position);
			_ && this.editor.changeDecorations((e) => {
				_.activate(e, v), this.activeLinkDecorationId = _.decorationId;
			});
		} else this.cleanUpActiveLinkDecoration();
	}
	cleanUpActiveLinkDecoration() {
		let e = this.editor.getOption(78) === "altKey";
		if (this.activeLinkDecorationId) {
			let _ = this.currentOccurrences[this.activeLinkDecorationId];
			_ && this.editor.changeDecorations((v) => {
				_.deactivate(v, e);
			}), this.activeLinkDecorationId = null;
		}
	}
	onEditorMouseUp(e) {
		if (!this.isEnabled(e)) return;
		let _ = this.getLinkOccurrence(e.target.position);
		_ && this.openLinkOccurrence(_, e.hasSideBySideModifier, !0);
	}
	openLinkOccurrence(e, _, v = !1) {
		if (!this.openerService) return;
		let { link: y } = e;
		y.resolve(CancellationToken.None).then((e) => {
			if (typeof e == "string" && this.editor.hasModel()) {
				let _ = this.editor.getModel().uri;
				if (_.scheme === Schemas.file && e.startsWith(`${Schemas.file}:`)) {
					let v = URI.parse(e);
					if (v.scheme === Schemas.file) {
						let y = originalFSPath(v), b = null;
						y.startsWith("/./") || y.startsWith("\\.\\") ? b = `.${y.substr(1)}` : (y.startsWith("//./") || y.startsWith("\\\\.\\")) && (b = `.${y.substr(2)}`), b && (e = joinPath(_, b));
					}
				}
			}
			return this.openerService.open(e, {
				openToSide: _,
				fromUserGesture: v,
				allowContributedOpeners: !0,
				allowCommands: !0,
				fromWorkspace: !0
			});
		}, (e) => {
			let _ = e instanceof Error ? e.message : e;
			_ === "invalid" ? this.notificationService.warn(localize("invalid.url", "Failed to open this link because it is not well-formed: {0}", y.url.toString())) : _ === "missing" ? this.notificationService.warn(localize("missing.url", "Failed to open this link because its target is missing.")) : onUnexpectedError(e);
		});
	}
	getLinkOccurrence(e) {
		if (!this.editor.hasModel() || !e) return null;
		let _ = this.editor.getModel().getDecorationsInRange({
			startLineNumber: e.lineNumber,
			startColumn: e.column,
			endLineNumber: e.lineNumber,
			endColumn: e.column
		}, 0, !0);
		for (let e of _) {
			let _ = this.currentOccurrences[e.id];
			if (_) return _;
		}
		return null;
	}
	isEnabled(e, _) {
		return !!(e.target.type === 6 && (e.hasTriggerModifier || _ && _.keyCodeIsTriggerKey));
	}
	stop() {
		this.computeLinks.cancel(), this.activeLinksList &&= (this.activeLinksList?.dispose(), null), this.computePromise &&= (this.computePromise.cancel(), null);
	}
	dispose() {
		super.dispose(), this.stop();
	}
};
LinkDetector = LinkDetector_1 = __decorate$36([
	__param$36(1, IOpenerService),
	__param$36(2, INotificationService),
	__param$36(3, ILanguageFeaturesService),
	__param$36(4, ILanguageFeatureDebounceService)
], LinkDetector);
var decoration$1 = {
	general: ModelDecorationOptions.register({
		description: "detected-link",
		stickiness: 1,
		collapseOnReplaceEdit: !0,
		inlineClassName: "detected-link"
	}),
	active: ModelDecorationOptions.register({
		description: "detected-link-active",
		stickiness: 1,
		collapseOnReplaceEdit: !0,
		inlineClassName: "detected-link-active"
	})
}, LinkOccurrence = class e {
	static decoration(_, v) {
		return {
			range: _.range,
			options: e._getOptions(_, v, !1)
		};
	}
	static _getOptions(e, _, v) {
		let y = { ...v ? decoration$1.active : decoration$1.general };
		return y.hoverMessage = getHoverMessage(e, _), y;
	}
	constructor(e, _) {
		this.link = e, this.decorationId = _;
	}
	activate(_, v) {
		_.changeDecorationOptions(this.decorationId, e._getOptions(this.link, v, !0));
	}
	deactivate(_, v) {
		_.changeDecorationOptions(this.decorationId, e._getOptions(this.link, v, !1));
	}
};
function getHoverMessage(e, _) {
	let v = e.url && /^command:/i.test(e.url.toString()), y = e.tooltip ? e.tooltip : v ? localize("links.navigate.executeCmd", "Execute command") : localize("links.navigate.follow", "Follow link"), b = _ ? isMacintosh ? localize("links.navigate.kb.meta.mac", "cmd + click") : localize("links.navigate.kb.meta", "ctrl + click") : isMacintosh ? localize("links.navigate.kb.alt.mac", "option + click") : localize("links.navigate.kb.alt", "alt + click");
	if (e.url) {
		let _ = "";
		if (/^command:/i.test(e.url.toString())) {
			let v = e.url.toString().match(/^command:([^?#]+)/);
			if (v) {
				let e = v[1];
				_ = localize("tooltip.explanation", "Execute command {0}", e);
			}
		}
		return new MarkdownString("", !0).appendLink(e.url.toString(!0).replace(/ /g, "%20"), y, _).appendMarkdown(` (${b})`);
	} else return new MarkdownString().appendText(`${y} (${b})`);
}
var OpenLinkAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.openLink",
			label: localize("label", "Open Link"),
			alias: "Open Link",
			precondition: void 0
		});
	}
	run(e, _) {
		let v = LinkDetector.get(_);
		if (!v || !_.hasModel()) return;
		let y = _.getSelections();
		for (let e of y) {
			let _ = v.getLinkOccurrence(e.getEndPosition());
			_ && v.openLinkOccurrence(_, !1);
		}
	}
};
registerEditorContribution(LinkDetector.ID, LinkDetector, 1), registerEditorAction(OpenLinkAction);
var LongLinesHelper = class extends Disposable {
	static {
		this.ID = "editor.contrib.longLinesHelper";
	}
	constructor(e) {
		super(), this._editor = e, this._register(this._editor.onMouseDown((e) => {
			let _ = this._editor.getOption(118);
			_ >= 0 && e.target.type === 6 && e.target.position.column >= _ && this._editor.updateOptions({ stopRenderingLineAfter: -1 });
		}));
	}
};
registerEditorContribution(LongLinesHelper.ID, LongLinesHelper, 2);
var wordHighlightBackground = registerColor("editor.wordHighlightBackground", {
	dark: "#575757B8",
	light: "#57575740",
	hcDark: null,
	hcLight: null
}, localize("wordHighlight", "Background color of a symbol during read-access, like reading a variable. The color must not be opaque so as not to hide underlying decorations."), !0);
registerColor("editor.wordHighlightStrongBackground", {
	dark: "#004972B8",
	light: "#0e639c40",
	hcDark: null,
	hcLight: null
}, localize("wordHighlightStrong", "Background color of a symbol during write-access, like writing to a variable. The color must not be opaque so as not to hide underlying decorations."), !0), registerColor("editor.wordHighlightTextBackground", wordHighlightBackground, localize("wordHighlightText", "Background color of a textual occurrence for a symbol. The color must not be opaque so as not to hide underlying decorations."), !0);
var wordHighlightBorder = registerColor("editor.wordHighlightBorder", {
	light: null,
	dark: null,
	hcDark: activeContrastBorder,
	hcLight: activeContrastBorder
}, localize("wordHighlightBorder", "Border color of a symbol during read-access, like reading a variable."));
registerColor("editor.wordHighlightStrongBorder", {
	light: null,
	dark: null,
	hcDark: activeContrastBorder,
	hcLight: activeContrastBorder
}, localize("wordHighlightStrongBorder", "Border color of a symbol during write-access, like writing to a variable.")), registerColor("editor.wordHighlightTextBorder", wordHighlightBorder, localize("wordHighlightTextBorder", "Border color of a textual occurrence for a symbol."));
var overviewRulerWordHighlightForeground = registerColor("editorOverviewRuler.wordHighlightForeground", "#A0A0A0CC", localize("overviewRulerWordHighlightForeground", "Overview ruler marker color for symbol highlights. The color must not be opaque so as not to hide underlying decorations."), !0), overviewRulerWordHighlightStrongForeground = registerColor("editorOverviewRuler.wordHighlightStrongForeground", "#C0A0C0CC", localize("overviewRulerWordHighlightStrongForeground", "Overview ruler marker color for write-access symbol highlights. The color must not be opaque so as not to hide underlying decorations."), !0), overviewRulerWordHighlightTextForeground = registerColor("editorOverviewRuler.wordHighlightTextForeground", overviewRulerSelectionHighlightForeground, localize("overviewRulerWordHighlightTextForeground", "Overview ruler marker color of a textual occurrence for a symbol. The color must not be opaque so as not to hide underlying decorations."), !0), _WRITE_OPTIONS = ModelDecorationOptions.register({
	description: "word-highlight-strong",
	stickiness: 1,
	className: "wordHighlightStrong",
	overviewRuler: {
		color: themeColorFromId(overviewRulerWordHighlightStrongForeground),
		position: OverviewRulerLane.Center
	},
	minimap: {
		color: themeColorFromId(minimapSelectionOccurrenceHighlight),
		position: 1
	}
}), _TEXT_OPTIONS = ModelDecorationOptions.register({
	description: "word-highlight-text",
	stickiness: 1,
	className: "wordHighlightText",
	overviewRuler: {
		color: themeColorFromId(overviewRulerWordHighlightTextForeground),
		position: OverviewRulerLane.Center
	},
	minimap: {
		color: themeColorFromId(minimapSelectionOccurrenceHighlight),
		position: 1
	}
}), _SELECTION_HIGHLIGHT_OPTIONS = ModelDecorationOptions.register({
	description: "selection-highlight-overview",
	stickiness: 1,
	className: "selectionHighlight",
	overviewRuler: {
		color: themeColorFromId(overviewRulerSelectionHighlightForeground),
		position: OverviewRulerLane.Center
	},
	minimap: {
		color: themeColorFromId(minimapSelectionOccurrenceHighlight),
		position: 1
	}
}), _SELECTION_HIGHLIGHT_OPTIONS_NO_OVERVIEW = ModelDecorationOptions.register({
	description: "selection-highlight",
	stickiness: 1,
	className: "selectionHighlight"
}), _REGULAR_OPTIONS = ModelDecorationOptions.register({
	description: "word-highlight",
	stickiness: 1,
	className: "wordHighlight",
	overviewRuler: {
		color: themeColorFromId(overviewRulerWordHighlightForeground),
		position: OverviewRulerLane.Center
	},
	minimap: {
		color: themeColorFromId(minimapSelectionOccurrenceHighlight),
		position: 1
	}
});
function getHighlightDecorationOptions(e) {
	return e === DocumentHighlightKind.Write ? _WRITE_OPTIONS : e === DocumentHighlightKind.Text ? _TEXT_OPTIONS : _REGULAR_OPTIONS;
}
function getSelectionHighlightDecorationOptions(e) {
	return e ? _SELECTION_HIGHLIGHT_OPTIONS_NO_OVERVIEW : _SELECTION_HIGHLIGHT_OPTIONS;
}
registerThemingParticipant((e, _) => {
	let v = e.getColor(editorSelectionHighlight);
	v && _.addRule(`.monaco-editor .selectionHighlight { background-color: ${v.transparent(.5)}; }`);
});
var __decorate$35 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$35 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SelectionHighlighter_1;
function announceCursorChange(e, _) {
	let v = _.filter((_) => !e.find((e) => e.equals(_)));
	if (v.length >= 1) {
		let e = v.map((e) => `line ${e.viewState.position.lineNumber} column ${e.viewState.position.column}`).join(", "), _ = v.length === 1 ? localize("cursorAdded", "Cursor added: {0}", e) : localize("cursorsAdded", "Cursors added: {0}", e);
		status(_);
	}
}
var InsertCursorAbove = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.insertCursorAbove",
			label: localize("mutlicursor.insertAbove", "Add Cursor Above"),
			alias: "Add Cursor Above",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2576,
				linux: {
					primary: 1552,
					secondary: [3088]
				},
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "3_multi",
				title: localize({
					key: "miInsertCursorAbove",
					comment: ["&& denotes a mnemonic"]
				}, "&&Add Cursor Above"),
				order: 2
			}
		});
	}
	run(e, _, v) {
		if (!_.hasModel()) return;
		let y = !0;
		v && v.logicalLine === !1 && (y = !1);
		let b = _._getViewModel();
		if (b.cursorConfig.readOnly) return;
		b.model.pushStackElement();
		let x = b.getCursorStates();
		b.setCursorStates(v.source, 3, CursorMoveCommands.addCursorUp(b, x, y)), b.revealTopMostCursor(v.source), announceCursorChange(x, b.getCursorStates());
	}
}, InsertCursorBelow = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.insertCursorBelow",
			label: localize("mutlicursor.insertBelow", "Add Cursor Below"),
			alias: "Add Cursor Below",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2578,
				linux: {
					primary: 1554,
					secondary: [3090]
				},
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "3_multi",
				title: localize({
					key: "miInsertCursorBelow",
					comment: ["&& denotes a mnemonic"]
				}, "A&&dd Cursor Below"),
				order: 3
			}
		});
	}
	run(e, _, v) {
		if (!_.hasModel()) return;
		let y = !0;
		v && v.logicalLine === !1 && (y = !1);
		let b = _._getViewModel();
		if (b.cursorConfig.readOnly) return;
		b.model.pushStackElement();
		let x = b.getCursorStates();
		b.setCursorStates(v.source, 3, CursorMoveCommands.addCursorDown(b, x, y)), b.revealBottomMostCursor(v.source), announceCursorChange(x, b.getCursorStates());
	}
}, InsertCursorAtEndOfEachLineSelected = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.insertCursorAtEndOfEachLineSelected",
			label: localize("mutlicursor.insertAtEndOfEachLineSelected", "Add Cursors to Line Ends"),
			alias: "Add Cursors to Line Ends",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1575,
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "3_multi",
				title: localize({
					key: "miInsertCursorAtEndOfEachLineSelected",
					comment: ["&& denotes a mnemonic"]
				}, "Add C&&ursors to Line Ends"),
				order: 4
			}
		});
	}
	getCursorsForSelection(e, _, v) {
		if (!e.isEmpty()) {
			for (let y = e.startLineNumber; y < e.endLineNumber; y++) {
				let e = _.getLineMaxColumn(y);
				v.push(new Selection(y, e, y, e));
			}
			e.endColumn > 1 && v.push(new Selection(e.endLineNumber, e.endColumn, e.endLineNumber, e.endColumn));
		}
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getModel(), y = _.getSelections(), b = _._getViewModel(), x = b.getCursorStates(), S = [];
		y.forEach((e) => this.getCursorsForSelection(e, v, S)), S.length > 0 && _.setSelections(S), announceCursorChange(x, b.getCursorStates());
	}
}, InsertCursorAtEndOfLineSelected = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.addCursorsToBottom",
			label: localize("mutlicursor.addCursorsToBottom", "Add Cursors To Bottom"),
			alias: "Add Cursors To Bottom",
			precondition: void 0
		});
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getSelections(), y = _.getModel().getLineCount(), b = [];
		for (let e = v[0].startLineNumber; e <= y; e++) b.push(new Selection(e, v[0].startColumn, e, v[0].endColumn));
		let x = _._getViewModel(), S = x.getCursorStates();
		b.length > 0 && _.setSelections(b), announceCursorChange(S, x.getCursorStates());
	}
}, InsertCursorAtTopOfLineSelected = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.addCursorsToTop",
			label: localize("mutlicursor.addCursorsToTop", "Add Cursors To Top"),
			alias: "Add Cursors To Top",
			precondition: void 0
		});
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getSelections(), y = [];
		for (let e = v[0].startLineNumber; e >= 1; e--) y.push(new Selection(e, v[0].startColumn, e, v[0].endColumn));
		let b = _._getViewModel(), x = b.getCursorStates();
		y.length > 0 && _.setSelections(y), announceCursorChange(x, b.getCursorStates());
	}
}, MultiCursorSessionResult = class {
	constructor(e, _, v) {
		this.selections = e, this.revealRange = _, this.revealScrollType = v;
	}
}, MultiCursorSession = class e {
	static create(_, v) {
		if (!_.hasModel()) return null;
		let y = v.getState();
		if (!_.hasTextFocus() && y.isRevealed && y.searchString.length > 0) return new e(_, v, !1, y.searchString, y.wholeWord, y.matchCase, null);
		let b = !1, x, S, C = _.getSelections();
		C.length === 1 && C[0].isEmpty() ? (b = !0, x = !0, S = !0) : (x = y.wholeWord, S = y.matchCase);
		let w = _.getSelection(), T, E = null;
		if (w.isEmpty()) {
			let e = _.getConfiguredWordAtPosition(w.getStartPosition());
			if (!e) return null;
			T = e.word, E = new Selection(w.startLineNumber, e.startColumn, w.startLineNumber, e.endColumn);
		} else T = _.getModel().getValueInRange(w).replace(/\r\n/g, "\n");
		return new e(_, v, b, T, x, S, E);
	}
	constructor(e, _, v, y, b, x, S) {
		this._editor = e, this.findController = _, this.isDisconnectedFromFindController = v, this.searchText = y, this.wholeWord = b, this.matchCase = x, this.currentMatch = S;
	}
	addSelectionToNextFindMatch() {
		if (!this._editor.hasModel()) return null;
		let e = this._getNextMatch();
		if (!e) return null;
		let _ = this._editor.getSelections();
		return new MultiCursorSessionResult(_.concat(e), e, 0);
	}
	moveSelectionToNextFindMatch() {
		if (!this._editor.hasModel()) return null;
		let e = this._getNextMatch();
		if (!e) return null;
		let _ = this._editor.getSelections();
		return new MultiCursorSessionResult(_.slice(0, _.length - 1).concat(e), e, 0);
	}
	_getNextMatch() {
		if (!this._editor.hasModel()) return null;
		if (this.currentMatch) {
			let e = this.currentMatch;
			return this.currentMatch = null, e;
		}
		this.findController.highlightFindOptions();
		let e = this._editor.getSelections(), _ = e[e.length - 1], v = this._editor.getModel().findNextMatch(this.searchText, _.getEndPosition(), !1, this.matchCase, this.wholeWord ? this._editor.getOption(132) : null, !1);
		return v ? new Selection(v.range.startLineNumber, v.range.startColumn, v.range.endLineNumber, v.range.endColumn) : null;
	}
	addSelectionToPreviousFindMatch() {
		if (!this._editor.hasModel()) return null;
		let e = this._getPreviousMatch();
		if (!e) return null;
		let _ = this._editor.getSelections();
		return new MultiCursorSessionResult(_.concat(e), e, 0);
	}
	moveSelectionToPreviousFindMatch() {
		if (!this._editor.hasModel()) return null;
		let e = this._getPreviousMatch();
		if (!e) return null;
		let _ = this._editor.getSelections();
		return new MultiCursorSessionResult(_.slice(0, _.length - 1).concat(e), e, 0);
	}
	_getPreviousMatch() {
		if (!this._editor.hasModel()) return null;
		if (this.currentMatch) {
			let e = this.currentMatch;
			return this.currentMatch = null, e;
		}
		this.findController.highlightFindOptions();
		let e = this._editor.getSelections(), _ = e[e.length - 1], v = this._editor.getModel().findPreviousMatch(this.searchText, _.getStartPosition(), !1, this.matchCase, this.wholeWord ? this._editor.getOption(132) : null, !1);
		return v ? new Selection(v.range.startLineNumber, v.range.startColumn, v.range.endLineNumber, v.range.endColumn) : null;
	}
	selectAll(e) {
		if (!this._editor.hasModel()) return [];
		this.findController.highlightFindOptions();
		let _ = this._editor.getModel();
		return e ? _.findMatches(this.searchText, e, !1, this.matchCase, this.wholeWord ? this._editor.getOption(132) : null, !1, 1073741824) : _.findMatches(this.searchText, !0, !1, this.matchCase, this.wholeWord ? this._editor.getOption(132) : null, !1, 1073741824);
	}
}, MultiCursorSelectionController = class e extends Disposable {
	static {
		this.ID = "editor.contrib.multiCursorController";
	}
	static get(_) {
		return _.getContribution(e.ID);
	}
	constructor(e) {
		super(), this._sessionDispose = this._register(new DisposableStore()), this._editor = e, this._ignoreSelectionChange = !1, this._session = null;
	}
	dispose() {
		this._endSession(), super.dispose();
	}
	_beginSessionIfNeeded(e) {
		if (!this._session) {
			let _ = MultiCursorSession.create(this._editor, e);
			if (!_) return;
			this._session = _;
			let v = { searchString: this._session.searchText };
			this._session.isDisconnectedFromFindController && (v.wholeWordOverride = 1, v.matchCaseOverride = 1, v.isRegexOverride = 2), e.getState().change(v, !1), this._sessionDispose.add(this._editor.onDidChangeCursorSelection((e) => {
				this._ignoreSelectionChange || this._endSession();
			})), this._sessionDispose.add(this._editor.onDidBlurEditorText(() => {
				this._endSession();
			})), this._sessionDispose.add(e.getState().onFindReplaceStateChange((e) => {
				(e.matchCase || e.wholeWord) && this._endSession();
			}));
		}
	}
	_endSession() {
		this._sessionDispose.clear(), this._session && this._session.isDisconnectedFromFindController && this._session.findController.getState().change({
			wholeWordOverride: 0,
			matchCaseOverride: 0,
			isRegexOverride: 0
		}, !1), this._session = null;
	}
	_setSelections(e) {
		this._ignoreSelectionChange = !0, this._editor.setSelections(e), this._ignoreSelectionChange = !1;
	}
	_expandEmptyToWord(e, _) {
		if (!_.isEmpty()) return _;
		let v = this._editor.getConfiguredWordAtPosition(_.getStartPosition());
		return v ? new Selection(_.startLineNumber, v.startColumn, _.startLineNumber, v.endColumn) : _;
	}
	_applySessionResult(e) {
		e && (this._setSelections(e.selections), e.revealRange && this._editor.revealRangeInCenterIfOutsideViewport(e.revealRange, e.revealScrollType));
	}
	getSession(e) {
		return this._session;
	}
	addSelectionToNextFindMatch(e) {
		if (this._editor.hasModel()) {
			if (!this._session) {
				let _ = this._editor.getSelections();
				if (_.length > 1) {
					let v = e.getState().matchCase;
					if (!modelRangesContainSameText(this._editor.getModel(), _, v)) {
						let e = this._editor.getModel(), v = [];
						for (let y = 0, b = _.length; y < b; y++) v[y] = this._expandEmptyToWord(e, _[y]);
						this._editor.setSelections(v);
						return;
					}
				}
			}
			this._beginSessionIfNeeded(e), this._session && this._applySessionResult(this._session.addSelectionToNextFindMatch());
		}
	}
	addSelectionToPreviousFindMatch(e) {
		this._beginSessionIfNeeded(e), this._session && this._applySessionResult(this._session.addSelectionToPreviousFindMatch());
	}
	moveSelectionToNextFindMatch(e) {
		this._beginSessionIfNeeded(e), this._session && this._applySessionResult(this._session.moveSelectionToNextFindMatch());
	}
	moveSelectionToPreviousFindMatch(e) {
		this._beginSessionIfNeeded(e), this._session && this._applySessionResult(this._session.moveSelectionToPreviousFindMatch());
	}
	selectAll(e) {
		if (!this._editor.hasModel()) return;
		let _ = null, v = e.getState();
		if (v.isRevealed && v.searchString.length > 0 && v.isRegex) {
			let e = this._editor.getModel();
			_ = v.searchScope ? e.findMatches(v.searchString, v.searchScope, v.isRegex, v.matchCase, v.wholeWord ? this._editor.getOption(132) : null, !1, 1073741824) : e.findMatches(v.searchString, !0, v.isRegex, v.matchCase, v.wholeWord ? this._editor.getOption(132) : null, !1, 1073741824);
		} else {
			if (this._beginSessionIfNeeded(e), !this._session) return;
			_ = this._session.selectAll(v.searchScope);
		}
		if (_.length > 0) {
			let e = this._editor.getSelection();
			for (let v = 0, y = _.length; v < y; v++) {
				let y = _[v];
				if (y.range.intersectRanges(e)) {
					_[v] = _[0], _[0] = y;
					break;
				}
			}
			this._setSelections(_.map((e) => new Selection(e.range.startLineNumber, e.range.startColumn, e.range.endLineNumber, e.range.endColumn)));
		}
	}
}, MultiCursorSelectionControllerAction = class extends EditorAction {
	run(e, _) {
		let v = MultiCursorSelectionController.get(_);
		if (!v) return;
		let y = _._getViewModel();
		if (y) {
			let b = y.getCursorStates(), x = CommonFindController.get(_);
			if (x) this._run(v, x);
			else {
				let y = e.get(IInstantiationService).createInstance(CommonFindController, _);
				this._run(v, y), y.dispose();
			}
			announceCursorChange(b, y.getCursorStates());
		}
	}
}, AddSelectionToNextFindMatchAction = class extends MultiCursorSelectionControllerAction {
	constructor() {
		super({
			id: "editor.action.addSelectionToNextFindMatch",
			label: localize("addSelectionToNextFindMatch", "Add Selection To Next Find Match"),
			alias: "Add Selection To Next Find Match",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 2082,
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "3_multi",
				title: localize({
					key: "miAddSelectionToNextFindMatch",
					comment: ["&& denotes a mnemonic"]
				}, "Add &&Next Occurrence"),
				order: 5
			}
		});
	}
	_run(e, _) {
		e.addSelectionToNextFindMatch(_);
	}
}, AddSelectionToPreviousFindMatchAction = class extends MultiCursorSelectionControllerAction {
	constructor() {
		super({
			id: "editor.action.addSelectionToPreviousFindMatch",
			label: localize("addSelectionToPreviousFindMatch", "Add Selection To Previous Find Match"),
			alias: "Add Selection To Previous Find Match",
			precondition: void 0,
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "3_multi",
				title: localize({
					key: "miAddSelectionToPreviousFindMatch",
					comment: ["&& denotes a mnemonic"]
				}, "Add P&&revious Occurrence"),
				order: 6
			}
		});
	}
	_run(e, _) {
		e.addSelectionToPreviousFindMatch(_);
	}
}, MoveSelectionToNextFindMatchAction = class extends MultiCursorSelectionControllerAction {
	constructor() {
		super({
			id: "editor.action.moveSelectionToNextFindMatch",
			label: localize("moveSelectionToNextFindMatch", "Move Last Selection To Next Find Match"),
			alias: "Move Last Selection To Next Find Match",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: KeyChord(2089, 2082),
				weight: 100
			}
		});
	}
	_run(e, _) {
		e.moveSelectionToNextFindMatch(_);
	}
}, MoveSelectionToPreviousFindMatchAction = class extends MultiCursorSelectionControllerAction {
	constructor() {
		super({
			id: "editor.action.moveSelectionToPreviousFindMatch",
			label: localize("moveSelectionToPreviousFindMatch", "Move Last Selection To Previous Find Match"),
			alias: "Move Last Selection To Previous Find Match",
			precondition: void 0
		});
	}
	_run(e, _) {
		e.moveSelectionToPreviousFindMatch(_);
	}
}, SelectHighlightsAction = class extends MultiCursorSelectionControllerAction {
	constructor() {
		super({
			id: "editor.action.selectHighlights",
			label: localize("selectAllOccurrencesOfFindMatch", "Select All Occurrences of Find Match"),
			alias: "Select All Occurrences of Find Match",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 3114,
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "3_multi",
				title: localize({
					key: "miSelectHighlights",
					comment: ["&& denotes a mnemonic"]
				}, "Select All &&Occurrences"),
				order: 7
			}
		});
	}
	_run(e, _) {
		e.selectAll(_);
	}
}, CompatChangeAll = class extends MultiCursorSelectionControllerAction {
	constructor() {
		super({
			id: "editor.action.changeAll",
			label: localize("changeAll.label", "Change All Occurrences"),
			alias: "Change All Occurrences",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.editorTextFocus),
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 2108,
				weight: 100
			},
			contextMenuOpts: {
				group: "1_modification",
				order: 1.2
			}
		});
	}
	_run(e, _) {
		e.selectAll(_);
	}
}, SelectionHighlighterState = class {
	constructor(e, _, v, y, b) {
		this._model = e, this._searchText = _, this._matchCase = v, this._wordSeparators = y, this._modelVersionId = this._model.getVersionId(), this._cachedFindMatches = null, b && this._model === b._model && this._searchText === b._searchText && this._matchCase === b._matchCase && this._wordSeparators === b._wordSeparators && this._modelVersionId === b._modelVersionId && (this._cachedFindMatches = b._cachedFindMatches);
	}
	findMatches() {
		return this._cachedFindMatches === null && (this._cachedFindMatches = this._model.findMatches(this._searchText, !0, !1, this._matchCase, this._wordSeparators, !1).map((e) => e.range), this._cachedFindMatches.sort(Range.compareRangesUsingStarts)), this._cachedFindMatches;
	}
}, SelectionHighlighter = class extends Disposable {
	static {
		SelectionHighlighter_1 = this;
	}
	static {
		this.ID = "editor.contrib.selectionHighlighter";
	}
	constructor(e, _) {
		super(), this._languageFeaturesService = _, this.editor = e, this._isEnabled = e.getOption(109), this._decorations = e.createDecorationsCollection(), this.updateSoon = this._register(new RunOnceScheduler(() => this._update(), 300)), this.state = null, this._register(e.onDidChangeConfiguration((_) => {
			this._isEnabled = e.getOption(109);
		})), this._register(e.onDidChangeCursorSelection((e) => {
			this._isEnabled && (e.selection.isEmpty() ? e.reason === 3 ? (this.state && this._setState(null), this.updateSoon.schedule()) : this._setState(null) : this._update());
		})), this._register(e.onDidChangeModel((e) => {
			this._setState(null);
		})), this._register(e.onDidChangeModelContent((e) => {
			this._isEnabled && this.updateSoon.schedule();
		}));
		let v = CommonFindController.get(e);
		v && this._register(v.getState().onFindReplaceStateChange((e) => {
			this._update();
		})), this.updateSoon.schedule();
	}
	_update() {
		this._setState(SelectionHighlighter_1._createState(this.state, this._isEnabled, this.editor));
	}
	static _createState(e, _, v) {
		if (!_ || !v.hasModel()) return null;
		let y = v.getSelection();
		if (y.startLineNumber !== y.endLineNumber) return null;
		let b = MultiCursorSelectionController.get(v);
		if (!b) return null;
		let x = CommonFindController.get(v);
		if (!x) return null;
		let S = b.getSession(x);
		if (!S) {
			let e = v.getSelections();
			if (e.length > 1) {
				let _ = x.getState().matchCase;
				if (!modelRangesContainSameText(v.getModel(), e, _)) return null;
			}
			S = MultiCursorSession.create(v, x);
		}
		if (!S || S.currentMatch || /^[ \t]+$/.test(S.searchText) || S.searchText.length > 200) return null;
		let C = x.getState(), w = C.matchCase;
		if (C.isRevealed) {
			let e = C.searchString;
			w || (e = e.toLowerCase());
			let _ = S.searchText;
			if (w || (_ = _.toLowerCase()), e === _ && S.matchCase === C.matchCase && S.wholeWord === C.wholeWord && !C.isRegex) return null;
		}
		return new SelectionHighlighterState(v.getModel(), S.searchText, S.matchCase, S.wholeWord ? v.getOption(132) : null, e);
	}
	_setState(e) {
		if (this.state = e, !this.state) {
			this._decorations.clear();
			return;
		}
		if (!this.editor.hasModel()) return;
		let _ = this.editor.getModel();
		if (_.isTooLargeForTokenization()) return;
		let v = this.state.findMatches(), y = this.editor.getSelections();
		y.sort(Range.compareRangesUsingStarts);
		let b = [];
		for (let e = 0, _ = 0, x = v.length, S = y.length; e < x;) {
			let x = v[e];
			if (_ >= S) b.push(x), e++;
			else {
				let v = Range.compareRangesUsingStarts(x, y[_]);
				v < 0 ? ((y[_].isEmpty() || !Range.areIntersecting(x, y[_])) && b.push(x), e++) : (v > 0 || e++, _++);
			}
		}
		let x = this.editor.getOption(81) !== "off", S = this._languageFeaturesService.documentHighlightProvider.has(_) && x, C = b.map((e) => ({
			range: e,
			options: getSelectionHighlightDecorationOptions(S)
		}));
		this._decorations.set(C);
	}
	dispose() {
		this._setState(null), super.dispose();
	}
};
SelectionHighlighter = SelectionHighlighter_1 = __decorate$35([__param$35(1, ILanguageFeaturesService)], SelectionHighlighter);
function modelRangesContainSameText(e, _, v) {
	let y = getValueInRange(e, _[0], !v);
	for (let b = 1, x = _.length; b < x; b++) {
		let x = _[b];
		if (x.isEmpty()) return !1;
		let S = getValueInRange(e, x, !v);
		if (y !== S) return !1;
	}
	return !0;
}
function getValueInRange(e, _, v) {
	let y = e.getValueInRange(_);
	return v ? y.toLowerCase() : y;
}
var FocusNextCursor = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.focusNextCursor",
			label: localize("mutlicursor.focusNextCursor", "Focus Next Cursor"),
			metadata: {
				description: localize("mutlicursor.focusNextCursor.description", "Focuses the next cursor"),
				args: []
			},
			alias: "Focus Next Cursor",
			precondition: void 0
		});
	}
	run(e, _, v) {
		if (!_.hasModel()) return;
		let y = _._getViewModel();
		if (y.cursorConfig.readOnly) return;
		y.model.pushStackElement();
		let b = Array.from(y.getCursorStates()), x = b.shift();
		x && (b.push(x), y.setCursorStates(v.source, 3, b), y.revealPrimaryCursor(v.source, !0), announceCursorChange(b, y.getCursorStates()));
	}
}, FocusPreviousCursor = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.focusPreviousCursor",
			label: localize("mutlicursor.focusPreviousCursor", "Focus Previous Cursor"),
			metadata: {
				description: localize("mutlicursor.focusPreviousCursor.description", "Focuses the previous cursor"),
				args: []
			},
			alias: "Focus Previous Cursor",
			precondition: void 0
		});
	}
	run(e, _, v) {
		if (!_.hasModel()) return;
		let y = _._getViewModel();
		if (y.cursorConfig.readOnly) return;
		y.model.pushStackElement();
		let b = Array.from(y.getCursorStates()), x = b.pop();
		x && (b.unshift(x), y.setCursorStates(v.source, 3, b), y.revealPrimaryCursor(v.source, !0), announceCursorChange(b, y.getCursorStates()));
	}
};
registerEditorContribution(MultiCursorSelectionController.ID, MultiCursorSelectionController, 4), registerEditorContribution(SelectionHighlighter.ID, SelectionHighlighter, 1), registerEditorAction(InsertCursorAbove), registerEditorAction(InsertCursorBelow), registerEditorAction(InsertCursorAtEndOfEachLineSelected), registerEditorAction(AddSelectionToNextFindMatchAction), registerEditorAction(AddSelectionToPreviousFindMatchAction), registerEditorAction(MoveSelectionToNextFindMatchAction), registerEditorAction(MoveSelectionToPreviousFindMatchAction), registerEditorAction(SelectHighlightsAction), registerEditorAction(CompatChangeAll), registerEditorAction(InsertCursorAtEndOfLineSelected), registerEditorAction(InsertCursorAtTopOfLineSelected), registerEditorAction(FocusNextCursor), registerEditorAction(FocusPreviousCursor);
var __decorate$34 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$34 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const INLINE_EDIT_DESCRIPTION = "inline-edit";
var GhostTextWidget = class extends Disposable {
	constructor(e, _, v) {
		super(), this.editor = e, this.model = _, this.languageService = v, this.isDisposed = observableValue(this, !1), this.currentTextModel = observableFromEvent(this, this.editor.onDidChangeModel, () => this.editor.getModel()), this.uiState = derived(this, (e) => {
			if (this.isDisposed.read(e)) return;
			let _ = this.currentTextModel.read(e);
			if (_ !== this.model.targetTextModel.read(e)) return;
			let v = this.model.ghostText.read(e);
			if (!v) return;
			let y = this.model.range?.read(e);
			y && y.startLineNumber === y.endLineNumber && y.startColumn === y.endColumn && (y = void 0);
			let b = (y ? y.startLineNumber === y.endLineNumber : !0) && v.parts.length === 1 && v.parts[0].lines.length === 1, x = v.parts.length === 1 && v.parts[0].lines.every((e) => e.length === 0), S = [], C = [];
			function w(e, _) {
				if (C.length > 0) {
					let v = C[C.length - 1];
					_ && v.decorations.push(new LineDecoration(v.content.length + 1, v.content.length + 1 + e[0].length, _, 0)), v.content += e[0], e = e.slice(1);
				}
				for (let v of e) C.push({
					content: v,
					decorations: _ ? [new LineDecoration(1, v.length + 1, _, 0)] : []
				});
			}
			let T = _.getLineContent(v.lineNumber), E, D = 0;
			if (!x && (b || !y)) {
				for (let e of v.parts) {
					let _ = e.lines;
					y && !b && (w(_, INLINE_EDIT_DESCRIPTION), _ = []), E === void 0 ? (S.push({
						column: e.column,
						text: _[0],
						preview: e.preview
					}), _ = _.slice(1)) : w([T.substring(D, e.column - 1)], void 0), _.length > 0 && (w(_, INLINE_EDIT_DESCRIPTION), E === void 0 && e.column <= T.length && (E = e.column)), D = e.column - 1;
				}
				E !== void 0 && w([T.substring(D)], void 0);
			}
			let O = E === void 0 ? void 0 : new ColumnRange(E, T.length + 1), k = b || !y ? v.lineNumber : y.endLineNumber - 1;
			return {
				inlineTexts: S,
				additionalLines: C,
				hiddenRange: O,
				lineNumber: k,
				additionalReservedLineCount: this.model.minReservedLineCount.read(e),
				targetTextModel: _,
				range: y,
				isSingleLine: b,
				isPureRemove: x
			};
		}), this.decorations = derived(this, (e) => {
			let _ = this.uiState.read(e);
			if (!_) return [];
			let v = [];
			if (_.hiddenRange && v.push({
				range: _.hiddenRange.toRange(_.lineNumber),
				options: {
					inlineClassName: "inline-edit-hidden",
					description: "inline-edit-hidden"
				}
			}), _.range) {
				let e = [];
				if (_.isSingleLine) e.push(_.range);
				else if (!_.isPureRemove) {
					let v = _.range.endLineNumber - _.range.startLineNumber;
					for (let y = 0; y < v; y++) {
						let v = _.range.startLineNumber + y, b = _.targetTextModel.getLineFirstNonWhitespaceColumn(v), x = _.targetTextModel.getLineLastNonWhitespaceColumn(v), S = new Range(v, b, v, x);
						e.push(S);
					}
				}
				for (let _ of e) v.push({
					range: _,
					options: diffDeleteDecoration
				});
			}
			if (_.range && !_.isSingleLine && _.isPureRemove) {
				let e = new Range(_.range.startLineNumber, 1, _.range.endLineNumber - 1, 1);
				v.push({
					range: e,
					options: diffLineDeleteDecorationBackgroundWithIndicator
				});
			}
			for (let e of _.inlineTexts) v.push({
				range: Range.fromPositions(new Position(_.lineNumber, e.column)),
				options: {
					description: INLINE_EDIT_DESCRIPTION,
					after: {
						content: e.text,
						inlineClassName: e.preview ? "inline-edit-decoration-preview" : "inline-edit-decoration",
						cursorStops: InjectedTextCursorStops.Left
					},
					showIfCollapsed: !0
				}
			});
			return v;
		}), this._register(toDisposable(() => {
			this.isDisposed.set(!0, void 0);
		})), this._register(applyObservableDecorations(this.editor, this.decorations));
	}
};
GhostTextWidget = __decorate$34([__param$34(2, ILanguageService)], GhostTextWidget);
var __decorate$33 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$33 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineEditHintsContentWidget_1, InlineEditHintsWidget = class extends Disposable {
	constructor(e, _, v) {
		super(), this.editor = e, this.model = _, this.instantiationService = v, this.alwaysShowToolbar = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(63).showToolbar === "always"), this.sessionPosition = void 0, this.position = derived(this, (e) => {
			let _ = this.model.read(e)?.model.ghostText.read(e);
			if (!this.alwaysShowToolbar.read(e) || !_ || _.parts.length === 0) return this.sessionPosition = void 0, null;
			let v = _.parts[0].column;
			this.sessionPosition && this.sessionPosition.lineNumber !== _.lineNumber && (this.sessionPosition = void 0);
			let y = new Position(_.lineNumber, Math.min(v, this.sessionPosition?.column ?? 2 ** 53 - 1));
			return this.sessionPosition = y, y;
		}), this._register(autorunWithStore((_, v) => {
			if (!this.model.read(_) || !this.alwaysShowToolbar.read(_)) return;
			let y = v.add(this.instantiationService.createInstance(InlineEditHintsContentWidget, this.editor, !0, this.position));
			e.addContentWidget(y), v.add(toDisposable(() => e.removeContentWidget(y)));
		}));
	}
};
InlineEditHintsWidget = __decorate$33([__param$33(2, IInstantiationService)], InlineEditHintsWidget);
var InlineEditHintsContentWidget = class extends Disposable {
	static {
		InlineEditHintsContentWidget_1 = this;
	}
	static {
		this._dropDownVisible = !1;
	}
	static {
		this.id = 0;
	}
	constructor(e, _, v, y, b, x) {
		super(), this.editor = e, this.withBorder = _, this._position = v, this._contextKeyService = b, this._menuService = x, this.id = `InlineEditHintsContentWidget${InlineEditHintsContentWidget_1.id++}`, this.allowEditorOverflow = !0, this.suppressMouseDown = !1, this.nodes = h("div.inlineEditHints", { className: this.withBorder ? ".withBorder" : "" }, [h("div@toolBar")]), this.inlineCompletionsActionsMenus = this._register(this._menuService.createMenu(MenuId.InlineEditActions, this._contextKeyService)), this.toolBar = this._register(y.createInstance(CustomizedMenuWorkbenchToolBar, this.nodes.toolBar, this.editor, MenuId.InlineEditToolbar, {
			menuOptions: { renderShortTitle: !0 },
			toolbarOptions: { primaryGroup: (e) => e.startsWith("primary") },
			actionViewItemProvider: (e, _) => {
				if (e instanceof MenuItemAction) return y.createInstance(StatusBarViewItem, e, void 0);
			},
			telemetrySource: "InlineEditToolbar"
		})), this._register(this.toolBar.onDidChangeDropdownVisibility((e) => {
			InlineEditHintsContentWidget_1._dropDownVisible = e;
		})), this._register(autorun((e) => {
			this._position.read(e), this.editor.layoutContentWidget(this);
		})), this._register(autorun((e) => {
			let _ = [];
			for (let [e, v] of this.inlineCompletionsActionsMenus.getActions()) for (let e of v) e instanceof MenuItemAction && _.push(e);
			_.length > 0 && _.unshift(new Separator()), this.toolBar.setAdditionalSecondaryActions(_);
		}));
	}
	getId() {
		return this.id;
	}
	getDomNode() {
		return this.nodes.root;
	}
	getPosition() {
		return {
			position: this._position.get(),
			preference: [1, 2],
			positionAffinity: 3
		};
	}
};
InlineEditHintsContentWidget = InlineEditHintsContentWidget_1 = __decorate$33([
	__param$33(3, IInstantiationService),
	__param$33(4, IContextKeyService),
	__param$33(5, IMenuService)
], InlineEditHintsContentWidget);
var StatusBarViewItem = class extends MenuEntryActionViewItem {
	updateLabel() {
		let e = this._keybindingService.lookupKeybinding(this._action.id, this._contextKeyService);
		if (!e) return super.updateLabel();
		if (this.label) {
			let _ = h("div.keybinding").root;
			this._register(new KeybindingLabel(_, OS, {
				disableTitle: !0,
				...unthemedKeybindingLabelOptions
			})).set(e), this.label.textContent = this._action.label, this.label.appendChild(_), this.label.classList.add("inlineEditStatusBarItemLabel");
		}
	}
	updateTooltip() {}
}, CustomizedMenuWorkbenchToolBar = class extends WorkbenchToolBar {
	constructor(e, _, v, y, b, x, S, C, w, T) {
		super(e, {
			resetMenu: v,
			...y
		}, b, x, S, C, w, T), this.editor = _, this.menuId = v, this.options2 = y, this.menuService = b, this.contextKeyService = x, this.menu = this._store.add(this.menuService.createMenu(this.menuId, this.contextKeyService, { emitEventsForSubmenuChanges: !0 })), this.additionalActions = [], this.prependedPrimaryActions = [], this._store.add(this.menu.onDidChange(() => this.updateToolbar())), this._store.add(this.editor.onDidChangeCursorPosition(() => this.updateToolbar())), this.updateToolbar();
	}
	updateToolbar() {
		let e = [], _ = [];
		createAndFillInActionBarActions(this.menu, this.options2?.menuOptions, {
			primary: e,
			secondary: _
		}, this.options2?.toolbarOptions?.primaryGroup, this.options2?.toolbarOptions?.shouldInlineSubmenu, this.options2?.toolbarOptions?.useSeparatorsInPrimaryActions), _.push(...this.additionalActions), e.unshift(...this.prependedPrimaryActions), this.setActions(e, _);
	}
	setAdditionalSecondaryActions(e) {
		equals(this.additionalActions, e, (e, _) => e === _) || (this.additionalActions = e, this.updateToolbar());
	}
};
CustomizedMenuWorkbenchToolBar = __decorate$33([
	__param$33(4, IMenuService),
	__param$33(5, IContextKeyService),
	__param$33(6, IContextMenuService),
	__param$33(7, IKeybindingService),
	__param$33(8, ICommandService),
	__param$33(9, ITelemetryService)
], CustomizedMenuWorkbenchToolBar);
var __decorate$32 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$32 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineEditSideBySideWidget_1, InlineEditSideBySideContentWidget_1;
function* range(e, _, v = 1) {
	_ === void 0 && ([_, e] = [e, 0]);
	for (let y = e; y < _; y += v) yield y;
}
function removeIndentation(e) {
	let _ = e[0].match(/^\s*/)?.[0] ?? "", v = _.length;
	return {
		text: e.map((e) => e.replace(/* @__PURE__ */ RegExp("^" + _), "")),
		shift: v
	};
}
var InlineEditSideBySideWidget = class extends Disposable {
	static {
		InlineEditSideBySideWidget_1 = this;
	}
	static {
		this._modelId = 0;
	}
	static _createUniqueUri() {
		return URI.from({
			scheme: "inline-edit-widget",
			path: (/* @__PURE__ */ new Date()).toString() + String(InlineEditSideBySideWidget_1._modelId++)
		});
	}
	constructor(e, _, v, y, b) {
		super(), this._editor = e, this._model = _, this._instantiationService = v, this._diffProviderFactoryService = y, this._modelService = b, this._position = derived(this, (e) => {
			let _ = this._model.read(e);
			if (!_ || _.text.length === 0 || _.range.startLineNumber === _.range.endLineNumber && !(_.range.startColumn === _.range.endColumn && _.range.startColumn === 1)) return null;
			let v = this._editor.getModel();
			if (!v) return null;
			let y = Array.from(range(_.range.startLineNumber, _.range.endLineNumber + 1)), b = y.map((e) => v.getLineLastNonWhitespaceColumn(e)), x = Math.max(...b), S = y[b.indexOf(x)], C = new Position(S, x);
			return {
				top: _.range.startLineNumber,
				left: C
			};
		}), this._text = derived(this, (e) => {
			let _ = this._model.read(e);
			if (!_) return {
				text: "",
				shift: 0
			};
			let v = removeIndentation(_.text.split("\n"));
			return {
				text: v.text.join("\n"),
				shift: v.shift
			};
		}), this._originalModel = derivedDisposable(() => this._modelService.createModel("", null, InlineEditSideBySideWidget_1._createUniqueUri())).keepObserved(this._store), this._modifiedModel = derivedDisposable(() => this._modelService.createModel("", null, InlineEditSideBySideWidget_1._createUniqueUri())).keepObserved(this._store), this._diff = derived(this, (e) => this._diffPromise.read(e)?.promiseResult.read(e)?.data), this._diffPromise = derived(this, (e) => {
			let _ = this._model.read(e);
			if (!_) return;
			let v = this._editor.getModel();
			if (!v) return;
			let y = removeIndentation(v.getValueInRange(_.range).split("\n")).text.join("\n"), b = removeIndentation(_.text.split("\n")).text.join("\n");
			this._originalModel.get().setValue(y), this._modifiedModel.get().setValue(b);
			let x = this._diffProviderFactoryService.createDiffProvider({ diffAlgorithm: "advanced" });
			return ObservablePromise.fromFn(async () => {
				let e = await x.computeDiff(this._originalModel.get(), this._modifiedModel.get(), {
					computeMoves: !1,
					ignoreTrimWhitespace: !1,
					maxComputationTimeMs: 1e3
				}, CancellationToken.None);
				if (!e.identical) return e.changes;
			});
		}), this._register(autorunWithStore((_, v) => {
			if (!this._model.read(_) || this._position.get() === null) return;
			let y = v.add(this._instantiationService.createInstance(InlineEditSideBySideContentWidget, this._editor, this._position, this._text.map((e) => e.text), this._text.map((e) => e.shift), this._diff));
			e.addOverlayWidget(y), v.add(toDisposable(() => e.removeOverlayWidget(y)));
		}));
	}
};
InlineEditSideBySideWidget = InlineEditSideBySideWidget_1 = __decorate$32([
	__param$32(2, IInstantiationService),
	__param$32(3, IDiffProviderFactoryService),
	__param$32(4, IModelService)
], InlineEditSideBySideWidget);
var InlineEditSideBySideContentWidget = class extends Disposable {
	static {
		InlineEditSideBySideContentWidget_1 = this;
	}
	static {
		this.id = 0;
	}
	constructor(e, _, v, y, b, x) {
		super(), this._editor = e, this._position = _, this._text = v, this._shift = y, this._diff = b, this._instantiationService = x, this.id = `InlineEditSideBySideContentWidget${InlineEditSideBySideContentWidget_1.id++}`, this.allowEditorOverflow = !1, this._nodes = $("div.inlineEditSideBySide", void 0), this._scrollChanged = observableSignalFromEvent("editor.onDidScrollChange", this._editor.onDidScrollChange), this._previewEditor = this._register(this._instantiationService.createInstance(EmbeddedCodeEditorWidget, this._nodes, {
			glyphMargin: !1,
			lineNumbers: "off",
			minimap: { enabled: !1 },
			guides: {
				indentation: !1,
				bracketPairs: !1,
				bracketPairsHorizontal: !1,
				highlightActiveIndentation: !1
			},
			folding: !1,
			selectOnLineNumbers: !1,
			selectionHighlight: !1,
			columnSelection: !1,
			overviewRulerBorder: !1,
			overviewRulerLanes: 0,
			lineDecorationsWidth: 0,
			lineNumbersMinChars: 0,
			scrollbar: {
				vertical: "hidden",
				horizontal: "hidden",
				alwaysConsumeMouseWheel: !1,
				handleMouseWheel: !1
			},
			readOnly: !0,
			wordWrap: "off",
			wordWrapOverride1: "off",
			wordWrapOverride2: "off",
			wrappingIndent: "none",
			wrappingStrategy: void 0
		}, {
			contributions: [],
			isSimpleWidget: !0
		}, this._editor)), this._previewEditorObs = observableCodeEditor(this._previewEditor), this._editorObs = observableCodeEditor(this._editor), this._previewTextModel = this._register(this._instantiationService.createInstance(TextModel, "", this._editor.getModel()?.getLanguageId() ?? "plaintext", TextModel.DEFAULT_CREATION_OPTIONS, null)), this._setText = derived((e) => {
			let _ = this._text.read(e);
			_ && this._previewTextModel.setValue(_);
		}).recomputeInitiallyAndOnChange(this._store), this._decorations = derived(this, (e) => {
			this._setText.read(e);
			let _ = this._position.read(e);
			if (!_) return {
				org: [],
				mod: []
			};
			let v = this._diff.read(e);
			if (!v) return {
				org: [],
				mod: []
			};
			let y = [], b = [];
			if (v.length === 1 && v[0].innerChanges[0].modifiedRange.equalsRange(this._previewTextModel.getFullModelRange())) return {
				org: [],
				mod: []
			};
			let x = this._shift.get(), S = (e) => new Range(e.startLineNumber + _.top - 1, e.startColumn + x, e.endLineNumber + _.top - 1, e.endColumn + x);
			for (let e of v) if (e.original.isEmpty || y.push({
				range: S(e.original.toInclusiveRange()),
				options: diffLineDeleteDecorationBackgroundWithIndicator
			}), e.modified.isEmpty || b.push({
				range: e.modified.toInclusiveRange(),
				options: diffLineAddDecorationBackgroundWithIndicator
			}), e.modified.isEmpty || e.original.isEmpty) e.original.isEmpty || y.push({
				range: S(e.original.toInclusiveRange()),
				options: diffWholeLineDeleteDecoration
			}), e.modified.isEmpty || b.push({
				range: e.modified.toInclusiveRange(),
				options: diffWholeLineAddDecoration
			});
			else for (let _ of e.innerChanges || []) e.original.contains(_.originalRange.startLineNumber) && y.push({
				range: S(_.originalRange),
				options: _.originalRange.isEmpty() ? diffDeleteDecorationEmpty : diffDeleteDecoration
			}), e.modified.contains(_.modifiedRange.startLineNumber) && b.push({
				range: _.modifiedRange,
				options: _.modifiedRange.isEmpty() ? diffAddDecorationEmpty : diffAddDecoration
			});
			return {
				org: y,
				mod: b
			};
		}), this._originalDecorations = derived(this, (e) => this._decorations.read(e).org), this._modifiedDecorations = derived(this, (e) => this._decorations.read(e).mod), this._previewEditor.setModel(this._previewTextModel), this._register(this._editorObs.setDecorations(this._originalDecorations)), this._register(this._previewEditorObs.setDecorations(this._modifiedDecorations)), this._register(autorun((e) => {
			let _ = this._previewEditorObs.contentWidth.read(e), v = this._text.read(e).split("\n").length - 1, y = this._editor.getOption(67) * v;
			_ <= 0 || this._previewEditor.layout({
				height: y,
				width: _
			});
		})), this._register(autorun((e) => {
			this._position.read(e), this._editor.layoutOverlayWidget(this);
		})), this._register(autorun((e) => {
			this._scrollChanged.read(e), this._position.read(e) && this._editor.layoutOverlayWidget(this);
		}));
	}
	getId() {
		return this.id;
	}
	getDomNode() {
		return this._nodes;
	}
	getPosition() {
		let e = this._position.get();
		if (!e) return null;
		let _ = this._editor.getLayoutInfo(), v = this._editor.getScrolledVisiblePosition(new Position(e.top, 1));
		if (!v) return null;
		let y = v.top - 1, b = this._editor.getOffsetForColumn(e.left.lineNumber, e.left.column);
		return { preference: {
			left: _.contentLeft + b + 10,
			top: y
		} };
	}
};
InlineEditSideBySideContentWidget = InlineEditSideBySideContentWidget_1 = __decorate$32([__param$32(5, IInstantiationService)], InlineEditSideBySideContentWidget);
var __decorate$31 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$31 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineEditController_1, InlineEditController = class extends Disposable {
	static {
		InlineEditController_1 = this;
	}
	static {
		this.ID = "editor.contrib.inlineEditController";
	}
	static {
		this.inlineEditVisibleKey = "inlineEditVisible";
	}
	static {
		this.inlineEditVisibleContext = new RawContextKey(this.inlineEditVisibleKey, !1);
	}
	static {
		this.cursorAtInlineEditKey = "cursorAtInlineEdit";
	}
	static {
		this.cursorAtInlineEditContext = new RawContextKey(this.cursorAtInlineEditKey, !1);
	}
	static get(e) {
		return e.getContribution(InlineEditController_1.ID);
	}
	constructor(e, _, v, y, b, x, S, C) {
		super(), this.editor = e, this.instantiationService = _, this.contextKeyService = v, this.languageFeaturesService = y, this._commandService = b, this._configurationService = x, this._diffProviderFactoryService = S, this._modelService = C, this._isVisibleContext = InlineEditController_1.inlineEditVisibleContext.bindTo(this.contextKeyService), this._isCursorAtInlineEditContext = InlineEditController_1.cursorAtInlineEditContext.bindTo(this.contextKeyService), this._currentEdit = observableValue(this, void 0), this._currentWidget = derivedDisposable(this._currentEdit, (e) => {
			let _ = this._currentEdit.read(e);
			if (!_) return;
			let v = _.range.endLineNumber, y = _.range.endColumn, b = _.text.endsWith("\n") && !(_.range.startLineNumber === _.range.endLineNumber && _.range.startColumn === _.range.endColumn) ? _.text.slice(0, -1) : _.text, x = new GhostText(v, [new GhostTextPart(y, b, !1)]), S = _.range.startLineNumber === _.range.endLineNumber && x.parts.length === 1 && x.parts[0].lines.length === 1, C = _.text === "";
			if (!(!S && !C)) return this.instantiationService.createInstance(GhostTextWidget, this.editor, {
				ghostText: constObservable(x),
				minReservedLineCount: constObservable(0),
				targetTextModel: constObservable(this.editor.getModel() ?? void 0),
				range: constObservable(_.range)
			});
		}), this._isAccepting = observableValue(this, !1), this._enabled = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(63).enabled), this._fontFamily = observableFromEvent(this, this.editor.onDidChangeConfiguration, () => this.editor.getOption(63).fontFamily);
		let w = observableSignalFromEvent("InlineEditController.modelContentChangedSignal", e.onDidChangeModelContent);
		this._register(autorun((_) => {
			this._enabled.read(_) && (w.read(_), !this._isAccepting.read(_) && this.getInlineEdit(e, !0));
		}));
		let T = observableFromEvent(this, e.onDidChangeCursorPosition, () => e.getPosition());
		this._register(autorun((e) => {
			if (!this._enabled.read(e)) return;
			let _ = T.read(e);
			_ && this.checkCursorPosition(_);
		})), this._register(autorun((_) => {
			let v = this._currentEdit.read(_);
			if (this._isCursorAtInlineEditContext.set(!1), !v) {
				this._isVisibleContext.set(!1);
				return;
			}
			this._isVisibleContext.set(!0);
			let y = e.getPosition();
			y && this.checkCursorPosition(y);
		}));
		let E = observableSignalFromEvent("InlineEditController.editorBlurSignal", e.onDidBlurEditorWidget);
		this._register(autorun(async (_) => {
			this._enabled.read(_) && (E.read(_), !(this._configurationService.getValue("editor.experimentalInlineEdit.keepOnBlur") || e.getOption(63).keepOnBlur) && (this._currentRequestCts?.dispose(!0), this._currentRequestCts = void 0, await this.clear(!1)));
		}));
		let D = observableSignalFromEvent("InlineEditController.editorFocusSignal", e.onDidFocusEditorText);
		this._register(autorun((_) => {
			this._enabled.read(_) && (D.read(_), this.getInlineEdit(e, !0));
		}));
		let O = this._register(createStyleSheet2());
		this._register(autorun((e) => {
			let _ = this._fontFamily.read(e);
			O.setStyle(_ === "" || _ === "default" ? "" : `
.monaco-editor .inline-edit-decoration,
.monaco-editor .inline-edit-decoration-preview,
.monaco-editor .inline-edit {
	font-family: ${_};
}`);
		})), this._register(new InlineEditHintsWidget(this.editor, this._currentWidget, this.instantiationService)), this._register(new InlineEditSideBySideWidget(this.editor, this._currentEdit, this.instantiationService, this._diffProviderFactoryService, this._modelService));
	}
	checkCursorPosition(e) {
		if (!this._currentEdit) {
			this._isCursorAtInlineEditContext.set(!1);
			return;
		}
		let _ = this._currentEdit.get();
		if (!_) {
			this._isCursorAtInlineEditContext.set(!1);
			return;
		}
		this._isCursorAtInlineEditContext.set(Range.containsPosition(_.range, e));
	}
	validateInlineEdit(e, _) {
		if (_.text.includes("\n") && _.range.startLineNumber !== _.range.endLineNumber && _.range.startColumn !== _.range.endColumn) {
			if (_.range.startColumn !== 1) return !1;
			let v = _.range.endLineNumber, y = _.range.endColumn, b = e.getModel()?.getLineLength(v) ?? 0;
			if (y !== b + 1) return !1;
		}
		return !0;
	}
	async fetchInlineEdit(e, _) {
		this._currentRequestCts && this._currentRequestCts.dispose(!0);
		let v = e.getModel();
		if (!v) return;
		let y = v.getVersionId(), b = this.languageFeaturesService.inlineEditProvider.all(v);
		if (b.length === 0) return;
		let x = b[0];
		this._currentRequestCts = new CancellationTokenSource();
		let S = this._currentRequestCts.token, C = _ ? InlineEditTriggerKind.Automatic : InlineEditTriggerKind.Invoke;
		if (_ && await wait(50, S), S.isCancellationRequested || v.isDisposed() || v.getVersionId() !== y) return;
		let w = await x.provideInlineEdit(v, { triggerKind: C }, S);
		if (w && !(S.isCancellationRequested || v.isDisposed() || v.getVersionId() !== y) && this.validateInlineEdit(e, w)) return w;
	}
	async getInlineEdit(e, _) {
		this._isCursorAtInlineEditContext.set(!1), await this.clear();
		let v = await this.fetchInlineEdit(e, _);
		v && this._currentEdit.set(v, void 0);
	}
	async trigger() {
		await this.getInlineEdit(this.editor, !1);
	}
	async jumpBack() {
		this._jumpBackPosition && (this.editor.setPosition(this._jumpBackPosition), this.editor.revealPositionInCenterIfOutsideViewport(this._jumpBackPosition));
	}
	async accept() {
		this._isAccepting.set(!0, void 0);
		let e = this._currentEdit.get();
		if (!e) return;
		let _ = e.text;
		e.text.startsWith("\n") && (_ = e.text.substring(1)), this.editor.pushUndoStop(), this.editor.executeEdits("acceptCurrent", [EditOperation.replace(Range.lift(e.range), _)]), e.accepted && await this._commandService.executeCommand(e.accepted.id, ...e.accepted.arguments || []).then(void 0, onUnexpectedExternalError), this.freeEdit(e), transaction((e) => {
			this._currentEdit.set(void 0, e), this._isAccepting.set(!1, e);
		});
	}
	jumpToCurrent() {
		this._jumpBackPosition = this.editor.getSelection()?.getStartPosition();
		let e = this._currentEdit.get();
		if (!e) return;
		let _ = Position.lift({
			lineNumber: e.range.startLineNumber,
			column: e.range.startColumn
		});
		this.editor.setPosition(_), this.editor.revealPositionInCenterIfOutsideViewport(_);
	}
	async clear(e = !0) {
		let _ = this._currentEdit.get();
		_ && _?.rejected && e && await this._commandService.executeCommand(_.rejected.id, ..._.rejected.arguments || []).then(void 0, onUnexpectedExternalError), _ && this.freeEdit(_), this._currentEdit.set(void 0, void 0);
	}
	freeEdit(e) {
		let _ = this.editor.getModel();
		if (!_) return;
		let v = this.languageFeaturesService.inlineEditProvider.all(_);
		v.length !== 0 && v[0].freeInlineEdit(e);
	}
};
InlineEditController = InlineEditController_1 = __decorate$31([
	__param$31(1, IInstantiationService),
	__param$31(2, IContextKeyService),
	__param$31(3, ILanguageFeaturesService),
	__param$31(4, ICommandService),
	__param$31(5, IConfigurationService),
	__param$31(6, IDiffProviderFactoryService),
	__param$31(7, IModelService)
], InlineEditController);
function wait(e, _) {
	return new Promise((v) => {
		let y, b = setTimeout(() => {
			y && y.dispose(), v();
		}, e);
		_ && (y = _.onCancellationRequested(() => {
			clearTimeout(b), y && y.dispose(), v();
		}));
	});
}
var AcceptInlineEdit$1 = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inlineEdit.accept",
			label: "Accept Inline Edit",
			alias: "Accept Inline Edit",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, InlineEditController.inlineEditVisibleContext),
			kbOpts: [{
				weight: 101,
				primary: 2,
				kbExpr: ContextKeyExpr.and(EditorContextKeys.writable, InlineEditController.inlineEditVisibleContext, InlineEditController.cursorAtInlineEditContext)
			}],
			menuOpts: [{
				menuId: MenuId.InlineEditToolbar,
				title: "Accept",
				group: "primary",
				order: 1
			}]
		});
	}
	async run(e, _) {
		await InlineEditController.get(_)?.accept();
	}
}, TriggerInlineEdit = class extends EditorAction {
	constructor() {
		let e = ContextKeyExpr.and(EditorContextKeys.writable, ContextKeyExpr.not(InlineEditController.inlineEditVisibleKey));
		super({
			id: "editor.action.inlineEdit.trigger",
			label: "Trigger Inline Edit",
			alias: "Trigger Inline Edit",
			precondition: e,
			kbOpts: {
				weight: 101,
				primary: 2646,
				kbExpr: e
			}
		});
	}
	async run(e, _) {
		InlineEditController.get(_)?.trigger();
	}
}, JumpToInlineEdit = class extends EditorAction {
	constructor() {
		let e = ContextKeyExpr.and(EditorContextKeys.writable, InlineEditController.inlineEditVisibleContext, ContextKeyExpr.not(InlineEditController.cursorAtInlineEditKey));
		super({
			id: "editor.action.inlineEdit.jumpTo",
			label: "Jump to Inline Edit",
			alias: "Jump to Inline Edit",
			precondition: e,
			kbOpts: {
				weight: 101,
				primary: 2646,
				kbExpr: e
			},
			menuOpts: [{
				menuId: MenuId.InlineEditToolbar,
				title: "Jump To Edit",
				group: "primary",
				order: 3,
				when: e
			}]
		});
	}
	async run(e, _) {
		InlineEditController.get(_)?.jumpToCurrent();
	}
}, JumpBackInlineEdit = class extends EditorAction {
	constructor() {
		let e = ContextKeyExpr.and(EditorContextKeys.writable, InlineEditController.cursorAtInlineEditContext);
		super({
			id: "editor.action.inlineEdit.jumpBack",
			label: "Jump Back from Inline Edit",
			alias: "Jump Back from Inline Edit",
			precondition: e,
			kbOpts: {
				weight: 110,
				primary: 2646,
				kbExpr: e
			},
			menuOpts: [{
				menuId: MenuId.InlineEditToolbar,
				title: "Jump Back",
				group: "primary",
				order: 3,
				when: e
			}]
		});
	}
	async run(e, _) {
		InlineEditController.get(_)?.jumpBack();
	}
}, RejectInlineEdit = class extends EditorAction {
	constructor() {
		let e = ContextKeyExpr.and(EditorContextKeys.writable, InlineEditController.inlineEditVisibleContext);
		super({
			id: "editor.action.inlineEdit.reject",
			label: "Reject Inline Edit",
			alias: "Reject Inline Edit",
			precondition: e,
			kbOpts: {
				weight: 100,
				primary: 9,
				kbExpr: e
			},
			menuOpts: [{
				menuId: MenuId.InlineEditToolbar,
				title: "Reject",
				group: "secondary",
				order: 2
			}]
		});
	}
	async run(e, _) {
		await InlineEditController.get(_)?.clear();
	}
};
registerEditorAction(AcceptInlineEdit$1), registerEditorAction(RejectInlineEdit), registerEditorAction(JumpToInlineEdit), registerEditorAction(JumpBackInlineEdit), registerEditorAction(TriggerInlineEdit), registerEditorContribution(InlineEditController.ID, InlineEditController, 3);
const inlineEditVisible = new RawContextKey("inlineEditsVisible", !1, localize("inlineEditsVisible", "Whether an inline edit is visible")), isPinnedContextKey = new RawContextKey("inlineEditsIsPinned", !1, localize("isPinned", "Whether an inline edit is visible"));
var PlaceholderTextContribution = class extends Disposable {
	static {
		this.ID = "editor.contrib.placeholderText";
	}
	constructor(e) {
		super(), this._editor = e, this._editorObs = observableCodeEditor(this._editor), this._placeholderText = this._editorObs.getOption(88), this._state = derivedOpts({
			owner: this,
			equalsFn: structuralEquals
		}, (e) => {
			let _ = this._placeholderText.read(e);
			if (_ && this._editorObs.valueIsEmpty.read(e)) return { placeholder: _ };
		}), this._shouldViewBeAlive = isOrWasTrue(this, (e) => this._state.read(e)?.placeholder !== void 0), this._view = derivedWithStore((e, _) => {
			if (!this._shouldViewBeAlive.read(e)) return;
			let v = h("div.editorPlaceholder");
			_.add(autorun((e) => {
				let _ = this._state.read(e), y = _?.placeholder !== void 0;
				v.root.style.display = y ? "block" : "none", v.root.innerText = _?.placeholder ?? "";
			})), _.add(autorun((e) => {
				let _ = this._editorObs.layoutInfo.read(e);
				v.root.style.left = `${_.contentLeft}px`, v.root.style.width = _.contentWidth - _.verticalScrollbarWidth + "px", v.root.style.top = `${this._editor.getTopForLineNumber(0)}px`;
			})), _.add(autorun((e) => {
				v.root.style.fontFamily = this._editorObs.getOption(49).read(e), v.root.style.fontSize = this._editorObs.getOption(52).read(e) + "px", v.root.style.lineHeight = this._editorObs.getOption(67).read(e) + "px";
			})), _.add(this._editorObs.createOverlayWidget({
				allowEditorOverflow: !1,
				minContentWidthInPx: constObservable(0),
				position: constObservable(null),
				domNode: v.root
			}));
		}), this._view.recomputeInitiallyAndOnChange(this._store);
	}
};
function isOrWasTrue(e, _) {
	return derivedObservableWithCache(e, (e, v) => v === !0 ? !0 : _(e));
}
var __decorate$30 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$30 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineEdit = class {
	constructor(e, _, v) {
		this.range = e, this.newLines = _, this.changes = v;
	}
}, InlineEditsWidget = class extends Disposable {
	constructor(_, v, y, b) {
		super(), this._editor = _, this._edit = v, this._userPrompt = y, this._instantiationService = b, this._editorObs = observableCodeEditor(this._editor), this._elements = h("div.inline-edits-widget", { style: {
			position: "absolute",
			overflow: "visible",
			top: "0px",
			left: "0px"
		} }, [h("div@editorContainer", { style: {
			position: "absolute",
			top: "0px",
			left: "0px",
			width: "500px",
			height: "500px"
		} }, [
			h("div.toolbar@toolbar", { style: {
				position: "absolute",
				top: "-25px",
				left: "0px"
			} }),
			h("div.promptEditor@promptEditor", { style: {
				position: "absolute",
				top: "-25px",
				left: "80px",
				width: "300px",
				height: "22px"
			} }),
			h("div.preview@editor", { style: {
				position: "absolute",
				top: "0px",
				left: "0px"
			} })
		]), svgElem("svg", { style: {
			overflow: "visible",
			pointerEvents: "none"
		} }, [svgElem("defs", [svgElem("linearGradient", {
			id: "Gradient2",
			x1: "0",
			y1: "0",
			x2: "1",
			y2: "0"
		}, [svgElem("stop", {
			offset: "0%",
			class: "gradient-stop"
		}), svgElem("stop", {
			offset: "100%",
			class: "gradient-stop"
		})])]), svgElem("path@path", {
			d: "",
			fill: "url(#Gradient2)"
		})])]), this._previewTextModel = this._register(this._instantiationService.createInstance(TextModel, "", PLAINTEXT_LANGUAGE_ID, TextModel.DEFAULT_CREATION_OPTIONS, null)), this._setText = derived((e) => {
			let _ = this._edit.read(e);
			_ && this._previewTextModel.setValue(_.newLines.join("\n"));
		}).recomputeInitiallyAndOnChange(this._store), this._promptTextModel = this._register(this._instantiationService.createInstance(TextModel, "", PLAINTEXT_LANGUAGE_ID, TextModel.DEFAULT_CREATION_OPTIONS, null)), this._promptEditor = this._register(this._instantiationService.createInstance(EmbeddedCodeEditorWidget, this._elements.promptEditor, {
			glyphMargin: !1,
			lineNumbers: "off",
			minimap: { enabled: !1 },
			guides: {
				indentation: !1,
				bracketPairs: !1,
				bracketPairsHorizontal: !1,
				highlightActiveIndentation: !1
			},
			folding: !1,
			selectOnLineNumbers: !1,
			selectionHighlight: !1,
			columnSelection: !1,
			overviewRulerBorder: !1,
			overviewRulerLanes: 0,
			lineDecorationsWidth: 0,
			lineNumbersMinChars: 0,
			placeholder: "Describe the change you want...",
			fontFamily: DEFAULT_FONT_FAMILY
		}, {
			contributions: EditorExtensionsRegistry.getSomeEditorContributions([
				SuggestController.ID,
				PlaceholderTextContribution.ID,
				ContextMenuController.ID
			]),
			isSimpleWidget: !0
		}, this._editor)), this._previewEditor = this._register(this._instantiationService.createInstance(EmbeddedCodeEditorWidget, this._elements.editor, {
			glyphMargin: !1,
			lineNumbers: "off",
			minimap: { enabled: !1 },
			guides: {
				indentation: !1,
				bracketPairs: !1,
				bracketPairsHorizontal: !1,
				highlightActiveIndentation: !1
			},
			folding: !1,
			selectOnLineNumbers: !1,
			selectionHighlight: !1,
			columnSelection: !1,
			overviewRulerBorder: !1,
			overviewRulerLanes: 0,
			lineDecorationsWidth: 0,
			lineNumbersMinChars: 0
		}, { contributions: [] }, this._editor)), this._previewEditorObs = observableCodeEditor(this._previewEditor), this._decorations = derived(this, (e) => {
			this._setText.read(e);
			let _ = this._edit.read(e)?.changes;
			if (!_) return [];
			let v = [], y = [];
			if (_.length === 1 && _[0].innerChanges[0].modifiedRange.equalsRange(this._previewTextModel.getFullModelRange())) return [];
			for (let e of _) if (e.original.isEmpty || v.push({
				range: e.original.toInclusiveRange(),
				options: diffLineDeleteDecorationBackgroundWithIndicator
			}), e.modified.isEmpty || y.push({
				range: e.modified.toInclusiveRange(),
				options: diffLineAddDecorationBackgroundWithIndicator
			}), e.modified.isEmpty || e.original.isEmpty) e.original.isEmpty || v.push({
				range: e.original.toInclusiveRange(),
				options: diffWholeLineDeleteDecoration
			}), e.modified.isEmpty || y.push({
				range: e.modified.toInclusiveRange(),
				options: diffWholeLineAddDecoration
			});
			else for (let _ of e.innerChanges || []) e.original.contains(_.originalRange.startLineNumber) && v.push({
				range: _.originalRange,
				options: _.originalRange.isEmpty() ? diffDeleteDecorationEmpty : diffDeleteDecoration
			}), e.modified.contains(_.modifiedRange.startLineNumber) && y.push({
				range: _.modifiedRange,
				options: _.modifiedRange.isEmpty() ? diffAddDecorationEmpty : diffAddDecoration
			});
			return y;
		}), this._layout1 = derived(this, (e) => {
			let _ = this._editor.getModel(), v = this._edit.read(e);
			if (!v) return null;
			let y = v.range, b = 0;
			for (let e = y.startLineNumber; e < y.endLineNumberExclusive; e++) {
				let v = _.getLineMaxColumn(e), y = this._editor.getOffsetForColumn(e, v);
				b = Math.max(b, y);
			}
			return { left: this._editor.getLayoutInfo().contentLeft + b };
		}), this._layout = derived(this, (e) => {
			let _ = this._edit.read(e);
			if (!_) return null;
			let v = _.range, y = this._editorObs.scrollLeft.read(e), b = this._layout1.read(e).left + 20 - y, x = this._editor.getTopForLineNumber(v.startLineNumber) - this._editorObs.scrollTop.read(e), S = this._editor.getTopForLineNumber(v.endLineNumberExclusive) - this._editorObs.scrollTop.read(e), C = new Point(b, x), w = new Point(b, S), T = S - x, E = this._editor.getOption(67) * _.newLines.length, D = T - E, O = new Point(b + 50, x + D / 2), k = new Point(b + 50, S - D / 2);
			return {
				topCode: C,
				bottomCode: w,
				codeHeight: T,
				topEdit: O,
				bottomEdit: k,
				editHeight: E
			};
		});
		let x = derived(this, (e) => this._edit.read(e) !== void 0 || this._userPrompt.read(e) !== void 0);
		this._register(applyStyle(this._elements.root, { display: derived(this, (e) => x.read(e) ? "block" : "none") })), this._register(appendRemoveOnDispose(this._editor.getDomNode(), this._elements.root)), this._register(observableCodeEditor(_).createOverlayWidget({
			domNode: this._elements.root,
			position: constObservable(null),
			allowEditorOverflow: !1,
			minContentWidthInPx: derived((e) => {
				let _ = this._layout1.read(e)?.left;
				if (_ === void 0) return 0;
				let v = this._previewEditorObs.contentWidth.read(e);
				return _ + v;
			})
		})), this._previewEditor.setModel(this._previewTextModel), this._register(this._previewEditorObs.setDecorations(this._decorations)), this._register(autorun((e) => {
			let _ = this._layout.read(e);
			if (!_) return;
			let { topCode: v, bottomCode: y, topEdit: b, bottomEdit: x, editHeight: S } = _, C = new PathBuilder().moveTo(v).lineTo(v.deltaX(10)).curveTo(v.deltaX(50), b.deltaX(-40), b.deltaX(-0)).lineTo(b).lineTo(x).lineTo(x.deltaX(-0)).curveTo(x.deltaX(-40), y.deltaX(50), y.deltaX(10)).lineTo(y).build();
			this._elements.path.setAttribute("d", C), this._elements.editorContainer.style.top = `${b.y}px`, this._elements.editorContainer.style.left = `${b.x}px`, this._elements.editorContainer.style.height = `${S}px`;
			let w = this._previewEditorObs.contentWidth.read(e);
			this._previewEditor.layout({
				height: S,
				width: w
			});
		})), this._promptEditor.setModel(this._promptTextModel), this._promptEditor.layout(), this._register(createTwoWaySync(mapSettableObservable(this._userPrompt, (e) => e ?? "", (e) => e), observableCodeEditor(this._promptEditor).value)), this._register(autorun((e) => {
			let _ = observableCodeEditor(this._promptEditor).isFocused.read(e);
			this._elements.root.classList.toggle("focused", _);
		}));
	}
};
InlineEditsWidget = __decorate$30([__param$30(3, IInstantiationService)], InlineEditsWidget);
function mapSettableObservable(e, _, v) {
	return derivedWithSetter(void 0, (v) => _(e.read(v)), (_, y) => e.set(v(_), y));
}
var Point = class e {
	constructor(e, _) {
		this.x = e, this.y = _;
	}
	deltaX(_) {
		return new e(this.x + _, this.y);
	}
}, PathBuilder = class {
	constructor() {
		this._data = "";
	}
	moveTo(e) {
		return this._data += `M ${e.x} ${e.y} `, this;
	}
	lineTo(e) {
		return this._data += `L ${e.x} ${e.y} `, this;
	}
	curveTo(e, _, v) {
		return this._data += `C ${e.x} ${e.y} ${_.x} ${_.y} ${v.x} ${v.y} `, this;
	}
	build() {
		return this._data;
	}
};
function createTwoWaySync(e, _) {
	let v = new DisposableStore();
	return v.add(autorun((v) => {
		let y = e.read(v);
		_.set(y, void 0);
	})), v.add(autorun((v) => {
		let y = _.read(v);
		e.set(y, void 0);
	})), v;
}
var __decorate$29 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$29 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineEditsModel_1, InlineEditsModel = class extends Disposable {
	static {
		InlineEditsModel_1 = this;
	}
	static {
		this._modelId = 0;
	}
	static _createUniqueUri() {
		return URI.from({
			scheme: "inline-edits",
			path: (/* @__PURE__ */ new Date()).toString() + String(InlineEditsModel_1._modelId++)
		});
	}
	constructor(e, _, v, y, b, x, S) {
		super(), this.textModel = e, this._textModelVersionId = _, this._selection = v, this._debounceValue = y, this.languageFeaturesService = b, this._diffProviderFactoryService = x, this._modelService = S, this._forceUpdateExplicitlySignal = observableSignal(this), this._selectedInlineCompletionId = observableValue(this, void 0), this._isActive = observableValue(this, !1), this._originalModel = derivedDisposable(() => this._modelService.createModel("", null, InlineEditsModel_1._createUniqueUri())).keepObserved(this._store), this._modifiedModel = derivedDisposable(() => this._modelService.createModel("", null, InlineEditsModel_1._createUniqueUri())).keepObserved(this._store), this._pinnedRange = new TrackedRange(this.textModel, this._textModelVersionId), this.isPinned = this._pinnedRange.range.map((e) => !!e), this.userPrompt = observableValue(this, void 0), this.inlineEdit = derived(this, (e) => this._inlineEdit.read(e)?.promiseResult.read(e)?.data), this._inlineEdit = derived(this, (e) => {
			let _ = this.selectedInlineEdit.read(e);
			if (!_) return;
			let v = _.inlineCompletion.range;
			if (_.inlineCompletion.insertText.trim() === "") return;
			let y = _.inlineCompletion.insertText.split(/\r\n|\r|\n/);
			function b(e) {
				let _ = e[0].match(/^\s*/)?.[0] ?? "";
				return e.map((e) => e.replace(/* @__PURE__ */ RegExp("^" + _), ""));
			}
			y = b(y);
			let x = this.textModel.getValueInRange(v).split(/\r\n|\r|\n/);
			x = b(x), this._originalModel.get().setValue(x.join("\n")), this._modifiedModel.get().setValue(y.join("\n"));
			let S = this._diffProviderFactoryService.createDiffProvider({ diffAlgorithm: "advanced" });
			return ObservablePromise.fromFn(async () => {
				let e = await S.computeDiff(this._originalModel.get(), this._modifiedModel.get(), {
					computeMoves: !1,
					ignoreTrimWhitespace: !1,
					maxComputationTimeMs: 1e3
				}, CancellationToken.None);
				if (!e.identical) return new InlineEdit(LineRange.fromRangeInclusive(v), b(y), e.changes);
			});
		}), this._fetchStore = this._register(new DisposableStore()), this._inlineEditsFetchResult = disposableObservableValue(this, void 0), this._inlineEdits = derivedOpts({
			owner: this,
			equalsFn: structuralEquals
		}, (e) => this._inlineEditsFetchResult.read(e)?.completions.map((e) => new InlineEditData(e)) ?? []), this._fetchInlineEditsPromise = derivedHandleChanges({
			owner: this,
			createEmptyChangeSummary: () => ({ inlineCompletionTriggerKind: InlineCompletionTriggerKind.Automatic }),
			handleChange: (e, _) => (e.didChange(this._forceUpdateExplicitlySignal) && (_.inlineCompletionTriggerKind = InlineCompletionTriggerKind.Explicit), !0)
		}, async (e, _) => {
			this._fetchStore.clear(), this._forceUpdateExplicitlySignal.read(e), this._textModelVersionId.read(e);
			function v(e, _) {
				return _(e);
			}
			let y = this._pinnedRange.range.read(e) ?? v(this._selection.read(e), (e) => e.isEmpty() ? void 0 : e);
			if (!y) {
				this._inlineEditsFetchResult.set(void 0, void 0), this.userPrompt.set(void 0, void 0);
				return;
			}
			let b = {
				triggerKind: _.inlineCompletionTriggerKind,
				selectedSuggestionInfo: void 0,
				userPrompt: this.userPrompt.read(e)
			}, x = cancelOnDispose(this._fetchStore);
			await timeout(200, x);
			let S = await provideInlineCompletions(this.languageFeaturesService.inlineCompletionsProvider, y, this.textModel, b, x);
			x.isCancellationRequested || this._inlineEditsFetchResult.set(S, void 0);
		}), this._filteredInlineEditItems = derivedOpts({
			owner: this,
			equalsFn: itemsEquals()
		}, (e) => this._inlineEdits.read(e)), this.selectedInlineCompletionIndex = derived(this, (e) => {
			let _ = this._selectedInlineCompletionId.read(e), v = this._filteredInlineEditItems.read(e), y = this._selectedInlineCompletionId === void 0 ? -1 : v.findIndex((e) => e.semanticId === _);
			return y === -1 ? (this._selectedInlineCompletionId.set(void 0, void 0), 0) : y;
		}), this.selectedInlineEdit = derived(this, (e) => {
			let _ = this._filteredInlineEditItems.read(e), v = this.selectedInlineCompletionIndex.read(e);
			return _[v];
		}), this._register(recomputeInitiallyAndOnChange(this._fetchInlineEditsPromise));
	}
	async triggerExplicitly(e) {
		subtransaction(e, (e) => {
			this._isActive.set(!0, e), this._forceUpdateExplicitlySignal.trigger(e);
		}), await this._fetchInlineEditsPromise.get();
	}
	stop(e) {
		subtransaction(e, (e) => {
			this.userPrompt.set(void 0, e), this._isActive.set(!1, e), this._inlineEditsFetchResult.set(void 0, e), this._pinnedRange.setRange(void 0, e);
		});
	}
	async _deltaSelectedInlineCompletionIndex(e) {
		await this.triggerExplicitly();
		let _ = this._filteredInlineEditItems.get() || [];
		if (_.length > 0) {
			let v = (this.selectedInlineCompletionIndex.get() + e + _.length) % _.length;
			this._selectedInlineCompletionId.set(_[v].semanticId, void 0);
		} else this._selectedInlineCompletionId.set(void 0, void 0);
	}
	async next() {
		await this._deltaSelectedInlineCompletionIndex(1);
	}
	async previous() {
		await this._deltaSelectedInlineCompletionIndex(-1);
	}
	async accept(e) {
		if (e.getModel() !== this.textModel) throw new BugIndicatingError();
		let _ = this.selectedInlineEdit.get();
		_ && (e.pushUndoStop(), e.executeEdits("inlineSuggestion.accept", [_.inlineCompletion.toSingleTextEdit().toSingleEditOperation()]), this.stop());
	}
};
InlineEditsModel = InlineEditsModel_1 = __decorate$29([
	__param$29(4, ILanguageFeaturesService),
	__param$29(5, IDiffProviderFactoryService),
	__param$29(6, IModelService)
], InlineEditsModel);
var InlineEditData = class {
	constructor(e) {
		this.inlineCompletion = e, this.semanticId = this.inlineCompletion.hash();
	}
}, TrackedRange = class extends Disposable {
	constructor(e, _) {
		super(), this._textModel = e, this._versionId = _, this._decorations = observableValue(this, []), this.range = derived(this, (e) => {
			this._versionId.read(e);
			let _ = this._decorations.read(e)[0];
			return _ ? this._textModel.getDecorationRange(_) ?? null : null;
		}), this._register(toDisposable(() => {
			this._textModel.deltaDecorations(this._decorations.get(), []);
		}));
	}
	setRange(e, _) {
		this._decorations.set(this._textModel.deltaDecorations(this._decorations.get(), e ? [{
			range: e,
			options: { description: "trackedRange" }
		}] : []), _);
	}
}, __decorate$28 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$28 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InlineEditsController_1, InlineEditsController = class extends Disposable {
	static {
		InlineEditsController_1 = this;
	}
	static {
		this.ID = "editor.contrib.inlineEditsController";
	}
	static get(e) {
		return e.getContribution(InlineEditsController_1.ID);
	}
	constructor(e, _, v, y, b, x) {
		super(), this.editor = e, this._instantiationService = _, this._contextKeyService = v, this._debounceService = y, this._languageFeaturesService = b, this._configurationService = x, this._enabled = observableConfigValue("editor.inlineEdits.enabled", !1, this._configurationService), this._editorObs = observableCodeEditor(this.editor), this._selection = derived(this, (e) => this._editorObs.cursorSelection.read(e) ?? new Selection(1, 1, 1, 1)), this._debounceValue = this._debounceService.for(this._languageFeaturesService.inlineCompletionsProvider, "InlineEditsDebounce", {
			min: 50,
			max: 50
		}), this.model = derivedDisposable(this, (e) => {
			if (!this._enabled.read(e) || this._editorObs.isReadonly.read(e)) return;
			let _ = this._editorObs.model.read(e);
			if (_) return this._instantiationService.createInstance(readHotReloadableExport(InlineEditsModel, e), _, this._editorObs.versionId, this._selection, this._debounceValue);
		}), this._hadInlineEdit = derivedObservableWithCache(this, (e, _) => _ || this.model.read(e)?.inlineEdit.read(e) !== void 0), this._widget = derivedDisposable(this, (e) => {
			if (this._hadInlineEdit.read(e)) return this._instantiationService.createInstance(readHotReloadableExport(InlineEditsWidget, e), this.editor, this.model.map((e, _) => e?.inlineEdit.read(_)), flattenSettableObservable((e) => this.model.read(e)?.userPrompt ?? observableValue("empty", "")));
		}), this._register(bindContextKey(inlineEditVisible, this._contextKeyService, (e) => !!this.model.read(e)?.inlineEdit.read(e))), this._register(bindContextKey(isPinnedContextKey, this._contextKeyService, (e) => !!this.model.read(e)?.isPinned.read(e))), this.model.recomputeInitiallyAndOnChange(this._store), this._widget.recomputeInitiallyAndOnChange(this._store);
	}
};
InlineEditsController = InlineEditsController_1 = __decorate$28([
	__param$28(1, IInstantiationService),
	__param$28(2, IContextKeyService),
	__param$28(3, ILanguageFeatureDebounceService),
	__param$28(4, ILanguageFeaturesService),
	__param$28(5, IConfigurationService)
], InlineEditsController);
function flattenSettableObservable(e) {
	return derivedWithSetter(void 0, (_) => e(_).read(_), (_, v) => {
		e(void 0).set(_, v);
	});
}
function labelAndAlias(e) {
	return {
		label: e.value,
		alias: e.original
	};
}
var ShowNextInlineEditAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.inlineEdits.showNext";
	}
	constructor() {
		super({
			id: e.ID,
			...labelAndAlias(localize2("action.inlineEdits.showNext", "Show Next Inline Edit")),
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, inlineEditVisible),
			kbOpts: {
				weight: 100,
				primary: 606
			}
		});
	}
	async run(e, _) {
		InlineEditsController.get(_)?.model.get()?.next();
	}
}, ShowPreviousInlineEditAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.inlineEdits.showPrevious";
	}
	constructor() {
		super({
			id: e.ID,
			...labelAndAlias(localize2("action.inlineEdits.showPrevious", "Show Previous Inline Edit")),
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, inlineEditVisible),
			kbOpts: {
				weight: 100,
				primary: 604
			}
		});
	}
	async run(e, _) {
		InlineEditsController.get(_)?.model.get()?.previous();
	}
}, TriggerInlineEditAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inlineEdits.trigger",
			...labelAndAlias(localize2("action.inlineEdits.trigger", "Trigger Inline Edit")),
			precondition: EditorContextKeys.writable
		});
	}
	async run(e, _) {
		let v = InlineEditsController.get(_);
		await asyncTransaction(async (e) => {
			await v?.model.get()?.triggerExplicitly(e);
		});
	}
}, AcceptInlineEdit = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inlineEdits.accept",
			...labelAndAlias(localize2("action.inlineEdits.accept", "Accept Inline Edit")),
			precondition: inlineEditVisible,
			menuOpts: {
				menuId: MenuId.InlineEditsActions,
				title: localize("inlineEditsActions", "Accept Inline Edit"),
				group: "primary",
				order: 1,
				icon: Codicon.check
			},
			kbOpts: {
				primary: 2058,
				weight: 2e4,
				kbExpr: inlineEditVisible
			}
		});
	}
	async run(e, _) {
		_ instanceof EmbeddedCodeEditorWidget && (_ = _.getParentEditor());
		let v = InlineEditsController.get(_);
		v && (v.model.get()?.accept(v.editor), v.editor.focus());
	}
}, HideInlineEdit = class e extends EditorAction {
	static {
		this.ID = "editor.action.inlineEdits.hide";
	}
	constructor() {
		super({
			id: e.ID,
			...labelAndAlias(localize2("action.inlineEdits.hide", "Hide Inline Edit")),
			precondition: inlineEditVisible,
			kbOpts: {
				weight: 100,
				primary: 9
			}
		});
	}
	async run(e, _) {
		let v = InlineEditsController.get(_);
		transaction((e) => {
			v?.model.get()?.stop(e);
		});
	}
};
registerEditorContribution(InlineEditsController.ID, InlineEditsController, 3), registerEditorAction(TriggerInlineEditAction), registerEditorAction(ShowNextInlineEditAction), registerEditorAction(ShowPreviousInlineEditAction), registerEditorAction(AcceptInlineEdit), registerEditorAction(HideInlineEdit);
const Context = {
	Visible: new RawContextKey("parameterHintsVisible", !1),
	MultipleSignatures: new RawContextKey("parameterHintsMultipleSignatures", !1)
};
async function provideSignatureHelp(e, _, v, y, b) {
	let x = e.ordered(_);
	for (let e of x) try {
		let x = await e.provideSignatureHelp(_, v, b, y);
		if (x) return x;
	} catch (e) {
		onUnexpectedExternalError(e);
	}
}
CommandsRegistry.registerCommand("_executeSignatureHelpProvider", async (e, ..._) => {
	let [v, y, b] = _;
	assertType(URI.isUri(v)), assertType(Position.isIPosition(y)), assertType(typeof b == "string" || !b);
	let x = e.get(ILanguageFeaturesService), S = await e.get(ITextModelService).createModelReference(v);
	try {
		let e = await provideSignatureHelp(x.signatureHelpProvider, S.object.textEditorModel, Position.lift(y), {
			triggerKind: SignatureHelpTriggerKind.Invoke,
			isRetrigger: !1,
			triggerCharacter: b
		}, CancellationToken.None);
		return e ? (setTimeout(() => e.dispose(), 0), e.value) : void 0;
	} finally {
		S.dispose();
	}
});
var ParameterHintState;
(function(e) {
	e.Default = { type: 0 };
	class _ {
		constructor(e, _) {
			this.request = e, this.previouslyActiveHints = _, this.type = 2;
		}
	}
	e.Pending = _;
	class v {
		constructor(e) {
			this.hints = e, this.type = 1;
		}
	}
	e.Active = v;
})(ParameterHintState ||= {});
var ParameterHintsModel = class e extends Disposable {
	static {
		this.DEFAULT_DELAY = 120;
	}
	constructor(_, v, y = e.DEFAULT_DELAY) {
		super(), this._onChangedHints = this._register(new Emitter()), this.onChangedHints = this._onChangedHints.event, this.triggerOnType = !1, this._state = ParameterHintState.Default, this._pendingTriggers = [], this._lastSignatureHelpResult = this._register(new MutableDisposable()), this.triggerChars = new CharacterSet(), this.retriggerChars = new CharacterSet(), this.triggerId = 0, this.editor = _, this.providers = v, this.throttledDelayer = new Delayer(y), this._register(this.editor.onDidBlurEditorWidget(() => this.cancel())), this._register(this.editor.onDidChangeConfiguration(() => this.onEditorConfigurationChange())), this._register(this.editor.onDidChangeModel((e) => this.onModelChanged())), this._register(this.editor.onDidChangeModelLanguage((e) => this.onModelChanged())), this._register(this.editor.onDidChangeCursorSelection((e) => this.onCursorChange(e))), this._register(this.editor.onDidChangeModelContent((e) => this.onModelContentChange())), this._register(this.providers.onDidChange(this.onModelChanged, this)), this._register(this.editor.onDidType((e) => this.onDidType(e))), this.onEditorConfigurationChange(), this.onModelChanged();
	}
	get state() {
		return this._state;
	}
	set state(e) {
		this._state.type === 2 && this._state.request.cancel(), this._state = e;
	}
	cancel(e = !1) {
		this.state = ParameterHintState.Default, this.throttledDelayer.cancel(), e || this._onChangedHints.fire(void 0);
	}
	trigger(e, _) {
		let v = this.editor.getModel();
		if (!v || !this.providers.has(v)) return;
		let y = ++this.triggerId;
		this._pendingTriggers.push(e), this.throttledDelayer.trigger(() => this.doTrigger(y), _).catch(onUnexpectedError);
	}
	next() {
		if (this.state.type !== 1) return;
		let e = this.state.hints.signatures.length, _ = this.state.hints.activeSignature, v = _ % e === e - 1, y = this.editor.getOption(86).cycle;
		if ((e < 2 || v) && !y) {
			this.cancel();
			return;
		}
		this.updateActiveSignature(v && y ? 0 : _ + 1);
	}
	previous() {
		if (this.state.type !== 1) return;
		let e = this.state.hints.signatures.length, _ = this.state.hints.activeSignature, v = _ === 0, y = this.editor.getOption(86).cycle;
		if ((e < 2 || v) && !y) {
			this.cancel();
			return;
		}
		this.updateActiveSignature(v && y ? e - 1 : _ - 1);
	}
	updateActiveSignature(e) {
		this.state.type === 1 && (this.state = new ParameterHintState.Active({
			...this.state.hints,
			activeSignature: e
		}), this._onChangedHints.fire(this.state.hints));
	}
	async doTrigger(e) {
		let _ = this.state.type === 1 || this.state.type === 2, v = this.getLastActiveHints();
		if (this.cancel(!0), this._pendingTriggers.length === 0) return !1;
		let y = this._pendingTriggers.reduce(mergeTriggerContexts);
		this._pendingTriggers = [];
		let b = {
			triggerKind: y.triggerKind,
			triggerCharacter: y.triggerCharacter,
			isRetrigger: _,
			activeSignatureHelp: v
		};
		if (!this.editor.hasModel()) return !1;
		let x = this.editor.getModel(), S = this.editor.getPosition();
		this.state = new ParameterHintState.Pending(createCancelablePromise((e) => provideSignatureHelp(this.providers, x, S, b, e)), v);
		try {
			let _ = await this.state.request;
			return e === this.triggerId ? !_ || !_.value.signatures || _.value.signatures.length === 0 ? (_?.dispose(), this._lastSignatureHelpResult.clear(), this.cancel(), !1) : (this.state = new ParameterHintState.Active(_.value), this._lastSignatureHelpResult.value = _, this._onChangedHints.fire(this.state.hints), !0) : (_?.dispose(), !1);
		} catch (_) {
			return e === this.triggerId && (this.state = ParameterHintState.Default), onUnexpectedError(_), !1;
		}
	}
	getLastActiveHints() {
		switch (this.state.type) {
			case 1: return this.state.hints;
			case 2: return this.state.previouslyActiveHints;
			default: return;
		}
	}
	get isTriggered() {
		return this.state.type === 1 || this.state.type === 2 || this.throttledDelayer.isTriggered();
	}
	onModelChanged() {
		this.cancel(), this.triggerChars.clear(), this.retriggerChars.clear();
		let e = this.editor.getModel();
		if (e) for (let _ of this.providers.ordered(e)) {
			for (let e of _.signatureHelpTriggerCharacters || []) if (e.length) {
				let _ = e.charCodeAt(0);
				this.triggerChars.add(_), this.retriggerChars.add(_);
			}
			for (let e of _.signatureHelpRetriggerCharacters || []) e.length && this.retriggerChars.add(e.charCodeAt(0));
		}
	}
	onDidType(e) {
		if (!this.triggerOnType) return;
		let _ = e.length - 1, v = e.charCodeAt(_);
		(this.triggerChars.has(v) || this.isTriggered && this.retriggerChars.has(v)) && this.trigger({
			triggerKind: SignatureHelpTriggerKind.TriggerCharacter,
			triggerCharacter: e.charAt(_)
		});
	}
	onCursorChange(e) {
		e.source === "mouse" ? this.cancel() : this.isTriggered && this.trigger({ triggerKind: SignatureHelpTriggerKind.ContentChange });
	}
	onModelContentChange() {
		this.isTriggered && this.trigger({ triggerKind: SignatureHelpTriggerKind.ContentChange });
	}
	onEditorConfigurationChange() {
		this.triggerOnType = this.editor.getOption(86).enabled, this.triggerOnType || this.cancel();
	}
	dispose() {
		this.cancel(!0), super.dispose();
	}
};
function mergeTriggerContexts(e, _) {
	switch (_.triggerKind) {
		case SignatureHelpTriggerKind.Invoke: return _;
		case SignatureHelpTriggerKind.ContentChange: return e;
		case SignatureHelpTriggerKind.TriggerCharacter:
		default: return _;
	}
}
var __decorate$27 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$27 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ParameterHintsWidget_1, $$1 = $, parameterHintsNextIcon = registerIcon("parameter-hints-next", Codicon.chevronDown, localize("parameterHintsNextIcon", "Icon for show next parameter hint.")), parameterHintsPreviousIcon = registerIcon("parameter-hints-previous", Codicon.chevronUp, localize("parameterHintsPreviousIcon", "Icon for show previous parameter hint.")), ParameterHintsWidget = class extends Disposable {
	static {
		ParameterHintsWidget_1 = this;
	}
	static {
		this.ID = "editor.widget.parameterHintsWidget";
	}
	constructor(e, _, v, y, b, x) {
		super(), this.editor = e, this.model = _, this.telemetryService = x, this.renderDisposeables = this._register(new DisposableStore()), this.visible = !1, this.announcedLabel = null, this.allowEditorOverflow = !0, this.markdownRenderer = this._register(new MarkdownRenderer({ editor: e }, b, y)), this.keyVisible = Context.Visible.bindTo(v), this.keyMultipleSignatures = Context.MultipleSignatures.bindTo(v);
	}
	createParameterHintDOMNodes() {
		let e = $$1(".editor-widget.parameter-hints-widget"), _ = append(e, $$1(".phwrapper"));
		_.tabIndex = -1;
		let v = append(_, $$1(".controls")), y = append(v, $$1(".button" + ThemeIcon.asCSSSelector(parameterHintsPreviousIcon))), b = append(v, $$1(".overloads")), x = append(v, $$1(".button" + ThemeIcon.asCSSSelector(parameterHintsNextIcon)));
		this._register(addDisposableListener(y, "click", (e) => {
			EventHelper.stop(e), this.previous();
		})), this._register(addDisposableListener(x, "click", (e) => {
			EventHelper.stop(e), this.next();
		}));
		let S = $$1(".body"), C = new DomScrollableElement(S, { alwaysConsumeMouseWheel: !0 });
		this._register(C), _.appendChild(C.getDomNode());
		let w = append(S, $$1(".signature")), T = append(S, $$1(".docs"));
		e.style.userSelect = "text", this.domNodes = {
			element: e,
			signature: w,
			overloads: b,
			docs: T,
			scrollbar: C
		}, this.editor.addContentWidget(this), this.hide(), this._register(this.editor.onDidChangeCursorSelection((e) => {
			this.visible && this.editor.layoutContentWidget(this);
		}));
		let E = () => {
			if (!this.domNodes) return;
			let e = this.editor.getOption(50), _ = this.domNodes.element;
			_.style.fontSize = `${e.fontSize}px`, _.style.lineHeight = `${e.lineHeight / e.fontSize}`, _.style.setProperty("--vscode-parameterHintsWidget-editorFontFamily", e.fontFamily), _.style.setProperty("--vscode-parameterHintsWidget-editorFontFamilyDefault", EDITOR_FONT_DEFAULTS.fontFamily);
		};
		E(), this._register(Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor), (e) => e.filter((e) => e.hasChanged(50)))(E)), this._register(this.editor.onDidLayoutChange((e) => this.updateMaxHeight())), this.updateMaxHeight();
	}
	show() {
		this.visible || (this.domNodes || this.createParameterHintDOMNodes(), this.keyVisible.set(!0), this.visible = !0, setTimeout(() => {
			this.domNodes?.element.classList.add("visible");
		}, 100), this.editor.layoutContentWidget(this));
	}
	hide() {
		this.renderDisposeables.clear(), this.visible && (this.keyVisible.reset(), this.visible = !1, this.announcedLabel = null, this.domNodes?.element.classList.remove("visible"), this.editor.layoutContentWidget(this));
	}
	getPosition() {
		return this.visible ? {
			position: this.editor.getPosition(),
			preference: [1, 2]
		} : null;
	}
	render(e) {
		if (this.renderDisposeables.clear(), !this.domNodes) return;
		let _ = e.signatures.length > 1;
		this.domNodes.element.classList.toggle("multiple", _), this.keyMultipleSignatures.set(_), this.domNodes.signature.innerText = "", this.domNodes.docs.innerText = "";
		let v = e.signatures[e.activeSignature];
		if (!v) return;
		let y = append(this.domNodes.signature, $$1(".code")), b = v.parameters.length > 0, x = v.activeParameter ?? e.activeParameter;
		if (b) this.renderParameters(y, v, x);
		else {
			let e = append(y, $$1("span"));
			e.textContent = v.label;
		}
		let S = v.parameters[x];
		if (S?.documentation) {
			let e = $$1("span.documentation");
			if (typeof S.documentation == "string") e.textContent = S.documentation;
			else {
				let _ = this.renderMarkdownDocs(S.documentation);
				e.appendChild(_.element);
			}
			append(this.domNodes.docs, $$1("p", {}, e));
		}
		if (v.documentation !== void 0) if (typeof v.documentation == "string") append(this.domNodes.docs, $$1("p", {}, v.documentation));
		else {
			let e = this.renderMarkdownDocs(v.documentation);
			append(this.domNodes.docs, e.element);
		}
		let C = this.hasDocs(v, S);
		if (this.domNodes.signature.classList.toggle("has-docs", C), this.domNodes.docs.classList.toggle("empty", !C), this.domNodes.overloads.textContent = String(e.activeSignature + 1).padStart(e.signatures.length.toString().length, "0") + "/" + e.signatures.length, S) {
			let e = "", _ = v.parameters[x];
			e = Array.isArray(_.label) ? v.label.substring(_.label[0], _.label[1]) : _.label, _.documentation && (e += typeof _.documentation == "string" ? `, ${_.documentation}` : `, ${_.documentation.value}`), v.documentation && (e += typeof v.documentation == "string" ? `, ${v.documentation}` : `, ${v.documentation.value}`), this.announcedLabel !== e && (alert(localize("hint", "{0}, hint", e)), this.announcedLabel = e);
		}
		this.editor.layoutContentWidget(this), this.domNodes.scrollbar.scanDomNode();
	}
	renderMarkdownDocs(e) {
		let _ = new StopWatch(), v = this.renderDisposeables.add(this.markdownRenderer.render(e, { asyncRenderCallback: () => {
			this.domNodes?.scrollbar.scanDomNode();
		} }));
		v.element.classList.add("markdown-docs");
		let y = _.elapsed();
		return y > 300 && this.telemetryService.publicLog2("parameterHints.parseMarkdown", { renderDuration: y }), v;
	}
	hasDocs(e, _) {
		return !!(_ && typeof _.documentation == "string" && assertIsDefined(_.documentation).length > 0 || _ && typeof _.documentation == "object" && assertIsDefined(_.documentation).value.length > 0 || e.documentation && typeof e.documentation == "string" && assertIsDefined(e.documentation).length > 0 || e.documentation && typeof e.documentation == "object" && assertIsDefined(e.documentation.value).length > 0);
	}
	renderParameters(e, _, v) {
		let [y, b] = this.getParameterLabelOffsets(_, v), x = document.createElement("span");
		x.textContent = _.label.substring(0, y);
		let S = document.createElement("span");
		S.textContent = _.label.substring(y, b), S.className = "parameter active";
		let C = document.createElement("span");
		C.textContent = _.label.substring(b), append(e, x, S, C);
	}
	getParameterLabelOffsets(e, _) {
		let v = e.parameters[_];
		if (v) {
			if (Array.isArray(v.label)) return v.label;
			if (v.label.length) {
				let _ = RegExp(`(\\W|^)${escapeRegExpCharacters(v.label)}(?=\\W|$)`, "g");
				_.test(e.label);
				let y = _.lastIndex - v.label.length;
				return y >= 0 ? [y, _.lastIndex] : [0, 0];
			} else return [0, 0];
		} else return [0, 0];
	}
	next() {
		this.editor.focus(), this.model.next();
	}
	previous() {
		this.editor.focus(), this.model.previous();
	}
	getDomNode() {
		return this.domNodes || this.createParameterHintDOMNodes(), this.domNodes.element;
	}
	getId() {
		return ParameterHintsWidget_1.ID;
	}
	updateMaxHeight() {
		if (!this.domNodes) return;
		let e = `${Math.max(this.editor.getLayoutInfo().height / 4, 250)}px`;
		this.domNodes.element.style.maxHeight = e;
		let _ = this.domNodes.element.getElementsByClassName("phwrapper");
		_.length && (_[0].style.maxHeight = e);
	}
};
ParameterHintsWidget = ParameterHintsWidget_1 = __decorate$27([
	__param$27(2, IContextKeyService),
	__param$27(3, IOpenerService),
	__param$27(4, ILanguageService),
	__param$27(5, ITelemetryService)
], ParameterHintsWidget), registerColor("editorHoverWidget.highlightForeground", listHighlightForeground, localize("editorHoverWidgetHighlightForeground", "Foreground color of the active item in the parameter hint."));
var __decorate$26 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$26 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ParameterHintsController_1, ParameterHintsController = class extends Disposable {
	static {
		ParameterHintsController_1 = this;
	}
	static {
		this.ID = "editor.controller.parameterHints";
	}
	static get(e) {
		return e.getContribution(ParameterHintsController_1.ID);
	}
	constructor(e, _, v) {
		super(), this.editor = e, this.model = this._register(new ParameterHintsModel(e, v.signatureHelpProvider)), this._register(this.model.onChangedHints((e) => {
			e ? (this.widget.value.show(), this.widget.value.render(e)) : this.widget.rawValue?.hide();
		})), this.widget = new Lazy(() => this._register(_.createInstance(ParameterHintsWidget, this.editor, this.model)));
	}
	cancel() {
		this.model.cancel();
	}
	previous() {
		this.widget.rawValue?.previous();
	}
	next() {
		this.widget.rawValue?.next();
	}
	trigger(e) {
		this.model.trigger(e, 0);
	}
};
ParameterHintsController = ParameterHintsController_1 = __decorate$26([__param$26(1, IInstantiationService), __param$26(2, ILanguageFeaturesService)], ParameterHintsController);
var TriggerParameterHintsAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.triggerParameterHints",
			label: localize("parameterHints.trigger.label", "Trigger Parameter Hints"),
			alias: "Trigger Parameter Hints",
			precondition: EditorContextKeys.hasSignatureHelpProvider,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 3082,
				weight: 100
			}
		});
	}
	run(e, _) {
		ParameterHintsController.get(_)?.trigger({ triggerKind: SignatureHelpTriggerKind.Invoke });
	}
};
registerEditorContribution(ParameterHintsController.ID, ParameterHintsController, 2), registerEditorAction(TriggerParameterHintsAction);
var weight$1 = 175, ParameterHintsCommand = EditorCommand.bindToContribution(ParameterHintsController.get);
registerEditorCommand(new ParameterHintsCommand({
	id: "closeParameterHints",
	precondition: Context.Visible,
	handler: (e) => e.cancel(),
	kbOpts: {
		weight: weight$1,
		kbExpr: EditorContextKeys.focus,
		primary: 9,
		secondary: [1033]
	}
})), registerEditorCommand(new ParameterHintsCommand({
	id: "showPrevParameterHint",
	precondition: ContextKeyExpr.and(Context.Visible, Context.MultipleSignatures),
	handler: (e) => e.previous(),
	kbOpts: {
		weight: weight$1,
		kbExpr: EditorContextKeys.focus,
		primary: 16,
		secondary: [528],
		mac: {
			primary: 16,
			secondary: [528, 302]
		}
	}
})), registerEditorCommand(new ParameterHintsCommand({
	id: "showNextParameterHint",
	precondition: ContextKeyExpr.and(Context.Visible, Context.MultipleSignatures),
	handler: (e) => e.next(),
	kbOpts: {
		weight: weight$1,
		kbExpr: EditorContextKeys.focus,
		primary: 18,
		secondary: [530],
		mac: {
			primary: 18,
			secondary: [530, 300]
		}
	}
}));
var __decorate$25 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$25 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, BaseClass = class {
	constructor(e) {
		this.instantiationService = e;
	}
	init(...e) {}
};
function createWrapper(e, _) {
	return class extends _ {
		constructor() {
			super(...arguments), this._autorun = void 0;
		}
		init(..._) {
			this._autorun = autorunWithStore((v, y) => {
				let b = readHotReloadableExport(e(), v);
				y.add(this.instantiationService.createInstance(b, ..._));
			});
		}
		dispose() {
			this._autorun?.dispose();
		}
	};
}
function wrapInReloadableClass1(e) {
	return isHotReloadEnabled() ? createWrapper(e, BaseClass1) : e();
}
var BaseClass1 = class extends BaseClass {
	constructor(e, _) {
		super(_), this.init(e);
	}
};
BaseClass1 = __decorate$25([__param$25(1, IInstantiationService)], BaseClass1), registerEditorContribution(PlaceholderTextContribution.ID, wrapInReloadableClass1(() => PlaceholderTextContribution), 0), registerColor("editor.placeholder.foreground", ghostTextForeground, localize("placeholderForeground", "Foreground color of the placeholder text in the editor."));
var __decorate$24 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$24 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const CONTEXT_RENAME_INPUT_VISIBLE = new RawContextKey("renameInputVisible", !1, localize("renameInputVisible", "Whether the rename input widget is visible"));
new RawContextKey("renameInputFocused", !1, localize("renameInputFocused", "Whether the rename input widget is focused"));
var RenameWidget = class {
	constructor(e, _, v, y, b, x) {
		this._editor = e, this._acceptKeybindings = _, this._themeService = v, this._keybindingService = y, this._logService = x, this.allowEditorOverflow = !0, this._disposables = new DisposableStore(), this._visibleContextKey = CONTEXT_RENAME_INPUT_VISIBLE.bindTo(b), this._isEditingRenameCandidate = !1, this._nRenameSuggestionsInvocations = 0, this._hadAutomaticRenameSuggestionsInvocation = !1, this._candidates = /* @__PURE__ */ new Set(), this._beforeFirstInputFieldEditSW = new StopWatch(), this._inputWithButton = new InputWithButton(), this._disposables.add(this._inputWithButton), this._editor.addContentWidget(this), this._disposables.add(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(50) && this._updateFont();
		})), this._disposables.add(v.onDidColorThemeChange(this._updateStyles, this));
	}
	dispose() {
		this._disposables.dispose(), this._editor.removeContentWidget(this);
	}
	getId() {
		return "__renameInputWidget";
	}
	getDomNode() {
		return this._domNode || (this._domNode = document.createElement("div"), this._domNode.className = "monaco-editor rename-box", this._domNode.appendChild(this._inputWithButton.domNode), this._renameCandidateListView = this._disposables.add(new RenameCandidateListView(this._domNode, {
			fontInfo: this._editor.getOption(50),
			onFocusChange: (e) => {
				this._inputWithButton.input.value = e, this._isEditingRenameCandidate = !1;
			},
			onSelectionChange: () => {
				this._isEditingRenameCandidate = !1, this.acceptInput(!1);
			}
		})), this._disposables.add(this._inputWithButton.onDidInputChange(() => {
			this._renameCandidateListView?.focusedCandidate !== void 0 && (this._isEditingRenameCandidate = !0), this._timeBeforeFirstInputFieldEdit ??= this._beforeFirstInputFieldEditSW.elapsed(), this._renameCandidateProvidersCts?.token.isCancellationRequested === !1 && this._renameCandidateProvidersCts.cancel(), this._renameCandidateListView?.clearFocus();
		})), this._label = document.createElement("div"), this._label.className = "rename-label", this._domNode.appendChild(this._label), this._updateFont(), this._updateStyles(this._themeService.getColorTheme())), this._domNode;
	}
	_updateStyles(e) {
		if (!this._domNode) return;
		let _ = e.getColor(widgetShadow), v = e.getColor(widgetBorder);
		this._domNode.style.backgroundColor = String(e.getColor(editorWidgetBackground) ?? ""), this._domNode.style.boxShadow = _ ? ` 0 0 8px 2px ${_}` : "", this._domNode.style.border = v ? `1px solid ${v}` : "", this._domNode.style.color = String(e.getColor(inputForeground) ?? "");
		let y = e.getColor(inputBorder);
		this._inputWithButton.domNode.style.backgroundColor = String(e.getColor(inputBackground) ?? ""), this._inputWithButton.input.style.backgroundColor = String(e.getColor(inputBackground) ?? ""), this._inputWithButton.domNode.style.borderWidth = y ? "1px" : "0px", this._inputWithButton.domNode.style.borderStyle = y ? "solid" : "none", this._inputWithButton.domNode.style.borderColor = y?.toString() ?? "none";
	}
	_updateFont() {
		if (this._domNode === void 0) return;
		assertType(this._label !== void 0, "RenameWidget#_updateFont: _label must not be undefined given _domNode is defined"), this._editor.applyFontInfo(this._inputWithButton.input);
		let e = this._editor.getOption(50);
		this._label.style.fontSize = `${this._computeLabelFontSize(e.fontSize)}px`;
	}
	_computeLabelFontSize(e) {
		return e * .8;
	}
	getPosition() {
		if (!this._visible || !this._editor.hasModel() || !this._editor.getDomNode()) return null;
		let e = getClientArea(this.getDomNode().ownerDocument.body), _ = getDomNodePagePosition(this._editor.getDomNode());
		this._nPxAvailableAbove = this._getTopForPosition() + _.top, this._nPxAvailableBelow = e.height - this._nPxAvailableAbove;
		let v = this._editor.getOption(67), { totalHeight: y } = RenameCandidateView.getLayoutInfo({ lineHeight: v }), b = this._nPxAvailableBelow > y * 6 ? [2, 1] : [1, 2];
		return {
			position: this._position,
			preference: b
		};
	}
	beforeRender() {
		let [e, _] = this._acceptKeybindings;
		return this._label.innerText = localize({
			key: "label",
			comment: ["placeholders are keybindings, e.g \"F2 to Rename, Shift+F2 to Preview\""]
		}, "{0} to Rename, {1} to Preview", this._keybindingService.lookupKeybinding(e)?.getLabel(), this._keybindingService.lookupKeybinding(_)?.getLabel()), this._domNode.style.minWidth = "200px", null;
	}
	afterRender(e) {
		if (e === null) {
			this.cancelInput(!0, "afterRender (because position is null)");
			return;
		}
		if (!this._editor.hasModel() || !this._editor.getDomNode()) return;
		assertType(this._renameCandidateListView), assertType(this._nPxAvailableAbove !== void 0), assertType(this._nPxAvailableBelow !== void 0);
		let _ = getTotalHeight(this._inputWithButton.domNode), v = getTotalHeight(this._label), y;
		y = e === 2 ? this._nPxAvailableBelow : this._nPxAvailableAbove, this._renameCandidateListView.layout({
			height: y - v - _,
			width: getTotalWidth(this._inputWithButton.domNode)
		});
	}
	acceptInput(e) {
		this._trace("invoking acceptInput"), this._currentAcceptInput?.(e);
	}
	cancelInput(e, _) {
		this._currentCancelInput?.(e);
	}
	focusNextRenameSuggestion() {
		this._renameCandidateListView?.focusNext() || (this._inputWithButton.input.value = this._currentName);
	}
	focusPreviousRenameSuggestion() {
		this._renameCandidateListView?.focusPrevious() || (this._inputWithButton.input.value = this._currentName);
	}
	getInput(e, _, v, y, b) {
		let { start: x, end: S } = this._getSelection(e, _);
		this._renameCts = b;
		let C = new DisposableStore();
		this._nRenameSuggestionsInvocations = 0, this._hadAutomaticRenameSuggestionsInvocation = !1, y === void 0 ? this._inputWithButton.button.style.display = "none" : (this._inputWithButton.button.style.display = "flex", this._requestRenameCandidatesOnce = y, this._requestRenameCandidates(_, !1), C.add(addDisposableListener(this._inputWithButton.button, "click", () => this._requestRenameCandidates(_, !0))), C.add(addDisposableListener(this._inputWithButton.button, EventType$1.KEY_DOWN, (e) => {
			let v = new StandardKeyboardEvent(e);
			(v.equals(3) || v.equals(10)) && (v.stopPropagation(), v.preventDefault(), this._requestRenameCandidates(_, !0));
		}))), this._isEditingRenameCandidate = !1, this._domNode.classList.toggle("preview", v), this._position = new Position(e.startLineNumber, e.startColumn), this._currentName = _, this._inputWithButton.input.value = _, this._inputWithButton.input.setAttribute("selectionStart", x.toString()), this._inputWithButton.input.setAttribute("selectionEnd", S.toString()), this._inputWithButton.input.size = Math.max((e.endColumn - e.startColumn) * 1.1, 20), this._beforeFirstInputFieldEditSW.reset(), C.add(toDisposable(() => {
			this._renameCts = void 0, b.dispose(!0);
		})), C.add(toDisposable(() => {
			this._renameCandidateProvidersCts !== void 0 && (this._renameCandidateProvidersCts.dispose(!0), this._renameCandidateProvidersCts = void 0);
		})), C.add(toDisposable(() => this._candidates.clear()));
		let w = new DeferredPromise();
		return w.p.finally(() => {
			C.dispose(), this._hide();
		}), this._currentCancelInput = (e) => (this._trace("invoking _currentCancelInput"), this._currentAcceptInput = void 0, this._currentCancelInput = void 0, this._renameCandidateListView?.clearCandidates(), w.complete(e), !0), this._currentAcceptInput = (e) => {
			this._trace("invoking _currentAcceptInput"), assertType(this._renameCandidateListView !== void 0);
			let y = this._renameCandidateListView.nCandidates, b, x, S = this._renameCandidateListView.focusedCandidate;
			if (S === void 0 ? (this._trace("using new name from inputField"), b = this._inputWithButton.input.value, x = this._isEditingRenameCandidate ? { k: "userEditedRenameSuggestion" } : { k: "inputField" }) : (this._trace("using new name from renameSuggestion"), b = S, x = { k: "renameSuggestion" }), b === _ || b.trim().length === 0) {
				this.cancelInput(!0, "_currentAcceptInput (because newName === value || newName.trim().length === 0)");
				return;
			}
			this._currentAcceptInput = void 0, this._currentCancelInput = void 0, this._renameCandidateListView.clearCandidates(), w.complete({
				newName: b,
				wantsPreview: v && e,
				stats: {
					source: x,
					nRenameSuggestions: y,
					timeBeforeFirstInputFieldEdit: this._timeBeforeFirstInputFieldEdit,
					nRenameSuggestionsInvocations: this._nRenameSuggestionsInvocations,
					hadAutomaticRenameSuggestionsInvocation: this._hadAutomaticRenameSuggestionsInvocation
				}
			});
		}, C.add(b.token.onCancellationRequested(() => this.cancelInput(!0, "cts.token.onCancellationRequested"))), C.add(this._editor.onDidBlurEditorWidget(() => this.cancelInput(!this._domNode?.ownerDocument.hasFocus(), "editor.onDidBlurEditorWidget"))), this._show(), w.p;
	}
	_requestRenameCandidates(e, _) {
		if (this._requestRenameCandidatesOnce !== void 0 && (this._renameCandidateProvidersCts !== void 0 && this._renameCandidateProvidersCts.dispose(!0), assertType(this._renameCts), this._inputWithButton.buttonState !== "stop")) {
			this._renameCandidateProvidersCts = new CancellationTokenSource();
			let v = _ ? NewSymbolNameTriggerKind.Invoke : NewSymbolNameTriggerKind.Automatic, y = this._requestRenameCandidatesOnce(v, this._renameCandidateProvidersCts.token);
			if (y.length === 0) {
				this._inputWithButton.setSparkleButton();
				return;
			}
			_ || (this._hadAutomaticRenameSuggestionsInvocation = !0), this._nRenameSuggestionsInvocations += 1, this._inputWithButton.setStopButton(), this._updateRenameCandidates(y, e, this._renameCts.token);
		}
	}
	_getSelection(e, _) {
		assertType(this._editor.hasModel());
		let v = this._editor.getSelection(), y = 0, b = _.length;
		return !Range.isEmpty(v) && !Range.spansMultipleLines(v) && Range.containsRange(e, v) && (y = Math.max(0, v.startColumn - e.startColumn), b = Math.min(e.endColumn, v.endColumn) - e.startColumn), {
			start: y,
			end: b
		};
	}
	_show() {
		this._trace("invoking _show"), this._editor.revealLineInCenterIfOutsideViewport(this._position.lineNumber, 0), this._visible = !0, this._visibleContextKey.set(!0), this._editor.layoutContentWidget(this), setTimeout(() => {
			this._inputWithButton.input.focus(), this._inputWithButton.input.setSelectionRange(parseInt(this._inputWithButton.input.getAttribute("selectionStart")), parseInt(this._inputWithButton.input.getAttribute("selectionEnd")));
		}, 100);
	}
	async _updateRenameCandidates(e, _, v) {
		let y = (...e) => this._trace("_updateRenameCandidates", ...e);
		y("start");
		let b = await raceCancellation(Promise.allSettled(e), v);
		if (this._inputWithButton.setSparkleButton(), b === void 0) {
			y("returning early - received updateRenameCandidates results - undefined");
			return;
		}
		let x = b.flatMap((e) => e.status === "fulfilled" && isDefined(e.value) ? e.value : []);
		y(`received updateRenameCandidates results - total (unfiltered) ${x.length} candidates.`);
		let S = distinct(x, (e) => e.newSymbolName);
		y(`distinct candidates - ${S.length} candidates.`);
		let C = S.filter(({ newSymbolName: e }) => e.trim().length > 0 && e !== this._inputWithButton.input.value && e !== _ && !this._candidates.has(e));
		if (y(`valid distinct candidates - ${x.length} candidates.`), C.forEach((e) => this._candidates.add(e.newSymbolName)), C.length < 1) {
			y("returning early - no valid distinct candidates");
			return;
		}
		y("setting candidates"), this._renameCandidateListView.setCandidates(C), y("asking editor to re-layout"), this._editor.layoutContentWidget(this);
	}
	_hide() {
		this._trace("invoked _hide"), this._visible = !1, this._visibleContextKey.reset(), this._editor.layoutContentWidget(this);
	}
	_getTopForPosition() {
		let e = this._editor.getVisibleRanges(), _;
		return e.length > 0 ? _ = e[0].startLineNumber : (this._logService.warn("RenameWidget#_getTopForPosition: this should not happen - visibleRanges is empty"), _ = Math.max(1, this._position.lineNumber - 5)), this._editor.getTopForLineNumber(this._position.lineNumber) - this._editor.getTopForLineNumber(_);
	}
	_trace(...e) {
		this._logService.trace("RenameWidget", ...e);
	}
};
RenameWidget = __decorate$24([
	__param$24(2, IThemeService),
	__param$24(3, IKeybindingService),
	__param$24(4, IContextKeyService),
	__param$24(5, ILogService)
], RenameWidget);
var RenameCandidateListView = class e {
	constructor(_, v) {
		this._disposables = new DisposableStore(), this._availableHeight = 0, this._minimumWidth = 0, this._lineHeight = v.fontInfo.lineHeight, this._typicalHalfwidthCharacterWidth = v.fontInfo.typicalHalfwidthCharacterWidth, this._listContainer = document.createElement("div"), this._listContainer.className = "rename-box rename-candidate-list-container", _.appendChild(this._listContainer), this._listWidget = e._createListWidget(this._listContainer, this._candidateViewHeight, v.fontInfo), this._listWidget.onDidChangeFocus((e) => {
			e.elements.length === 1 && v.onFocusChange(e.elements[0].newSymbolName);
		}, this._disposables), this._listWidget.onDidChangeSelection((e) => {
			e.elements.length === 1 && v.onSelectionChange();
		}, this._disposables), this._disposables.add(this._listWidget.onDidBlur((e) => {
			this._listWidget.setFocus([]);
		})), this._listWidget.style(getListStyles({
			listInactiveFocusForeground: quickInputListFocusForeground,
			listInactiveFocusBackground: quickInputListFocusBackground
		}));
	}
	dispose() {
		this._listWidget.dispose(), this._disposables.dispose();
	}
	layout({ height: e, width: _ }) {
		this._availableHeight = e, this._minimumWidth = _;
	}
	setCandidates(e) {
		this._listWidget.splice(0, 0, e);
		let _ = this._pickListHeight(this._listWidget.length), v = this._pickListWidth(e);
		this._listWidget.layout(_, v), this._listContainer.style.height = `${_}px`, this._listContainer.style.width = `${v}px`, status(localize("renameSuggestionsReceivedAria", "Received {0} rename suggestions", e.length));
	}
	clearCandidates() {
		this._listContainer.style.height = "0px", this._listContainer.style.width = "0px", this._listWidget.splice(0, this._listWidget.length, []);
	}
	get nCandidates() {
		return this._listWidget.length;
	}
	get focusedCandidate() {
		if (this._listWidget.length === 0) return;
		let e = this._listWidget.getSelectedElements()[0];
		if (e !== void 0) return e.newSymbolName;
		let _ = this._listWidget.getFocusedElements()[0];
		if (_ !== void 0) return _.newSymbolName;
	}
	focusNext() {
		if (this._listWidget.length === 0) return !1;
		let e = this._listWidget.getFocus();
		if (e.length === 0) return this._listWidget.focusFirst(), this._listWidget.reveal(0), !0;
		if (e[0] === this._listWidget.length - 1) return this._listWidget.setFocus([]), this._listWidget.reveal(0), !1;
		{
			this._listWidget.focusNext();
			let e = this._listWidget.getFocus()[0];
			return this._listWidget.reveal(e), !0;
		}
	}
	focusPrevious() {
		if (this._listWidget.length === 0) return !1;
		let e = this._listWidget.getFocus();
		if (e.length === 0) {
			this._listWidget.focusLast();
			let e = this._listWidget.getFocus()[0];
			return this._listWidget.reveal(e), !0;
		} else if (e[0] === 0) return this._listWidget.setFocus([]), !1;
		else {
			this._listWidget.focusPrevious();
			let e = this._listWidget.getFocus()[0];
			return this._listWidget.reveal(e), !0;
		}
	}
	clearFocus() {
		this._listWidget.setFocus([]);
	}
	get _candidateViewHeight() {
		let { totalHeight: e } = RenameCandidateView.getLayoutInfo({ lineHeight: this._lineHeight });
		return e;
	}
	_pickListHeight(e) {
		let _ = this._candidateViewHeight * e;
		return Math.min(_, this._availableHeight, this._candidateViewHeight * 7);
	}
	_pickListWidth(e) {
		let _ = Math.ceil(Math.max(...e.map((e) => e.newSymbolName.length)) * this._typicalHalfwidthCharacterWidth);
		return Math.max(this._minimumWidth, 25 + _ + 10);
	}
	static _createListWidget(e, _, v) {
		let y = new class {
			getTemplateId(e) {
				return "candidate";
			}
			getHeight(e) {
				return _;
			}
		}(), b = new class {
			constructor() {
				this.templateId = "candidate";
			}
			renderTemplate(e) {
				return new RenameCandidateView(e, v);
			}
			renderElement(e, _, v) {
				v.populate(e);
			}
			disposeTemplate(e) {
				e.dispose();
			}
		}();
		return new List("NewSymbolNameCandidates", e, y, [b], {
			keyboardSupport: !1,
			mouseSupport: !0,
			multipleSelectionSupport: !1
		});
	}
}, InputWithButton = class {
	constructor() {
		this._onDidInputChange = new Emitter(), this.onDidInputChange = this._onDidInputChange.event, this._disposables = new DisposableStore();
	}
	get domNode() {
		return this._domNode || (this._domNode = document.createElement("div"), this._domNode.className = "rename-input-with-button", this._domNode.style.display = "flex", this._domNode.style.flexDirection = "row", this._domNode.style.alignItems = "center", this._inputNode = document.createElement("input"), this._inputNode.className = "rename-input", this._inputNode.type = "text", this._inputNode.style.border = "none", this._inputNode.setAttribute("aria-label", localize("renameAriaLabel", "Rename input. Type new name and press Enter to commit.")), this._domNode.appendChild(this._inputNode), this._buttonNode = document.createElement("div"), this._buttonNode.className = "rename-suggestions-button", this._buttonNode.setAttribute("tabindex", "0"), this._buttonGenHoverText = localize("generateRenameSuggestionsButton", "Generate new name suggestions"), this._buttonCancelHoverText = localize("cancelRenameSuggestionsButton", "Cancel"), this._buttonHover = getBaseLayerHoverDelegate().setupManagedHover(getDefaultHoverDelegate("element"), this._buttonNode, this._buttonGenHoverText), this._disposables.add(this._buttonHover), this._domNode.appendChild(this._buttonNode), this._disposables.add(addDisposableListener(this.input, EventType$1.INPUT, () => this._onDidInputChange.fire())), this._disposables.add(addDisposableListener(this.input, EventType$1.KEY_DOWN, (e) => {
			let _ = new StandardKeyboardEvent(e);
			(_.keyCode === 15 || _.keyCode === 17) && this._onDidInputChange.fire();
		})), this._disposables.add(addDisposableListener(this.input, EventType$1.CLICK, () => this._onDidInputChange.fire())), this._disposables.add(addDisposableListener(this.input, EventType$1.FOCUS, () => {
			this.domNode.style.outlineWidth = "1px", this.domNode.style.outlineStyle = "solid", this.domNode.style.outlineOffset = "-1px", this.domNode.style.outlineColor = "var(--vscode-focusBorder)";
		})), this._disposables.add(addDisposableListener(this.input, EventType$1.BLUR, () => {
			this.domNode.style.outline = "none";
		}))), this._domNode;
	}
	get input() {
		return assertType(this._inputNode), this._inputNode;
	}
	get button() {
		return assertType(this._buttonNode), this._buttonNode;
	}
	get buttonState() {
		return this._buttonState;
	}
	setSparkleButton() {
		this._buttonState = "sparkle", this._sparkleIcon ??= renderIcon(Codicon.sparkle), clearNode(this.button), this.button.appendChild(this._sparkleIcon), this.button.setAttribute("aria-label", "Generating new name suggestions"), this._buttonHover?.update(this._buttonGenHoverText), this.input.focus();
	}
	setStopButton() {
		this._buttonState = "stop", this._stopIcon ??= renderIcon(Codicon.primitiveSquare), clearNode(this.button), this.button.appendChild(this._stopIcon), this.button.setAttribute("aria-label", "Cancel generating new name suggestions"), this._buttonHover?.update(this._buttonCancelHoverText), this.input.focus();
	}
	dispose() {
		this._disposables.dispose();
	}
}, RenameCandidateView = class e {
	static {
		this._PADDING = 2;
	}
	constructor(_, v) {
		this._domNode = document.createElement("div"), this._domNode.className = "rename-box rename-candidate", this._domNode.style.display = "flex", this._domNode.style.columnGap = "5px", this._domNode.style.alignItems = "center", this._domNode.style.height = `${v.lineHeight}px`, this._domNode.style.padding = `${e._PADDING}px`;
		let y = document.createElement("div");
		y.style.display = "flex", y.style.alignItems = "center", y.style.width = y.style.height = `${v.lineHeight * .8}px`, this._domNode.appendChild(y), this._icon = renderIcon(Codicon.sparkle), this._icon.style.display = "none", y.appendChild(this._icon), this._label = document.createElement("div"), applyFontInfo(this._label, v), this._domNode.appendChild(this._label), _.appendChild(this._domNode);
	}
	populate(e) {
		this._updateIcon(e), this._updateLabel(e);
	}
	_updateIcon(e) {
		let _ = !!e.tags?.includes(NewSymbolNameTag.AIGenerated);
		this._icon.style.display = _ ? "inherit" : "none";
	}
	_updateLabel(e) {
		this._label.innerText = e.newSymbolName;
	}
	static getLayoutInfo({ lineHeight: _ }) {
		return { totalHeight: _ + e._PADDING * 2 };
	}
	dispose() {}
}, __decorate$23 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$23 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, RenameController_1, RenameSkeleton = class {
	constructor(e, _, v) {
		this.model = e, this.position = _, this._providerRenameIdx = 0, this._providers = v.ordered(e);
	}
	hasProvider() {
		return this._providers.length > 0;
	}
	async resolveRenameLocation(e) {
		let _ = [];
		for (this._providerRenameIdx = 0; this._providerRenameIdx < this._providers.length; this._providerRenameIdx++) {
			let v = this._providers[this._providerRenameIdx];
			if (!v.resolveRenameLocation) break;
			let y = await v.resolveRenameLocation(this.model, this.position, e);
			if (y) {
				if (y.rejectReason) {
					_.push(y.rejectReason);
					continue;
				}
				return y;
			}
		}
		this._providerRenameIdx = 0;
		let v = this.model.getWordAtPosition(this.position);
		return v ? {
			range: new Range(this.position.lineNumber, v.startColumn, this.position.lineNumber, v.endColumn),
			text: v.word,
			rejectReason: _.length > 0 ? _.join("\n") : void 0
		} : {
			range: Range.fromPositions(this.position),
			text: "",
			rejectReason: _.length > 0 ? _.join("\n") : void 0
		};
	}
	async provideRenameEdits(e, _) {
		return this._provideRenameEdits(e, this._providerRenameIdx, [], _);
	}
	async _provideRenameEdits(e, _, v, y) {
		let b = this._providers[_];
		if (!b) return {
			edits: [],
			rejectReason: v.join("\n")
		};
		let x = await b.provideRenameEdits(this.model, this.position, e, y);
		if (x) {
			if (x.rejectReason) return this._provideRenameEdits(e, _ + 1, v.concat(x.rejectReason), y);
		} else return this._provideRenameEdits(e, _ + 1, v.concat(localize("no result", "No result.")), y);
		return x;
	}
};
async function rename(e, _, v, y) {
	let b = new RenameSkeleton(_, v, e), x = await b.resolveRenameLocation(CancellationToken.None);
	return x?.rejectReason ? {
		edits: [],
		rejectReason: x.rejectReason
	} : b.provideRenameEdits(y, CancellationToken.None);
}
var RenameController = class {
	static {
		RenameController_1 = this;
	}
	static {
		this.ID = "editor.contrib.renameController";
	}
	static get(e) {
		return e.getContribution(RenameController_1.ID);
	}
	constructor(e, _, v, y, b, x, S, C, w) {
		this.editor = e, this._instaService = _, this._notificationService = v, this._bulkEditService = y, this._progressService = b, this._logService = x, this._configService = S, this._languageFeaturesService = C, this._telemetryService = w, this._disposableStore = new DisposableStore(), this._cts = new CancellationTokenSource(), this._renameWidget = this._disposableStore.add(this._instaService.createInstance(RenameWidget, this.editor, ["acceptRenameInput", "acceptRenameInputWithPreview"]));
	}
	dispose() {
		this._disposableStore.dispose(), this._cts.dispose(!0);
	}
	async run() {
		let e = this._logService.trace.bind(this._logService, "[rename]");
		if (this._cts.dispose(!0), this._cts = new CancellationTokenSource(), !this.editor.hasModel()) {
			e("editor has no model");
			return;
		}
		let _ = this.editor.getPosition(), v = new RenameSkeleton(this.editor.getModel(), _, this._languageFeaturesService.renameProvider);
		if (!v.hasProvider()) {
			e("skeleton has no provider");
			return;
		}
		let y = new EditorStateCancellationTokenSource(this.editor, 5, void 0, this._cts.token), b;
		try {
			e("resolving rename location");
			let _ = v.resolveRenameLocation(y.token);
			this._progressService.showWhile(_, 250), b = await _, e("resolved rename location");
		} catch (v) {
			v instanceof CancellationError ? e("resolve rename location cancelled", JSON.stringify(v, null, "	")) : (e("resolve rename location failed", v instanceof Error ? v : JSON.stringify(v, null, "	")), (typeof v == "string" || isMarkdownString(v)) && MessageController.get(this.editor)?.showMessage(v || localize("resolveRenameLocationFailed", "An unknown error occurred while resolving rename location"), _));
			return;
		} finally {
			y.dispose();
		}
		if (!b) {
			e("returning early - no loc");
			return;
		}
		if (b.rejectReason) {
			e(`returning early - rejected with reason: ${b.rejectReason}`, b.rejectReason), MessageController.get(this.editor)?.showMessage(b.rejectReason, _);
			return;
		}
		if (y.token.isCancellationRequested) {
			e("returning early - cts1 cancelled");
			return;
		}
		let x = new EditorStateCancellationTokenSource(this.editor, 5, b.range, this._cts.token), S = this.editor.getModel(), C = this._languageFeaturesService.newSymbolNamesProvider.all(S), w = await Promise.all(C.map(async (e) => [e, await e.supportsAutomaticNewSymbolNamesTriggerKind ?? !1])), T = (e, _) => {
			let v = w.slice();
			return e === NewSymbolNameTriggerKind.Automatic && (v = v.filter(([e, _]) => _)), v.map(([v]) => v.provideNewSymbolNames(S, b.range, e, _));
		};
		e("creating rename input field and awaiting its result");
		let E = this._bulkEditService.hasPreviewHandler() && this._configService.getValue(this.editor.getModel().uri, "editor.rename.enablePreview"), D = await this._renameWidget.getInput(b.range, b.text, E, C.length > 0 ? T : void 0, x);
		if (e("received response from rename input field"), C.length > 0 && this._reportTelemetry(C.length, S.getLanguageId(), D), typeof D == "boolean") {
			e(`returning early - rename input field response - ${D}`), D && this.editor.focus(), x.dispose();
			return;
		}
		this.editor.focus(), e("requesting rename edits");
		let O = raceCancellation(v.provideRenameEdits(D.newName, x.token), x.token).then(async (_) => {
			if (!_) {
				e("returning early - no rename edits result");
				return;
			}
			if (!this.editor.hasModel()) {
				e("returning early - no model after rename edits are provided");
				return;
			}
			if (_.rejectReason) {
				e(`returning early - rejected with reason: ${_.rejectReason}`), this._notificationService.info(_.rejectReason);
				return;
			}
			this.editor.setSelection(Range.fromPositions(this.editor.getSelection().getPosition())), e("applying edits"), this._bulkEditService.apply(_, {
				editor: this.editor,
				showPreview: D.wantsPreview,
				label: localize("label", "Renaming '{0}' to '{1}'", b?.text, D.newName),
				code: "undoredo.rename",
				quotableLabel: localize("quotableLabel", "Renaming {0} to {1}", b?.text, D.newName),
				respectAutoSaveConfig: !0
			}).then((_) => {
				e("edits applied"), _.ariaSummary && alert(localize("aria", "Successfully renamed '{0}' to '{1}'. Summary: {2}", b.text, D.newName, _.ariaSummary));
			}).catch((_) => {
				e(`error when applying edits ${JSON.stringify(_, null, "	")}`), this._notificationService.error(localize("rename.failedApply", "Rename failed to apply edits")), this._logService.error(_);
			});
		}, (_) => {
			e("error when providing rename edits", JSON.stringify(_, null, "	")), this._notificationService.error(localize("rename.failed", "Rename failed to compute edits")), this._logService.error(_);
		}).finally(() => {
			x.dispose();
		});
		return e("returning rename operation"), this._progressService.showWhile(O, 250), O;
	}
	acceptRenameInput(e) {
		this._renameWidget.acceptInput(e);
	}
	cancelRenameInput() {
		this._renameWidget.cancelInput(!0, "cancelRenameInput command");
	}
	focusNextRenameSuggestion() {
		this._renameWidget.focusNextRenameSuggestion();
	}
	focusPreviousRenameSuggestion() {
		this._renameWidget.focusPreviousRenameSuggestion();
	}
	_reportTelemetry(e, _, v) {
		let y = typeof v == "boolean" ? {
			kind: "cancelled",
			languageId: _,
			nRenameSuggestionProviders: e
		} : {
			kind: "accepted",
			languageId: _,
			nRenameSuggestionProviders: e,
			source: v.stats.source.k,
			nRenameSuggestions: v.stats.nRenameSuggestions,
			timeBeforeFirstInputFieldEdit: v.stats.timeBeforeFirstInputFieldEdit,
			wantsPreview: v.wantsPreview,
			nRenameSuggestionsInvocations: v.stats.nRenameSuggestionsInvocations,
			hadAutomaticRenameSuggestionsInvocation: v.stats.hadAutomaticRenameSuggestionsInvocation
		};
		this._telemetryService.publicLog2("renameInvokedEvent", y);
	}
};
RenameController = RenameController_1 = __decorate$23([
	__param$23(1, IInstantiationService),
	__param$23(2, INotificationService),
	__param$23(3, IBulkEditService),
	__param$23(4, IEditorProgressService),
	__param$23(5, ILogService),
	__param$23(6, ITextResourceConfigurationService),
	__param$23(7, ILanguageFeaturesService),
	__param$23(8, ITelemetryService)
], RenameController);
var RenameAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.rename",
			label: localize("rename.label", "Rename Symbol"),
			alias: "Rename Symbol",
			precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasRenameProvider),
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 60,
				weight: 100
			},
			contextMenuOpts: {
				group: "1_modification",
				order: 1.1
			}
		});
	}
	runCommand(e, _) {
		let v = e.get(ICodeEditorService), [y, b] = Array.isArray(_) && _ || [void 0, void 0];
		return URI.isUri(y) && Position.isIPosition(b) ? v.openCodeEditor({ resource: y }, v.getActiveCodeEditor()).then((e) => {
			e && (e.setPosition(b), e.invokeWithinContext((_) => (this.reportTelemetry(_, e), this.run(_, e))));
		}, onUnexpectedError) : super.runCommand(e, _);
	}
	run(e, _) {
		let v = e.get(ILogService), y = RenameController.get(_);
		return y ? (v.trace("[RenameAction] got controller, running..."), y.run()) : (v.trace("[RenameAction] returning early - controller missing"), Promise.resolve());
	}
};
registerEditorContribution(RenameController.ID, RenameController, 4), registerEditorAction(RenameAction);
var RenameCommand = EditorCommand.bindToContribution(RenameController.get);
registerEditorCommand(new RenameCommand({
	id: "acceptRenameInput",
	precondition: CONTEXT_RENAME_INPUT_VISIBLE,
	handler: (e) => e.acceptRenameInput(!1),
	kbOpts: {
		weight: 199,
		kbExpr: ContextKeyExpr.and(EditorContextKeys.focus, ContextKeyExpr.not("isComposing")),
		primary: 3
	}
})), registerEditorCommand(new RenameCommand({
	id: "acceptRenameInputWithPreview",
	precondition: ContextKeyExpr.and(CONTEXT_RENAME_INPUT_VISIBLE, ContextKeyExpr.has("config.editor.rename.enablePreview")),
	handler: (e) => e.acceptRenameInput(!0),
	kbOpts: {
		weight: 199,
		kbExpr: ContextKeyExpr.and(EditorContextKeys.focus, ContextKeyExpr.not("isComposing")),
		primary: 2051
	}
})), registerEditorCommand(new RenameCommand({
	id: "cancelRenameInput",
	precondition: CONTEXT_RENAME_INPUT_VISIBLE,
	handler: (e) => e.cancelRenameInput(),
	kbOpts: {
		weight: 199,
		kbExpr: EditorContextKeys.focus,
		primary: 9,
		secondary: [1033]
	}
})), registerAction2(class extends Action2 {
	constructor() {
		super({
			id: "focusNextRenameSuggestion",
			title: { ...localize2("focusNextRenameSuggestion", "Focus Next Rename Suggestion") },
			precondition: CONTEXT_RENAME_INPUT_VISIBLE,
			keybinding: [{
				primary: 18,
				weight: 199
			}]
		});
	}
	run(e) {
		let _ = e.get(ICodeEditorService).getFocusedCodeEditor();
		if (!_) return;
		let v = RenameController.get(_);
		v && v.focusNextRenameSuggestion();
	}
}), registerAction2(class extends Action2 {
	constructor() {
		super({
			id: "focusPreviousRenameSuggestion",
			title: { ...localize2("focusPreviousRenameSuggestion", "Focus Previous Rename Suggestion") },
			precondition: CONTEXT_RENAME_INPUT_VISIBLE,
			keybinding: [{
				primary: 16,
				weight: 199
			}]
		});
	}
	run(e) {
		let _ = e.get(ICodeEditorService).getFocusedCodeEditor();
		if (!_) return;
		let v = RenameController.get(_);
		v && v.focusPreviousRenameSuggestion();
	}
}), registerModelAndPositionCommand("_executeDocumentRenameProvider", function(e, _, v, ...y) {
	let [b] = y;
	assertType(typeof b == "string");
	let { renameProvider: x } = e.get(ILanguageFeaturesService);
	return rename(x, _, v, b);
}), registerModelAndPositionCommand("_executePrepareRename", async function(e, _, v) {
	let { renameProvider: y } = e.get(ILanguageFeaturesService), b = await new RenameSkeleton(_, v, y).resolveRenameLocation(CancellationToken.None);
	if (b?.rejectReason) throw Error(b.rejectReason);
	return b;
}), Registry.as(Extensions$1.Configuration).registerConfiguration({
	id: "editor",
	properties: { "editor.rename.enablePreview": {
		scope: 5,
		description: localize("enablePreview", "Enable/disable the ability to preview changes before renaming"),
		default: !0,
		type: "boolean"
	} }
});
var __decorate$22 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$22 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SectionHeaderDetector = class extends Disposable {
	static {
		this.ID = "editor.sectionHeaderDetector";
	}
	constructor(e, _, v) {
		super(), this.editor = e, this.languageConfigurationService = _, this.editorWorkerService = v, this.decorations = this.editor.createDecorationsCollection(), this.options = this.createOptions(e.getOption(73)), this.computePromise = null, this.currentOccurrences = {}, this._register(e.onDidChangeModel((_) => {
			this.currentOccurrences = {}, this.options = this.createOptions(e.getOption(73)), this.stop(), this.computeSectionHeaders.schedule(0);
		})), this._register(e.onDidChangeModelLanguage((_) => {
			this.currentOccurrences = {}, this.options = this.createOptions(e.getOption(73)), this.stop(), this.computeSectionHeaders.schedule(0);
		})), this._register(_.onDidChange((_) => {
			let v = this.editor.getModel()?.getLanguageId();
			v && _.affects(v) && (this.currentOccurrences = {}, this.options = this.createOptions(e.getOption(73)), this.stop(), this.computeSectionHeaders.schedule(0));
		})), this._register(e.onDidChangeConfiguration((_) => {
			this.options && !_.hasChanged(73) || (this.options = this.createOptions(e.getOption(73)), this.updateDecorations([]), this.stop(), this.computeSectionHeaders.schedule(0));
		})), this._register(this.editor.onDidChangeModelContent((e) => {
			this.computeSectionHeaders.schedule();
		})), this._register(e.onDidChangeModelTokens((e) => {
			this.computeSectionHeaders.isScheduled() || this.computeSectionHeaders.schedule(1e3);
		})), this.computeSectionHeaders = this._register(new RunOnceScheduler(() => {
			this.findSectionHeaders();
		}, 250)), this.computeSectionHeaders.schedule(0);
	}
	createOptions(e) {
		if (!e || !this.editor.hasModel()) return;
		let _ = this.editor.getModel().getLanguageId();
		if (!_) return;
		let v = this.languageConfigurationService.getLanguageConfiguration(_).comments, y = this.languageConfigurationService.getLanguageConfiguration(_).foldingRules;
		if (!(!v && !y?.markers)) return {
			foldingRules: y,
			findMarkSectionHeaders: e.showMarkSectionHeaders,
			findRegionSectionHeaders: e.showRegionSectionHeaders
		};
	}
	findSectionHeaders() {
		if (!this.editor.hasModel() || !this.options?.findMarkSectionHeaders && !this.options?.findRegionSectionHeaders) return;
		let e = this.editor.getModel();
		if (e.isDisposed() || e.isTooLargeForSyncing()) return;
		let _ = e.getVersionId();
		this.editorWorkerService.findSectionHeaders(e.uri, this.options).then((v) => {
			e.isDisposed() || e.getVersionId() !== _ || this.updateDecorations(v);
		});
	}
	updateDecorations(e) {
		let _ = this.editor.getModel();
		_ && (e = e.filter((e) => {
			if (!e.shouldBeInComments) return !0;
			let v = _.validateRange(e.range), y = _.tokenization.getLineTokens(v.startLineNumber), b = y.findTokenIndexAtOffset(v.startColumn - 1), x = y.getStandardTokenType(b);
			return y.getLanguageId(b) === _.getLanguageId() && x === 1;
		}));
		let v = Object.values(this.currentOccurrences).map((e) => e.decorationId), y = e.map((e) => decoration(e));
		this.editor.changeDecorations((_) => {
			let b = _.deltaDecorations(v, y);
			this.currentOccurrences = {};
			for (let _ = 0, v = b.length; _ < v; _++) {
				let v = {
					sectionHeader: e[_],
					decorationId: b[_]
				};
				this.currentOccurrences[v.decorationId] = v;
			}
		});
	}
	stop() {
		this.computeSectionHeaders.cancel(), this.computePromise &&= (this.computePromise.cancel(), null);
	}
	dispose() {
		super.dispose(), this.stop(), this.decorations.clear();
	}
};
SectionHeaderDetector = __decorate$22([__param$22(1, ILanguageConfigurationService), __param$22(2, IEditorWorkerService)], SectionHeaderDetector);
function decoration(e) {
	return {
		range: e.range,
		options: ModelDecorationOptions.createDynamic({
			description: "section-header",
			stickiness: 3,
			collapseOnReplaceEdit: !0,
			minimap: {
				color: void 0,
				position: 1,
				sectionHeaderStyle: e.hasSeparatorLine ? 2 : 1,
				sectionHeaderText: e.text
			}
		})
	};
}
registerEditorContribution(SectionHeaderDetector.ID, SectionHeaderDetector, 1);
function reverseEndianness(e) {
	for (let _ = 0, v = e.length; _ < v; _ += 4) {
		let v = e[_ + 0], y = e[_ + 1], b = e[_ + 2], x = e[_ + 3];
		e[_ + 0] = x, e[_ + 1] = b, e[_ + 2] = y, e[_ + 3] = v;
	}
}
function toLittleEndianBuffer(e) {
	let _ = new Uint8Array(e.buffer, e.byteOffset, e.length * 4);
	return isLittleEndian() || reverseEndianness(_), VSBuffer.wrap(_);
}
function encodeSemanticTokensDto(e) {
	let _ = new Uint32Array(encodeSemanticTokensDtoSize(e)), v = 0;
	if (_[v++] = e.id, e.type === "full") _[v++] = 1, _[v++] = e.data.length, _.set(e.data, v), v += e.data.length;
	else {
		_[v++] = 2, _[v++] = e.deltas.length;
		for (let y of e.deltas) _[v++] = y.start, _[v++] = y.deleteCount, y.data ? (_[v++] = y.data.length, _.set(y.data, v), v += y.data.length) : _[v++] = 0;
	}
	return toLittleEndianBuffer(_);
}
function encodeSemanticTokensDtoSize(e) {
	let _ = 0;
	if (_ += 2, e.type === "full") _ += 1 + e.data.length;
	else {
		_ += 1, _ += 3 * e.deltas.length;
		for (let v of e.deltas) v.data && (_ += v.data.length);
	}
	return _;
}
function isSemanticTokens(e) {
	return e && !!e.data;
}
function isSemanticTokensEdits(e) {
	return e && Array.isArray(e.edits);
}
var DocumentSemanticTokensResult = class {
	constructor(e, _, v) {
		this.provider = e, this.tokens = _, this.error = v;
	}
};
function hasDocumentSemanticTokensProvider(e, _) {
	return e.has(_);
}
function getDocumentSemanticTokensProviders(e, _) {
	let v = e.orderedGroups(_);
	return v.length > 0 ? v[0] : [];
}
async function getDocumentSemanticTokens(e, _, v, y, b) {
	let x = getDocumentSemanticTokensProviders(e, _), S = await Promise.all(x.map(async (e) => {
		let x, S = null;
		try {
			x = await e.provideDocumentSemanticTokens(_, e === v ? y : null, b);
		} catch (e) {
			S = e, x = null;
		}
		return (!x || !isSemanticTokens(x) && !isSemanticTokensEdits(x)) && (x = null), new DocumentSemanticTokensResult(e, x, S);
	}));
	for (let e of S) {
		if (e.error) throw e.error;
		if (e.tokens) return e;
	}
	return S.length > 0 ? S[0] : null;
}
function _getDocumentSemanticTokensProviderHighestGroup(e, _) {
	let v = e.orderedGroups(_);
	return v.length > 0 ? v[0] : null;
}
var DocumentRangeSemanticTokensResult = class {
	constructor(e, _) {
		this.provider = e, this.tokens = _;
	}
};
function hasDocumentRangeSemanticTokensProvider(e, _) {
	return e.has(_);
}
function getDocumentRangeSemanticTokensProviders(e, _) {
	let v = e.orderedGroups(_);
	return v.length > 0 ? v[0] : [];
}
async function getDocumentRangeSemanticTokens(e, _, v, y) {
	let b = getDocumentRangeSemanticTokensProviders(e, _), x = await Promise.all(b.map(async (e) => {
		let b;
		try {
			b = await e.provideDocumentRangeSemanticTokens(_, v, y);
		} catch (e) {
			onUnexpectedExternalError(e), b = null;
		}
		return (!b || !isSemanticTokens(b)) && (b = null), new DocumentRangeSemanticTokensResult(e, b);
	}));
	for (let e of x) if (e.tokens) return e;
	return x.length > 0 ? x[0] : null;
}
CommandsRegistry.registerCommand("_provideDocumentSemanticTokensLegend", async (e, ..._) => {
	let [v] = _;
	assertType(v instanceof URI);
	let y = e.get(IModelService).getModel(v);
	if (!y) return;
	let { documentSemanticTokensProvider: b } = e.get(ILanguageFeaturesService), x = _getDocumentSemanticTokensProviderHighestGroup(b, y);
	return x ? x[0].getLegend() : e.get(ICommandService).executeCommand("_provideDocumentRangeSemanticTokensLegend", v);
}), CommandsRegistry.registerCommand("_provideDocumentSemanticTokens", async (e, ..._) => {
	let [v] = _;
	assertType(v instanceof URI);
	let y = e.get(IModelService).getModel(v);
	if (!y) return;
	let { documentSemanticTokensProvider: b } = e.get(ILanguageFeaturesService);
	if (!hasDocumentSemanticTokensProvider(b, y)) return e.get(ICommandService).executeCommand("_provideDocumentRangeSemanticTokens", v, y.getFullModelRange());
	let x = await getDocumentSemanticTokens(b, y, null, null, CancellationToken.None);
	if (!x) return;
	let { provider: S, tokens: C } = x;
	if (!C || !isSemanticTokens(C)) return;
	let w = encodeSemanticTokensDto({
		id: 0,
		type: "full",
		data: C.data
	});
	return C.resultId && S.releaseDocumentSemanticTokens(C.resultId), w;
}), CommandsRegistry.registerCommand("_provideDocumentRangeSemanticTokensLegend", async (e, ..._) => {
	let [v, y] = _;
	assertType(v instanceof URI);
	let b = e.get(IModelService).getModel(v);
	if (!b) return;
	let { documentRangeSemanticTokensProvider: x } = e.get(ILanguageFeaturesService), S = getDocumentRangeSemanticTokensProviders(x, b);
	if (S.length === 0) return;
	if (S.length === 1) return S[0].getLegend();
	if (!y || !Range.isIRange(y)) return console.warn("provideDocumentRangeSemanticTokensLegend might be out-of-sync with provideDocumentRangeSemanticTokens unless a range argument is passed in"), S[0].getLegend();
	let C = await getDocumentRangeSemanticTokens(x, b, Range.lift(y), CancellationToken.None);
	if (C) return C.provider.getLegend();
}), CommandsRegistry.registerCommand("_provideDocumentRangeSemanticTokens", async (e, ..._) => {
	let [v, y] = _;
	assertType(v instanceof URI), assertType(Range.isIRange(y));
	let b = e.get(IModelService).getModel(v);
	if (!b) return;
	let { documentRangeSemanticTokensProvider: x } = e.get(ILanguageFeaturesService), S = await getDocumentRangeSemanticTokens(x, b, Range.lift(y), CancellationToken.None);
	if (!(!S || !S.tokens)) return encodeSemanticTokensDto({
		id: 0,
		type: "full",
		data: S.tokens.data
	});
});
function isSemanticColoringEnabled(e, _, v) {
	let y = v.getValue("editor.semanticHighlighting", {
		overrideIdentifier: e.getLanguageId(),
		resource: e.uri
	})?.enabled;
	return typeof y == "boolean" ? y : _.getColorTheme().semanticHighlighting;
}
var __decorate$21 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$21 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ModelSemanticColoring_1, DocumentSemanticTokensFeature = class extends Disposable {
	constructor(e, _, v, y, b, x) {
		super(), this._watchers = Object.create(null);
		let S = (_) => {
			this._watchers[_.uri.toString()] = new ModelSemanticColoring(_, e, v, b, x);
		}, C = (e, _) => {
			_.dispose(), delete this._watchers[e.uri.toString()];
		}, w = () => {
			for (let e of _.getModels()) {
				let _ = this._watchers[e.uri.toString()];
				isSemanticColoringEnabled(e, v, y) ? _ || S(e) : _ && C(e, _);
			}
		};
		_.getModels().forEach((e) => {
			isSemanticColoringEnabled(e, v, y) && S(e);
		}), this._register(_.onModelAdded((e) => {
			isSemanticColoringEnabled(e, v, y) && S(e);
		})), this._register(_.onModelRemoved((e) => {
			let _ = this._watchers[e.uri.toString()];
			_ && C(e, _);
		})), this._register(y.onDidChangeConfiguration((e) => {
			e.affectsConfiguration("editor.semanticHighlighting") && w();
		})), this._register(v.onDidColorThemeChange(w));
	}
	dispose() {
		for (let e of Object.values(this._watchers)) e.dispose();
		super.dispose();
	}
};
DocumentSemanticTokensFeature = __decorate$21([
	__param$21(0, ISemanticTokensStylingService),
	__param$21(1, IModelService),
	__param$21(2, IThemeService),
	__param$21(3, IConfigurationService),
	__param$21(4, ILanguageFeatureDebounceService),
	__param$21(5, ILanguageFeaturesService)
], DocumentSemanticTokensFeature);
var ModelSemanticColoring = class extends Disposable {
	static {
		ModelSemanticColoring_1 = this;
	}
	static {
		this.REQUEST_MIN_DELAY = 300;
	}
	static {
		this.REQUEST_MAX_DELAY = 2e3;
	}
	constructor(e, _, v, y, b) {
		super(), this._semanticTokensStylingService = _, this._isDisposed = !1, this._model = e, this._provider = b.documentSemanticTokensProvider, this._debounceInformation = y.for(this._provider, "DocumentSemanticTokens", {
			min: ModelSemanticColoring_1.REQUEST_MIN_DELAY,
			max: ModelSemanticColoring_1.REQUEST_MAX_DELAY
		}), this._fetchDocumentSemanticTokens = this._register(new RunOnceScheduler(() => this._fetchDocumentSemanticTokensNow(), ModelSemanticColoring_1.REQUEST_MIN_DELAY)), this._currentDocumentResponse = null, this._currentDocumentRequestCancellationTokenSource = null, this._documentProvidersChangeListeners = [], this._providersChangedDuringRequest = !1, this._register(this._model.onDidChangeContent(() => {
			this._fetchDocumentSemanticTokens.isScheduled() || this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model));
		})), this._register(this._model.onDidChangeAttached(() => {
			this._fetchDocumentSemanticTokens.isScheduled() || this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model));
		})), this._register(this._model.onDidChangeLanguage(() => {
			this._currentDocumentResponse &&= (this._currentDocumentResponse.dispose(), null), this._currentDocumentRequestCancellationTokenSource &&= (this._currentDocumentRequestCancellationTokenSource.cancel(), null), this._setDocumentSemanticTokens(null, null, null, []), this._fetchDocumentSemanticTokens.schedule(0);
		}));
		let x = () => {
			dispose(this._documentProvidersChangeListeners), this._documentProvidersChangeListeners = [];
			for (let _ of this._provider.all(e)) typeof _.onDidChange == "function" && this._documentProvidersChangeListeners.push(_.onDidChange(() => {
				if (this._currentDocumentRequestCancellationTokenSource) {
					this._providersChangedDuringRequest = !0;
					return;
				}
				this._fetchDocumentSemanticTokens.schedule(0);
			}));
		};
		x(), this._register(this._provider.onDidChange(() => {
			x(), this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model));
		})), this._register(v.onDidColorThemeChange((e) => {
			this._setDocumentSemanticTokens(null, null, null, []), this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model));
		})), this._fetchDocumentSemanticTokens.schedule(0);
	}
	dispose() {
		this._currentDocumentResponse &&= (this._currentDocumentResponse.dispose(), null), this._currentDocumentRequestCancellationTokenSource &&= (this._currentDocumentRequestCancellationTokenSource.cancel(), null), dispose(this._documentProvidersChangeListeners), this._documentProvidersChangeListeners = [], this._setDocumentSemanticTokens(null, null, null, []), this._isDisposed = !0, super.dispose();
	}
	_fetchDocumentSemanticTokensNow() {
		if (this._currentDocumentRequestCancellationTokenSource) return;
		if (!hasDocumentSemanticTokensProvider(this._provider, this._model)) {
			this._currentDocumentResponse && this._model.tokenization.setSemanticTokens(null, !1);
			return;
		}
		if (!this._model.isAttachedToEditor()) return;
		let e = new CancellationTokenSource(), _ = this._currentDocumentResponse ? this._currentDocumentResponse.provider : null, v = this._currentDocumentResponse && this._currentDocumentResponse.resultId || null, y = getDocumentSemanticTokens(this._provider, this._model, _, v, e.token);
		this._currentDocumentRequestCancellationTokenSource = e, this._providersChangedDuringRequest = !1;
		let b = [], x = this._model.onDidChangeContent((e) => {
			b.push(e);
		}), S = new StopWatch(!1);
		y.then((e) => {
			if (this._debounceInformation.update(this._model, S.elapsed()), this._currentDocumentRequestCancellationTokenSource = null, x.dispose(), !e) this._setDocumentSemanticTokens(null, null, null, b);
			else {
				let { provider: _, tokens: v } = e, y = this._semanticTokensStylingService.getStyling(_);
				this._setDocumentSemanticTokens(_, v || null, y, b);
			}
		}, (e) => {
			e && (isCancellationError(e) || typeof e.message == "string" && e.message.indexOf("busy") !== -1) || onUnexpectedError(e), this._currentDocumentRequestCancellationTokenSource = null, x.dispose(), (b.length > 0 || this._providersChangedDuringRequest) && (this._fetchDocumentSemanticTokens.isScheduled() || this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model)));
		});
	}
	static _copy(e, _, v, y, b) {
		b = Math.min(b, v.length - y, e.length - _);
		for (let x = 0; x < b; x++) v[y + x] = e[_ + x];
	}
	_setDocumentSemanticTokens(e, _, v, y) {
		let b = this._currentDocumentResponse, x = () => {
			(y.length > 0 || this._providersChangedDuringRequest) && !this._fetchDocumentSemanticTokens.isScheduled() && this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model));
		};
		if (this._currentDocumentResponse &&= (this._currentDocumentResponse.dispose(), null), this._isDisposed) {
			e && _ && e.releaseDocumentSemanticTokens(_.resultId);
			return;
		}
		if (!e || !v) {
			this._model.tokenization.setSemanticTokens(null, !1);
			return;
		}
		if (!_) {
			this._model.tokenization.setSemanticTokens(null, !0), x();
			return;
		}
		if (isSemanticTokensEdits(_)) {
			if (!b) {
				this._model.tokenization.setSemanticTokens(null, !0);
				return;
			}
			if (_.edits.length === 0) _ = {
				resultId: _.resultId,
				data: b.data
			};
			else {
				let e = 0;
				for (let v of _.edits) e += (v.data ? v.data.length : 0) - v.deleteCount;
				let y = b.data, x = new Uint32Array(y.length + e), S = y.length, C = x.length;
				for (let e = _.edits.length - 1; e >= 0; e--) {
					let w = _.edits[e];
					if (w.start > y.length) {
						v.warnInvalidEditStart(b.resultId, _.resultId, e, w.start, y.length), this._model.tokenization.setSemanticTokens(null, !0);
						return;
					}
					let T = S - (w.start + w.deleteCount);
					T > 0 && (ModelSemanticColoring_1._copy(y, S - T, x, C - T, T), C -= T), w.data && (ModelSemanticColoring_1._copy(w.data, 0, x, C - w.data.length, w.data.length), C -= w.data.length), S = w.start;
				}
				S > 0 && ModelSemanticColoring_1._copy(y, 0, x, 0, S), _ = {
					resultId: _.resultId,
					data: x
				};
			}
		}
		if (isSemanticTokens(_)) {
			this._currentDocumentResponse = new SemanticTokensResponse(e, _.resultId, _.data);
			let b = toMultilineTokens2(_, v, this._model.getLanguageId());
			if (y.length > 0) for (let e of y) for (let _ of b) for (let v of e.changes) _.applyEdit(v.range, v.text);
			this._model.tokenization.setSemanticTokens(b, !0);
		} else this._model.tokenization.setSemanticTokens(null, !0);
		x();
	}
};
ModelSemanticColoring = ModelSemanticColoring_1 = __decorate$21([
	__param$21(1, ISemanticTokensStylingService),
	__param$21(2, IThemeService),
	__param$21(3, ILanguageFeatureDebounceService),
	__param$21(4, ILanguageFeaturesService)
], ModelSemanticColoring);
var SemanticTokensResponse = class {
	constructor(e, _, v) {
		this.provider = e, this.resultId = _, this.data = v;
	}
	dispose() {
		this.provider.releaseDocumentSemanticTokens(this.resultId);
	}
};
registerEditorFeature(DocumentSemanticTokensFeature);
var __decorate$20 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$20 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ViewportSemanticTokensContribution = class extends Disposable {
	static {
		this.ID = "editor.contrib.viewportSemanticTokens";
	}
	constructor(e, _, v, y, b, x) {
		super(), this._semanticTokensStylingService = _, this._themeService = v, this._configurationService = y, this._editor = e, this._provider = x.documentRangeSemanticTokensProvider, this._debounceInformation = b.for(this._provider, "DocumentRangeSemanticTokens", {
			min: 100,
			max: 500
		}), this._tokenizeViewport = this._register(new RunOnceScheduler(() => this._tokenizeViewportNow(), 100)), this._outstandingRequests = [];
		let S = () => {
			this._editor.hasModel() && this._tokenizeViewport.schedule(this._debounceInformation.get(this._editor.getModel()));
		};
		this._register(this._editor.onDidScrollChange(() => {
			S();
		})), this._register(this._editor.onDidChangeModel(() => {
			this._cancelAll(), S();
		})), this._register(this._editor.onDidChangeModelContent((e) => {
			this._cancelAll(), S();
		})), this._register(this._provider.onDidChange(() => {
			this._cancelAll(), S();
		})), this._register(this._configurationService.onDidChangeConfiguration((e) => {
			e.affectsConfiguration("editor.semanticHighlighting") && (this._cancelAll(), S());
		})), this._register(this._themeService.onDidColorThemeChange(() => {
			this._cancelAll(), S();
		})), S();
	}
	_cancelAll() {
		for (let e of this._outstandingRequests) e.cancel();
		this._outstandingRequests = [];
	}
	_removeOutstandingRequest(e) {
		for (let _ = 0, v = this._outstandingRequests.length; _ < v; _++) if (this._outstandingRequests[_] === e) {
			this._outstandingRequests.splice(_, 1);
			return;
		}
	}
	_tokenizeViewportNow() {
		if (!this._editor.hasModel()) return;
		let e = this._editor.getModel();
		if (e.tokenization.hasCompleteSemanticTokens()) return;
		if (!isSemanticColoringEnabled(e, this._themeService, this._configurationService)) {
			e.tokenization.hasSomeSemanticTokens() && e.tokenization.setSemanticTokens(null, !1);
			return;
		}
		if (!hasDocumentRangeSemanticTokensProvider(this._provider, e)) {
			e.tokenization.hasSomeSemanticTokens() && e.tokenization.setSemanticTokens(null, !1);
			return;
		}
		let _ = this._editor.getVisibleRangesPlusViewportAboveBelow();
		this._outstandingRequests = this._outstandingRequests.concat(_.map((_) => this._requestRange(e, _)));
	}
	_requestRange(e, _) {
		let v = e.getVersionId(), y = createCancelablePromise((v) => Promise.resolve(getDocumentRangeSemanticTokens(this._provider, e, _, v))), b = new StopWatch(!1);
		return y.then((y) => {
			if (this._debounceInformation.update(e, b.elapsed()), !y || !y.tokens || e.isDisposed() || e.getVersionId() !== v) return;
			let { provider: x, tokens: S } = y, C = this._semanticTokensStylingService.getStyling(x);
			e.tokenization.setPartialSemanticTokens(_, toMultilineTokens2(S, C, e.getLanguageId()));
		}).then(() => this._removeOutstandingRequest(y), () => this._removeOutstandingRequest(y)), y;
	}
};
ViewportSemanticTokensContribution = __decorate$20([
	__param$20(1, ISemanticTokensStylingService),
	__param$20(2, IThemeService),
	__param$20(3, IConfigurationService),
	__param$20(4, ILanguageFeatureDebounceService),
	__param$20(5, ILanguageFeaturesService)
], ViewportSemanticTokensContribution), registerEditorContribution(ViewportSemanticTokensContribution.ID, ViewportSemanticTokensContribution, 1);
var WordSelectionRangeProvider = class {
	constructor(e = !0) {
		this.selectSubwords = e;
	}
	provideSelectionRanges(e, _) {
		let v = [];
		for (let y of _) {
			let _ = [];
			v.push(_), this.selectSubwords && this._addInWordRanges(_, e, y), this._addWordRanges(_, e, y), this._addWhitespaceLine(_, e, y), _.push({ range: e.getFullModelRange() });
		}
		return v;
	}
	_addInWordRanges(e, _, y) {
		let b = _.getWordAtPosition(y);
		if (!b) return;
		let { word: x, startColumn: S } = b, C = y.column - S, w = C, T = C, E = 0;
		for (; w >= 0; w--) {
			let e = x.charCodeAt(w);
			if (w !== C && (e === 95 || e === 45) || isLowerAsciiLetter(e) && isUpperAsciiLetter(E)) break;
			E = e;
		}
		for (w += 1; T < x.length; T++) {
			let e = x.charCodeAt(T);
			if (isUpperAsciiLetter(e) && isLowerAsciiLetter(E) || e === 95 || e === 45) break;
			E = e;
		}
		w < T && e.push({ range: new Range(y.lineNumber, S + w, y.lineNumber, S + T) });
	}
	_addWordRanges(e, _, v) {
		let y = _.getWordAtPosition(v);
		y && e.push({ range: new Range(v.lineNumber, y.startColumn, v.lineNumber, y.endColumn) });
	}
	_addWhitespaceLine(e, _, v) {
		_.getLineLength(v.lineNumber) > 0 && _.getLineFirstNonWhitespaceColumn(v.lineNumber) === 0 && _.getLineLastNonWhitespaceColumn(v.lineNumber) === 0 && e.push({ range: new Range(v.lineNumber, 1, v.lineNumber, _.getLineMaxColumn(v.lineNumber)) });
	}
}, __decorate$19 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$19 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SmartSelectController_1, SelectionRanges = class e {
	constructor(e, _) {
		this.index = e, this.ranges = _;
	}
	mov(_) {
		let v = this.index + (_ ? 1 : -1);
		if (v < 0 || v >= this.ranges.length) return this;
		let y = new e(v, this.ranges);
		return y.ranges[v].equalsRange(this.ranges[this.index]) ? y.mov(_) : y;
	}
}, SmartSelectController = class {
	static {
		SmartSelectController_1 = this;
	}
	static {
		this.ID = "editor.contrib.smartSelectController";
	}
	static get(e) {
		return e.getContribution(SmartSelectController_1.ID);
	}
	constructor(e, _) {
		this._editor = e, this._languageFeaturesService = _, this._ignoreSelection = !1;
	}
	dispose() {
		this._selectionListener?.dispose();
	}
	async run(e) {
		if (!this._editor.hasModel()) return;
		let _ = this._editor.getSelections(), v = this._editor.getModel();
		if (this._state || await provideSelectionRanges(this._languageFeaturesService.selectionRangeProvider, v, _.map((e) => e.getPosition()), this._editor.getOption(114), CancellationToken.None).then((e) => {
			if (!(!isNonEmptyArray(e) || e.length !== _.length) && !(!this._editor.hasModel() || !equals(this._editor.getSelections(), _, (e, _) => e.equalsSelection(_)))) {
				for (let v = 0; v < e.length; v++) e[v] = e[v].filter((e) => e.containsPosition(_[v].getStartPosition()) && e.containsPosition(_[v].getEndPosition())), e[v].unshift(_[v]);
				this._state = e.map((e) => new SelectionRanges(0, e)), this._selectionListener?.dispose(), this._selectionListener = this._editor.onDidChangeCursorPosition(() => {
					this._ignoreSelection || (this._selectionListener?.dispose(), this._state = void 0);
				});
			}
		}), !this._state) return;
		this._state = this._state.map((_) => _.mov(e));
		let y = this._state.map((e) => Selection.fromPositions(e.ranges[e.index].getStartPosition(), e.ranges[e.index].getEndPosition()));
		this._ignoreSelection = !0;
		try {
			this._editor.setSelections(y);
		} finally {
			this._ignoreSelection = !1;
		}
	}
};
SmartSelectController = SmartSelectController_1 = __decorate$19([__param$19(1, ILanguageFeaturesService)], SmartSelectController);
var AbstractSmartSelect = class extends EditorAction {
	constructor(e, _) {
		super(_), this._forward = e;
	}
	async run(e, _) {
		let v = SmartSelectController.get(_);
		v && await v.run(this._forward);
	}
}, GrowSelectionAction = class extends AbstractSmartSelect {
	constructor() {
		super(!0, {
			id: "editor.action.smartSelect.expand",
			label: localize("smartSelect.expand", "Expand Selection"),
			alias: "Expand Selection",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1553,
				mac: {
					primary: 3345,
					secondary: [1297]
				},
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "1_basic",
				title: localize({
					key: "miSmartSelectGrow",
					comment: ["&& denotes a mnemonic"]
				}, "&&Expand Selection"),
				order: 2
			}
		});
	}
};
CommandsRegistry.registerCommandAlias("editor.action.smartSelect.grow", "editor.action.smartSelect.expand");
var ShrinkSelectionAction = class extends AbstractSmartSelect {
	constructor() {
		super(!1, {
			id: "editor.action.smartSelect.shrink",
			label: localize("smartSelect.shrink", "Shrink Selection"),
			alias: "Shrink Selection",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1551,
				mac: {
					primary: 3343,
					secondary: [1295]
				},
				weight: 100
			},
			menuOpts: {
				menuId: MenuId.MenubarSelectionMenu,
				group: "1_basic",
				title: localize({
					key: "miSmartSelectShrink",
					comment: ["&& denotes a mnemonic"]
				}, "&&Shrink Selection"),
				order: 3
			}
		});
	}
};
registerEditorContribution(SmartSelectController.ID, SmartSelectController, 4), registerEditorAction(GrowSelectionAction), registerEditorAction(ShrinkSelectionAction);
async function provideSelectionRanges(e, _, v, y, b) {
	let x = e.all(_).concat(new WordSelectionRangeProvider(y.selectSubwords));
	x.length === 1 && x.unshift(new BracketSelectionRangeProvider());
	let S = [], C = [];
	for (let e of x) S.push(Promise.resolve(e.provideSelectionRanges(_, v, b)).then((e) => {
		if (isNonEmptyArray(e) && e.length === v.length) for (let _ = 0; _ < v.length; _++) {
			C[_] || (C[_] = []);
			for (let y of e[_]) Range.isIRange(y.range) && Range.containsPosition(y.range, v[_]) && C[_].push(Range.lift(y.range));
		}
	}, onUnexpectedExternalError));
	return await Promise.all(S), C.map((e) => {
		if (e.length === 0) return [];
		e.sort((e, _) => Position.isBefore(e.getStartPosition(), _.getStartPosition()) ? 1 : Position.isBefore(_.getStartPosition(), e.getStartPosition()) || Position.isBefore(e.getEndPosition(), _.getEndPosition()) ? -1 : Position.isBefore(_.getEndPosition(), e.getEndPosition()) ? 1 : 0);
		let v = [], b;
		for (let _ of e) (!b || Range.containsRange(_, b) && !Range.equalsRange(_, b)) && (v.push(_), b = _);
		if (!y.selectLeadingAndTrailingWhitespace) return v;
		let x = [v[0]];
		for (let e = 1; e < v.length; e++) {
			let y = v[e - 1], b = v[e];
			if (b.startLineNumber !== y.startLineNumber || b.endLineNumber !== y.endLineNumber) {
				let e = new Range(y.startLineNumber, _.getLineFirstNonWhitespaceColumn(y.startLineNumber), y.endLineNumber, _.getLineLastNonWhitespaceColumn(y.endLineNumber));
				e.containsRange(y) && !e.equalsRange(y) && b.containsRange(e) && !b.equalsRange(e) && x.push(e);
				let v = new Range(y.startLineNumber, 1, y.endLineNumber, _.getLineMaxColumn(y.endLineNumber));
				v.containsRange(y) && !v.equalsRange(e) && b.containsRange(v) && !b.equalsRange(v) && x.push(v);
			}
			x.push(b);
		}
		return x;
	});
}
CommandsRegistry.registerCommand("_executeSelectionRangeProvider", async function(e, ..._) {
	let [v, y] = _;
	assertType(URI.isUri(v));
	let b = e.get(ILanguageFeaturesService).selectionRangeProvider, x = await e.get(ITextModelService).createModelReference(v);
	try {
		return provideSelectionRanges(b, x.object.textEditorModel, y, {
			selectLeadingAndTrailingWhitespace: !0,
			selectSubwords: !0
		}, CancellationToken.None);
	} finally {
		x.dispose();
	}
});
const Categories = Object.freeze({
	View: localize2("view", "View"),
	Help: localize2("help", "Help"),
	Test: localize2("test", "Test"),
	File: localize2("file", "File"),
	Preferences: localize2("preferences", "Preferences"),
	Developer: localize2({
		key: "developer",
		comment: ["A developer on Code itself or someone diagnosing issues in Code"]
	}, "Developer")
});
var StickyScrollWidgetState = class e {
	constructor(e, _, v, y = null) {
		this.startLineNumbers = e, this.endLineNumbers = _, this.lastLineRelativePosition = v, this.showEndForLine = y;
	}
	equals(e) {
		return !!e && this.lastLineRelativePosition === e.lastLineRelativePosition && this.showEndForLine === e.showEndForLine && equals(this.startLineNumbers, e.startLineNumbers) && equals(this.endLineNumbers, e.endLineNumbers);
	}
	static get Empty() {
		return new e([], [], 0);
	}
}, _ttPolicy = createTrustedTypesPolicy("stickyScrollViewLayer", { createHTML: (e) => e }), STICKY_INDEX_ATTR = "data-sticky-line-index", STICKY_IS_LINE_ATTR = "data-sticky-is-line", STICKY_IS_LINE_NUMBER_ATTR = "data-sticky-is-line-number", STICKY_IS_FOLDING_ICON_ATTR = "data-sticky-is-folding-icon", StickyScrollWidget = class extends Disposable {
	constructor(e) {
		super(), this._editor = e, this._foldingIconStore = new DisposableStore(), this._rootDomNode = document.createElement("div"), this._lineNumbersDomNode = document.createElement("div"), this._linesDomNodeScrollable = document.createElement("div"), this._linesDomNode = document.createElement("div"), this._lineHeight = this._editor.getOption(67), this._renderedStickyLines = [], this._lineNumbers = [], this._lastLineRelativePosition = 0, this._minContentWidthInPx = 0, this._isOnGlyphMargin = !1, this._lineNumbersDomNode.className = "sticky-widget-line-numbers", this._lineNumbersDomNode.setAttribute("role", "none"), this._linesDomNode.className = "sticky-widget-lines", this._linesDomNode.setAttribute("role", "list"), this._linesDomNodeScrollable.className = "sticky-widget-lines-scrollable", this._linesDomNodeScrollable.appendChild(this._linesDomNode), this._rootDomNode.className = "sticky-widget", this._rootDomNode.classList.toggle("peek", e instanceof EmbeddedCodeEditorWidget), this._rootDomNode.appendChild(this._lineNumbersDomNode), this._rootDomNode.appendChild(this._linesDomNodeScrollable);
		let _ = () => {
			this._linesDomNode.style.left = this._editor.getOption(116).scrollWithEditor ? `-${this._editor.getScrollLeft()}px` : "0px";
		};
		this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(116) && _(), e.hasChanged(67) && (this._lineHeight = this._editor.getOption(67));
		})), this._register(this._editor.onDidScrollChange((e) => {
			e.scrollLeftChanged && _(), e.scrollWidthChanged && this._updateWidgetWidth();
		})), this._register(this._editor.onDidChangeModel(() => {
			_(), this._updateWidgetWidth();
		})), this._register(this._foldingIconStore), _(), this._register(this._editor.onDidLayoutChange((e) => {
			this._updateWidgetWidth();
		})), this._updateWidgetWidth();
	}
	get lineNumbers() {
		return this._lineNumbers;
	}
	get lineNumberCount() {
		return this._lineNumbers.length;
	}
	getRenderedStickyLine(e) {
		return this._renderedStickyLines.find((_) => _.lineNumber === e);
	}
	getCurrentLines() {
		return this._lineNumbers;
	}
	setState(e, _, v) {
		if (v === void 0 && (!this._previousState && !e || this._previousState && this._previousState.equals(e))) return;
		let y = this._isWidgetHeightZero(e), b = y ? void 0 : e, x = y ? 0 : this._findLineToRebuildWidgetFrom(e, v);
		this._renderRootNode(b, _, x), this._previousState = e;
	}
	_isWidgetHeightZero(e) {
		if (!e) return !0;
		let _ = e.startLineNumbers.length * this._lineHeight + e.lastLineRelativePosition;
		if (_ > 0) {
			this._lastLineRelativePosition = e.lastLineRelativePosition;
			let _ = [...e.startLineNumbers];
			e.showEndForLine !== null && (_[e.showEndForLine] = e.endLineNumbers[e.showEndForLine]), this._lineNumbers = _;
		} else this._lastLineRelativePosition = 0, this._lineNumbers = [];
		return _ === 0;
	}
	_findLineToRebuildWidgetFrom(e, _) {
		if (!e || !this._previousState) return 0;
		if (_ !== void 0) return _;
		let v = this._previousState, y = e.startLineNumbers.findIndex((e) => !v.startLineNumbers.includes(e));
		return y === -1 ? 0 : y;
	}
	_updateWidgetWidth() {
		let e = this._editor.getLayoutInfo(), _ = e.contentLeft;
		this._lineNumbersDomNode.style.width = `${_}px`, this._linesDomNodeScrollable.style.setProperty("--vscode-editorStickyScroll-scrollableWidth", `${this._editor.getScrollWidth() - e.verticalScrollbarWidth}px`), this._rootDomNode.style.width = `${e.width - e.verticalScrollbarWidth}px`;
	}
	_clearStickyLinesFromLine(e) {
		this._foldingIconStore.clear();
		for (let _ = e; _ < this._renderedStickyLines.length; _++) {
			let e = this._renderedStickyLines[_];
			e.lineNumberDomNode.remove(), e.lineDomNode.remove();
		}
		this._renderedStickyLines = this._renderedStickyLines.slice(0, e), this._rootDomNode.style.display = "none";
	}
	_useFoldingOpacityTransition(e) {
		this._lineNumbersDomNode.style.setProperty("--vscode-editorStickyScroll-foldingOpacityTransition", `opacity ${e ? .5 : 0}s`);
	}
	_setFoldingIconsVisibility(e) {
		for (let _ of this._renderedStickyLines) {
			let v = _.foldingIcon;
			v && v.setVisible(e ? !0 : v.isCollapsed);
		}
	}
	async _renderRootNode(e, _, v) {
		if (this._clearStickyLinesFromLine(v), !e) return;
		for (let e of this._renderedStickyLines) this._updateTopAndZIndexOfStickyLine(e);
		let y = this._editor.getLayoutInfo(), b = this._lineNumbers.slice(v);
		for (let [e, x] of b.entries()) {
			let b = this._renderChildNode(e + v, x, _, y);
			b && (this._linesDomNode.appendChild(b.lineDomNode), this._lineNumbersDomNode.appendChild(b.lineNumberDomNode), this._renderedStickyLines.push(b));
		}
		_ && (this._setFoldingHoverListeners(), this._useFoldingOpacityTransition(!this._isOnGlyphMargin));
		let x = this._lineNumbers.length * this._lineHeight + this._lastLineRelativePosition;
		this._rootDomNode.style.display = "block", this._lineNumbersDomNode.style.height = `${x}px`, this._linesDomNodeScrollable.style.height = `${x}px`, this._rootDomNode.style.height = `${x}px`, this._rootDomNode.style.marginLeft = "0px", this._minContentWidthInPx = Math.max(...this._renderedStickyLines.map((e) => e.scrollWidth)) + y.verticalScrollbarWidth, this._editor.layoutOverlayWidget(this);
	}
	_setFoldingHoverListeners() {
		this._editor.getOption(111) === "mouseover" && (this._foldingIconStore.add(addDisposableListener(this._lineNumbersDomNode, EventType$1.MOUSE_ENTER, () => {
			this._isOnGlyphMargin = !0, this._setFoldingIconsVisibility(!0);
		})), this._foldingIconStore.add(addDisposableListener(this._lineNumbersDomNode, EventType$1.MOUSE_LEAVE, () => {
			this._isOnGlyphMargin = !1, this._useFoldingOpacityTransition(!0), this._setFoldingIconsVisibility(!1);
		})));
	}
	_renderChildNode(e, _, v, y) {
		let b = this._editor._getViewModel();
		if (!b) return;
		let x = b.coordinatesConverter.convertModelPositionToViewPosition(new Position(_, 1)).lineNumber, S = b.getViewLineRenderingData(x), C = this._editor.getOption(68), w;
		try {
			w = LineDecoration.filter(S.inlineDecorations, x, S.minColumn, S.maxColumn);
		} catch {
			w = [];
		}
		let T = new RenderLineInput(!0, !0, S.content, S.continuesWithWrappedLine, S.isBasicASCII, S.containsRTL, 0, S.tokens, w, S.tabSize, S.startVisibleColumn, 1, 1, 1, 500, "none", !0, !0, null), E = new StringBuilder(2e3), D = renderViewLine(T, E), O;
		O = _ttPolicy ? _ttPolicy.createHTML(E.build()) : E.build();
		let k = document.createElement("span");
		k.setAttribute(STICKY_INDEX_ATTR, String(e)), k.setAttribute(STICKY_IS_LINE_ATTR, ""), k.setAttribute("role", "listitem"), k.tabIndex = 0, k.className = "sticky-line-content", k.classList.add(`stickyLine${_}`), k.style.lineHeight = `${this._lineHeight}px`, k.innerHTML = O;
		let A = document.createElement("span");
		A.setAttribute(STICKY_INDEX_ATTR, String(e)), A.setAttribute(STICKY_IS_LINE_NUMBER_ATTR, ""), A.className = "sticky-line-number", A.style.lineHeight = `${this._lineHeight}px`;
		let j = y.contentLeft;
		A.style.width = `${j}px`;
		let M = document.createElement("span");
		C.renderType === 1 || C.renderType === 3 && _ % 10 == 0 ? M.innerText = _.toString() : C.renderType === 2 && (M.innerText = Math.abs(_ - this._editor.getPosition().lineNumber).toString()), M.className = "sticky-line-number-inner", M.style.lineHeight = `${this._lineHeight}px`, M.style.width = `${y.lineNumbersWidth}px`, M.style.paddingLeft = `${y.lineNumbersLeft}px`, A.appendChild(M);
		let N = this._renderFoldingIconForLine(v, _);
		N && A.appendChild(N.domNode), this._editor.applyFontInfo(k), this._editor.applyFontInfo(M), A.style.lineHeight = `${this._lineHeight}px`, k.style.lineHeight = `${this._lineHeight}px`, A.style.height = `${this._lineHeight}px`, k.style.height = `${this._lineHeight}px`;
		let P = new RenderedStickyLine(e, _, k, A, N, D.characterMapping, k.scrollWidth);
		return this._updateTopAndZIndexOfStickyLine(P);
	}
	_updateTopAndZIndexOfStickyLine(e) {
		let _ = e.index, v = e.lineDomNode, y = e.lineNumberDomNode, b = _ === this._lineNumbers.length - 1;
		v.style.zIndex = b ? "0" : "1", y.style.zIndex = b ? "0" : "1";
		let x = `${_ * this._lineHeight + this._lastLineRelativePosition + (e.foldingIcon?.isCollapsed ? 1 : 0)}px`, S = `${_ * this._lineHeight}px`;
		return v.style.top = b ? x : S, y.style.top = b ? x : S, e;
	}
	_renderFoldingIconForLine(e, _) {
		let v = this._editor.getOption(111);
		if (!e || v === "never") return;
		let y = e.regions, b = y.findRange(_), x = y.getStartLineNumber(b);
		if (_ !== x) return;
		let S = y.isCollapsed(b), C = new StickyFoldingIcon(S, x, y.getEndLineNumber(b), this._lineHeight);
		return C.setVisible(this._isOnGlyphMargin ? !0 : S || v === "always"), C.domNode.setAttribute(STICKY_IS_FOLDING_ICON_ATTR, ""), C;
	}
	getId() {
		return "editor.contrib.stickyScrollWidget";
	}
	getDomNode() {
		return this._rootDomNode;
	}
	getPosition() {
		return {
			preference: 2,
			stackOridinal: 10
		};
	}
	getMinContentWidthInPx() {
		return this._minContentWidthInPx;
	}
	focusLineWithIndex(e) {
		0 <= e && e < this._renderedStickyLines.length && this._renderedStickyLines[e].lineDomNode.focus();
	}
	getEditorPositionFromNode(e) {
		if (!e || e.children.length > 0) return null;
		let _ = this._getRenderedStickyLineFromChildDomNode(e);
		if (!_) return null;
		let v = getColumnOfNodeOffset(_.characterMapping, e, 0);
		return new Position(_.lineNumber, v);
	}
	getLineNumberFromChildDomNode(e) {
		return this._getRenderedStickyLineFromChildDomNode(e)?.lineNumber ?? null;
	}
	_getRenderedStickyLineFromChildDomNode(e) {
		let _ = this.getLineIndexFromChildDomNode(e);
		return _ === null || _ < 0 || _ >= this._renderedStickyLines.length ? null : this._renderedStickyLines[_];
	}
	getLineIndexFromChildDomNode(e) {
		let _ = this._getAttributeValue(e, STICKY_INDEX_ATTR);
		return _ ? parseInt(_, 10) : null;
	}
	isInStickyLine(e) {
		return this._getAttributeValue(e, STICKY_IS_LINE_ATTR) !== void 0;
	}
	isInFoldingIconDomNode(e) {
		return this._getAttributeValue(e, STICKY_IS_FOLDING_ICON_ATTR) !== void 0;
	}
	_getAttributeValue(e, _) {
		for (; e && e !== this._rootDomNode;) {
			let v = e.getAttribute(_);
			if (v !== null) return v;
			e = e.parentElement;
		}
	}
}, RenderedStickyLine = class {
	constructor(e, _, v, y, b, x, S) {
		this.index = e, this.lineNumber = _, this.lineDomNode = v, this.lineNumberDomNode = y, this.foldingIcon = b, this.characterMapping = x, this.scrollWidth = S;
	}
}, StickyFoldingIcon = class {
	constructor(e, _, v, y) {
		this.isCollapsed = e, this.foldingStartLine = _, this.foldingEndLine = v, this.dimension = y, this.domNode = document.createElement("div"), this.domNode.style.width = `${y}px`, this.domNode.style.height = `${y}px`, this.domNode.className = ThemeIcon.asClassName(e ? foldingCollapsedIcon : foldingExpandedIcon);
	}
	setVisible(e) {
		this.domNode.style.cursor = e ? "pointer" : "default", this.domNode.style.opacity = e ? "1" : "0";
	}
}, StickyRange = class {
	constructor(e, _) {
		this.startLineNumber = e, this.endLineNumber = _;
	}
}, StickyElement = class {
	constructor(e, _, v) {
		this.range = e, this.children = _, this.parent = v;
	}
}, StickyModel = class {
	constructor(e, _, v, y) {
		this.uri = e, this.version = _, this.element = v, this.outlineProviderId = y;
	}
}, __decorate$18 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$18 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ModelProvider;
(function(e) {
	e.OUTLINE_MODEL = "outlineModel", e.FOLDING_PROVIDER_MODEL = "foldingProviderModel", e.INDENTATION_MODEL = "indentationModel";
})(ModelProvider ||= {});
var Status;
(function(e) {
	e[e.VALID = 0] = "VALID", e[e.INVALID = 1] = "INVALID", e[e.CANCELED = 2] = "CANCELED";
})(Status ||= {});
var StickyModelProvider = class extends Disposable {
	constructor(e, _, v, y) {
		switch (super(), this._editor = e, this._modelProviders = [], this._modelPromise = null, this._updateScheduler = this._register(new Delayer(300)), this._updateOperation = this._register(new DisposableStore()), this._editor.getOption(116).defaultModel) {
			case ModelProvider.OUTLINE_MODEL: this._modelProviders.push(new StickyModelFromCandidateOutlineProvider(this._editor, y));
			case ModelProvider.FOLDING_PROVIDER_MODEL: this._modelProviders.push(new StickyModelFromCandidateSyntaxFoldingProvider(this._editor, _, y));
			case ModelProvider.INDENTATION_MODEL:
				this._modelProviders.push(new StickyModelFromCandidateIndentationFoldingProvider(this._editor, v));
				break;
		}
	}
	dispose() {
		this._modelProviders.forEach((e) => e.dispose()), this._updateOperation.clear(), this._cancelModelPromise(), super.dispose();
	}
	_cancelModelPromise() {
		this._modelPromise &&= (this._modelPromise.cancel(), null);
	}
	async update(e) {
		return this._updateOperation.clear(), this._updateOperation.add({ dispose: () => {
			this._cancelModelPromise(), this._updateScheduler.cancel();
		} }), this._cancelModelPromise(), await this._updateScheduler.trigger(async () => {
			for (let _ of this._modelProviders) {
				let { statusPromise: v, modelPromise: y } = _.computeStickyModel(e);
				this._modelPromise = y;
				let b = await v;
				if (this._modelPromise !== y) return null;
				switch (b) {
					case Status.CANCELED: return this._updateOperation.clear(), null;
					case Status.VALID: return _.stickyModel;
				}
			}
			return null;
		}).catch((e) => (onUnexpectedError(e), null));
	}
};
StickyModelProvider = __decorate$18([__param$18(2, IInstantiationService), __param$18(3, ILanguageFeaturesService)], StickyModelProvider);
var StickyModelCandidateProvider = class extends Disposable {
	constructor(e) {
		super(), this._editor = e, this._stickyModel = null;
	}
	get stickyModel() {
		return this._stickyModel;
	}
	_invalid() {
		return this._stickyModel = null, Status.INVALID;
	}
	computeStickyModel(e) {
		if (e.isCancellationRequested || !this.isProviderValid()) return {
			statusPromise: this._invalid(),
			modelPromise: null
		};
		let _ = createCancelablePromise((e) => this.createModelFromProvider(e));
		return {
			statusPromise: _.then((_) => this.isModelValid(_) ? e.isCancellationRequested ? Status.CANCELED : (this._stickyModel = this.createStickyModel(e, _), Status.VALID) : this._invalid()).then(void 0, (e) => (onUnexpectedError(e), Status.CANCELED)),
			modelPromise: _
		};
	}
	isModelValid(e) {
		return !0;
	}
	isProviderValid() {
		return !0;
	}
}, StickyModelFromCandidateOutlineProvider = class extends StickyModelCandidateProvider {
	constructor(e, _) {
		super(e), this._languageFeaturesService = _;
	}
	createModelFromProvider(e) {
		return OutlineModel.create(this._languageFeaturesService.documentSymbolProvider, this._editor.getModel(), e);
	}
	createStickyModel(e, _) {
		let { stickyOutlineElement: v, providerID: y } = this._stickyModelFromOutlineModel(_, this._stickyModel?.outlineProviderId), b = this._editor.getModel();
		return new StickyModel(b.uri, b.getVersionId(), v, y);
	}
	isModelValid(e) {
		return e && e.children.size > 0;
	}
	_stickyModelFromOutlineModel(e, _) {
		let v;
		if (Iterable.first(e.children.values()) instanceof OutlineGroup) {
			let y = Iterable.find(e.children.values(), (e) => e.id === _);
			if (y) v = y.children;
			else {
				let y = "", b = -1, x;
				for (let [_, v] of e.children.entries()) {
					let e = this._findSumOfRangesOfGroup(v);
					e > b && (x = v, b = e, y = v.id);
				}
				_ = y, v = x.children;
			}
		} else v = e.children;
		let y = [], b = Array.from(v.values()).sort((e, _) => {
			let v = new StickyRange(e.symbol.range.startLineNumber, e.symbol.range.endLineNumber), y = new StickyRange(_.symbol.range.startLineNumber, _.symbol.range.endLineNumber);
			return this._comparator(v, y);
		});
		for (let e of b) y.push(this._stickyModelFromOutlineElement(e, e.symbol.selectionRange.startLineNumber));
		return {
			stickyOutlineElement: new StickyElement(void 0, y, void 0),
			providerID: _
		};
	}
	_stickyModelFromOutlineElement(e, _) {
		let v = [];
		for (let y of e.children.values()) if (y.symbol.selectionRange.startLineNumber !== y.symbol.range.endLineNumber) if (y.symbol.selectionRange.startLineNumber !== _) v.push(this._stickyModelFromOutlineElement(y, y.symbol.selectionRange.startLineNumber));
		else for (let e of y.children.values()) v.push(this._stickyModelFromOutlineElement(e, y.symbol.selectionRange.startLineNumber));
		v.sort((e, _) => this._comparator(e.range, _.range));
		let y = new StickyRange(e.symbol.selectionRange.startLineNumber, e.symbol.range.endLineNumber);
		return new StickyElement(y, v, void 0);
	}
	_comparator(e, _) {
		return e.startLineNumber === _.startLineNumber ? _.endLineNumber - e.endLineNumber : e.startLineNumber - _.startLineNumber;
	}
	_findSumOfRangesOfGroup(e) {
		let _ = 0;
		for (let v of e.children.values()) _ += this._findSumOfRangesOfGroup(v);
		return e instanceof OutlineElement ? _ + e.symbol.range.endLineNumber - e.symbol.selectionRange.startLineNumber : _;
	}
};
StickyModelFromCandidateOutlineProvider = __decorate$18([__param$18(1, ILanguageFeaturesService)], StickyModelFromCandidateOutlineProvider);
var StickyModelFromCandidateFoldingProvider = class extends StickyModelCandidateProvider {
	constructor(e) {
		super(e), this._foldingLimitReporter = new RangesLimitReporter(e);
	}
	createStickyModel(e, _) {
		let v = this._fromFoldingRegions(_), y = this._editor.getModel();
		return new StickyModel(y.uri, y.getVersionId(), v, void 0);
	}
	isModelValid(e) {
		return e !== null;
	}
	_fromFoldingRegions(e) {
		let _ = e.length, v = [], y = new StickyElement(void 0, [], void 0);
		for (let b = 0; b < _; b++) {
			let _ = e.getParentIndex(b), x;
			x = _ === -1 ? y : v[_];
			let S = new StickyElement(new StickyRange(e.getStartLineNumber(b), e.getEndLineNumber(b) + 1), [], x);
			x.children.push(S), v.push(S);
		}
		return y;
	}
}, StickyModelFromCandidateIndentationFoldingProvider = class extends StickyModelFromCandidateFoldingProvider {
	constructor(e, _) {
		super(e), this._languageConfigurationService = _, this.provider = this._register(new IndentRangeProvider(e.getModel(), this._languageConfigurationService, this._foldingLimitReporter));
	}
	async createModelFromProvider(e) {
		return this.provider.compute(e);
	}
};
StickyModelFromCandidateIndentationFoldingProvider = __decorate$18([__param$18(1, ILanguageConfigurationService)], StickyModelFromCandidateIndentationFoldingProvider);
var StickyModelFromCandidateSyntaxFoldingProvider = class extends StickyModelFromCandidateFoldingProvider {
	constructor(e, _, v) {
		super(e), this._languageFeaturesService = v;
		let y = FoldingController.getFoldingRangeProviders(this._languageFeaturesService, e.getModel());
		y.length > 0 && (this.provider = this._register(new SyntaxRangeProvider(e.getModel(), y, _, this._foldingLimitReporter, void 0)));
	}
	isProviderValid() {
		return this.provider !== void 0;
	}
	async createModelFromProvider(e) {
		return this.provider?.compute(e) ?? null;
	}
};
StickyModelFromCandidateSyntaxFoldingProvider = __decorate$18([__param$18(2, ILanguageFeaturesService)], StickyModelFromCandidateSyntaxFoldingProvider);
var __decorate$17 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$17 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, StickyLineCandidate = class {
	constructor(e, _, v) {
		this.startLineNumber = e, this.endLineNumber = _, this.nestingDepth = v;
	}
}, StickyLineCandidateProvider = class extends Disposable {
	constructor(e, _, v) {
		super(), this._languageFeaturesService = _, this._languageConfigurationService = v, this._onDidChangeStickyScroll = this._register(new Emitter()), this.onDidChangeStickyScroll = this._onDidChangeStickyScroll.event, this._model = null, this._cts = null, this._stickyModelProvider = null, this._editor = e, this._sessionStore = this._register(new DisposableStore()), this._updateSoon = this._register(new RunOnceScheduler(() => this.update(), 50)), this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(116) && this.readConfiguration();
		})), this.readConfiguration();
	}
	readConfiguration() {
		this._sessionStore.clear(), this._editor.getOption(116).enabled && (this._sessionStore.add(this._editor.onDidChangeModel(() => {
			this._model = null, this.updateStickyModelProvider(), this._onDidChangeStickyScroll.fire(), this.update();
		})), this._sessionStore.add(this._editor.onDidChangeHiddenAreas(() => this.update())), this._sessionStore.add(this._editor.onDidChangeModelContent(() => this._updateSoon.schedule())), this._sessionStore.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(() => this.update())), this._sessionStore.add(toDisposable(() => {
			this._stickyModelProvider?.dispose(), this._stickyModelProvider = null;
		})), this.updateStickyModelProvider(), this.update());
	}
	getVersionId() {
		return this._model?.version;
	}
	updateStickyModelProvider() {
		this._stickyModelProvider?.dispose(), this._stickyModelProvider = null;
		let e = this._editor;
		e.hasModel() && (this._stickyModelProvider = new StickyModelProvider(e, () => this._updateSoon.schedule(), this._languageConfigurationService, this._languageFeaturesService));
	}
	async update() {
		this._cts?.dispose(!0), this._cts = new CancellationTokenSource(), await this.updateStickyModel(this._cts.token), this._onDidChangeStickyScroll.fire();
	}
	async updateStickyModel(e) {
		if (!this._editor.hasModel() || !this._stickyModelProvider || this._editor.getModel().isTooLargeForTokenization()) {
			this._model = null;
			return;
		}
		let _ = await this._stickyModelProvider.update(e);
		e.isCancellationRequested || (this._model = _);
	}
	updateIndex(e) {
		return e === -1 ? e = 0 : e < 0 && (e = -e - 2), e;
	}
	getCandidateStickyLinesIntersectingFromStickyModel(e, _, v, y, b) {
		if (_.children.length === 0) return;
		let x = b, S = [];
		for (let e = 0; e < _.children.length; e++) {
			let v = _.children[e];
			v.range && S.push(v.range.startLineNumber);
		}
		let C = this.updateIndex(binarySearch(S, e.startLineNumber, (e, _) => e - _)), w = this.updateIndex(binarySearch(S, e.startLineNumber + y, (e, _) => e - _));
		for (let S = C; S <= w; S++) {
			let C = _.children[S];
			if (!C) return;
			if (C.range) {
				let _ = C.range.startLineNumber, b = C.range.endLineNumber;
				e.startLineNumber <= b + 1 && _ - 1 <= e.endLineNumber && _ !== x && (x = _, v.push(new StickyLineCandidate(_, b - 1, y + 1)), this.getCandidateStickyLinesIntersectingFromStickyModel(e, C, v, y + 1, _));
			} else this.getCandidateStickyLinesIntersectingFromStickyModel(e, C, v, y, b);
		}
	}
	getCandidateStickyLinesIntersecting(e) {
		if (!this._model?.element) return [];
		let _ = [];
		this.getCandidateStickyLinesIntersectingFromStickyModel(e, this._model.element, _, 0, -1);
		let v = this._editor._getViewModel()?.getHiddenAreas();
		if (v) for (let e of v) _ = _.filter((_) => !(_.startLineNumber >= e.startLineNumber && _.endLineNumber <= e.endLineNumber + 1));
		return _;
	}
};
StickyLineCandidateProvider = __decorate$17([__param$17(1, ILanguageFeaturesService), __param$17(2, ILanguageConfigurationService)], StickyLineCandidateProvider);
var __decorate$16 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$16 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, StickyScrollController_1, StickyScrollController = class extends Disposable {
	static {
		StickyScrollController_1 = this;
	}
	static {
		this.ID = "store.contrib.stickyScrollController";
	}
	constructor(e, _, v, y, b, x, S) {
		super(), this._editor = e, this._contextMenuService = _, this._languageFeaturesService = v, this._instaService = y, this._contextKeyService = S, this._sessionStore = new DisposableStore(), this._maxStickyLines = 2 ** 53 - 1, this._candidateDefinitionsLength = -1, this._focusedStickyElementIndex = -1, this._enabled = !1, this._focused = !1, this._positionRevealed = !1, this._onMouseDown = !1, this._endLineNumbers = [], this._stickyScrollWidget = new StickyScrollWidget(this._editor), this._stickyLineCandidateProvider = new StickyLineCandidateProvider(this._editor, v, b), this._register(this._stickyScrollWidget), this._register(this._stickyLineCandidateProvider), this._widgetState = StickyScrollWidgetState.Empty, this._onDidResize(), this._readConfiguration();
		let C = this._stickyScrollWidget.getDomNode();
		this._register(this._editor.onDidChangeConfiguration((e) => {
			this._readConfigurationChange(e);
		})), this._register(addDisposableListener(C, EventType$1.CONTEXT_MENU, async (e) => {
			this._onContextMenu(getWindow(C), e);
		})), this._stickyScrollFocusedContextKey = EditorContextKeys.stickyScrollFocused.bindTo(this._contextKeyService), this._stickyScrollVisibleContextKey = EditorContextKeys.stickyScrollVisible.bindTo(this._contextKeyService);
		let w = this._register(trackFocus(C));
		this._register(w.onDidBlur((e) => {
			this._positionRevealed === !1 && C.clientHeight === 0 ? (this._focusedStickyElementIndex = -1, this.focus()) : this._disposeFocusStickyScrollStore();
		})), this._register(w.onDidFocus((e) => {
			this.focus();
		})), this._registerMouseListeners(), this._register(addDisposableListener(C, EventType$1.MOUSE_DOWN, (e) => {
			this._onMouseDown = !0;
		}));
	}
	static get(e) {
		return e.getContribution(StickyScrollController_1.ID);
	}
	_disposeFocusStickyScrollStore() {
		this._stickyScrollFocusedContextKey.set(!1), this._focusDisposableStore?.dispose(), this._focused = !1, this._positionRevealed = !1, this._onMouseDown = !1;
	}
	focus() {
		if (this._onMouseDown) {
			this._onMouseDown = !1, this._editor.focus();
			return;
		}
		this._stickyScrollFocusedContextKey.get() !== !0 && (this._focused = !0, this._focusDisposableStore = new DisposableStore(), this._stickyScrollFocusedContextKey.set(!0), this._focusedStickyElementIndex = this._stickyScrollWidget.lineNumbers.length - 1, this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex));
	}
	focusNext() {
		this._focusedStickyElementIndex < this._stickyScrollWidget.lineNumberCount - 1 && this._focusNav(!0);
	}
	focusPrevious() {
		this._focusedStickyElementIndex > 0 && this._focusNav(!1);
	}
	selectEditor() {
		this._editor.focus();
	}
	_focusNav(e) {
		this._focusedStickyElementIndex = e ? this._focusedStickyElementIndex + 1 : this._focusedStickyElementIndex - 1, this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);
	}
	goToFocused() {
		let e = this._stickyScrollWidget.lineNumbers;
		this._disposeFocusStickyScrollStore(), this._revealPosition({
			lineNumber: e[this._focusedStickyElementIndex],
			column: 1
		});
	}
	_revealPosition(e) {
		this._reveaInEditor(e, () => this._editor.revealPosition(e));
	}
	_revealLineInCenterIfOutsideViewport(e) {
		this._reveaInEditor(e, () => this._editor.revealLineInCenterIfOutsideViewport(e.lineNumber, 0));
	}
	_reveaInEditor(e, _) {
		this._focused && this._disposeFocusStickyScrollStore(), this._positionRevealed = !0, _(), this._editor.setSelection(Range.fromPositions(e)), this._editor.focus();
	}
	_registerMouseListeners() {
		let e = this._register(new DisposableStore()), _ = this._register(new ClickLinkGesture(this._editor, { extractLineNumberFromMouseEvent: (e) => {
			let _ = this._stickyScrollWidget.getEditorPositionFromNode(e.target.element);
			return _ ? _.lineNumber : 0;
		} })), v = (e) => {
			if (!this._editor.hasModel() || e.target.type !== 12 || e.target.detail !== this._stickyScrollWidget.getId()) return null;
			let _ = e.target.element;
			if (!_ || _.innerText !== _.innerHTML) return null;
			let v = this._stickyScrollWidget.getEditorPositionFromNode(_);
			return v ? {
				range: new Range(v.lineNumber, v.column, v.lineNumber, v.column + _.innerText.length),
				textElement: _
			} : null;
		}, y = this._stickyScrollWidget.getDomNode();
		this._register(addStandardDisposableListener(y, EventType$1.CLICK, (e) => {
			if (e.ctrlKey || e.altKey || e.metaKey || !e.leftButton) return;
			if (e.shiftKey) {
				let _ = this._stickyScrollWidget.getLineIndexFromChildDomNode(e.target);
				if (_ === null) return;
				let v = new Position(this._endLineNumbers[_], 1);
				this._revealLineInCenterIfOutsideViewport(v);
				return;
			}
			if (this._stickyScrollWidget.isInFoldingIconDomNode(e.target)) {
				let _ = this._stickyScrollWidget.getLineNumberFromChildDomNode(e.target);
				this._toggleFoldingRegionForLine(_);
				return;
			}
			if (!this._stickyScrollWidget.isInStickyLine(e.target)) return;
			let _ = this._stickyScrollWidget.getEditorPositionFromNode(e.target);
			if (!_) {
				let v = this._stickyScrollWidget.getLineNumberFromChildDomNode(e.target);
				if (v === null) return;
				_ = new Position(v, 1);
			}
			this._revealPosition(_);
		})), this._register(addStandardDisposableListener(y, EventType$1.MOUSE_MOVE, (e) => {
			if (e.shiftKey) {
				let _ = this._stickyScrollWidget.getLineIndexFromChildDomNode(e.target);
				if (_ === null || this._showEndForLine !== null && this._showEndForLine === _) return;
				this._showEndForLine = _, this._renderStickyScroll();
				return;
			}
			this._showEndForLine !== void 0 && (this._showEndForLine = void 0, this._renderStickyScroll());
		})), this._register(addDisposableListener(y, EventType$1.MOUSE_LEAVE, (e) => {
			this._showEndForLine !== void 0 && (this._showEndForLine = void 0, this._renderStickyScroll());
		})), this._register(_.onMouseMoveOrRelevantKeyDown(([_, y]) => {
			let b = v(_);
			if (!b || !_.hasTriggerModifier || !this._editor.hasModel()) {
				e.clear();
				return;
			}
			let { range: x, textElement: S } = b;
			if (!x.equalsRange(this._stickyRangeProjectedOnEditor)) this._stickyRangeProjectedOnEditor = x, e.clear();
			else if (S.style.textDecoration === "underline") return;
			let C = new CancellationTokenSource();
			e.add(toDisposable(() => C.dispose(!0)));
			let w;
			getDefinitionsAtPosition(this._languageFeaturesService.definitionProvider, this._editor.getModel(), new Position(x.startLineNumber, x.startColumn + 1), !1, C.token).then(((_) => {
				if (!C.token.isCancellationRequested) if (_.length !== 0) {
					this._candidateDefinitionsLength = _.length;
					let v = S;
					w === v ? w || (w = v, w.style.textDecoration = "underline", e.add(toDisposable(() => {
						w.style.textDecoration = "none";
					}))) : (e.clear(), w = v, w.style.textDecoration = "underline", e.add(toDisposable(() => {
						w.style.textDecoration = "none";
					})));
				} else e.clear();
			}));
		})), this._register(_.onCancel(() => {
			e.clear();
		})), this._register(_.onExecute(async (e) => {
			if (e.target.type !== 12 || e.target.detail !== this._stickyScrollWidget.getId()) return;
			let _ = this._stickyScrollWidget.getEditorPositionFromNode(e.target.element);
			_ && (!this._editor.hasModel() || !this._stickyRangeProjectedOnEditor || (this._candidateDefinitionsLength > 1 && (this._focused && this._disposeFocusStickyScrollStore(), this._revealPosition({
				lineNumber: _.lineNumber,
				column: 1
			})), this._instaService.invokeFunction(goToDefinitionWithLocation, e, this._editor, {
				uri: this._editor.getModel().uri,
				range: this._stickyRangeProjectedOnEditor
			})));
		}));
	}
	_onContextMenu(e, _) {
		let v = new StandardMouseEvent(e, _);
		this._contextMenuService.showContextMenu({
			menuId: MenuId.StickyScrollContext,
			getAnchor: () => v
		});
	}
	_toggleFoldingRegionForLine(e) {
		if (!this._foldingModel || e === null) return;
		let _ = this._stickyScrollWidget.getRenderedStickyLine(e), v = _?.foldingIcon;
		if (!v) return;
		toggleCollapseState(this._foldingModel, Number.MAX_VALUE, [e]), v.isCollapsed = !v.isCollapsed;
		let y = (v.isCollapsed ? this._editor.getTopForLineNumber(v.foldingEndLine) : this._editor.getTopForLineNumber(v.foldingStartLine)) - this._editor.getOption(67) * _.index + 1;
		this._editor.setScrollTop(y), this._renderStickyScroll(e);
	}
	_readConfiguration() {
		let e = this._editor.getOption(116);
		if (e.enabled === !1) {
			this._editor.removeOverlayWidget(this._stickyScrollWidget), this._sessionStore.clear(), this._enabled = !1;
			return;
		} else e.enabled && !this._enabled && (this._editor.addOverlayWidget(this._stickyScrollWidget), this._sessionStore.add(this._editor.onDidScrollChange((e) => {
			e.scrollTopChanged && (this._showEndForLine = void 0, this._renderStickyScroll());
		})), this._sessionStore.add(this._editor.onDidLayoutChange(() => this._onDidResize())), this._sessionStore.add(this._editor.onDidChangeModelTokens((e) => this._onTokensChange(e))), this._sessionStore.add(this._stickyLineCandidateProvider.onDidChangeStickyScroll(() => {
			this._showEndForLine = void 0, this._renderStickyScroll();
		})), this._enabled = !0);
		this._editor.getOption(68).renderType === 2 && this._sessionStore.add(this._editor.onDidChangeCursorPosition(() => {
			this._showEndForLine = void 0, this._renderStickyScroll(0);
		}));
	}
	_readConfigurationChange(e) {
		(e.hasChanged(116) || e.hasChanged(73) || e.hasChanged(67) || e.hasChanged(111) || e.hasChanged(68)) && this._readConfiguration(), e.hasChanged(68) && this._renderStickyScroll(0);
	}
	_needsUpdate(e) {
		let _ = this._stickyScrollWidget.getCurrentLines();
		for (let v of _) for (let _ of e.ranges) if (v >= _.fromLineNumber && v <= _.toLineNumber) return !0;
		return !1;
	}
	_onTokensChange(e) {
		this._needsUpdate(e) && this._renderStickyScroll(0);
	}
	_onDidResize() {
		let e = this._editor.getLayoutInfo().height / this._editor.getOption(67);
		this._maxStickyLines = Math.round(e * .25);
	}
	async _renderStickyScroll(e) {
		let _ = this._editor.getModel();
		if (!_ || _.isTooLargeForTokenization()) {
			this._resetState();
			return;
		}
		let v = this._updateAndGetMinRebuildFromLine(e), y = this._stickyLineCandidateProvider.getVersionId();
		if (y === void 0 || y === _.getVersionId()) if (!this._focused) await this._updateState(v);
		else if (this._focusedStickyElementIndex === -1) await this._updateState(v), this._focusedStickyElementIndex = this._stickyScrollWidget.lineNumberCount - 1, this._focusedStickyElementIndex !== -1 && this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);
		else {
			let e = this._stickyScrollWidget.lineNumbers[this._focusedStickyElementIndex];
			await this._updateState(v), this._stickyScrollWidget.lineNumberCount === 0 ? this._focusedStickyElementIndex = -1 : (this._stickyScrollWidget.lineNumbers.includes(e) || (this._focusedStickyElementIndex = this._stickyScrollWidget.lineNumberCount - 1), this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex));
		}
	}
	_updateAndGetMinRebuildFromLine(e) {
		if (e !== void 0) {
			let _ = this._minRebuildFromLine === void 0 ? Infinity : this._minRebuildFromLine;
			this._minRebuildFromLine = Math.min(e, _);
		}
		return this._minRebuildFromLine;
	}
	async _updateState(e) {
		this._minRebuildFromLine = void 0, this._foldingModel = await FoldingController.get(this._editor)?.getFoldingModel() ?? void 0, this._widgetState = this.findScrollWidgetState();
		let _ = this._widgetState.startLineNumbers.length > 0;
		this._stickyScrollVisibleContextKey.set(_), this._stickyScrollWidget.setState(this._widgetState, this._foldingModel, e);
	}
	async _resetState() {
		this._minRebuildFromLine = void 0, this._foldingModel = void 0, this._widgetState = StickyScrollWidgetState.Empty, this._stickyScrollVisibleContextKey.set(!1), this._stickyScrollWidget.setState(void 0, void 0);
	}
	findScrollWidgetState() {
		let e = this._editor.getOption(67), _ = Math.min(this._maxStickyLines, this._editor.getOption(116).maxLineCount), v = this._editor.getScrollTop(), y = 0, b = [], x = [], S = this._editor.getVisibleRanges();
		if (S.length !== 0) {
			let C = new StickyRange(S[0].startLineNumber, S[S.length - 1].endLineNumber), w = this._stickyLineCandidateProvider.getCandidateStickyLinesIntersecting(C);
			for (let S of w) {
				let C = S.startLineNumber, w = S.endLineNumber, T = S.nestingDepth;
				if (w - C > 0) {
					let S = (T - 1) * e, E = T * e, D = this._editor.getBottomForLineNumber(C) - v, O = this._editor.getTopForLineNumber(w) - v, k = this._editor.getBottomForLineNumber(w) - v;
					if (S > O && S <= k) {
						b.push(C), x.push(w + 1), y = k - E;
						break;
					} else E > D && E <= k && (b.push(C), x.push(w + 1));
					if (b.length === _) break;
				}
			}
		}
		return this._endLineNumbers = x, new StickyScrollWidgetState(b, x, y, this._showEndForLine);
	}
	dispose() {
		super.dispose(), this._sessionStore.dispose();
	}
};
StickyScrollController = StickyScrollController_1 = __decorate$16([
	__param$16(1, IContextMenuService),
	__param$16(2, ILanguageFeaturesService),
	__param$16(3, IInstantiationService),
	__param$16(4, ILanguageConfigurationService),
	__param$16(5, ILanguageFeatureDebounceService),
	__param$16(6, IContextKeyService)
], StickyScrollController);
var ToggleStickyScroll = class extends Action2 {
	constructor() {
		super({
			id: "editor.action.toggleStickyScroll",
			title: {
				...localize2("toggleEditorStickyScroll", "Toggle Editor Sticky Scroll"),
				mnemonicTitle: localize({
					key: "mitoggleStickyScroll",
					comment: ["&& denotes a mnemonic"]
				}, "&&Toggle Editor Sticky Scroll")
			},
			metadata: { description: localize2("toggleEditorStickyScroll.description", "Toggle/enable the editor sticky scroll which shows the nested scopes at the top of the viewport") },
			category: Categories.View,
			toggled: {
				condition: ContextKeyExpr.equals("config.editor.stickyScroll.enabled", !0),
				title: localize("stickyScroll", "Sticky Scroll"),
				mnemonicTitle: localize({
					key: "miStickyScroll",
					comment: ["&& denotes a mnemonic"]
				}, "&&Sticky Scroll")
			},
			menu: [
				{ id: MenuId.CommandPalette },
				{
					id: MenuId.MenubarAppearanceMenu,
					group: "4_editor",
					order: 3
				},
				{ id: MenuId.StickyScrollContext }
			]
		});
	}
	async run(e) {
		let _ = e.get(IConfigurationService), v = !_.getValue("editor.stickyScroll.enabled");
		return _.updateValue("editor.stickyScroll.enabled", v);
	}
}, weight = 100, FocusStickyScroll = class extends EditorAction2 {
	constructor() {
		super({
			id: "editor.action.focusStickyScroll",
			title: {
				...localize2("focusStickyScroll", "Focus on the editor sticky scroll"),
				mnemonicTitle: localize({
					key: "mifocusStickyScroll",
					comment: ["&& denotes a mnemonic"]
				}, "&&Focus Sticky Scroll")
			},
			precondition: ContextKeyExpr.and(ContextKeyExpr.has("config.editor.stickyScroll.enabled"), EditorContextKeys.stickyScrollVisible),
			menu: [{ id: MenuId.CommandPalette }]
		});
	}
	runEditorCommand(e, _) {
		StickyScrollController.get(_)?.focus();
	}
}, SelectNextStickyScrollLine = class extends EditorAction2 {
	constructor() {
		super({
			id: "editor.action.selectNextStickyScrollLine",
			title: localize2("selectNextStickyScrollLine.title", "Select the next editor sticky scroll line"),
			precondition: EditorContextKeys.stickyScrollFocused.isEqualTo(!0),
			keybinding: {
				weight,
				primary: 18
			}
		});
	}
	runEditorCommand(e, _) {
		StickyScrollController.get(_)?.focusNext();
	}
}, SelectPreviousStickyScrollLine = class extends EditorAction2 {
	constructor() {
		super({
			id: "editor.action.selectPreviousStickyScrollLine",
			title: localize2("selectPreviousStickyScrollLine.title", "Select the previous sticky scroll line"),
			precondition: EditorContextKeys.stickyScrollFocused.isEqualTo(!0),
			keybinding: {
				weight,
				primary: 16
			}
		});
	}
	runEditorCommand(e, _) {
		StickyScrollController.get(_)?.focusPrevious();
	}
}, GoToStickyScrollLine = class extends EditorAction2 {
	constructor() {
		super({
			id: "editor.action.goToFocusedStickyScrollLine",
			title: localize2("goToFocusedStickyScrollLine.title", "Go to the focused sticky scroll line"),
			precondition: EditorContextKeys.stickyScrollFocused.isEqualTo(!0),
			keybinding: {
				weight,
				primary: 3
			}
		});
	}
	runEditorCommand(e, _) {
		StickyScrollController.get(_)?.goToFocused();
	}
}, SelectEditor = class extends EditorAction2 {
	constructor() {
		super({
			id: "editor.action.selectEditor",
			title: localize2("selectEditor.title", "Select Editor"),
			precondition: EditorContextKeys.stickyScrollFocused.isEqualTo(!0),
			keybinding: {
				weight,
				primary: 9
			}
		});
	}
	runEditorCommand(e, _) {
		StickyScrollController.get(_)?.selectEditor();
	}
};
registerEditorContribution(StickyScrollController.ID, StickyScrollController, 1), registerAction2(ToggleStickyScroll), registerAction2(FocusStickyScroll), registerAction2(SelectPreviousStickyScrollLine), registerAction2(SelectNextStickyScrollLine), registerAction2(GoToStickyScrollLine), registerAction2(SelectEditor);
var __decorate$15 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$15 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, SuggestInlineCompletion = class {
	constructor(e, _, v, y, b, x) {
		this.range = e, this.insertText = _, this.filterText = v, this.additionalTextEdits = y, this.command = b, this.completion = x;
	}
}, InlineCompletionResults = class extends RefCountedDisposable {
	constructor(e, _, v, y, b, x) {
		super(b.disposable), this.model = e, this.line = _, this.word = v, this.completionModel = y, this._suggestMemoryService = x;
	}
	canBeReused(e, _, v) {
		return this.model === e && this.line === _ && this.word.word.length > 0 && this.word.startColumn === v.startColumn && this.word.endColumn < v.endColumn && this.completionModel.getIncompleteProvider().size === 0;
	}
	get items() {
		let e = [], { items: _ } = this.completionModel, v = this._suggestMemoryService.select(this.model, {
			lineNumber: this.line,
			column: this.word.endColumn + this.completionModel.lineContext.characterCountDelta
		}, _), y = Iterable.slice(_, v), b = Iterable.slice(_, 0, v), x = 5;
		for (let _ of Iterable.concat(y, b)) {
			if (_.score === FuzzyScore.Default) continue;
			let v = new Range(_.editStart.lineNumber, _.editStart.column, _.editInsertEnd.lineNumber, _.editInsertEnd.column + this.completionModel.lineContext.characterCountDelta), y = _.completion.insertTextRules && _.completion.insertTextRules & 4 ? { snippet: _.completion.insertText } : _.completion.insertText;
			e.push(new SuggestInlineCompletion(v, y, _.filterTextLow ?? _.labelLow, _.completion.additionalTextEdits, _.completion.command, _)), x-- >= 0 && _.resolve(CancellationToken.None);
		}
		return e;
	}
};
InlineCompletionResults = __decorate$15([__param$15(5, ISuggestMemoryService)], InlineCompletionResults);
var SuggestInlineCompletions = class extends Disposable {
	constructor(e, _, v, y) {
		super(), this._languageFeatureService = e, this._clipboardService = _, this._suggestMemoryService = v, this._editorService = y, this._store.add(e.inlineCompletionsProvider.register("*", this));
	}
	async provideInlineCompletions(e, _, v, y) {
		if (v.selectedSuggestionInfo) return;
		let b;
		for (let _ of this._editorService.listCodeEditors()) if (_.getModel() === e) {
			b = _;
			break;
		}
		if (!b) return;
		let x = b.getOption(90);
		if (QuickSuggestionsOptions.isAllOff(x)) return;
		e.tokenization.tokenizeIfCheap(_.lineNumber);
		let S = e.tokenization.getLineTokens(_.lineNumber), C = S.getStandardTokenType(S.findTokenIndexAtOffset(Math.max(_.column - 1 - 1, 0)));
		if (QuickSuggestionsOptions.valueFor(x, C) !== "inline") return;
		let w = e.getWordAtPosition(_), T;
		if (w?.word || (T = this._getTriggerCharacterInfo(e, _)), !w?.word && !T || (w ||= e.getWordUntilPosition(_), w.endColumn !== _.column)) return;
		let E, D = e.getValueInRange(new Range(_.lineNumber, 1, _.lineNumber, _.column));
		if (!T && this._lastResult?.canBeReused(e, _.lineNumber, w)) {
			let e = new LineContext(D, _.column - this._lastResult.word.endColumn);
			this._lastResult.completionModel.lineContext = e, this._lastResult.acquire(), E = this._lastResult;
		} else {
			let v = await provideSuggestionItems(this._languageFeatureService.completionProvider, e, _, new CompletionOptions(void 0, SuggestModel.createSuggestFilter(b).itemKind, T?.providers), T && {
				triggerKind: 1,
				triggerCharacter: T.ch
			}, y), x;
			v.needsClipboard && (x = await this._clipboardService.readText());
			let S = new CompletionModel(v.items, _.column, new LineContext(D, 0), WordDistance.None, b.getOption(119), b.getOption(113), {
				boostFullMatch: !1,
				firstMatchCanBeWeak: !1
			}, x);
			E = new InlineCompletionResults(e, _.lineNumber, w, S, v, this._suggestMemoryService);
		}
		return this._lastResult = E, E;
	}
	handleItemDidShow(e, _) {
		_.completion.resolve(CancellationToken.None);
	}
	freeInlineCompletions(e) {
		e.release();
	}
	_getTriggerCharacterInfo(e, _) {
		let v = e.getValueInRange(Range.fromPositions({
			lineNumber: _.lineNumber,
			column: _.column - 1
		}, _)), y = /* @__PURE__ */ new Set();
		for (let _ of this._languageFeatureService.completionProvider.all(e)) _.triggerCharacters?.includes(v) && y.add(_);
		if (y.size !== 0) return {
			providers: y,
			ch: v
		};
	}
};
SuggestInlineCompletions = __decorate$15([
	__param$15(0, ILanguageFeaturesService),
	__param$15(1, IClipboardService),
	__param$15(2, ISuggestMemoryService),
	__param$15(3, ICodeEditorService)
], SuggestInlineCompletions), registerEditorFeature(SuggestInlineCompletions), registerEditorAction(class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.forceRetokenize",
			label: localize("forceRetokenize", "Developer: Force Retokenize"),
			alias: "Developer: Force Retokenize",
			precondition: void 0
		});
	}
	run(e, _) {
		if (!_.hasModel()) return;
		let v = _.getModel();
		v.tokenization.resetTokenization();
		let y = new StopWatch();
		v.tokenization.forceTokenization(v.getLineCount()), y.stop(), console.log(`tokenization took ${y.elapsed()}`);
	}
});
var ToggleTabFocusModeAction = class e extends Action2 {
	static {
		this.ID = "editor.action.toggleTabFocusMode";
	}
	constructor() {
		super({
			id: e.ID,
			title: localize2({
				key: "toggle.tabMovesFocus",
				comment: ["Turn on/off use of tab key for moving focus around VS Code"]
			}, "Toggle Tab Key Moves Focus"),
			precondition: void 0,
			keybinding: {
				primary: 2091,
				mac: { primary: 1323 },
				weight: 100
			},
			metadata: { description: localize2("tabMovesFocusDescriptions", "Determines whether the tab key moves focus around the workbench or inserts the tab character in the current editor. This is also called tab trapping, tab navigation, or tab focus mode.") },
			f1: !0
		});
	}
	run() {
		let e = !TabFocus.getTabFocusMode();
		TabFocus.setTabFocusMode(e), alert(e ? localize("toggle.tabMovesFocus.on", "Pressing Tab will now move focus to the next focusable element") : localize("toggle.tabMovesFocus.off", "Pressing Tab will now insert the tab character"));
	}
};
registerAction2(ToggleTabFocusModeAction);
var __decorate$14 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$14 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, Link = class extends Disposable {
	get enabled() {
		return this._enabled;
	}
	set enabled(e) {
		e ? (this.el.setAttribute("aria-disabled", "false"), this.el.tabIndex = 0, this.el.style.pointerEvents = "auto", this.el.style.opacity = "1", this.el.style.cursor = "pointer", this._enabled = !1) : (this.el.setAttribute("aria-disabled", "true"), this.el.tabIndex = -1, this.el.style.pointerEvents = "none", this.el.style.opacity = "0.4", this.el.style.cursor = "default", this._enabled = !0), this._enabled = e;
	}
	constructor(e, _, v = {}, y, b) {
		super(), this._link = _, this._hoverService = y, this._enabled = !0, this.el = append(e, $("a.monaco-link", {
			tabIndex: _.tabIndex ?? 0,
			href: _.href
		}, _.label)), this.hoverDelegate = v.hoverDelegate ?? getDefaultHoverDelegate("mouse"), this.setTooltip(_.title), this.el.setAttribute("role", "button");
		let x = this._register(new DomEmitter(this.el, "click")), S = this._register(new DomEmitter(this.el, "keypress")), C = Event.chain(S.event, (e) => e.map((e) => new StandardKeyboardEvent(e)).filter((e) => e.keyCode === 3)), w = this._register(new DomEmitter(this.el, EventType.Tap)).event;
		this._register(Gesture.addTarget(this.el));
		let T = Event.any(x.event, C, w);
		this._register(T((e) => {
			this.enabled && (EventHelper.stop(e, !0), v?.opener ? v.opener(this._link.href) : b.open(this._link.href, { allowCommands: !0 }));
		})), this.enabled = !0;
	}
	setTooltip(e) {
		this.hoverDelegate.showNativeHover ? this.el.title = e ?? "" : !this.hover && e ? this.hover = this._register(this._hoverService.setupManagedHover(this.hoverDelegate, this.el, e)) : this.hover && this.hover.update(e);
	}
};
Link = __decorate$14([__param$14(3, IHoverService), __param$14(4, IOpenerService)], Link);
var __decorate$13 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$13 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, BANNER_ELEMENT_HEIGHT = 26, BannerController = class extends Disposable {
	constructor(e, _) {
		super(), this._editor = e, this.instantiationService = _, this.banner = this._register(this.instantiationService.createInstance(Banner));
	}
	hide() {
		this._editor.setBanner(null, 0), this.banner.clear();
	}
	show(e) {
		this.banner.show({
			...e,
			onClose: () => {
				this.hide(), e.onClose?.();
			}
		}), this._editor.setBanner(this.banner.element, BANNER_ELEMENT_HEIGHT);
	}
};
BannerController = __decorate$13([__param$13(1, IInstantiationService)], BannerController);
var Banner = class extends Disposable {
	constructor(e) {
		super(), this.instantiationService = e, this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {}), this.element = $("div.editor-banner"), this.element.tabIndex = 0;
	}
	getAriaLabel(e) {
		if (e.ariaLabel) return e.ariaLabel;
		if (typeof e.message == "string") return e.message;
	}
	getBannerMessage(e) {
		if (typeof e == "string") {
			let _ = $("span");
			return _.innerText = e, _;
		}
		return this.markdownRenderer.render(e).element;
	}
	clear() {
		clearNode(this.element);
	}
	show(e) {
		clearNode(this.element);
		let _ = this.getAriaLabel(e);
		_ && this.element.setAttribute("aria-label", _);
		let v = append(this.element, $("div.icon-container"));
		v.setAttribute("aria-hidden", "true"), e.icon && v.appendChild($(`div${ThemeIcon.asCSSSelector(e.icon)}`));
		let y = append(this.element, $("div.message-container"));
		if (y.setAttribute("aria-hidden", "true"), y.appendChild(this.getBannerMessage(e.message)), this.messageActionsContainer = append(this.element, $("div.message-actions-container")), e.actions) for (let _ of e.actions) this._register(this.instantiationService.createInstance(Link, this.messageActionsContainer, {
			..._,
			tabIndex: -1
		}, {}));
		let b = append(this.element, $("div.action-container"));
		this.actionBar = this._register(new ActionBar(b)), this.actionBar.push(this._register(new Action("banner.close", "Close Banner", ThemeIcon.asClassName(widgetClose), !0, () => {
			typeof e.onClose == "function" && e.onClose();
		})), {
			icon: !0,
			label: !1
		}), this.actionBar.setFocusable(!1);
	}
};
Banner = __decorate$13([__param$13(0, IInstantiationService)], Banner);
var __decorate$12 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$12 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
};
const warningIcon = registerIcon("extensions-warning-message", Codicon.warning, localize("warningIcon", "Icon shown with a warning message in the extensions editor."));
var UnicodeHighlighter = class extends Disposable {
	static {
		this.ID = "editor.contrib.unicodeHighlighter";
	}
	constructor(e, _, v, y) {
		super(), this._editor = e, this._editorWorkerService = _, this._workspaceTrustService = v, this._highlighter = null, this._bannerClosed = !1, this._updateState = (e) => {
			if (e && e.hasMore) {
				if (this._bannerClosed) return;
				let _ = Math.max(e.ambiguousCharacterCount, e.nonBasicAsciiCharacterCount, e.invisibleCharacterCount), v;
				if (e.nonBasicAsciiCharacterCount >= _) v = {
					message: localize("unicodeHighlighting.thisDocumentHasManyNonBasicAsciiUnicodeCharacters", "This document contains many non-basic ASCII unicode characters"),
					command: new DisableHighlightingOfNonBasicAsciiCharactersAction()
				};
				else if (e.ambiguousCharacterCount >= _) v = {
					message: localize("unicodeHighlighting.thisDocumentHasManyAmbiguousUnicodeCharacters", "This document contains many ambiguous unicode characters"),
					command: new DisableHighlightingOfAmbiguousCharactersAction()
				};
				else if (e.invisibleCharacterCount >= _) v = {
					message: localize("unicodeHighlighting.thisDocumentHasManyInvisibleUnicodeCharacters", "This document contains many invisible unicode characters"),
					command: new DisableHighlightingOfInvisibleCharactersAction()
				};
				else throw Error("Unreachable");
				this._bannerController.show({
					id: "unicodeHighlightBanner",
					message: v.message,
					icon: warningIcon,
					actions: [{
						label: v.command.shortLabel,
						href: `command:${v.command.id}`
					}],
					onClose: () => {
						this._bannerClosed = !0;
					}
				});
			} else this._bannerController.hide();
		}, this._bannerController = this._register(y.createInstance(BannerController, e)), this._register(this._editor.onDidChangeModel(() => {
			this._bannerClosed = !1, this._updateHighlighter();
		})), this._options = e.getOption(126), this._register(v.onDidChangeTrust((e) => {
			this._updateHighlighter();
		})), this._register(e.onDidChangeConfiguration((_) => {
			_.hasChanged(126) && (this._options = e.getOption(126), this._updateHighlighter());
		})), this._updateHighlighter();
	}
	dispose() {
		this._highlighter &&= (this._highlighter.dispose(), null), super.dispose();
	}
	_updateHighlighter() {
		if (this._updateState(null), this._highlighter &&= (this._highlighter.dispose(), null), !this._editor.hasModel()) return;
		let e = resolveOptions(this._workspaceTrustService.isWorkspaceTrusted(), this._options);
		if ([
			e.nonBasicASCII,
			e.ambiguousCharacters,
			e.invisibleCharacters
		].every((e) => e === !1)) return;
		let _ = {
			nonBasicASCII: e.nonBasicASCII,
			ambiguousCharacters: e.ambiguousCharacters,
			invisibleCharacters: e.invisibleCharacters,
			includeComments: e.includeComments,
			includeStrings: e.includeStrings,
			allowedCodePoints: Object.keys(e.allowedCharacters).map((e) => e.codePointAt(0)),
			allowedLocales: Object.keys(e.allowedLocales).map((e) => e === "_os" ? new Intl.NumberFormat().resolvedOptions().locale : e === "_vscode" ? language : e)
		};
		this._editorWorkerService.canComputeUnicodeHighlights(this._editor.getModel().uri) ? this._highlighter = new DocumentUnicodeHighlighter(this._editor, _, this._updateState, this._editorWorkerService) : this._highlighter = new ViewportUnicodeHighlighter(this._editor, _, this._updateState);
	}
	getDecorationInfo(e) {
		return this._highlighter ? this._highlighter.getDecorationInfo(e) : null;
	}
};
UnicodeHighlighter = __decorate$12([
	__param$12(1, IEditorWorkerService),
	__param$12(2, IWorkspaceTrustManagementService),
	__param$12(3, IInstantiationService)
], UnicodeHighlighter);
function resolveOptions(e, _) {
	return {
		nonBasicASCII: _.nonBasicASCII === "inUntrustedWorkspace" ? !e : _.nonBasicASCII,
		ambiguousCharacters: _.ambiguousCharacters,
		invisibleCharacters: _.invisibleCharacters,
		includeComments: _.includeComments === "inUntrustedWorkspace" ? !e : _.includeComments,
		includeStrings: _.includeStrings === "inUntrustedWorkspace" ? !e : _.includeStrings,
		allowedCharacters: _.allowedCharacters,
		allowedLocales: _.allowedLocales
	};
}
var DocumentUnicodeHighlighter = class extends Disposable {
	constructor(e, _, v, y) {
		super(), this._editor = e, this._options = _, this._updateState = v, this._editorWorkerService = y, this._model = this._editor.getModel(), this._decorations = this._editor.createDecorationsCollection(), this._updateSoon = this._register(new RunOnceScheduler(() => this._update(), 250)), this._register(this._editor.onDidChangeModelContent(() => {
			this._updateSoon.schedule();
		})), this._updateSoon.schedule();
	}
	dispose() {
		this._decorations.clear(), super.dispose();
	}
	_update() {
		if (this._model.isDisposed()) return;
		if (!this._model.mightContainNonBasicASCII()) {
			this._decorations.clear();
			return;
		}
		let e = this._model.getVersionId();
		this._editorWorkerService.computedUnicodeHighlights(this._model.uri, this._options).then((_) => {
			if (this._model.isDisposed() || this._model.getVersionId() !== e) return;
			this._updateState(_);
			let v = [];
			if (!_.hasMore) for (let e of _.ranges) v.push({
				range: e,
				options: Decorations.instance.getDecorationFromOptions(this._options)
			});
			this._decorations.set(v);
		});
	}
	getDecorationInfo(e) {
		if (!this._decorations.has(e)) return null;
		let _ = this._editor.getModel();
		if (!isModelDecorationVisible(_, e)) return null;
		let v = _.getValueInRange(e.range);
		return {
			reason: computeReason(v, this._options),
			inComment: isModelDecorationInComment(_, e),
			inString: isModelDecorationInString(_, e)
		};
	}
};
DocumentUnicodeHighlighter = __decorate$12([__param$12(3, IEditorWorkerService)], DocumentUnicodeHighlighter);
var ViewportUnicodeHighlighter = class extends Disposable {
	constructor(e, _, v) {
		super(), this._editor = e, this._options = _, this._updateState = v, this._model = this._editor.getModel(), this._decorations = this._editor.createDecorationsCollection(), this._updateSoon = this._register(new RunOnceScheduler(() => this._update(), 250)), this._register(this._editor.onDidLayoutChange(() => {
			this._updateSoon.schedule();
		})), this._register(this._editor.onDidScrollChange(() => {
			this._updateSoon.schedule();
		})), this._register(this._editor.onDidChangeHiddenAreas(() => {
			this._updateSoon.schedule();
		})), this._register(this._editor.onDidChangeModelContent(() => {
			this._updateSoon.schedule();
		})), this._updateSoon.schedule();
	}
	dispose() {
		this._decorations.clear(), super.dispose();
	}
	_update() {
		if (this._model.isDisposed()) return;
		if (!this._model.mightContainNonBasicASCII()) {
			this._decorations.clear();
			return;
		}
		let e = this._editor.getVisibleRanges(), _ = [], v = {
			ranges: [],
			ambiguousCharacterCount: 0,
			invisibleCharacterCount: 0,
			nonBasicAsciiCharacterCount: 0,
			hasMore: !1
		};
		for (let _ of e) {
			let e = UnicodeTextModelHighlighter.computeUnicodeHighlights(this._model, this._options, _);
			for (let _ of e.ranges) v.ranges.push(_);
			v.ambiguousCharacterCount += v.ambiguousCharacterCount, v.invisibleCharacterCount += v.invisibleCharacterCount, v.nonBasicAsciiCharacterCount += v.nonBasicAsciiCharacterCount, v.hasMore = v.hasMore || e.hasMore;
		}
		if (!v.hasMore) for (let e of v.ranges) _.push({
			range: e,
			options: Decorations.instance.getDecorationFromOptions(this._options)
		});
		this._updateState(v), this._decorations.set(_);
	}
	getDecorationInfo(e) {
		if (!this._decorations.has(e)) return null;
		let _ = this._editor.getModel(), v = _.getValueInRange(e.range);
		return isModelDecorationVisible(_, e) ? {
			reason: computeReason(v, this._options),
			inComment: isModelDecorationInComment(_, e),
			inString: isModelDecorationInString(_, e)
		} : null;
	}
}, configureUnicodeHighlightOptionsStr = localize("unicodeHighlight.configureUnicodeHighlightOptions", "Configure Unicode Highlight Options"), UnicodeHighlighterHoverParticipant = class {
	constructor(e, _, v) {
		this._editor = e, this._languageService = _, this._openerService = v, this.hoverOrdinal = 5;
	}
	computeSync(e, _) {
		if (!this._editor.hasModel() || e.type !== 1) return [];
		let v = this._editor.getModel(), y = this._editor.getContribution(UnicodeHighlighter.ID);
		if (!y) return [];
		let b = [], x = /* @__PURE__ */ new Set(), S = 300;
		for (let e of _) {
			let _ = y.getDecorationInfo(e);
			if (!_) continue;
			let C = v.getValueInRange(e.range).codePointAt(0), w = formatCodePointMarkdown(C), T;
			switch (_.reason.kind) {
				case 0:
					T = isBasicASCII(_.reason.confusableWith) ? localize("unicodeHighlight.characterIsAmbiguousASCII", "The character {0} could be confused with the ASCII character {1}, which is more common in source code.", w, formatCodePointMarkdown(_.reason.confusableWith.codePointAt(0))) : localize("unicodeHighlight.characterIsAmbiguous", "The character {0} could be confused with the character {1}, which is more common in source code.", w, formatCodePointMarkdown(_.reason.confusableWith.codePointAt(0)));
					break;
				case 1:
					T = localize("unicodeHighlight.characterIsInvisible", "The character {0} is invisible.", w);
					break;
				case 2:
					T = localize("unicodeHighlight.characterIsNonBasicAscii", "The character {0} is not a basic ASCII character.", w);
					break;
			}
			if (x.has(T)) continue;
			x.add(T);
			let E = {
				codePoint: C,
				reason: _.reason,
				inComment: _.inComment,
				inString: _.inString
			}, D = localize("unicodeHighlight.adjustSettings", "Adjust settings"), O = `command:${ShowExcludeOptions.ID}?${encodeURIComponent(JSON.stringify(E))}`, k = new MarkdownString("", !0).appendMarkdown(T).appendText(" ").appendLink(O, D, configureUnicodeHighlightOptionsStr);
			b.push(new MarkdownHover(this, e.range, [k], !1, S++));
		}
		return b;
	}
	renderHoverParts(e, _) {
		return renderMarkdownHovers(e, _, this._editor, this._languageService, this._openerService);
	}
};
UnicodeHighlighterHoverParticipant = __decorate$12([__param$12(1, ILanguageService), __param$12(2, IOpenerService)], UnicodeHighlighterHoverParticipant);
function codePointToHex(e) {
	return `U+${e.toString(16).padStart(4, "0")}`;
}
function formatCodePointMarkdown(e) {
	let _ = `\`${codePointToHex(e)}\``;
	return InvisibleCharacters.isInvisibleCharacter(e) || (_ += ` "${`${renderCodePointAsInlineCode(e)}`}"`), _;
}
function renderCodePointAsInlineCode(e) {
	return e === 96 ? "`` ` ``" : "`" + String.fromCodePoint(e) + "`";
}
function computeReason(e, _) {
	return UnicodeTextModelHighlighter.computeUnicodeHighlightReason(e, _);
}
var Decorations = class e {
	constructor() {
		this.map = /* @__PURE__ */ new Map();
	}
	static {
		this.instance = new e();
	}
	getDecorationFromOptions(e) {
		return this.getDecoration(!e.includeComments, !e.includeStrings);
	}
	getDecoration(e, _) {
		let v = `${e}${_}`, y = this.map.get(v);
		return y || (y = ModelDecorationOptions.createDynamic({
			description: "unicode-highlight",
			stickiness: 1,
			className: "unicode-highlight",
			showIfCollapsed: !0,
			overviewRuler: null,
			minimap: null,
			hideInCommentTokens: e,
			hideInStringTokens: _
		}), this.map.set(v, y)), y;
	}
}, DisableHighlightingInCommentsAction = class extends EditorAction {
	constructor() {
		super({
			id: DisableHighlightingOfAmbiguousCharactersAction.ID,
			label: localize("action.unicodeHighlight.disableHighlightingInComments", "Disable highlighting of characters in comments"),
			alias: "Disable highlighting of characters in comments",
			precondition: void 0
		}), this.shortLabel = localize("unicodeHighlight.disableHighlightingInComments.shortLabel", "Disable Highlight In Comments");
	}
	async run(e, _, v) {
		let y = e?.get(IConfigurationService);
		y && this.runAction(y);
	}
	async runAction(e) {
		await e.updateValue(unicodeHighlightConfigKeys.includeComments, !1, 2);
	}
}, DisableHighlightingInStringsAction = class extends EditorAction {
	constructor() {
		super({
			id: DisableHighlightingOfAmbiguousCharactersAction.ID,
			label: localize("action.unicodeHighlight.disableHighlightingInStrings", "Disable highlighting of characters in strings"),
			alias: "Disable highlighting of characters in strings",
			precondition: void 0
		}), this.shortLabel = localize("unicodeHighlight.disableHighlightingInStrings.shortLabel", "Disable Highlight In Strings");
	}
	async run(e, _, v) {
		let y = e?.get(IConfigurationService);
		y && this.runAction(y);
	}
	async runAction(e) {
		await e.updateValue(unicodeHighlightConfigKeys.includeStrings, !1, 2);
	}
}, DisableHighlightingOfAmbiguousCharactersAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.unicodeHighlight.disableHighlightingOfAmbiguousCharacters";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("action.unicodeHighlight.disableHighlightingOfAmbiguousCharacters", "Disable highlighting of ambiguous characters"),
			alias: "Disable highlighting of ambiguous characters",
			precondition: void 0
		}), this.shortLabel = localize("unicodeHighlight.disableHighlightingOfAmbiguousCharacters.shortLabel", "Disable Ambiguous Highlight");
	}
	async run(e, _, v) {
		let y = e?.get(IConfigurationService);
		y && this.runAction(y);
	}
	async runAction(e) {
		await e.updateValue(unicodeHighlightConfigKeys.ambiguousCharacters, !1, 2);
	}
}, DisableHighlightingOfInvisibleCharactersAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.unicodeHighlight.disableHighlightingOfInvisibleCharacters";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("action.unicodeHighlight.disableHighlightingOfInvisibleCharacters", "Disable highlighting of invisible characters"),
			alias: "Disable highlighting of invisible characters",
			precondition: void 0
		}), this.shortLabel = localize("unicodeHighlight.disableHighlightingOfInvisibleCharacters.shortLabel", "Disable Invisible Highlight");
	}
	async run(e, _, v) {
		let y = e?.get(IConfigurationService);
		y && this.runAction(y);
	}
	async runAction(e) {
		await e.updateValue(unicodeHighlightConfigKeys.invisibleCharacters, !1, 2);
	}
}, DisableHighlightingOfNonBasicAsciiCharactersAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("action.unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters", "Disable highlighting of non basic ASCII characters"),
			alias: "Disable highlighting of non basic ASCII characters",
			precondition: void 0
		}), this.shortLabel = localize("unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters.shortLabel", "Disable Non ASCII Highlight");
	}
	async run(e, _, v) {
		let y = e?.get(IConfigurationService);
		y && this.runAction(y);
	}
	async runAction(e) {
		await e.updateValue(unicodeHighlightConfigKeys.nonBasicASCII, !1, 2);
	}
}, ShowExcludeOptions = class e extends EditorAction {
	static {
		this.ID = "editor.action.unicodeHighlight.showExcludeOptions";
	}
	constructor() {
		super({
			id: e.ID,
			label: localize("action.unicodeHighlight.showExcludeOptions", "Show Exclude Options"),
			alias: "Show Exclude Options",
			precondition: void 0
		});
	}
	async run(e, _, v) {
		let { codePoint: y, reason: b, inString: x, inComment: S } = v, C = String.fromCodePoint(y), w = e.get(IQuickInputService), T = e.get(IConfigurationService);
		function E(e) {
			return InvisibleCharacters.isInvisibleCharacter(e) ? localize("unicodeHighlight.excludeInvisibleCharFromBeingHighlighted", "Exclude {0} (invisible character) from being highlighted", codePointToHex(e)) : localize("unicodeHighlight.excludeCharFromBeingHighlighted", "Exclude {0} from being highlighted", `${codePointToHex(e)} "${C}"`);
		}
		let D = [];
		if (b.kind === 0) for (let e of b.notAmbiguousInLocales) D.push({
			label: localize("unicodeHighlight.allowCommonCharactersInLanguage", "Allow unicode characters that are more common in the language \"{0}\".", e),
			run: async () => {
				excludeLocaleFromBeingHighlighted(T, [e]);
			}
		});
		if (D.push({
			label: E(y),
			run: () => excludeCharFromBeingHighlighted(T, [y])
		}), S) {
			let e = new DisableHighlightingInCommentsAction();
			D.push({
				label: e.label,
				run: async () => e.runAction(T)
			});
		} else if (x) {
			let e = new DisableHighlightingInStringsAction();
			D.push({
				label: e.label,
				run: async () => e.runAction(T)
			});
		}
		if (b.kind === 0) {
			let e = new DisableHighlightingOfAmbiguousCharactersAction();
			D.push({
				label: e.label,
				run: async () => e.runAction(T)
			});
		} else if (b.kind === 1) {
			let e = new DisableHighlightingOfInvisibleCharactersAction();
			D.push({
				label: e.label,
				run: async () => e.runAction(T)
			});
		} else if (b.kind === 2) {
			let e = new DisableHighlightingOfNonBasicAsciiCharactersAction();
			D.push({
				label: e.label,
				run: async () => e.runAction(T)
			});
		} else expectNever(b);
		let O = await w.pick(D, { title: configureUnicodeHighlightOptionsStr });
		O && await O.run();
	}
};
async function excludeCharFromBeingHighlighted(e, _) {
	let v = e.getValue(unicodeHighlightConfigKeys.allowedCharacters), y;
	y = typeof v == "object" && v ? v : {};
	for (let e of _) y[String.fromCodePoint(e)] = !0;
	await e.updateValue(unicodeHighlightConfigKeys.allowedCharacters, y, 2);
}
async function excludeLocaleFromBeingHighlighted(e, _) {
	let v = e.inspect(unicodeHighlightConfigKeys.allowedLocales).user?.value, y;
	y = typeof v == "object" && v ? Object.assign({}, v) : {};
	for (let e of _) y[e] = !0;
	await e.updateValue(unicodeHighlightConfigKeys.allowedLocales, y, 2);
}
function expectNever(e) {
	throw Error(`Unexpected value: ${e}`);
}
registerEditorAction(DisableHighlightingOfAmbiguousCharactersAction), registerEditorAction(DisableHighlightingOfInvisibleCharactersAction), registerEditorAction(DisableHighlightingOfNonBasicAsciiCharactersAction), registerEditorAction(ShowExcludeOptions), registerEditorContribution(UnicodeHighlighter.ID, UnicodeHighlighter, 1), HoverParticipantRegistry.register(UnicodeHighlighterHoverParticipant);
var __decorate$11 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$11 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, ignoreUnusualLineTerminators = "ignoreUnusualLineTerminators";
function writeIgnoreState(e, _, v) {
	e.setModelProperty(_.uri, ignoreUnusualLineTerminators, v);
}
function readIgnoreState(e, _) {
	return e.getModelProperty(_.uri, ignoreUnusualLineTerminators);
}
var UnusualLineTerminatorsDetector = class extends Disposable {
	static {
		this.ID = "editor.contrib.unusualLineTerminatorsDetector";
	}
	constructor(e, _, v) {
		super(), this._editor = e, this._dialogService = _, this._codeEditorService = v, this._isPresentingDialog = !1, this._config = this._editor.getOption(127), this._register(this._editor.onDidChangeConfiguration((e) => {
			e.hasChanged(127) && (this._config = this._editor.getOption(127), this._checkForUnusualLineTerminators());
		})), this._register(this._editor.onDidChangeModel(() => {
			this._checkForUnusualLineTerminators();
		})), this._register(this._editor.onDidChangeModelContent((e) => {
			e.isUndoing || this._checkForUnusualLineTerminators();
		})), this._checkForUnusualLineTerminators();
	}
	async _checkForUnusualLineTerminators() {
		if (this._config === "off" || !this._editor.hasModel()) return;
		let e = this._editor.getModel();
		if (!e.mightContainUnusualLineTerminators() || readIgnoreState(this._codeEditorService, e) === !0 || this._editor.getOption(92)) return;
		if (this._config === "auto") {
			e.removeUnusualLineTerminators(this._editor.getSelections());
			return;
		}
		if (this._isPresentingDialog) return;
		let _;
		try {
			this._isPresentingDialog = !0, _ = await this._dialogService.confirm({
				title: localize("unusualLineTerminators.title", "Unusual Line Terminators"),
				message: localize("unusualLineTerminators.message", "Detected unusual line terminators"),
				detail: localize("unusualLineTerminators.detail", "The file '{0}' contains one or more unusual line terminator characters, like Line Separator (LS) or Paragraph Separator (PS).\n\nIt is recommended to remove them from the file. This can be configured via `editor.unusualLineTerminators`.", basename(e.uri)),
				primaryButton: localize({
					key: "unusualLineTerminators.fix",
					comment: ["&& denotes a mnemonic"]
				}, "&&Remove Unusual Line Terminators"),
				cancelButton: localize("unusualLineTerminators.ignore", "Ignore")
			});
		} finally {
			this._isPresentingDialog = !1;
		}
		if (!_.confirmed) {
			writeIgnoreState(this._codeEditorService, e, !0);
			return;
		}
		e.removeUnusualLineTerminators(this._editor.getSelections());
	}
};
UnusualLineTerminatorsDetector = __decorate$11([__param$11(1, IDialogService), __param$11(2, ICodeEditorService)], UnusualLineTerminatorsDetector), registerEditorContribution(UnusualLineTerminatorsDetector.ID, UnusualLineTerminatorsDetector, 1);
var __decorate$10 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$10 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, TextualDocumentHighlightProvider = class {
	constructor() {
		this.selector = { language: "*" };
	}
	provideDocumentHighlights(e, _, v) {
		let y = [], b = e.getWordAtPosition({
			lineNumber: _.lineNumber,
			column: _.column
		});
		if (!b) return Promise.resolve(y);
		if (!e.isDisposed()) return e.findMatches(b.word, !0, !1, !0, USUAL_WORD_SEPARATORS, !1).map((e) => ({
			range: e.range,
			kind: DocumentHighlightKind.Text
		}));
	}
	provideMultiDocumentHighlights(e, _, v, y) {
		let b = new ResourceMap(), x = e.getWordAtPosition({
			lineNumber: _.lineNumber,
			column: _.column
		});
		if (!x) return Promise.resolve(b);
		for (let _ of [e, ...v]) {
			if (_.isDisposed()) continue;
			let e = _.findMatches(x.word, !0, !1, !0, USUAL_WORD_SEPARATORS, !1).map((e) => ({
				range: e.range,
				kind: DocumentHighlightKind.Text
			}));
			e && b.set(_.uri, e);
		}
		return b;
	}
}, TextualMultiDocumentHighlightFeature = class extends Disposable {
	constructor(e) {
		super(), this._register(e.documentHighlightProvider.register("*", new TextualDocumentHighlightProvider())), this._register(e.multiDocumentHighlightProvider.register("*", new TextualDocumentHighlightProvider()));
	}
};
TextualMultiDocumentHighlightFeature = __decorate$10([__param$10(0, ILanguageFeaturesService)], TextualMultiDocumentHighlightFeature);
var __decorate$9 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$9 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, WordHighlighter_1, WordHighlighterContribution_1, ctxHasWordHighlights = new RawContextKey("hasWordHighlights", !1);
function getOccurrencesAtPosition(e, _, v, y) {
	let b = e.ordered(_);
	return first(b.map((e) => () => Promise.resolve(e.provideDocumentHighlights(_, v, y)).then(void 0, onUnexpectedExternalError)), (e) => e != null).then((e) => {
		if (e) {
			let v = new ResourceMap();
			return v.set(_.uri, e), v;
		}
		return new ResourceMap();
	});
}
function getOccurrencesAcrossMultipleModels(e, _, v, y, b, x) {
	let S = e.ordered(_);
	return first(S.map((e) => () => {
		let y = x.filter((e) => shouldSynchronizeModel(e)).filter((_) => score(e.selector, _.uri, _.getLanguageId(), !0, void 0, void 0) > 0);
		return Promise.resolve(e.provideMultiDocumentHighlights(_, v, y, b)).then(void 0, onUnexpectedExternalError);
	}), (e) => e != null);
}
var OccurenceAtPositionRequest = class {
	constructor(e, _, v) {
		this._model = e, this._selection = _, this._wordSeparators = v, this._wordRange = this._getCurrentWordRange(e, _), this._result = null;
	}
	get result() {
		return this._result ||= createCancelablePromise((e) => this._compute(this._model, this._selection, this._wordSeparators, e)), this._result;
	}
	_getCurrentWordRange(e, _) {
		let v = e.getWordAtPosition(_.getPosition());
		return v ? new Range(_.startLineNumber, v.startColumn, _.startLineNumber, v.endColumn) : null;
	}
	isValid(e, _, v) {
		let y = _.startLineNumber, b = _.startColumn, x = _.endColumn, S = this._getCurrentWordRange(e, _), C = !!(this._wordRange && this._wordRange.equalsRange(S));
		for (let e = 0, _ = v.length; !C && e < _; e++) {
			let _ = v.getRange(e);
			_ && _.startLineNumber === y && _.startColumn <= b && _.endColumn >= x && (C = !0);
		}
		return C;
	}
	cancel() {
		this.result.cancel();
	}
}, SemanticOccurenceAtPositionRequest = class extends OccurenceAtPositionRequest {
	constructor(e, _, v, y) {
		super(e, _, v), this._providers = y;
	}
	_compute(e, _, v, y) {
		return getOccurrencesAtPosition(this._providers, e, _.getPosition(), y).then((e) => e || new ResourceMap());
	}
}, MultiModelOccurenceRequest = class extends OccurenceAtPositionRequest {
	constructor(e, _, v, y, b) {
		super(e, _, v), this._providers = y, this._otherModels = b;
	}
	_compute(e, _, v, y) {
		return getOccurrencesAcrossMultipleModels(this._providers, e, _.getPosition(), v, y, this._otherModels).then((e) => e || new ResourceMap());
	}
};
function computeOccurencesAtPosition(e, _, v, y, b) {
	return new SemanticOccurenceAtPositionRequest(_, v, b, e);
}
function computeOccurencesMultiModel(e, _, v, y, b, x) {
	return new MultiModelOccurenceRequest(_, v, b, e, x);
}
registerModelAndPositionCommand("_executeDocumentHighlights", async (e, _, v) => {
	let y = e.get(ILanguageFeaturesService);
	return (await getOccurrencesAtPosition(y.documentHighlightProvider, _, v, CancellationToken.None))?.get(_.uri);
});
var WordHighlighter = class {
	static {
		WordHighlighter_1 = this;
	}
	static {
		this.storedDecorationIDs = new ResourceMap();
	}
	static {
		this.query = null;
	}
	constructor(e, _, v, y, b) {
		this.toUnhook = new DisposableStore(), this.workerRequestTokenId = 0, this.workerRequestCompleted = !1, this.workerRequestValue = new ResourceMap(), this.lastCursorPositionChangeTime = 0, this.renderDecorationsTimer = -1, this.runDelayer = this.toUnhook.add(new Delayer(50)), this.editor = e, this.providers = _, this.multiDocumentProviders = v, this.codeEditorService = b, this._hasWordHighlights = ctxHasWordHighlights.bindTo(y), this._ignorePositionChangeEvent = !1, this.occurrencesHighlight = this.editor.getOption(81), this.model = this.editor.getModel(), this.toUnhook.add(e.onDidChangeCursorPosition((e) => {
			this._ignorePositionChangeEvent || this.occurrencesHighlight !== "off" && this.runDelayer.trigger(() => {
				this._onPositionChanged(e);
			});
		})), this.toUnhook.add(e.onDidFocusEditorText((e) => {
			this.occurrencesHighlight !== "off" && (this.workerRequest || this.runDelayer.trigger(() => {
				this._run();
			}));
		})), this.toUnhook.add(e.onDidChangeModelContent((e) => {
			matchesScheme(this.model.uri, "output") || this._stopAll();
		})), this.toUnhook.add(e.onDidChangeModel((e) => {
			!e.newModelUrl && e.oldModelUrl ? this._stopSingular() : WordHighlighter_1.query && this._run();
		})), this.toUnhook.add(e.onDidChangeConfiguration((e) => {
			let _ = this.editor.getOption(81);
			if (this.occurrencesHighlight !== _) switch (this.occurrencesHighlight = _, _) {
				case "off":
					this._stopAll();
					break;
				case "singleFile":
					this._stopAll(WordHighlighter_1.query?.modelInfo?.model);
					break;
				case "multiFile":
					WordHighlighter_1.query && this._run(!0);
					break;
				default:
					console.warn("Unknown occurrencesHighlight setting value:", _);
					break;
			}
		})), this.decorations = this.editor.createDecorationsCollection(), this.workerRequestTokenId = 0, this.workerRequest = null, this.workerRequestCompleted = !1, this.lastCursorPositionChangeTime = 0, this.renderDecorationsTimer = -1, WordHighlighter_1.query && this._run();
	}
	hasDecorations() {
		return this.decorations.length > 0;
	}
	restore() {
		this.occurrencesHighlight !== "off" && (this.runDelayer.cancel(), this._run());
	}
	_getSortedHighlights() {
		return this.decorations.getRanges().sort(Range.compareRangesUsingStarts);
	}
	moveNext() {
		let e = this._getSortedHighlights(), _ = (e.findIndex((e) => e.containsPosition(this.editor.getPosition())) + 1) % e.length, v = e[_];
		try {
			this._ignorePositionChangeEvent = !0, this.editor.setPosition(v.getStartPosition()), this.editor.revealRangeInCenterIfOutsideViewport(v);
			let y = this._getWord();
			if (y) {
				let b = this.editor.getModel().getLineContent(v.startLineNumber);
				alert(`${b}, ${_ + 1} of ${e.length} for '${y.word}'`);
			}
		} finally {
			this._ignorePositionChangeEvent = !1;
		}
	}
	moveBack() {
		let e = this._getSortedHighlights(), _ = (e.findIndex((e) => e.containsPosition(this.editor.getPosition())) - 1 + e.length) % e.length, v = e[_];
		try {
			this._ignorePositionChangeEvent = !0, this.editor.setPosition(v.getStartPosition()), this.editor.revealRangeInCenterIfOutsideViewport(v);
			let y = this._getWord();
			if (y) {
				let b = this.editor.getModel().getLineContent(v.startLineNumber);
				alert(`${b}, ${_ + 1} of ${e.length} for '${y.word}'`);
			}
		} finally {
			this._ignorePositionChangeEvent = !1;
		}
	}
	_removeSingleDecorations() {
		if (!this.editor.hasModel()) return;
		let e = WordHighlighter_1.storedDecorationIDs.get(this.editor.getModel().uri);
		e && (this.editor.removeDecorations(e), WordHighlighter_1.storedDecorationIDs.delete(this.editor.getModel().uri), this.decorations.length > 0 && (this.decorations.clear(), this._hasWordHighlights.set(!1)));
	}
	_removeAllDecorations(e) {
		let _ = this.codeEditorService.listCodeEditors(), v = [];
		for (let y of _) {
			if (!y.hasModel() || isEqual(y.getModel().uri, e?.uri)) continue;
			let _ = WordHighlighter_1.storedDecorationIDs.get(y.getModel().uri);
			if (!_) continue;
			y.removeDecorations(_), v.push(y.getModel().uri);
			let b = WordHighlighterContribution.get(y);
			b?.wordHighlighter && b.wordHighlighter.decorations.length > 0 && (b.wordHighlighter.decorations.clear(), b.wordHighlighter.workerRequest = null, b.wordHighlighter._hasWordHighlights.set(!1));
		}
		for (let e of v) WordHighlighter_1.storedDecorationIDs.delete(e);
	}
	_stopSingular() {
		this._removeSingleDecorations(), this.editor.hasTextFocus() && (this.editor.getModel()?.uri.scheme !== Schemas.vscodeNotebookCell && WordHighlighter_1.query?.modelInfo?.model.uri.scheme !== Schemas.vscodeNotebookCell ? (WordHighlighter_1.query = null, this._run()) : WordHighlighter_1.query?.modelInfo && (WordHighlighter_1.query.modelInfo = null)), this.renderDecorationsTimer !== -1 && (clearTimeout(this.renderDecorationsTimer), this.renderDecorationsTimer = -1), this.workerRequest !== null && (this.workerRequest.cancel(), this.workerRequest = null), this.workerRequestCompleted ||= (this.workerRequestTokenId++, !0);
	}
	_stopAll(e) {
		this._removeAllDecorations(e), this.renderDecorationsTimer !== -1 && (clearTimeout(this.renderDecorationsTimer), this.renderDecorationsTimer = -1), this.workerRequest !== null && (this.workerRequest.cancel(), this.workerRequest = null), this.workerRequestCompleted ||= (this.workerRequestTokenId++, !0);
	}
	_onPositionChanged(e) {
		if (this.occurrencesHighlight === "off") {
			this._stopAll();
			return;
		}
		if (e.reason !== 3 && this.editor.getModel()?.uri.scheme !== Schemas.vscodeNotebookCell) {
			this._stopAll();
			return;
		}
		this._run();
	}
	_getWord() {
		let e = this.editor.getSelection(), _ = e.startLineNumber, v = e.startColumn;
		return this.model.isDisposed() ? null : this.model.getWordAtPosition({
			lineNumber: _,
			column: v
		});
	}
	getOtherModelsToHighlight(e) {
		if (!e) return [];
		if (e.uri.scheme === Schemas.vscodeNotebookCell) {
			let _ = [], v = this.codeEditorService.listCodeEditors();
			for (let y of v) {
				let v = y.getModel();
				v && v !== e && v.uri.scheme === Schemas.vscodeNotebookCell && _.push(v);
			}
			return _;
		}
		let _ = [], v = this.codeEditorService.listCodeEditors();
		for (let y of v) {
			if (!isDiffEditor(y)) continue;
			let v = y.getModel();
			v && e === v.modified && _.push(v.modified);
		}
		if (_.length) return _;
		if (this.occurrencesHighlight === "singleFile") return [];
		for (let y of v) {
			let v = y.getModel();
			v && v !== e && _.push(v);
		}
		return _;
	}
	_run(e) {
		let _;
		if (this.editor.hasTextFocus()) {
			let e = this.editor.getSelection();
			if (!e || e.startLineNumber !== e.endLineNumber) {
				WordHighlighter_1.query = null, this._stopAll();
				return;
			}
			let v = e.startColumn, y = e.endColumn, b = this._getWord();
			if (!b || b.startColumn > v || b.endColumn < y) {
				WordHighlighter_1.query = null, this._stopAll();
				return;
			}
			_ = this.workerRequest && this.workerRequest.isValid(this.model, e, this.decorations), WordHighlighter_1.query = {
				modelInfo: {
					model: this.model,
					selection: e
				},
				word: b
			};
		} else if (!WordHighlighter_1.query) {
			this._stopAll();
			return;
		}
		if (this.lastCursorPositionChangeTime = (/* @__PURE__ */ new Date()).getTime(), _) this.workerRequestCompleted && this.renderDecorationsTimer !== -1 && (clearTimeout(this.renderDecorationsTimer), this.renderDecorationsTimer = -1, this._beginRenderDecorations());
		else if (isEqual(this.editor.getModel().uri, WordHighlighter_1.query.modelInfo?.model.uri)) {
			if (!e) {
				let e = this.decorations.getRanges();
				for (let _ of e) if (_.containsPosition(this.editor.getPosition())) return;
			}
			this._stopAll(e ? this.model : void 0);
			let _ = ++this.workerRequestTokenId;
			this.workerRequestCompleted = !1;
			let v = this.getOtherModelsToHighlight(this.editor.getModel());
			if (!WordHighlighter_1.query || !WordHighlighter_1.query.modelInfo || WordHighlighter_1.query.modelInfo.model.isDisposed()) return;
			this.workerRequest = this.computeWithModel(WordHighlighter_1.query.modelInfo.model, WordHighlighter_1.query.modelInfo.selection, WordHighlighter_1.query.word, v), this.workerRequest?.result.then((e) => {
				_ === this.workerRequestTokenId && (this.workerRequestCompleted = !0, this.workerRequestValue = e || [], this._beginRenderDecorations());
			}, onUnexpectedError);
		}
	}
	computeWithModel(e, _, v, y) {
		return y.length ? computeOccurencesMultiModel(this.multiDocumentProviders, e, _, v, this.editor.getOption(132), y) : computeOccurencesAtPosition(this.providers, e, _, v, this.editor.getOption(132));
	}
	_beginRenderDecorations() {
		let e = (/* @__PURE__ */ new Date()).getTime(), _ = this.lastCursorPositionChangeTime + 250;
		e >= _ ? (this.renderDecorationsTimer = -1, this.renderDecorations()) : this.renderDecorationsTimer = setTimeout(() => {
			this.renderDecorations();
		}, _ - e);
	}
	renderDecorations() {
		this.renderDecorationsTimer = -1;
		let e = this.codeEditorService.listCodeEditors();
		for (let _ of e) {
			let e = WordHighlighterContribution.get(_);
			if (!e) continue;
			let v = [], y = _.getModel()?.uri;
			if (y && this.workerRequestValue.has(y)) {
				let b = WordHighlighter_1.storedDecorationIDs.get(y), x = this.workerRequestValue.get(y);
				if (x) for (let e of x) e.range && v.push({
					range: e.range,
					options: getHighlightDecorationOptions(e.kind)
				});
				let S = [];
				_.changeDecorations((e) => {
					S = e.deltaDecorations(b ?? [], v);
				}), WordHighlighter_1.storedDecorationIDs = WordHighlighter_1.storedDecorationIDs.set(y, S), v.length > 0 && (e.wordHighlighter?.decorations.set(v), e.wordHighlighter?._hasWordHighlights.set(!0));
			}
		}
	}
	dispose() {
		this._stopSingular(), this.toUnhook.dispose();
	}
};
WordHighlighter = WordHighlighter_1 = __decorate$9([__param$9(4, ICodeEditorService)], WordHighlighter);
var WordHighlighterContribution = class extends Disposable {
	static {
		WordHighlighterContribution_1 = this;
	}
	static {
		this.ID = "editor.contrib.wordHighlighter";
	}
	static get(e) {
		return e.getContribution(WordHighlighterContribution_1.ID);
	}
	constructor(e, _, v, y) {
		super(), this._wordHighlighter = null;
		let b = () => {
			e.hasModel() && !e.getModel().isTooLargeForTokenization() && (this._wordHighlighter = new WordHighlighter(e, v.documentHighlightProvider, v.multiDocumentHighlightProvider, _, y));
		};
		this._register(e.onDidChangeModel((e) => {
			this._wordHighlighter &&= (this._wordHighlighter.dispose(), null), b();
		})), b();
	}
	get wordHighlighter() {
		return this._wordHighlighter;
	}
	saveViewState() {
		return !!(this._wordHighlighter && this._wordHighlighter.hasDecorations());
	}
	moveNext() {
		this._wordHighlighter?.moveNext();
	}
	moveBack() {
		this._wordHighlighter?.moveBack();
	}
	restoreViewState(e) {
		this._wordHighlighter && e && this._wordHighlighter.restore();
	}
	dispose() {
		this._wordHighlighter &&= (this._wordHighlighter.dispose(), null), super.dispose();
	}
};
WordHighlighterContribution = WordHighlighterContribution_1 = __decorate$9([
	__param$9(1, IContextKeyService),
	__param$9(2, ILanguageFeaturesService),
	__param$9(3, ICodeEditorService)
], WordHighlighterContribution);
var WordHighlightNavigationAction = class extends EditorAction {
	constructor(e, _) {
		super(_), this._isNext = e;
	}
	run(e, _) {
		let v = WordHighlighterContribution.get(_);
		v && (this._isNext ? v.moveNext() : v.moveBack());
	}
}, NextWordHighlightAction = class extends WordHighlightNavigationAction {
	constructor() {
		super(!0, {
			id: "editor.action.wordHighlight.next",
			label: localize("wordHighlight.next.label", "Go to Next Symbol Highlight"),
			alias: "Go to Next Symbol Highlight",
			precondition: ctxHasWordHighlights,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 65,
				weight: 100
			}
		});
	}
}, PrevWordHighlightAction = class extends WordHighlightNavigationAction {
	constructor() {
		super(!1, {
			id: "editor.action.wordHighlight.prev",
			label: localize("wordHighlight.previous.label", "Go to Previous Symbol Highlight"),
			alias: "Go to Previous Symbol Highlight",
			precondition: ctxHasWordHighlights,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 1089,
				weight: 100
			}
		});
	}
}, TriggerWordHighlightAction = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.wordHighlight.trigger",
			label: localize("wordHighlight.trigger.label", "Trigger Symbol Highlight"),
			alias: "Trigger Symbol Highlight",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.editorTextFocus,
				primary: 0,
				weight: 100
			}
		});
	}
	run(e, _, v) {
		let y = WordHighlighterContribution.get(_);
		y && y.restoreViewState(!0);
	}
};
registerEditorContribution(WordHighlighterContribution.ID, WordHighlighterContribution, 0), registerEditorAction(NextWordHighlightAction), registerEditorAction(PrevWordHighlightAction), registerEditorAction(TriggerWordHighlightAction), registerEditorFeature(TextualMultiDocumentHighlightFeature);
var MoveWordCommand = class extends EditorCommand {
	constructor(e) {
		super(e), this._inSelectionMode = e.inSelectionMode, this._wordNavigationType = e.wordNavigationType;
	}
	runEditorCommand(e, _, v) {
		if (!_.hasModel()) return;
		let y = getMapForWordSeparators(_.getOption(132), _.getOption(131)), b = _.getModel(), x = _.getSelections(), S = x.length > 1, C = x.map((e) => {
			let _ = new Position(e.positionLineNumber, e.positionColumn), v = this._move(y, b, _, this._wordNavigationType, S);
			return this._moveTo(e, v, this._inSelectionMode);
		});
		if (b.pushStackElement(), _._getViewModel().setCursorStates("moveWordCommand", 3, C.map((e) => CursorState.fromModelSelection(e))), C.length === 1) {
			let e = new Position(C[0].positionLineNumber, C[0].positionColumn);
			_.revealPosition(e, 0);
		}
	}
	_moveTo(e, _, v) {
		return v ? new Selection(e.selectionStartLineNumber, e.selectionStartColumn, _.lineNumber, _.column) : new Selection(_.lineNumber, _.column, _.lineNumber, _.column);
	}
}, WordLeftCommand = class extends MoveWordCommand {
	_move(e, _, v, y, b) {
		return WordOperations.moveWordLeft(e, _, v, y, b);
	}
}, WordRightCommand = class extends MoveWordCommand {
	_move(e, _, v, y, b) {
		return WordOperations.moveWordRight(e, _, v, y);
	}
}, CursorWordStartLeft = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 0,
			id: "cursorWordStartLeft",
			precondition: void 0
		});
	}
}, CursorWordEndLeft = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 2,
			id: "cursorWordEndLeft",
			precondition: void 0
		});
	}
}, CursorWordLeft = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 1,
			id: "cursorWordLeft",
			precondition: void 0,
			kbOpts: {
				kbExpr: ContextKeyExpr.and(EditorContextKeys.textInputFocus, ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, IsWindowsContext)?.negate()),
				primary: 2063,
				mac: { primary: 527 },
				weight: 100
			}
		});
	}
}, CursorWordStartLeftSelect = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 0,
			id: "cursorWordStartLeftSelect",
			precondition: void 0
		});
	}
}, CursorWordEndLeftSelect = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 2,
			id: "cursorWordEndLeftSelect",
			precondition: void 0
		});
	}
}, CursorWordLeftSelect = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 1,
			id: "cursorWordLeftSelect",
			precondition: void 0,
			kbOpts: {
				kbExpr: ContextKeyExpr.and(EditorContextKeys.textInputFocus, ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, IsWindowsContext)?.negate()),
				primary: 3087,
				mac: { primary: 1551 },
				weight: 100
			}
		});
	}
}, CursorWordAccessibilityLeft = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 3,
			id: "cursorWordAccessibilityLeft",
			precondition: void 0
		});
	}
	_move(e, _, v, y, b) {
		return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue, e.intlSegmenterLocales), _, v, y, b);
	}
}, CursorWordAccessibilityLeftSelect = class extends WordLeftCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 3,
			id: "cursorWordAccessibilityLeftSelect",
			precondition: void 0
		});
	}
	_move(e, _, v, y, b) {
		return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue, e.intlSegmenterLocales), _, v, y, b);
	}
}, CursorWordStartRight = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 0,
			id: "cursorWordStartRight",
			precondition: void 0
		});
	}
}, CursorWordEndRight = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 2,
			id: "cursorWordEndRight",
			precondition: void 0,
			kbOpts: {
				kbExpr: ContextKeyExpr.and(EditorContextKeys.textInputFocus, ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, IsWindowsContext)?.negate()),
				primary: 2065,
				mac: { primary: 529 },
				weight: 100
			}
		});
	}
}, CursorWordRight = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 2,
			id: "cursorWordRight",
			precondition: void 0
		});
	}
}, CursorWordStartRightSelect = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 0,
			id: "cursorWordStartRightSelect",
			precondition: void 0
		});
	}
}, CursorWordEndRightSelect = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 2,
			id: "cursorWordEndRightSelect",
			precondition: void 0,
			kbOpts: {
				kbExpr: ContextKeyExpr.and(EditorContextKeys.textInputFocus, ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, IsWindowsContext)?.negate()),
				primary: 3089,
				mac: { primary: 1553 },
				weight: 100
			}
		});
	}
}, CursorWordRightSelect = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 2,
			id: "cursorWordRightSelect",
			precondition: void 0
		});
	}
}, CursorWordAccessibilityRight = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 3,
			id: "cursorWordAccessibilityRight",
			precondition: void 0
		});
	}
	_move(e, _, v, y, b) {
		return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue, e.intlSegmenterLocales), _, v, y, b);
	}
}, CursorWordAccessibilityRightSelect = class extends WordRightCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 3,
			id: "cursorWordAccessibilityRightSelect",
			precondition: void 0
		});
	}
	_move(e, _, v, y, b) {
		return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue, e.intlSegmenterLocales), _, v, y, b);
	}
}, DeleteWordCommand = class extends EditorCommand {
	constructor(e) {
		super(e), this._whitespaceHeuristics = e.whitespaceHeuristics, this._wordNavigationType = e.wordNavigationType;
	}
	runEditorCommand(e, _, v) {
		let y = e.get(ILanguageConfigurationService);
		if (!_.hasModel()) return;
		let b = getMapForWordSeparators(_.getOption(132), _.getOption(131)), x = _.getModel(), S = _.getSelections(), C = _.getOption(6), w = _.getOption(11), T = y.getLanguageConfiguration(x.getLanguageId()).getAutoClosingPairs(), E = _._getViewModel(), D = S.map((e) => {
			let v = this._delete({
				wordSeparators: b,
				model: x,
				selection: e,
				whitespaceHeuristics: this._whitespaceHeuristics,
				autoClosingDelete: _.getOption(9),
				autoClosingBrackets: C,
				autoClosingQuotes: w,
				autoClosingPairs: T,
				autoClosedCharacters: E.getCursorAutoClosedCharacters()
			}, this._wordNavigationType);
			return new ReplaceCommand(v, "");
		});
		_.pushUndoStop(), _.executeCommands(this.id, D), _.pushUndoStop();
	}
}, DeleteWordLeftCommand = class extends DeleteWordCommand {
	_delete(e, _) {
		return WordOperations.deleteWordLeft(e, _) || new Range(1, 1, 1, 1);
	}
}, DeleteWordRightCommand = class extends DeleteWordCommand {
	_delete(e, _) {
		let v = WordOperations.deleteWordRight(e, _);
		if (v) return v;
		let y = e.model.getLineCount(), b = e.model.getLineMaxColumn(y);
		return new Range(y, b, y, b);
	}
}, DeleteWordStartLeft = class extends DeleteWordLeftCommand {
	constructor() {
		super({
			whitespaceHeuristics: !1,
			wordNavigationType: 0,
			id: "deleteWordStartLeft",
			precondition: EditorContextKeys.writable
		});
	}
}, DeleteWordEndLeft = class extends DeleteWordLeftCommand {
	constructor() {
		super({
			whitespaceHeuristics: !1,
			wordNavigationType: 2,
			id: "deleteWordEndLeft",
			precondition: EditorContextKeys.writable
		});
	}
}, DeleteWordLeft = class extends DeleteWordLeftCommand {
	constructor() {
		super({
			whitespaceHeuristics: !0,
			wordNavigationType: 0,
			id: "deleteWordLeft",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 2049,
				mac: { primary: 513 },
				weight: 100
			}
		});
	}
}, DeleteWordStartRight = class extends DeleteWordRightCommand {
	constructor() {
		super({
			whitespaceHeuristics: !1,
			wordNavigationType: 0,
			id: "deleteWordStartRight",
			precondition: EditorContextKeys.writable
		});
	}
}, DeleteWordEndRight = class extends DeleteWordRightCommand {
	constructor() {
		super({
			whitespaceHeuristics: !1,
			wordNavigationType: 2,
			id: "deleteWordEndRight",
			precondition: EditorContextKeys.writable
		});
	}
}, DeleteWordRight = class extends DeleteWordRightCommand {
	constructor() {
		super({
			whitespaceHeuristics: !0,
			wordNavigationType: 2,
			id: "deleteWordRight",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 2068,
				mac: { primary: 532 },
				weight: 100
			}
		});
	}
}, DeleteInsideWord = class extends EditorAction {
	constructor() {
		super({
			id: "deleteInsideWord",
			precondition: EditorContextKeys.writable,
			label: localize("deleteInsideWord", "Delete Word"),
			alias: "Delete Word"
		});
	}
	run(e, _, v) {
		if (!_.hasModel()) return;
		let y = getMapForWordSeparators(_.getOption(132), _.getOption(131)), b = _.getModel(), x = _.getSelections().map((e) => {
			let _ = WordOperations.deleteInsideWord(y, b, e);
			return new ReplaceCommand(_, "");
		});
		_.pushUndoStop(), _.executeCommands(this.id, x), _.pushUndoStop();
	}
};
registerEditorCommand(new CursorWordStartLeft()), registerEditorCommand(new CursorWordEndLeft()), registerEditorCommand(new CursorWordLeft()), registerEditorCommand(new CursorWordStartLeftSelect()), registerEditorCommand(new CursorWordEndLeftSelect()), registerEditorCommand(new CursorWordLeftSelect()), registerEditorCommand(new CursorWordStartRight()), registerEditorCommand(new CursorWordEndRight()), registerEditorCommand(new CursorWordRight()), registerEditorCommand(new CursorWordStartRightSelect()), registerEditorCommand(new CursorWordEndRightSelect()), registerEditorCommand(new CursorWordRightSelect()), registerEditorCommand(new CursorWordAccessibilityLeft()), registerEditorCommand(new CursorWordAccessibilityLeftSelect()), registerEditorCommand(new CursorWordAccessibilityRight()), registerEditorCommand(new CursorWordAccessibilityRightSelect()), registerEditorCommand(new DeleteWordStartLeft()), registerEditorCommand(new DeleteWordEndLeft()), registerEditorCommand(new DeleteWordLeft()), registerEditorCommand(new DeleteWordStartRight()), registerEditorCommand(new DeleteWordEndRight()), registerEditorCommand(new DeleteWordRight()), registerEditorAction(DeleteInsideWord);
var DeleteWordPartLeft = class extends DeleteWordCommand {
	constructor() {
		super({
			whitespaceHeuristics: !0,
			wordNavigationType: 0,
			id: "deleteWordPartLeft",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 769 },
				weight: 100
			}
		});
	}
	_delete(e, _) {
		return WordPartOperations.deleteWordPartLeft(e) || new Range(1, 1, 1, 1);
	}
}, DeleteWordPartRight = class extends DeleteWordCommand {
	constructor() {
		super({
			whitespaceHeuristics: !0,
			wordNavigationType: 2,
			id: "deleteWordPartRight",
			precondition: EditorContextKeys.writable,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 788 },
				weight: 100
			}
		});
	}
	_delete(e, _) {
		let v = WordPartOperations.deleteWordPartRight(e);
		if (v) return v;
		let y = e.model.getLineCount(), b = e.model.getLineMaxColumn(y);
		return new Range(y, b, y, b);
	}
}, WordPartLeftCommand = class extends MoveWordCommand {
	_move(e, _, v, y, b) {
		return WordPartOperations.moveWordPartLeft(e, _, v, b);
	}
}, CursorWordPartLeft = class extends WordPartLeftCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 0,
			id: "cursorWordPartLeft",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 783 },
				weight: 100
			}
		});
	}
};
CommandsRegistry.registerCommandAlias("cursorWordPartStartLeft", "cursorWordPartLeft");
var CursorWordPartLeftSelect = class extends WordPartLeftCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 0,
			id: "cursorWordPartLeftSelect",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 1807 },
				weight: 100
			}
		});
	}
};
CommandsRegistry.registerCommandAlias("cursorWordPartStartLeftSelect", "cursorWordPartLeftSelect");
var WordPartRightCommand = class extends MoveWordCommand {
	_move(e, _, v, y, b) {
		return WordPartOperations.moveWordPartRight(e, _, v);
	}
}, CursorWordPartRight = class extends WordPartRightCommand {
	constructor() {
		super({
			inSelectionMode: !1,
			wordNavigationType: 2,
			id: "cursorWordPartRight",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 785 },
				weight: 100
			}
		});
	}
}, CursorWordPartRightSelect = class extends WordPartRightCommand {
	constructor() {
		super({
			inSelectionMode: !0,
			wordNavigationType: 2,
			id: "cursorWordPartRightSelect",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.textInputFocus,
				primary: 0,
				mac: { primary: 1809 },
				weight: 100
			}
		});
	}
};
registerEditorCommand(new DeleteWordPartLeft()), registerEditorCommand(new DeleteWordPartRight()), registerEditorCommand(new CursorWordPartLeft()), registerEditorCommand(new CursorWordPartLeftSelect()), registerEditorCommand(new CursorWordPartRight()), registerEditorCommand(new CursorWordPartRightSelect());
var ReadOnlyMessageController = class extends Disposable {
	static {
		this.ID = "editor.contrib.readOnlyMessageController";
	}
	constructor(e) {
		super(), this.editor = e, this._register(this.editor.onDidAttemptReadOnlyEdit(() => this._onDidAttemptReadOnlyEdit()));
	}
	_onDidAttemptReadOnlyEdit() {
		let e = MessageController.get(this.editor);
		if (e && this.editor.hasModel()) {
			let _ = this.editor.getOptions().get(93);
			_ ||= this.editor.isSimpleWidget ? new MarkdownString(localize("editor.simple.readonly", "Cannot edit in read-only input")) : new MarkdownString(localize("editor.readonly", "Cannot edit in read-only editor")), e.showMessage(_, this.editor.getPosition());
		}
	}
};
registerEditorContribution(ReadOnlyMessageController.ID, ReadOnlyMessageController, 2);
var __decorate$8 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$8 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, DiffEditorBreadcrumbsSource = class extends Disposable {
	constructor(e, _, v) {
		super(), this._textModel = e, this._languageFeaturesService = _, this._outlineModelService = v, this._currentModel = observableValue(this, void 0);
		let y = observableSignalFromEvent("documentSymbolProvider.onDidChange", this._languageFeaturesService.documentSymbolProvider.onDidChange), b = observableSignalFromEvent("_textModel.onDidChangeContent", Event.debounce((e) => this._textModel.onDidChangeContent(e), () => void 0, 100));
		this._register(autorunWithStore(async (e, _) => {
			y.read(e), b.read(e);
			let v = _.add(new DisposableCancellationTokenSource()), x = await this._outlineModelService.getOrCreate(this._textModel, v.token);
			_.isDisposed || this._currentModel.set(x, void 0);
		}));
	}
	getBreadcrumbItems(e, _) {
		let v = this._currentModel.read(_);
		if (!v) return [];
		let y = v.asListOfDocumentSymbols().filter((_) => e.contains(_.range.startLineNumber) && !e.contains(_.range.endLineNumber));
		return y.sort(reverseOrder(compareBy((e) => e.range.endLineNumber - e.range.startLineNumber, numberComparator))), y.map((e) => ({
			name: e.name,
			kind: e.kind,
			startLineNumber: e.range.startLineNumber
		}));
	}
};
DiffEditorBreadcrumbsSource = __decorate$8([__param$8(1, ILanguageFeaturesService), __param$8(2, IOutlineModelService)], DiffEditorBreadcrumbsSource), HideUnchangedRegionsFeature.setBreadcrumbsSourceFactory((e, _) => _.createInstance(DiffEditorBreadcrumbsSource, e));
var IPadShowKeyboard = class extends Disposable {
	static {
		this.ID = "editor.contrib.iPadShowKeyboard";
	}
	constructor(e) {
		super(), this.editor = e, this.widget = null, isIOS && (this._register(e.onDidChangeConfiguration(() => this.update())), this.update());
	}
	update() {
		let e = !this.editor.getOption(92);
		!this.widget && e ? this.widget = new ShowKeyboardWidget(this.editor) : this.widget && !e && (this.widget.dispose(), this.widget = null);
	}
	dispose() {
		super.dispose(), this.widget &&= (this.widget.dispose(), null);
	}
}, ShowKeyboardWidget = class e extends Disposable {
	static {
		this.ID = "editor.contrib.ShowKeyboardWidget";
	}
	constructor(e) {
		super(), this.editor = e, this._domNode = document.createElement("textarea"), this._domNode.className = "iPadShowKeyboard", this._register(addDisposableListener(this._domNode, "touchstart", (e) => {
			this.editor.focus();
		})), this._register(addDisposableListener(this._domNode, "focus", (e) => {
			this.editor.focus();
		})), this.editor.addOverlayWidget(this);
	}
	dispose() {
		this.editor.removeOverlayWidget(this), super.dispose();
	}
	getId() {
		return e.ID;
	}
	getDomNode() {
		return this._domNode;
	}
	getPosition() {
		return { preference: 1 };
	}
};
registerEditorContribution(IPadShowKeyboard.ID, IPadShowKeyboard, 3);
var __decorate$7 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$7 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, InspectTokensController_1, InspectTokensController = class extends Disposable {
	static {
		InspectTokensController_1 = this;
	}
	static {
		this.ID = "editor.contrib.inspectTokens";
	}
	static get(e) {
		return e.getContribution(InspectTokensController_1.ID);
	}
	constructor(e, _, v) {
		super(), this._editor = e, this._languageService = v, this._widget = null, this._register(this._editor.onDidChangeModel((e) => this.stop())), this._register(this._editor.onDidChangeModelLanguage((e) => this.stop())), this._register(TokenizationRegistry.onDidChange((e) => this.stop())), this._register(this._editor.onKeyUp((e) => e.keyCode === 9 && this.stop()));
	}
	dispose() {
		this.stop(), super.dispose();
	}
	launch() {
		this._widget || this._editor.hasModel() && (this._widget = new InspectTokensWidget(this._editor, this._languageService));
	}
	stop() {
		this._widget &&= (this._widget.dispose(), null);
	}
};
InspectTokensController = InspectTokensController_1 = __decorate$7([__param$7(1, IStandaloneThemeService), __param$7(2, ILanguageService)], InspectTokensController);
var InspectTokens = class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.inspectTokens",
			label: InspectTokensNLS.inspectTokensAction,
			alias: "Developer: Inspect Tokens",
			precondition: void 0
		});
	}
	run(e, _) {
		InspectTokensController.get(_)?.launch();
	}
};
function renderTokenText(e) {
	let _ = "";
	for (let v = 0, y = e.length; v < y; v++) {
		let y = e.charCodeAt(v);
		switch (y) {
			case 9:
				_ += "→";
				break;
			case 32:
				_ += "·";
				break;
			default: _ += String.fromCharCode(y);
		}
	}
	return _;
}
function getSafeTokenizationSupport(e, _) {
	let v = TokenizationRegistry.get(_);
	if (v) return v;
	let y = e.encodeLanguageId(_);
	return {
		getInitialState: () => NullState,
		tokenize: (e, v, y) => nullTokenize(_, y),
		tokenizeEncoded: (e, _, v) => nullTokenizeEncoded(y, v)
	};
}
var InspectTokensWidget = class e extends Disposable {
	static {
		this._ID = "editor.contrib.inspectTokensWidget";
	}
	constructor(e, _) {
		super(), this.allowEditorOverflow = !0, this._editor = e, this._languageService = _, this._model = this._editor.getModel(), this._domNode = document.createElement("div"), this._domNode.className = "tokens-inspect-widget", this._tokenizationSupport = getSafeTokenizationSupport(this._languageService.languageIdCodec, this._model.getLanguageId()), this._compute(this._editor.getPosition()), this._register(this._editor.onDidChangeCursorPosition((e) => this._compute(this._editor.getPosition()))), this._editor.addContentWidget(this);
	}
	dispose() {
		this._editor.removeContentWidget(this), super.dispose();
	}
	getId() {
		return e._ID;
	}
	_compute(e) {
		let _ = this._getTokensAtLine(e.lineNumber), v = 0;
		for (let y = _.tokens1.length - 1; y >= 0; y--) {
			let b = _.tokens1[y];
			if (e.column - 1 >= b.offset) {
				v = y;
				break;
			}
		}
		let y = 0;
		for (let v = _.tokens2.length >>> 1; v >= 0; v--) if (e.column - 1 >= _.tokens2[v << 1]) {
			y = v;
			break;
		}
		let b = this._model.getLineContent(e.lineNumber), x = "";
		if (v < _.tokens1.length) {
			let e = _.tokens1[v].offset, y = v + 1 < _.tokens1.length ? _.tokens1[v + 1].offset : b.length;
			x = b.substring(e, y);
		}
		reset(this._domNode, $("h2.tm-token", void 0, renderTokenText(x), $("span.tm-token-length", void 0, `${x.length} ${x.length === 1 ? "char" : "chars"}`))), append(this._domNode, $("hr.tokens-inspect-separator", { style: "clear:both" }));
		let S = (y << 1) + 1 < _.tokens2.length ? this._decodeMetadata(_.tokens2[(y << 1) + 1]) : null;
		append(this._domNode, $("table.tm-metadata-table", void 0, $("tbody", void 0, $("tr", void 0, $("td.tm-metadata-key", void 0, "language"), $("td.tm-metadata-value", void 0, `${S ? S.languageId : "-?-"}`)), $("tr", void 0, $("td.tm-metadata-key", void 0, "token type"), $("td.tm-metadata-value", void 0, `${S ? this._tokenTypeToString(S.tokenType) : "-?-"}`)), $("tr", void 0, $("td.tm-metadata-key", void 0, "font style"), $("td.tm-metadata-value", void 0, `${S ? this._fontStyleToString(S.fontStyle) : "-?-"}`)), $("tr", void 0, $("td.tm-metadata-key", void 0, "foreground"), $("td.tm-metadata-value", void 0, `${S ? Color.Format.CSS.formatHex(S.foreground) : "-?-"}`)), $("tr", void 0, $("td.tm-metadata-key", void 0, "background"), $("td.tm-metadata-value", void 0, `${S ? Color.Format.CSS.formatHex(S.background) : "-?-"}`))))), append(this._domNode, $("hr.tokens-inspect-separator")), v < _.tokens1.length && append(this._domNode, $("span.tm-token-type", void 0, _.tokens1[v].type)), this._editor.layoutContentWidget(this);
	}
	_decodeMetadata(e) {
		let _ = TokenizationRegistry.getColorMap(), v = TokenMetadata.getLanguageId(e), y = TokenMetadata.getTokenType(e), b = TokenMetadata.getFontStyle(e), x = TokenMetadata.getForeground(e), S = TokenMetadata.getBackground(e);
		return {
			languageId: this._languageService.languageIdCodec.decodeLanguageId(v),
			tokenType: y,
			fontStyle: b,
			foreground: _[x],
			background: _[S]
		};
	}
	_tokenTypeToString(e) {
		switch (e) {
			case 0: return "Other";
			case 1: return "Comment";
			case 2: return "String";
			case 3: return "RegEx";
			default: return "??";
		}
	}
	_fontStyleToString(e) {
		let _ = "";
		return e & 1 && (_ += "italic "), e & 2 && (_ += "bold "), e & 4 && (_ += "underline "), e & 8 && (_ += "strikethrough "), _.length === 0 && (_ = "---"), _;
	}
	_getTokensAtLine(e) {
		let _ = this._getStateBeforeLine(e), v = this._tokenizationSupport.tokenize(this._model.getLineContent(e), !0, _), y = this._tokenizationSupport.tokenizeEncoded(this._model.getLineContent(e), !0, _);
		return {
			startState: _,
			tokens1: v.tokens,
			tokens2: y.tokens,
			endState: v.endState
		};
	}
	_getStateBeforeLine(e) {
		let _ = this._tokenizationSupport.getInitialState();
		for (let v = 1; v < e; v++) _ = this._tokenizationSupport.tokenize(this._model.getLineContent(v), !0, _).endState;
		return _;
	}
	getDomNode() {
		return this._domNode;
	}
	getPosition() {
		return {
			position: this._editor.getPosition(),
			preference: [2, 1]
		};
	}
};
registerEditorContribution(InspectTokensController.ID, InspectTokensController, 4), registerEditorAction(InspectTokens);
var __decorate$6 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$6 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, HelpQuickAccessProvider_1, HelpQuickAccessProvider = class {
	static {
		HelpQuickAccessProvider_1 = this;
	}
	static {
		this.PREFIX = "?";
	}
	constructor(e, _) {
		this.quickInputService = e, this.keybindingService = _, this.registry = Registry.as(Extensions.Quickaccess);
	}
	provide(e) {
		let _ = new DisposableStore();
		return _.add(e.onDidAccept(() => {
			let [_] = e.selectedItems;
			_ && this.quickInputService.quickAccess.show(_.prefix, { preserveValue: !0 });
		})), _.add(e.onDidChangeValue((e) => {
			let _ = this.registry.getQuickAccessProvider(e.substr(HelpQuickAccessProvider_1.PREFIX.length));
			_ && _.prefix && _.prefix !== HelpQuickAccessProvider_1.PREFIX && this.quickInputService.quickAccess.show(_.prefix, { preserveValue: !0 });
		})), e.items = this.getQuickAccessProviders().filter((e) => e.prefix !== HelpQuickAccessProvider_1.PREFIX), _;
	}
	getQuickAccessProviders() {
		return this.registry.getQuickAccessProviders().sort((e, _) => e.prefix.localeCompare(_.prefix)).flatMap((e) => this.createPicks(e));
	}
	createPicks(e) {
		return e.helpEntries.map((_) => {
			let v = _.prefix || e.prefix, y = v || "…";
			return {
				prefix: v,
				label: y,
				keybinding: _.commandId ? this.keybindingService.lookupKeybinding(_.commandId) : void 0,
				ariaLabel: localize("helpPickAriaLabel", "{0}, {1}", y, _.description),
				description: _.description
			};
		});
	}
};
HelpQuickAccessProvider = HelpQuickAccessProvider_1 = __decorate$6([__param$6(0, IQuickInputService), __param$6(1, IKeybindingService)], HelpQuickAccessProvider), Registry.as(Extensions.Quickaccess).registerQuickAccessProvider({
	ctor: HelpQuickAccessProvider,
	prefix: "",
	helpEntries: [{ description: QuickHelpNLS.helpQuickAccessActionLabel }]
});
var AbstractEditorNavigationQuickAccessProvider = class {
	constructor(e) {
		this.options = e, this.rangeHighlightDecorationId = void 0;
	}
	provide(e, _, v) {
		let y = new DisposableStore();
		e.canAcceptInBackground = !!this.options?.canAcceptInBackground, e.matchOnLabel = e.matchOnDescription = e.matchOnDetail = e.sortByLabel = !1;
		let b = y.add(new MutableDisposable());
		return b.value = this.doProvide(e, _, v), y.add(this.onDidActiveTextEditorControlChange(() => {
			b.value = void 0, b.value = this.doProvide(e, _);
		})), y;
	}
	doProvide(e, _, v) {
		let y = new DisposableStore(), b = this.activeTextEditorControl;
		if (b && this.canProvideWithTextEditor(b)) {
			let x = { editor: b }, S = getCodeEditor(b);
			if (S) {
				let e = b.saveViewState() ?? void 0;
				y.add(S.onDidChangeCursorPosition(() => {
					e = b.saveViewState() ?? void 0;
				})), x.restoreViewState = () => {
					e && b === this.activeTextEditorControl && b.restoreViewState(e);
				}, y.add(createSingleCallFunction(_.onCancellationRequested)(() => x.restoreViewState?.()));
			}
			y.add(toDisposable(() => this.clearDecorations(b))), y.add(this.provideWithTextEditor(x, e, _, v));
		} else y.add(this.provideWithoutTextEditor(e, _));
		return y;
	}
	canProvideWithTextEditor(e) {
		return !0;
	}
	gotoLocation({ editor: e }, _) {
		e.setSelection(_.range, "code.jump"), e.revealRangeInCenter(_.range, 0), _.preserveFocus || e.focus();
		let v = e.getModel();
		v && "getLineContent" in v && status(`${v.getLineContent(_.range.startLineNumber)}`);
	}
	getModel(e) {
		return isDiffEditor(e) ? e.getModel()?.modified : e.getModel();
	}
	addDecorations(e, _) {
		e.changeDecorations((e) => {
			let v = [];
			this.rangeHighlightDecorationId &&= (v.push(this.rangeHighlightDecorationId.overviewRulerDecorationId), v.push(this.rangeHighlightDecorationId.rangeHighlightId), void 0);
			let y = [{
				range: _,
				options: {
					description: "quick-access-range-highlight",
					className: "rangeHighlight",
					isWholeLine: !0
				}
			}, {
				range: _,
				options: {
					description: "quick-access-range-highlight-overview",
					overviewRuler: {
						color: themeColorFromId(overviewRulerRangeHighlight),
						position: OverviewRulerLane.Full
					}
				}
			}], [b, x] = e.deltaDecorations(v, y);
			this.rangeHighlightDecorationId = {
				rangeHighlightId: b,
				overviewRulerDecorationId: x
			};
		});
	}
	clearDecorations(e) {
		let _ = this.rangeHighlightDecorationId;
		_ && (e.changeDecorations((e) => {
			e.deltaDecorations([_.overviewRulerDecorationId, _.rangeHighlightId], []);
		}), this.rangeHighlightDecorationId = void 0);
	}
}, AbstractGotoLineQuickAccessProvider = class e extends AbstractEditorNavigationQuickAccessProvider {
	static {
		this.PREFIX = ":";
	}
	constructor() {
		super({ canAcceptInBackground: !0 });
	}
	provideWithoutTextEditor(e) {
		let _ = localize("cannotRunGotoLine", "Open a text editor first to go to a line.");
		return e.items = [{ label: _ }], e.ariaLabel = _, Disposable.None;
	}
	provideWithTextEditor(_, v, y) {
		let b = _.editor, x = new DisposableStore();
		x.add(v.onDidAccept((e) => {
			let [y] = v.selectedItems;
			if (y) {
				if (!this.isValidLineNumber(b, y.lineNumber)) return;
				this.gotoLocation(_, {
					range: this.toRange(y.lineNumber, y.column),
					keyMods: v.keyMods,
					preserveFocus: e.inBackground
				}), e.inBackground || v.hide();
			}
		}));
		let S = () => {
			let _ = this.parsePosition(b, v.value.trim().substr(e.PREFIX.length)), y = this.getPickLabel(b, _.lineNumber, _.column);
			if (v.items = [{
				lineNumber: _.lineNumber,
				column: _.column,
				label: y
			}], v.ariaLabel = y, !this.isValidLineNumber(b, _.lineNumber)) {
				this.clearDecorations(b);
				return;
			}
			let x = this.toRange(_.lineNumber, _.column);
			b.revealRangeInCenter(x, 0), this.addDecorations(b, x);
		};
		S(), x.add(v.onDidChangeValue(() => S()));
		let C = getCodeEditor(b);
		return C && C.getOptions().get(68).renderType === 2 && (C.updateOptions({ lineNumbers: "on" }), x.add(toDisposable(() => C.updateOptions({ lineNumbers: "relative" })))), x;
	}
	toRange(e = 1, _ = 1) {
		return {
			startLineNumber: e,
			startColumn: _,
			endLineNumber: e,
			endColumn: _
		};
	}
	parsePosition(e, _) {
		let v = _.split(/,|:|#/).map((e) => parseInt(e, 10)).filter((e) => !isNaN(e)), y = this.lineCount(e) + 1;
		return {
			lineNumber: v[0] > 0 ? v[0] : y + v[0],
			column: v[1]
		};
	}
	getPickLabel(e, _, v) {
		if (this.isValidLineNumber(e, _)) return this.isValidColumn(e, _, v) ? localize("gotoLineColumnLabel", "Go to line {0} and character {1}.", _, v) : localize("gotoLineLabel", "Go to line {0}.", _);
		let y = e.getPosition() || {
			lineNumber: 1,
			column: 1
		}, b = this.lineCount(e);
		return b > 1 ? localize("gotoLineLabelEmptyWithLimit", "Current Line: {0}, Character: {1}. Type a line number between 1 and {2} to navigate to.", y.lineNumber, y.column, b) : localize("gotoLineLabelEmpty", "Current Line: {0}, Character: {1}. Type a line number to navigate to.", y.lineNumber, y.column);
	}
	isValidLineNumber(e, _) {
		return !_ || typeof _ != "number" ? !1 : _ > 0 && _ <= this.lineCount(e);
	}
	isValidColumn(e, _, v) {
		if (!v || typeof v != "number") return !1;
		let y = this.getModel(e);
		if (!y) return !1;
		let b = {
			lineNumber: _,
			column: v
		};
		return y.validatePosition(b).equals(b);
	}
	lineCount(e) {
		return this.getModel(e)?.getLineCount() ?? 0;
	}
}, __decorate$5 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$5 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, StandaloneGotoLineQuickAccessProvider = class extends AbstractGotoLineQuickAccessProvider {
	constructor(e) {
		super(), this.editorService = e, this.onDidActiveTextEditorControlChange = Event.None;
	}
	get activeTextEditorControl() {
		return this.editorService.getFocusedCodeEditor() ?? void 0;
	}
};
StandaloneGotoLineQuickAccessProvider = __decorate$5([__param$5(0, ICodeEditorService)], StandaloneGotoLineQuickAccessProvider);
var GotoLineAction$1 = class e extends EditorAction {
	static {
		this.ID = "editor.action.gotoLine";
	}
	constructor() {
		super({
			id: e.ID,
			label: GoToLineNLS.gotoLineActionLabel,
			alias: "Go to Line/Column...",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 2085,
				mac: { primary: 293 },
				weight: 100
			}
		});
	}
	run(e) {
		e.get(IQuickInputService).quickAccess.show(StandaloneGotoLineQuickAccessProvider.PREFIX);
	}
};
registerEditorAction(GotoLineAction$1), Registry.as(Extensions.Quickaccess).registerQuickAccessProvider({
	ctor: StandaloneGotoLineQuickAccessProvider,
	prefix: StandaloneGotoLineQuickAccessProvider.PREFIX,
	helpEntries: [{
		description: GoToLineNLS.gotoLineActionLabel,
		commandId: GotoLineAction$1.ID
	}]
});
var NO_SCORE2 = [void 0, []];
function scoreFuzzy2(e, _, v = 0, y = 0) {
	let b = _;
	return b.values && b.values.length > 1 ? doScoreFuzzy2Multiple(e, b.values, v, y) : doScoreFuzzy2Single(e, _, v, y);
}
function doScoreFuzzy2Multiple(e, _, v, y) {
	let b = 0, x = [];
	for (let S of _) {
		let [_, C] = doScoreFuzzy2Single(e, S, v, y);
		if (typeof _ != "number") return NO_SCORE2;
		b += _, x.push(...C);
	}
	return [b, normalizeMatches(x)];
}
function doScoreFuzzy2Single(e, _, v, y) {
	let b = fuzzyScore(_.original, _.originalLowercase, v, e, e.toLowerCase(), y, {
		firstMatchCanBeWeak: !0,
		boostFullMatch: !0
	});
	return b ? [b[0], createMatches(b)] : NO_SCORE2;
}
Object.freeze({ score: 0 });
function normalizeMatches(e) {
	let _ = e.sort((e, _) => e.start - _.start), v = [], y;
	for (let e of _) !y || !matchOverlaps(y, e) ? (y = e, v.push(e)) : (y.start = Math.min(y.start, e.start), y.end = Math.max(y.end, e.end));
	return v;
}
function matchOverlaps(e, _) {
	return !(e.end < _.start || _.end < e.start);
}
function queryExpectsExactMatch(e) {
	return e.startsWith("\"") && e.endsWith("\"");
}
var MULTIPLE_QUERY_VALUES_SEPARATOR = " ";
function prepareQuery(e) {
	typeof e != "string" && (e = "");
	let _ = e.toLowerCase(), { pathNormalized: v, normalized: y, normalizedLowercase: b } = normalizeQuery(e), x = v.indexOf(sep) >= 0, S = queryExpectsExactMatch(e), C, w = e.split(MULTIPLE_QUERY_VALUES_SEPARATOR);
	if (w.length > 1) for (let e of w) {
		let _ = queryExpectsExactMatch(e), { pathNormalized: v, normalized: y, normalizedLowercase: b } = normalizeQuery(e);
		y && (C ||= [], C.push({
			original: e,
			originalLowercase: e.toLowerCase(),
			pathNormalized: v,
			normalized: y,
			normalizedLowercase: b,
			expectContiguousMatch: _
		}));
	}
	return {
		original: e,
		originalLowercase: _,
		pathNormalized: v,
		normalized: y,
		normalizedLowercase: b,
		values: C,
		containsPathSeparator: x,
		expectContiguousMatch: S
	};
}
function normalizeQuery(e) {
	let _;
	_ = isWindows ? e.replace(/\//g, sep) : e.replace(/\\/g, sep);
	let v = stripWildcards(_).replace(/\s|"/g, "");
	return {
		pathNormalized: _,
		normalized: v,
		normalizedLowercase: v.toLowerCase()
	};
}
function pieceToQuery(e) {
	return prepareQuery(Array.isArray(e) ? e.map((e) => e.original).join(MULTIPLE_QUERY_VALUES_SEPARATOR) : e.original);
}
var __decorate$4 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$4 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, AbstractGotoSymbolQuickAccessProvider_1, AbstractGotoSymbolQuickAccessProvider = class extends AbstractEditorNavigationQuickAccessProvider {
	static {
		AbstractGotoSymbolQuickAccessProvider_1 = this;
	}
	static {
		this.PREFIX = "@";
	}
	static {
		this.SCOPE_PREFIX = ":";
	}
	static {
		this.PREFIX_BY_CATEGORY = `${this.PREFIX}${this.SCOPE_PREFIX}`;
	}
	constructor(e, _, v = Object.create(null)) {
		super(v), this._languageFeaturesService = e, this._outlineModelService = _, this.options = v, this.options.canAcceptInBackground = !0;
	}
	provideWithoutTextEditor(e) {
		return this.provideLabelPick(e, localize("cannotRunGotoSymbolWithoutEditor", "To go to a symbol, first open a text editor with symbol information.")), Disposable.None;
	}
	provideWithTextEditor(e, _, v, y) {
		let b = e.editor, x = this.getModel(b);
		return x ? this._languageFeaturesService.documentSymbolProvider.has(x) ? this.doProvideWithEditorSymbols(e, x, _, v, y) : this.doProvideWithoutEditorSymbols(e, x, _, v) : Disposable.None;
	}
	doProvideWithoutEditorSymbols(e, _, v, y) {
		let b = new DisposableStore();
		return this.provideLabelPick(v, localize("cannotRunGotoSymbolWithoutSymbolProvider", "The active text editor does not provide symbol information.")), (async () => {
			!await this.waitForLanguageSymbolRegistry(_, b) || y.isCancellationRequested || b.add(this.doProvideWithEditorSymbols(e, _, v, y));
		})(), b;
	}
	provideLabelPick(e, _) {
		e.items = [{
			label: _,
			index: 0,
			kind: 14
		}], e.ariaLabel = _;
	}
	async waitForLanguageSymbolRegistry(e, _) {
		if (this._languageFeaturesService.documentSymbolProvider.has(e)) return !0;
		let v = new DeferredPromise(), y = _.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(() => {
			this._languageFeaturesService.documentSymbolProvider.has(e) && (y.dispose(), v.complete(!0));
		}));
		return _.add(toDisposable(() => v.complete(!1))), v.p;
	}
	doProvideWithEditorSymbols(e, _, v, y, b) {
		let x = e.editor, S = new DisposableStore();
		S.add(v.onDidAccept((_) => {
			let [y] = v.selectedItems;
			y && y.range && (this.gotoLocation(e, {
				range: y.range.selection,
				keyMods: v.keyMods,
				preserveFocus: _.inBackground
			}), b?.handleAccept?.(y), _.inBackground || v.hide());
		})), S.add(v.onDidTriggerItemButton(({ item: _ }) => {
			_ && _.range && (this.gotoLocation(e, {
				range: _.range.selection,
				keyMods: v.keyMods,
				forceSideBySide: !0
			}), v.hide());
		}));
		let C = this.getDocumentSymbols(_, y), w, T = async (e) => {
			w?.dispose(!0), v.busy = !1, w = new CancellationTokenSource(y), v.busy = !0;
			try {
				let b = prepareQuery(v.value.substr(AbstractGotoSymbolQuickAccessProvider_1.PREFIX.length).trim()), x = await this.doGetSymbolPicks(C, b, void 0, w.token, _);
				if (y.isCancellationRequested) return;
				if (x.length > 0) {
					if (v.items = x, e && b.original.length === 0) {
						let _ = findLast(x, (_) => !!(_.type !== "separator" && _.range && Range.containsPosition(_.range.decoration, e)));
						_ && (v.activeItems = [_]);
					}
				} else b.original.length > 0 ? this.provideLabelPick(v, localize("noMatchingSymbolResults", "No matching editor symbols")) : this.provideLabelPick(v, localize("noSymbolResults", "No editor symbols"));
			} finally {
				y.isCancellationRequested || (v.busy = !1);
			}
		};
		return S.add(v.onDidChangeValue(() => T(void 0))), T(x.getSelection()?.getPosition()), S.add(v.onDidChangeActive(() => {
			let [e] = v.activeItems;
			e && e.range && (x.revealRangeInCenter(e.range.selection, 0), this.addDecorations(x, e.range.decoration));
		})), S;
	}
	async doGetSymbolPicks(e, _, v, y, b) {
		let x = await e;
		if (y.isCancellationRequested) return [];
		let S = _.original.indexOf(AbstractGotoSymbolQuickAccessProvider_1.SCOPE_PREFIX) === 0, C = S ? 1 : 0, w, T;
		_.values && _.values.length > 1 ? (w = pieceToQuery(_.values[0]), T = pieceToQuery(_.values.slice(1))) : w = _;
		let E, D = this.options?.openSideBySideDirection?.();
		D && (E = [{
			iconClass: D === "right" ? ThemeIcon.asClassName(Codicon.splitHorizontal) : ThemeIcon.asClassName(Codicon.splitVertical),
			tooltip: D === "right" ? localize("openToSide", "Open to the Side") : localize("openToBottom", "Open to the Bottom")
		}]);
		let O = [];
		for (let e = 0; e < x.length; e++) {
			let y = x[e], S = trim(y.name), D = `$(${SymbolKinds.toIcon(y.kind).id}) ${S}`, k = D.length - S.length, A = y.containerName;
			v?.extraContainerLabel && (A = A ? `${v.extraContainerLabel} • ${A}` : v.extraContainerLabel);
			let j, M, N, P;
			if (_.original.length > C) {
				let e = !1;
				if (w !== _ && ([j, M] = scoreFuzzy2(D, {
					..._,
					values: void 0
				}, C, k), typeof j == "number" && (e = !0)), typeof j != "number" && ([j, M] = scoreFuzzy2(D, w, C, k), typeof j != "number")) continue;
				if (!e && T) {
					if (A && T.original.length > 0 && ([N, P] = scoreFuzzy2(A, T)), typeof N != "number") continue;
					typeof j == "number" && (j += N);
				}
			}
			let F = y.tags && y.tags.indexOf(1) >= 0;
			O.push({
				index: e,
				kind: y.kind,
				score: j,
				label: D,
				ariaLabel: getAriaLabelForSymbol(y.name, y.kind),
				description: A,
				highlights: F ? void 0 : {
					label: M,
					description: P
				},
				range: {
					selection: Range.collapseToStart(y.selectionRange),
					decoration: y.range
				},
				uri: b.uri,
				symbolName: S,
				strikethrough: F,
				buttons: E
			});
		}
		let k = O.sort((e, _) => S ? this.compareByKindAndScore(e, _) : this.compareByScore(e, _)), A = [];
		if (S) {
			let e, _, v = 0;
			function y() {
				_ && typeof e == "number" && v > 0 && (_.label = format(NLS_SYMBOL_KIND_CACHE[e] || FALLBACK_NLS_SYMBOL_KIND, v));
			}
			for (let b of k) e === b.kind ? v++ : (y(), e = b.kind, v = 1, _ = { type: "separator" }, A.push(_)), A.push(b);
			y();
		} else k.length > 0 && (A = [{
			label: localize("symbols", "symbols ({0})", O.length),
			type: "separator"
		}, ...k]);
		return A;
	}
	compareByScore(e, _) {
		if (typeof e.score != "number" && typeof _.score == "number") return 1;
		if (typeof e.score == "number" && typeof _.score != "number") return -1;
		if (typeof e.score == "number" && typeof _.score == "number") {
			if (e.score > _.score) return -1;
			if (e.score < _.score) return 1;
		}
		return e.index < _.index ? -1 : e.index > _.index ? 1 : 0;
	}
	compareByKindAndScore(e, _) {
		let v = NLS_SYMBOL_KIND_CACHE[e.kind] || FALLBACK_NLS_SYMBOL_KIND, y = NLS_SYMBOL_KIND_CACHE[_.kind] || FALLBACK_NLS_SYMBOL_KIND, b = v.localeCompare(y);
		return b === 0 ? this.compareByScore(e, _) : b;
	}
	async getDocumentSymbols(e, _) {
		let v = await this._outlineModelService.getOrCreate(e, _);
		return _.isCancellationRequested ? [] : v.asListOfDocumentSymbols();
	}
};
AbstractGotoSymbolQuickAccessProvider = AbstractGotoSymbolQuickAccessProvider_1 = __decorate$4([__param$4(0, ILanguageFeaturesService), __param$4(1, IOutlineModelService)], AbstractGotoSymbolQuickAccessProvider);
var FALLBACK_NLS_SYMBOL_KIND = localize("property", "properties ({0})"), NLS_SYMBOL_KIND_CACHE = {
	5: localize("method", "methods ({0})"),
	11: localize("function", "functions ({0})"),
	8: localize("_constructor", "constructors ({0})"),
	12: localize("variable", "variables ({0})"),
	4: localize("class", "classes ({0})"),
	22: localize("struct", "structs ({0})"),
	23: localize("event", "events ({0})"),
	24: localize("operator", "operators ({0})"),
	10: localize("interface", "interfaces ({0})"),
	2: localize("namespace", "namespaces ({0})"),
	3: localize("package", "packages ({0})"),
	25: localize("typeParameter", "type parameters ({0})"),
	1: localize("modules", "modules ({0})"),
	6: localize("property", "properties ({0})"),
	9: localize("enum", "enumerations ({0})"),
	21: localize("enumMember", "enumeration members ({0})"),
	14: localize("string", "strings ({0})"),
	0: localize("file", "files ({0})"),
	17: localize("array", "arrays ({0})"),
	15: localize("number", "numbers ({0})"),
	16: localize("boolean", "booleans ({0})"),
	18: localize("object", "objects ({0})"),
	19: localize("key", "keys ({0})"),
	7: localize("field", "fields ({0})"),
	13: localize("constant", "constants ({0})")
}, __decorate$3 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$3 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, StandaloneGotoSymbolQuickAccessProvider = class extends AbstractGotoSymbolQuickAccessProvider {
	constructor(e, _, v) {
		super(_, v), this.editorService = e, this.onDidActiveTextEditorControlChange = Event.None;
	}
	get activeTextEditorControl() {
		return this.editorService.getFocusedCodeEditor() ?? void 0;
	}
};
StandaloneGotoSymbolQuickAccessProvider = __decorate$3([
	__param$3(0, ICodeEditorService),
	__param$3(1, ILanguageFeaturesService),
	__param$3(2, IOutlineModelService)
], StandaloneGotoSymbolQuickAccessProvider);
var GotoSymbolAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.quickOutline";
	}
	constructor() {
		super({
			id: e.ID,
			label: QuickOutlineNLS.quickOutlineActionLabel,
			alias: "Go to Symbol...",
			precondition: EditorContextKeys.hasDocumentSymbolProvider,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 3117,
				weight: 100
			},
			contextMenuOpts: {
				group: "navigation",
				order: 3
			}
		});
	}
	run(e) {
		e.get(IQuickInputService).quickAccess.show(AbstractGotoSymbolQuickAccessProvider.PREFIX, { itemActivation: ItemActivation.NONE });
	}
};
registerEditorAction(GotoSymbolAction), Registry.as(Extensions.Quickaccess).registerQuickAccessProvider({
	ctor: StandaloneGotoSymbolQuickAccessProvider,
	prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX,
	helpEntries: [{
		description: QuickOutlineNLS.quickOutlineActionLabel,
		prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX,
		commandId: GotoSymbolAction.ID
	}, {
		description: QuickOutlineNLS.quickOutlineByCategoryActionLabel,
		prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX_BY_CATEGORY
	}]
});
function countMapFrom(e) {
	let _ = /* @__PURE__ */ new Map();
	for (let v of e) _.set(v, (_.get(v) ?? 0) + 1);
	return _;
}
var TfIdfCalculator = class e {
	constructor() {
		this.chunkCount = 0, this.chunkOccurrences = /* @__PURE__ */ new Map(), this.documents = /* @__PURE__ */ new Map();
	}
	calculateScores(e, _) {
		let v = this.computeEmbedding(e), y = /* @__PURE__ */ new Map(), b = [];
		for (let [e, x] of this.documents) {
			if (_.isCancellationRequested) return [];
			for (let _ of x.chunks) {
				let x = this.computeSimilarityScore(_, v, y);
				x > 0 && b.push({
					key: e,
					score: x
				});
			}
		}
		return b;
	}
	static termFrequencies(_) {
		return countMapFrom(e.splitTerms(_));
	}
	static *splitTerms(e) {
		let _ = (e) => e.toLowerCase();
		for (let [v] of e.matchAll(/\b\p{Letter}[\p{Letter}\d]{2,}\b/gu)) {
			yield _(v);
			let e = v.replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/g);
			if (e.length > 1) for (let v of e) v.length > 2 && /\p{Letter}{3,}/gu.test(v) && (yield _(v));
		}
	}
	updateDocuments(_) {
		for (let { key: e } of _) this.deleteDocument(e);
		for (let v of _) {
			let _ = [];
			for (let y of v.textChunks) {
				let v = e.termFrequencies(y);
				for (let e of v.keys()) this.chunkOccurrences.set(e, (this.chunkOccurrences.get(e) ?? 0) + 1);
				_.push({
					text: y,
					tf: v
				});
			}
			this.chunkCount += _.length, this.documents.set(v.key, { chunks: _ });
		}
		return this;
	}
	deleteDocument(e) {
		let _ = this.documents.get(e);
		if (_) {
			this.documents.delete(e), this.chunkCount -= _.chunks.length;
			for (let e of _.chunks) for (let _ of e.tf.keys()) {
				let e = this.chunkOccurrences.get(_);
				if (typeof e == "number") {
					let v = e - 1;
					v <= 0 ? this.chunkOccurrences.delete(_) : this.chunkOccurrences.set(_, v);
				}
			}
		}
	}
	computeSimilarityScore(e, _, v) {
		let y = 0;
		for (let [b, x] of Object.entries(_)) {
			let _ = e.tf.get(b);
			if (!_) continue;
			let S = v.get(b);
			typeof S != "number" && (S = this.computeIdf(b), v.set(b, S));
			let C = _ * S;
			y += C * x;
		}
		return y;
	}
	computeEmbedding(_) {
		let v = e.termFrequencies(_);
		return this.computeTfidf(v);
	}
	computeIdf(e) {
		let _ = this.chunkOccurrences.get(e) ?? 0;
		return _ > 0 ? Math.log((this.chunkCount + 1) / _) : 0;
	}
	computeTfidf(e) {
		let _ = Object.create(null);
		for (let [v, y] of e) {
			let e = this.computeIdf(v);
			e > 0 && (_[v] = y * e);
		}
		return _;
	}
};
function normalizeTfIdfScores(e) {
	let _ = e.slice(0);
	_.sort((e, _) => _.score - e.score);
	let v = _[0]?.score ?? 0;
	if (v > 0) for (let e of _) e.score /= v;
	return _;
}
var TriggerAction;
(function(e) {
	e[e.NO_ACTION = 0] = "NO_ACTION", e[e.CLOSE_PICKER = 1] = "CLOSE_PICKER", e[e.REFRESH_PICKER = 2] = "REFRESH_PICKER", e[e.REMOVE_ITEM = 3] = "REMOVE_ITEM";
})(TriggerAction ||= {});
function isPicksWithActive(e) {
	let _ = e;
	return Array.isArray(_.items);
}
function isFastAndSlowPicks(e) {
	let _ = e;
	return !!_.picks && _.additionalPicks instanceof Promise;
}
var PickerQuickAccessProvider = class extends Disposable {
	constructor(e, _) {
		super(), this.prefix = e, this.options = _;
	}
	provide(e, _, v) {
		let y = new DisposableStore();
		e.canAcceptInBackground = !!this.options?.canAcceptInBackground, e.matchOnLabel = e.matchOnDescription = e.matchOnDetail = e.sortByLabel = !1;
		let b, x = y.add(new MutableDisposable()), S = async () => {
			let y = x.value = new DisposableStore();
			b?.dispose(!0), e.busy = !1, b = new CancellationTokenSource(_);
			let S = b.token, C = e.value.substring(this.prefix.length);
			this.options?.shouldSkipTrimPickFilter || (C = C.trim());
			let w = this._getPicks(C, y, S, v), T = (_, v) => {
				let y, b;
				if (isPicksWithActive(_) ? (y = _.items, b = _.active) : y = _, y.length === 0) {
					if (v) return !1;
					(C.length > 0 || e.hideInput) && this.options?.noResultsPick && (y = isFunction(this.options.noResultsPick) ? [this.options.noResultsPick(C)] : [this.options.noResultsPick]);
				}
				return e.items = y, b && (e.activeItems = [b]), !0;
			}, E = async (_) => {
				let v = !1, y = !1;
				await Promise.all([(async () => {
					typeof _.mergeDelay == "number" && (await timeout(_.mergeDelay), S.isCancellationRequested) || y || (v = T(_.picks, !0));
				})(), (async () => {
					e.busy = !0;
					try {
						let y = await _.additionalPicks;
						if (S.isCancellationRequested) return;
						let b, x;
						isPicksWithActive(_.picks) ? (b = _.picks.items, x = _.picks.active) : b = _.picks;
						let C, w;
						if (isPicksWithActive(y) ? (C = y.items, w = y.active) : C = y, C.length > 0 || !v) {
							let _;
							if (!x && !w) {
								let v = e.activeItems[0];
								v && b.indexOf(v) !== -1 && (_ = v);
							}
							T({
								items: [...b, ...C],
								active: x || w || _
							});
						}
					} finally {
						S.isCancellationRequested || (e.busy = !1), y = !0;
					}
				})()]);
			};
			if (w !== null) if (isFastAndSlowPicks(w)) await E(w);
			else if (!(w instanceof Promise)) T(w);
			else {
				e.busy = !0;
				try {
					let e = await w;
					if (S.isCancellationRequested) return;
					isFastAndSlowPicks(e) ? await E(e) : T(e);
				} finally {
					S.isCancellationRequested || (e.busy = !1);
				}
			}
		};
		y.add(e.onDidChangeValue(() => S())), S(), y.add(e.onDidAccept((_) => {
			if (v?.handleAccept) {
				_.inBackground || e.hide(), v.handleAccept?.(e.activeItems[0]);
				return;
			}
			let [y] = e.selectedItems;
			typeof y?.accept == "function" && (_.inBackground || e.hide(), y.accept(e.keyMods, _));
		}));
		let C = async (v, y) => {
			if (typeof y.trigger != "function") return;
			let b = y.buttons?.indexOf(v) ?? -1;
			if (b >= 0) {
				let v = y.trigger(b, e.keyMods), x = typeof v == "number" ? v : await v;
				if (_.isCancellationRequested) return;
				switch (x) {
					case TriggerAction.NO_ACTION: break;
					case TriggerAction.CLOSE_PICKER:
						e.hide();
						break;
					case TriggerAction.REFRESH_PICKER:
						S();
						break;
					case TriggerAction.REMOVE_ITEM: {
						let _ = e.items.indexOf(y);
						if (_ !== -1) {
							let v = e.items.slice(), y = v.splice(_, 1), b = e.activeItems.filter((e) => e !== y[0]), x = e.keepScrollPosition;
							e.keepScrollPosition = !0, e.items = v, b && (e.activeItems = b), e.keepScrollPosition = x;
						}
						break;
					}
				}
			}
		};
		return y.add(e.onDidTriggerItemButton(({ button: e, item: _ }) => C(e, _))), y.add(e.onDidTriggerSeparatorButton(({ button: e, separator: _ }) => C(e, _))), y;
	}
}, __decorate$2 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$2 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, AbstractCommandsQuickAccessProvider_1, CommandsHistory_1, AbstractCommandsQuickAccessProvider = class extends PickerQuickAccessProvider {
	static {
		AbstractCommandsQuickAccessProvider_1 = this;
	}
	static {
		this.PREFIX = ">";
	}
	static {
		this.TFIDF_THRESHOLD = .5;
	}
	static {
		this.TFIDF_MAX_RESULTS = 5;
	}
	static {
		this.WORD_FILTER = or(matchesPrefix, matchesWords, matchesContiguousSubString);
	}
	constructor(e, _, v, y, b, x) {
		super(AbstractCommandsQuickAccessProvider_1.PREFIX, e), this.instantiationService = _, this.keybindingService = v, this.commandService = y, this.telemetryService = b, this.dialogService = x, this.commandsHistory = this._register(this.instantiationService.createInstance(CommandsHistory)), this.options = e;
	}
	async _getPicks(e, _, v, y) {
		let b = await this.getCommandPicks(v);
		if (v.isCancellationRequested) return [];
		let x = createSingleCallFunction(() => {
			let _ = new TfIdfCalculator();
			_.updateDocuments(b.map((e) => ({
				key: e.commandId,
				textChunks: [this.getTfIdfChunk(e)]
			})));
			let y = _.calculateScores(e, v);
			return normalizeTfIdfScores(y).filter((e) => e.score > AbstractCommandsQuickAccessProvider_1.TFIDF_THRESHOLD).slice(0, AbstractCommandsQuickAccessProvider_1.TFIDF_MAX_RESULTS);
		}), S = [];
		for (let _ of b) {
			let y = AbstractCommandsQuickAccessProvider_1.WORD_FILTER(e, _.label) ?? void 0, b = _.commandAlias ? AbstractCommandsQuickAccessProvider_1.WORD_FILTER(e, _.commandAlias) ?? void 0 : void 0;
			if (y || b) _.highlights = {
				label: y,
				detail: this.options.showAlias ? b : void 0
			}, S.push(_);
			else if (e === _.commandId) S.push(_);
			else if (e.length >= 3) {
				let e = x();
				if (v.isCancellationRequested) return [];
				let y = e.find((e) => e.key === _.commandId);
				y && (_.tfIdfScore = y.score, S.push(_));
			}
		}
		let C = /* @__PURE__ */ new Map();
		for (let e of S) {
			let _ = C.get(e.label);
			_ ? (e.description = e.commandId, _.description = _.commandId) : C.set(e.label, e);
		}
		S.sort((e, _) => {
			if (e.tfIdfScore && _.tfIdfScore) return e.tfIdfScore === _.tfIdfScore ? e.label.localeCompare(_.label) : _.tfIdfScore - e.tfIdfScore;
			if (e.tfIdfScore) return 1;
			if (_.tfIdfScore) return -1;
			let v = this.commandsHistory.peek(e.commandId), y = this.commandsHistory.peek(_.commandId);
			if (v && y) return v > y ? -1 : 1;
			if (v) return -1;
			if (y) return 1;
			if (this.options.suggestedCommandIds) {
				let v = this.options.suggestedCommandIds.has(e.commandId), y = this.options.suggestedCommandIds.has(_.commandId);
				if (v && y) return 0;
				if (v) return -1;
				if (y) return 1;
			}
			return e.label.localeCompare(_.label);
		});
		let w = [], T = !1, E = !0, D = !!this.options.suggestedCommandIds;
		for (let e = 0; e < S.length; e++) {
			let _ = S[e];
			e === 0 && this.commandsHistory.peek(_.commandId) && (w.push({
				type: "separator",
				label: localize("recentlyUsed", "recently used")
			}), T = !0), E && _.tfIdfScore !== void 0 && (w.push({
				type: "separator",
				label: localize("suggested", "similar commands")
			}), E = !1), D && _.tfIdfScore === void 0 && !this.commandsHistory.peek(_.commandId) && this.options.suggestedCommandIds?.has(_.commandId) && (w.push({
				type: "separator",
				label: localize("commonlyUsed", "commonly used")
			}), T = !0, D = !1), T && _.tfIdfScore === void 0 && !this.commandsHistory.peek(_.commandId) && !this.options.suggestedCommandIds?.has(_.commandId) && (w.push({
				type: "separator",
				label: localize("morecCommands", "other commands")
			}), T = !1), w.push(this.toCommandPick(_, y));
		}
		return this.hasAdditionalCommandPicks(e, v) ? {
			picks: w,
			additionalPicks: (async () => {
				let _ = await this.getAdditionalCommandPicks(b, S, e, v);
				if (v.isCancellationRequested) return [];
				let x = _.map((e) => this.toCommandPick(e, y));
				return E && x[0]?.type !== "separator" && x.unshift({
					type: "separator",
					label: localize("suggested", "similar commands")
				}), x;
			})()
		} : w;
	}
	toCommandPick(e, _) {
		if (e.type === "separator") return e;
		let v = this.keybindingService.lookupKeybinding(e.commandId), y = v ? localize("commandPickAriaLabelWithKeybinding", "{0}, {1}", e.label, v.getAriaLabel()) : e.label;
		return {
			...e,
			ariaLabel: y,
			detail: this.options.showAlias && e.commandAlias !== e.label ? e.commandAlias : void 0,
			keybinding: v,
			accept: async () => {
				this.commandsHistory.push(e.commandId), this.telemetryService.publicLog2("workbenchActionExecuted", {
					id: e.commandId,
					from: _?.from ?? "quick open"
				});
				try {
					e.args?.length ? await this.commandService.executeCommand(e.commandId, ...e.args) : await this.commandService.executeCommand(e.commandId);
				} catch (_) {
					isCancellationError(_) || this.dialogService.error(localize("canNotRun", "Command '{0}' resulted in an error", e.label), toErrorMessage(_));
				}
			}
		};
	}
	getTfIdfChunk({ label: e, commandAlias: _, commandDescription: v }) {
		let y = e;
		return _ && _ !== e && (y += ` - ${_}`), v && v.value !== e && (y += ` - ${v.value === v.original ? v.value : `${v.value} (${v.original})`}`), y;
	}
};
AbstractCommandsQuickAccessProvider = AbstractCommandsQuickAccessProvider_1 = __decorate$2([
	__param$2(1, IInstantiationService),
	__param$2(2, IKeybindingService),
	__param$2(3, ICommandService),
	__param$2(4, ITelemetryService),
	__param$2(5, IDialogService)
], AbstractCommandsQuickAccessProvider);
var CommandsHistory = class extends Disposable {
	static {
		CommandsHistory_1 = this;
	}
	static {
		this.DEFAULT_COMMANDS_HISTORY_LENGTH = 50;
	}
	static {
		this.PREF_KEY_CACHE = "commandPalette.mru.cache";
	}
	static {
		this.PREF_KEY_COUNTER = "commandPalette.mru.counter";
	}
	static {
		this.counter = 1;
	}
	static {
		this.hasChanges = !1;
	}
	constructor(e, _, v) {
		super(), this.storageService = e, this.configurationService = _, this.logService = v, this.configuredCommandsHistoryLength = 0, this.updateConfiguration(), this.load(), this.registerListeners();
	}
	registerListeners() {
		this._register(this.configurationService.onDidChangeConfiguration((e) => this.updateConfiguration(e))), this._register(this.storageService.onWillSaveState((e) => {
			e.reason === WillSaveStateReason.SHUTDOWN && this.saveState();
		}));
	}
	updateConfiguration(e) {
		e && !e.affectsConfiguration("workbench.commandPalette.history") || (this.configuredCommandsHistoryLength = CommandsHistory_1.getConfiguredCommandHistoryLength(this.configurationService), CommandsHistory_1.cache && CommandsHistory_1.cache.limit !== this.configuredCommandsHistoryLength && (CommandsHistory_1.cache.limit = this.configuredCommandsHistoryLength, CommandsHistory_1.hasChanges = !0));
	}
	load() {
		let e = this.storageService.get(CommandsHistory_1.PREF_KEY_CACHE, 0), _;
		if (e) try {
			_ = JSON.parse(e);
		} catch (e) {
			this.logService.error(`[CommandsHistory] invalid data: ${e}`);
		}
		let v = CommandsHistory_1.cache = new LRUCache(this.configuredCommandsHistoryLength, 1);
		if (_) {
			let e;
			e = _.usesLRU ? _.entries : _.entries.sort((e, _) => e.value - _.value), e.forEach((e) => v.set(e.key, e.value));
		}
		CommandsHistory_1.counter = this.storageService.getNumber(CommandsHistory_1.PREF_KEY_COUNTER, 0, CommandsHistory_1.counter);
	}
	push(e) {
		CommandsHistory_1.cache && (CommandsHistory_1.cache.set(e, CommandsHistory_1.counter++), CommandsHistory_1.hasChanges = !0);
	}
	peek(e) {
		return CommandsHistory_1.cache?.peek(e);
	}
	saveState() {
		if (!CommandsHistory_1.cache || !CommandsHistory_1.hasChanges) return;
		let e = {
			usesLRU: !0,
			entries: []
		};
		CommandsHistory_1.cache.forEach((_, v) => e.entries.push({
			key: v,
			value: _
		})), this.storageService.store(CommandsHistory_1.PREF_KEY_CACHE, JSON.stringify(e), 0, 0), this.storageService.store(CommandsHistory_1.PREF_KEY_COUNTER, CommandsHistory_1.counter, 0, 0), CommandsHistory_1.hasChanges = !1;
	}
	static getConfiguredCommandHistoryLength(e) {
		let _ = e.getValue().workbench?.commandPalette?.history;
		return typeof _ == "number" ? _ : CommandsHistory_1.DEFAULT_COMMANDS_HISTORY_LENGTH;
	}
};
CommandsHistory = CommandsHistory_1 = __decorate$2([
	__param$2(0, IStorageService),
	__param$2(1, IConfigurationService),
	__param$2(2, ILogService)
], CommandsHistory);
var AbstractEditorCommandsQuickAccessProvider = class extends AbstractCommandsQuickAccessProvider {
	constructor(e, _, v, y, b, x) {
		super(e, _, v, y, b, x);
	}
	getCodeEditorCommandPicks() {
		let e = this.activeTextEditorControl;
		if (!e) return [];
		let _ = [];
		for (let v of e.getSupportedActions()) {
			let e;
			v.metadata?.description && (e = isLocalizedString(v.metadata.description) ? v.metadata.description : {
				original: v.metadata.description,
				value: v.metadata.description
			}), _.push({
				commandId: v.id,
				commandAlias: v.alias,
				commandDescription: e,
				label: stripIcons(v.label) || v.id
			});
		}
		return _;
	}
}, __decorate$1 = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param$1 = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, StandaloneCommandsQuickAccessProvider = class extends AbstractEditorCommandsQuickAccessProvider {
	get activeTextEditorControl() {
		return this.codeEditorService.getFocusedCodeEditor() ?? void 0;
	}
	constructor(e, _, v, y, b, x) {
		super({ showAlias: !1 }, e, v, y, b, x), this.codeEditorService = _;
	}
	async getCommandPicks() {
		return this.getCodeEditorCommandPicks();
	}
	hasAdditionalCommandPicks() {
		return !1;
	}
	async getAdditionalCommandPicks() {
		return [];
	}
};
StandaloneCommandsQuickAccessProvider = __decorate$1([
	__param$1(0, IInstantiationService),
	__param$1(1, ICodeEditorService),
	__param$1(2, IKeybindingService),
	__param$1(3, ICommandService),
	__param$1(4, ITelemetryService),
	__param$1(5, IDialogService)
], StandaloneCommandsQuickAccessProvider);
var GotoLineAction = class e extends EditorAction {
	static {
		this.ID = "editor.action.quickCommand";
	}
	constructor() {
		super({
			id: e.ID,
			label: QuickCommandNLS.quickCommandActionLabel,
			alias: "Command Palette",
			precondition: void 0,
			kbOpts: {
				kbExpr: EditorContextKeys.focus,
				primary: 59,
				weight: 100
			},
			contextMenuOpts: {
				group: "z_commands",
				order: 1
			}
		});
	}
	run(e) {
		e.get(IQuickInputService).quickAccess.show(StandaloneCommandsQuickAccessProvider.PREFIX);
	}
};
registerEditorAction(GotoLineAction), Registry.as(Extensions.Quickaccess).registerQuickAccessProvider({
	ctor: StandaloneCommandsQuickAccessProvider,
	prefix: StandaloneCommandsQuickAccessProvider.PREFIX,
	helpEntries: [{
		description: QuickCommandNLS.quickCommandHelp,
		commandId: GotoLineAction.ID
	}]
});
var __decorate = function(e, _, v, y) {
	var b = arguments.length, x = b < 3 ? _ : y === null ? y = Object.getOwnPropertyDescriptor(_, v) : y, S;
	if (typeof Reflect == "object" && typeof Reflect.decorate == "function") x = Reflect.decorate(e, _, v, y);
	else for (var C = e.length - 1; C >= 0; C--) (S = e[C]) && (x = (b < 3 ? S(x) : b > 3 ? S(_, v, x) : S(_, v)) || x);
	return b > 3 && x && Object.defineProperty(_, v, x), x;
}, __param = function(e, _) {
	return function(v, y) {
		_(v, y, e);
	};
}, StandaloneReferencesController = class extends ReferencesController {
	constructor(e, _, v, y, b, x, S) {
		super(!0, e, _, v, y, b, x, S);
	}
};
StandaloneReferencesController = __decorate([
	__param(1, IContextKeyService),
	__param(2, ICodeEditorService),
	__param(3, INotificationService),
	__param(4, IInstantiationService),
	__param(5, IStorageService),
	__param(6, IConfigurationService)
], StandaloneReferencesController), registerEditorContribution(ReferencesController.ID, StandaloneReferencesController, 4), registerEditorAction(class extends EditorAction {
	constructor() {
		super({
			id: "editor.action.toggleHighContrast",
			label: ToggleHighContrastNLS.toggleHighContrast,
			alias: "Toggle High Contrast Theme",
			precondition: void 0
		}), this._originalThemeName = null;
	}
	run(e, _) {
		let v = e.get(IStandaloneThemeService), y = v.getColorTheme();
		isHighContrast(y.type) ? (v.setTheme(this._originalThemeName || (isDark(y.type) ? "vs-dark" : "vs")), this._originalThemeName = null) : (v.setTheme(isDark(y.type) ? HC_BLACK_THEME_NAME : HC_LIGHT_THEME_NAME), this._originalThemeName = y.themeName);
	}
});
export { GraphQLObjectType as $, isIntrospectionType as A, inspect as At, GraphQLBoolean as B, invariant as Bt, GraphQLSchema as C, print as Ct, TypeMetaFieldDef as D, parseValue as Dt, TypeKind as E, parse as Et, GraphQLDirective as F, printBlockString as Ft, isSpecifiedScalarType as G, GraphQLID as H, devAssert as Ht, GraphQLIncludeDirective as I, Kind as It, GraphQLEnumType as J, specifiedScalarTypes as K, GraphQLSkipDirective as L, DirectiveLocation as Lt, isIterableObject as M, isPunctuatorTokenKind as Mt, DEFAULT_DEPRECATION_REASON as N, TokenKind as Nt, TypeNameMetaFieldDef as O, Source as Ot, GraphQLDeprecatedDirective as P, isPrintableAsBlockString as Pt, GraphQLNonNull as Q, isSpecifiedDirective as R, OperationTypeNode as Rt, assertValidSchema as S, valueFromASTUntyped as St, SchemaMetaFieldDef as T, keyValMap as Tt, GraphQLInt as U, GraphQLFloat as V, isObjectLike as Vt, GraphQLString as W, GraphQLInterfaceType as X, GraphQLInputObjectType as Y, GraphQLList as Z, pathToArray as _, isNullableType as _t, getContextAtPosition as a, getNamedType as at, visitWithTypeInfo as b, isScalarType as bt, validate as c, isCompositeType as ct, getArgumentValues as d, isInputType as dt, GraphQLScalarType as et, getDirectiveValues as f, isInterfaceType as ft, addPath as g, isNonNullType as gt, coerceInputValue as h, isNamedType as ht, CompletionItemKind as i, assertObjectType as it, astFromValue as j, Lexer as jt, introspectionTypes as k, isSource as kt, collectFields as l, isEnumType as lt, valueFromAST as m, isListType as mt, getHoverInformation as n, assertInterfaceType as nt, buildASTSchema as o, getNullableType as ot, getVariableValues as p, isLeafType as pt, doTypesOverlap as q, Position$1 as r, assertNullableType as rt, buildSchema as s, isAbstractType as st, registerLanguage as t, GraphQLUnionType as tt, collectSubfields as u, isInputObjectType as ut, isTypeSystemDefinitionNode as v, isObjectType as vt, isSchema as w, visit as wt, typeFromAST as x, isUnionType as xt, TypeInfo as y, isOutputType as yt, specifiedDirectives as z, GraphQLError as zt };