@delta-ai/platform 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/action/common/action.d.ts +75 -0
  2. package/dist/action/common/action.d.ts.map +1 -0
  3. package/dist/action/common/action.js +17 -0
  4. package/dist/action/common/action.js.map +1 -0
  5. package/dist/action/common/actionCommonCategories.d.ts +9 -0
  6. package/dist/action/common/actionCommonCategories.d.ts.map +1 -0
  7. package/dist/action/common/actionCommonCategories.js +14 -0
  8. package/dist/action/common/actionCommonCategories.js.map +1 -0
  9. package/dist/commands/common/commands.d.ts +52 -0
  10. package/dist/commands/common/commands.d.ts.map +1 -0
  11. package/dist/commands/common/commands.js +79 -0
  12. package/dist/commands/common/commands.js.map +1 -0
  13. package/dist/contextkey/common/contextkey.d.ts +439 -0
  14. package/dist/contextkey/common/contextkey.d.ts.map +1 -0
  15. package/dist/contextkey/common/contextkey.js +1729 -0
  16. package/dist/contextkey/common/contextkey.js.map +1 -0
  17. package/dist/contextkey/common/scanner.d.ts +142 -0
  18. package/dist/contextkey/common/scanner.d.ts.map +1 -0
  19. package/dist/contextkey/common/scanner.js +311 -0
  20. package/dist/contextkey/common/scanner.js.map +1 -0
  21. package/dist/environment/common/argv.d.ts +173 -0
  22. package/dist/environment/common/argv.d.ts.map +1 -0
  23. package/dist/environment/common/argv.js +6 -0
  24. package/dist/environment/common/argv.js.map +1 -0
  25. package/dist/environment/common/environment.d.ts +113 -0
  26. package/dist/environment/common/environment.d.ts.map +1 -0
  27. package/dist/environment/common/environment.js +9 -0
  28. package/dist/environment/common/environment.js.map +1 -0
  29. package/dist/environment/common/environmentService.d.ts +91 -0
  30. package/dist/environment/common/environmentService.d.ts.map +1 -0
  31. package/dist/environment/common/environmentService.js +278 -0
  32. package/dist/environment/common/environmentService.js.map +1 -0
  33. package/dist/instantiation/common/descriptors.d.ts +10 -0
  34. package/dist/instantiation/common/descriptors.d.ts.map +1 -0
  35. package/dist/instantiation/common/descriptors.js +15 -0
  36. package/dist/instantiation/common/descriptors.js.map +1 -0
  37. package/dist/instantiation/common/graph.d.ts +26 -0
  38. package/dist/instantiation/common/graph.d.ts.map +1 -0
  39. package/dist/instantiation/common/graph.js +96 -0
  40. package/dist/instantiation/common/graph.js.map +1 -0
  41. package/dist/instantiation/common/instantiation.d.ts +76 -0
  42. package/dist/instantiation/common/instantiation.d.ts.map +1 -0
  43. package/dist/instantiation/common/instantiation.js +49 -0
  44. package/dist/instantiation/common/instantiation.js.map +1 -0
  45. package/dist/instantiation/common/instantiationService.d.ts +56 -0
  46. package/dist/instantiation/common/instantiationService.d.ts.map +1 -0
  47. package/dist/instantiation/common/instantiationService.js +415 -0
  48. package/dist/instantiation/common/instantiationService.js.map +1 -0
  49. package/dist/instantiation/common/serviceCollection.d.ts +10 -0
  50. package/dist/instantiation/common/serviceCollection.d.ts.map +1 -0
  51. package/dist/instantiation/common/serviceCollection.js +25 -0
  52. package/dist/instantiation/common/serviceCollection.js.map +1 -0
  53. package/dist/log/common/log.d.ts +297 -0
  54. package/dist/log/common/log.d.ts.map +1 -0
  55. package/dist/log/common/log.js +668 -0
  56. package/dist/log/common/log.js.map +1 -0
  57. package/dist/registry/common/platform.d.ts +21 -0
  58. package/dist/registry/common/platform.d.ts.map +1 -0
  59. package/dist/registry/common/platform.js +31 -0
  60. package/dist/registry/common/platform.js.map +1 -0
  61. package/package.json +42 -0
@@ -0,0 +1,75 @@
1
+ import { URI, type UriDto } from '@delta-ai/base/common/uri.js';
2
+ import type { ContextKeyExpression } from '@delta-ai/platform/contextkey/common/contextkey.js';
3
+ import { ThemeIcon } from '@delta-ai/base/common/themables.js';
4
+ import { Categories } from './actionCommonCategories.js';
5
+ import type { ICommandMetadata } from '@delta-ai/platform/commands/common/commands.js';
6
+ export interface ILocalizedString {
7
+ /**
8
+ * The localized value of the string.
9
+ */
10
+ value: string;
11
+ /**
12
+ * The original (non localized value of the string)
13
+ */
14
+ original: string;
15
+ }
16
+ export declare function isLocalizedString(thing: unknown): thing is ILocalizedString;
17
+ export interface ICommandActionTitle extends ILocalizedString {
18
+ /**
19
+ * The title with a mnemonic designation. && precedes the mnemonic.
20
+ */
21
+ mnemonicTitle?: string;
22
+ }
23
+ export type Icon = {
24
+ dark?: URI;
25
+ light?: URI;
26
+ } | ThemeIcon;
27
+ export interface ICommandActionToggleInfo {
28
+ /**
29
+ * The condition that marks the action as toggled.
30
+ */
31
+ condition: ContextKeyExpression;
32
+ icon?: Icon;
33
+ tooltip?: string;
34
+ /**
35
+ * The title that goes well with a a check mark, e.g "(check) Line Numbers" vs "Toggle Line Numbers"
36
+ */
37
+ title?: string;
38
+ /**
39
+ * Like title but with a mnemonic designation.
40
+ */
41
+ mnemonicTitle?: string;
42
+ }
43
+ export declare function isICommandActionToggleInfo(thing: ContextKeyExpression | ICommandActionToggleInfo | undefined): thing is ICommandActionToggleInfo;
44
+ export interface ICommandActionSource {
45
+ readonly id: string;
46
+ readonly title: string;
47
+ }
48
+ export interface ICommandAction {
49
+ id: string;
50
+ title: string | ICommandActionTitle;
51
+ shortTitle?: string | ICommandActionTitle;
52
+ /**
53
+ * Metadata about this command, used for:
54
+ * - API commands
55
+ * - when showing keybindings that have no other UX
56
+ * - when searching for commands in the Command Palette
57
+ */
58
+ metadata?: ICommandMetadata;
59
+ category?: keyof typeof Categories | ILocalizedString | string;
60
+ tooltip?: string | ILocalizedString;
61
+ icon?: Icon;
62
+ source?: ICommandActionSource;
63
+ /**
64
+ * Precondition controls enablement (for example for a menu item, show
65
+ * it in grey or for a command, do not allow to invoke it)
66
+ */
67
+ precondition?: ContextKeyExpression;
68
+ /**
69
+ * The action is a toggle action. Define the context key expression that reflects its toggle-state
70
+ * or define toggle-info including an icon and a title that goes well with a checkmark.
71
+ */
72
+ toggled?: ContextKeyExpression | ICommandActionToggleInfo;
73
+ }
74
+ export type ISerializableCommandAction = UriDto<ICommandAction>;
75
+ //# sourceMappingURL=action.d.ts.map
@@ -0,0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,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,OAAO,UAAU,GAAG,gBAAgB,GAAG,MAAM,CAAC;IAC/D,OAAO,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACpC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAEpC;;;OAGG;IACH,OAAO,CAAC,EAAE,oBAAoB,GAAG,wBAAwB,CAAC;CAC1D;AAED,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { URI } from '@delta-ai/base/common/uri.js';
6
+ import { ThemeIcon } from '@delta-ai/base/common/themables.js';
7
+ import { Categories } from './actionCommonCategories.js';
8
+ export function isLocalizedString(thing) {
9
+ return !!thing
10
+ && typeof thing === 'object'
11
+ && typeof thing.original === 'string'
12
+ && typeof thing.value === 'string';
13
+ }
14
+ export function isICommandActionToggleInfo(thing) {
15
+ return thing ? thing.condition !== undefined : false;
16
+ }
17
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/action/common/action.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,GAAG,EAAe,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAgBzD,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC/C,OAAO,CAAC,CAAC,KAAK;WACV,OAAO,KAAK,KAAK,QAAQ;WACzB,OAAQ,KAA0B,CAAC,QAAQ,KAAK,QAAQ;WACxD,OAAQ,KAA0B,CAAC,KAAK,KAAK,QAAQ,CAAC;AAC3D,CAAC;AAkCD,MAAM,UAAU,0BAA0B,CAAC,KAAkE;IAC5G,OAAO,KAAK,CAAC,CAAC,CAA4B,KAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AAClF,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const Categories: Readonly<{
2
+ View: import("@delta-ai/base/nls.js").ILocalizedString;
3
+ Help: import("@delta-ai/base/nls.js").ILocalizedString;
4
+ Test: import("@delta-ai/base/nls.js").ILocalizedString;
5
+ File: import("@delta-ai/base/nls.js").ILocalizedString;
6
+ Preferences: import("@delta-ai/base/nls.js").ILocalizedString;
7
+ Developer: import("@delta-ai/base/nls.js").ILocalizedString;
8
+ }>;
9
+ //# sourceMappingURL=actionCommonCategories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionCommonCategories.d.ts","sourceRoot":"","sources":["../../../src/action/common/actionCommonCategories.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU;;;;;;;EAOrB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { localize2 } from '@delta-ai/base/nls.js';
6
+ export const Categories = Object.freeze({
7
+ View: localize2('view', 'View'),
8
+ Help: localize2('help', 'Help'),
9
+ Test: localize2('test', 'Test'),
10
+ File: localize2('file', 'File'),
11
+ Preferences: localize2('preferences', 'Preferences'),
12
+ Developer: localize2({ key: 'developer', comment: ['A developer on Code itself or someone diagnosing issues in Code'] }, "Developer"),
13
+ });
14
+ //# sourceMappingURL=actionCommonCategories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionCommonCategories.js","sourceRoot":"","sources":["../../../src/action/common/actionCommonCategories.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAC/B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAC/B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAC/B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IACpD,SAAS,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,iEAAiE,CAAC,EAAE,EAAE,WAAW,CAAC;CACrI,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { Event } from '@delta-ai/base/common/event.js';
2
+ import type { IJSONSchema } from '@delta-ai/base/common/jsonSchema.js';
3
+ import { type IDisposable } from '@delta-ai/base/common/lifecycle.js';
4
+ import { type TypeConstraint } from '@delta-ai/base/common/types.js';
5
+ import type { ILocalizedString } from '@delta-ai/platform/action/common/action.js';
6
+ import { type ServicesAccessor } from '@delta-ai/platform/instantiation/common/instantiation.js';
7
+ export declare const ICommandService: import("@delta-ai/platform/instantiation/common/instantiation.js").ServiceIdentifier<ICommandService>;
8
+ export interface ICommandEvent {
9
+ readonly commandId: string;
10
+ readonly args: unknown[];
11
+ }
12
+ export interface ICommandService {
13
+ readonly _serviceBrand: undefined;
14
+ readonly onWillExecuteCommand: Event<ICommandEvent>;
15
+ readonly onDidExecuteCommand: Event<ICommandEvent>;
16
+ executeCommand<R = unknown>(commandId: string, ...args: unknown[]): Promise<R | undefined>;
17
+ }
18
+ export type ICommandsMap = Map<string, ICommand>;
19
+ export type ICommandHandler<Args extends unknown[] = unknown[], R = void> = (accessor: ServicesAccessor, ...args: Args) => R;
20
+ export interface ICommand<Args extends unknown[] = unknown[], R = void> {
21
+ id: string;
22
+ handler: ICommandHandler<Args, R>;
23
+ metadata?: ICommandMetadata | null;
24
+ }
25
+ export interface ICommandMetadata {
26
+ /**
27
+ * NOTE: Please use an ILocalizedString. string is in the type for backcompat for now.
28
+ * A short summary of what the command does. This will be used in:
29
+ * - API commands
30
+ * - when showing keybindings that have no other UX
31
+ * - when searching for commands in the Command Palette
32
+ */
33
+ readonly description: ILocalizedString | string;
34
+ readonly args?: ReadonlyArray<{
35
+ readonly name: string;
36
+ readonly isOptional?: boolean;
37
+ readonly description?: string;
38
+ readonly constraint?: TypeConstraint;
39
+ readonly schema?: IJSONSchema;
40
+ }>;
41
+ readonly returns?: string;
42
+ }
43
+ export interface ICommandRegistry {
44
+ readonly onDidRegisterCommand: Event<string>;
45
+ registerCommand<Args extends unknown[]>(id: string, command: ICommandHandler<Args>): IDisposable;
46
+ registerCommand<Args extends unknown[]>(command: ICommand<Args>): IDisposable;
47
+ registerCommandAlias(oldId: string, newId: string): IDisposable;
48
+ getCommand(id: string): ICommand | undefined;
49
+ getCommands(): ICommandsMap;
50
+ }
51
+ export declare const CommandsRegistry: ICommandRegistry;
52
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/commands/common/commands.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,E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ED,MAAM,WAAW,gBAAgB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;QAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;QACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,CAAC,CAAC;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7C,eAAe,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACjG,eAAe,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IAC9E,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAChE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC7C,WAAW,IAAI,YAAY,CAAC;CAC5B;AAED,eAAO,MAAM,gBAAgB,EAAE,gBAgF9B,CAAC"}
@@ -0,0 +1,79 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { Emitter, Event } from '@delta-ai/base/common/event.js';
6
+ import { Iterable } from '@delta-ai/base/common/iterator.js';
7
+ import { markAsSingleton, toDisposable } from '@delta-ai/base/common/lifecycle.js';
8
+ import { LinkedList } from '@delta-ai/base/common/linkedList.js';
9
+ import { validateConstraints } from '@delta-ai/base/common/types.js';
10
+ import { createDecorator } from '@delta-ai/platform/instantiation/common/instantiation.js';
11
+ export const ICommandService = createDecorator('commandService');
12
+ export const CommandsRegistry = new class {
13
+ _commands = new Map();
14
+ _onDidRegisterCommand = new Emitter();
15
+ onDidRegisterCommand = this._onDidRegisterCommand.event;
16
+ registerCommand(idOrCommand, handler) {
17
+ if (!idOrCommand) {
18
+ throw new Error(`invalid command`);
19
+ }
20
+ if (typeof idOrCommand === 'string') {
21
+ if (!handler) {
22
+ throw new Error(`invalid command`);
23
+ }
24
+ return this.registerCommand({ id: idOrCommand, handler });
25
+ }
26
+ // add argument validation if rich command metadata is provided
27
+ if (idOrCommand.metadata && Array.isArray(idOrCommand.metadata.args)) {
28
+ const constraints = [];
29
+ for (const arg of idOrCommand.metadata.args) {
30
+ constraints.push(arg.constraint);
31
+ }
32
+ const actualHandler = idOrCommand.handler;
33
+ idOrCommand.handler = function (accessor, ...args) {
34
+ validateConstraints(args, constraints);
35
+ return actualHandler(accessor, ...args);
36
+ };
37
+ }
38
+ // find a place to store the command
39
+ const { id } = idOrCommand;
40
+ let commands = this._commands.get(id);
41
+ if (!commands) {
42
+ commands = new LinkedList();
43
+ this._commands.set(id, commands);
44
+ }
45
+ const removeFn = commands.unshift(idOrCommand);
46
+ const ret = toDisposable(() => {
47
+ removeFn();
48
+ const command = this._commands.get(id);
49
+ if (command?.isEmpty()) {
50
+ this._commands.delete(id);
51
+ }
52
+ });
53
+ // tell the world about this command
54
+ this._onDidRegisterCommand.fire(id);
55
+ return markAsSingleton(ret);
56
+ }
57
+ registerCommandAlias(oldId, newId) {
58
+ return CommandsRegistry.registerCommand(oldId, (accessor, ...args) => accessor.get(ICommandService).executeCommand(newId, ...args));
59
+ }
60
+ getCommand(id) {
61
+ const list = this._commands.get(id);
62
+ if (!list || list.isEmpty()) {
63
+ return undefined;
64
+ }
65
+ return Iterable.first(list);
66
+ }
67
+ getCommands() {
68
+ const result = new Map();
69
+ for (const key of this._commands.keys()) {
70
+ const command = this.getCommand(key);
71
+ if (command) {
72
+ result.set(key, command);
73
+ }
74
+ }
75
+ return result;
76
+ }
77
+ };
78
+ CommandsRegistry.registerCommand('noop', () => { });
79
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/commands/common/commands.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EAAoB,eAAe,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAuB,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1F,OAAO,EAAE,eAAe,EAAyB,MAAM,0DAA0D,CAAC;AAElH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAkB,gBAAgB,CAAC,CAAC;AAoDlF,MAAM,CAAC,MAAM,gBAAgB,GAAqB,IAAI;IAEpC,SAAS,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEpD,qBAAqB,GAAG,IAAI,OAAO,EAAU,CAAC;IACtD,oBAAoB,GAAkB,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC;IAEhF,eAAe,CAAC,WAA8B,EAAE,OAAyB;QAExE,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,C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