@mongodb-js/compass-editor 0.66.1 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codemirror/ace-compat-autocompleter.d.ts +1 -2
- package/dist/codemirror/ace-compat-autocompleter.d.ts.map +1 -1
- package/dist/codemirror/ace-compat-autocompleter.js +1 -38
- package/dist/codemirror/ace-compat-autocompleter.js.map +1 -1
- package/dist/codemirror/query-autocompleter.d.ts +2 -2
- package/dist/codemirror/query-autocompleter.d.ts.map +1 -1
- package/dist/codemirror/query-autocompleter.js +33 -12
- package/dist/codemirror/query-autocompleter.js.map +1 -1
- package/dist/codemirror/query-history-autocompleter.d.ts +2 -2
- package/dist/codemirror/query-history-autocompleter.d.ts.map +1 -1
- package/dist/codemirror/query-history-autocompleter.js +145 -85
- package/dist/codemirror/query-history-autocompleter.js.map +1 -1
- package/dist/codemirror/stage-autocompleter.d.ts.map +1 -1
- package/dist/codemirror/stage-autocompleter.js +1 -0
- package/dist/codemirror/stage-autocompleter.js.map +1 -1
- package/dist/codemirror/utils.d.ts +4 -1
- package/dist/codemirror/utils.d.ts.map +1 -1
- package/dist/codemirror/utils.js +62 -0
- package/dist/codemirror/utils.js.map +1 -1
- package/dist/editor.d.ts +3 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +7 -2
- package/dist/editor.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/use-json-schema-autocompleter.d.ts +42 -0
- package/dist/use-json-schema-autocompleter.d.ts.map +1 -0
- package/dist/use-json-schema-autocompleter.js +446 -0
- package/dist/use-json-schema-autocompleter.js.map +1 -0
- package/package.json +20 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompletionContext, CompletionResult, CompletionSource } from '@codemirror/autocomplete';
|
|
2
2
|
import type { CompletionResult as MongoDBCompletionResult } from '../autocompleter';
|
|
3
3
|
import type { Token } from './utils';
|
|
4
|
-
export declare function mapMongoDBCompletionToCodemirrorCompletion(completion: MongoDBCompletionResult, escape?: 'always' | 'never' | 'invalid'): Completion;
|
|
5
4
|
type Prefix = {
|
|
6
5
|
from: number;
|
|
7
6
|
to: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ace-compat-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/ace-compat-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"ace-compat-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/ace-compat-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,IAAI,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAKpF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,KAAK,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,QAAQ,QAA+C,CAAC;AAErE,wBAAgB,iCAAiC,CAAC,EAChD,MAAM,EACN,WAAW,EACX,MAAM,GACP,EAAE;IACD,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACpC,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACvC,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;CACzC,GAAG,gBAAgB,CASnB;AAED,KAAK,yBAAyB,GAAG,CAAC,OAAO,EAAE;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,iBAAiB,CAAC;CAC5B,KAAK,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAEnC;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,UAAU,EAAE;IACvD,MAAM,CAAC,EAAE,yBAAyB,CAAC;IACnC,cAAc,CAAC,EAAE,yBAAyB,CAAC;CAC5C,GAAG,gBAAgB,CAqBnB"}
|
|
@@ -1,46 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ID_REGEX = void 0;
|
|
4
|
-
exports.mapMongoDBCompletionToCodemirrorCompletion = mapMongoDBCompletionToCodemirrorCompletion;
|
|
5
4
|
exports.createCompletionResultForIdPrefix = createCompletionResultForIdPrefix;
|
|
6
5
|
exports.createAceCompatAutocompleter = createAceCompatAutocompleter;
|
|
7
|
-
const autocomplete_1 = require("@codemirror/autocomplete");
|
|
8
|
-
const autocompleter_1 = require("../autocompleter");
|
|
9
6
|
const utils_1 = require("./utils");
|
|
10
|
-
function mapMongoDBCompletionToCodemirrorCompletion(completion, escape = 'invalid') {
|
|
11
|
-
const cmCompletion = {
|
|
12
|
-
label: completion.value,
|
|
13
|
-
apply: escape === 'never'
|
|
14
|
-
? completion.value
|
|
15
|
-
: (0, autocompleter_1.wrapField)(completion.value, escape === 'always'),
|
|
16
|
-
detail: completion.meta?.startsWith('field') ? 'field' : completion.meta,
|
|
17
|
-
type: completion.meta?.startsWith('field') ? 'field' : 'method',
|
|
18
|
-
info() {
|
|
19
|
-
if (!completion.description) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
const infoNode = document.createElement('div');
|
|
23
|
-
infoNode.classList.add('completion-info');
|
|
24
|
-
infoNode.addEventListener('mousedown', (evt) => {
|
|
25
|
-
// If we are clicking a link inside the info block, we have to prevent
|
|
26
|
-
// default browser behavior that will remove the focus from the editor
|
|
27
|
-
// and cause the autocompleter to dissapear before browser handles the
|
|
28
|
-
// actual click. This is very similar to how codemirror handles clicks
|
|
29
|
-
// on the list items
|
|
30
|
-
// @see {@link https://github.com/codemirror/autocomplete/blob/82480a7d51d60ad933808e42f6189d841a5a6bc8/src/tooltip.ts#L96-L97}
|
|
31
|
-
if (evt.target.nodeName === 'A') {
|
|
32
|
-
evt.preventDefault();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
infoNode.innerHTML = completion.description;
|
|
36
|
-
return infoNode;
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
if (completion.snippet) {
|
|
40
|
-
return (0, autocomplete_1.snippetCompletion)(completion.snippet, cmCompletion);
|
|
41
|
-
}
|
|
42
|
-
return cmCompletion;
|
|
43
|
-
}
|
|
44
7
|
/**
|
|
45
8
|
* Ace autocompleter "valid" identifier regex
|
|
46
9
|
*/
|
|
@@ -50,7 +13,7 @@ function createCompletionResultForIdPrefix({ prefix, completions, escape, }) {
|
|
|
50
13
|
from: prefix.from,
|
|
51
14
|
to: prefix.to,
|
|
52
15
|
options: completions.map((completion) => {
|
|
53
|
-
return mapMongoDBCompletionToCodemirrorCompletion(completion, escape);
|
|
16
|
+
return (0, utils_1.mapMongoDBCompletionToCodemirrorCompletion)(completion, escape);
|
|
54
17
|
}),
|
|
55
18
|
validFor: exports.ID_REGEX,
|
|
56
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ace-compat-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/ace-compat-autocompleter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ace-compat-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/ace-compat-autocompleter.ts"],"names":[],"mappings":";;;AAmBA,8EAiBC;AAiBD,oEAwBC;AAvED,mCAGiB;AAKjB;;GAEG;AACU,QAAA,QAAQ,GAAG,4CAA4C,CAAC;AAErE,SAAgB,iCAAiC,CAAC,EAChD,MAAM,EACN,WAAW,EACX,MAAM,GAKP;IACC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YACtC,OAAO,IAAA,kDAA0C,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACxE,CAAC,CAAC;QACF,QAAQ,EAAE,gBAAQ;KACnB,CAAC;AACJ,CAAC;AAQD;;;;;;;;GAQG;AACH,SAAgB,4BAA4B,CAAC,UAG5C;IACC,OAAO,SAAS,sBAAsB,CAAC,OAAO;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,gBAAQ,CAAC,CAAC;QAC7C,MAAM,KAAK,GAAG,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAExC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtD,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QACzC,CAAC;QAED,OAAO,UAAU,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CompletionSource } from '@codemirror/autocomplete';
|
|
2
2
|
import type { CompletionOptions } from '../autocompleter';
|
|
3
3
|
/**
|
|
4
|
-
* Autocompleter for
|
|
5
|
-
*
|
|
4
|
+
* Autocompleter for MongoDB queries, completes field names, query
|
|
5
|
+
* operators, and bson values based on the context.
|
|
6
6
|
*/
|
|
7
7
|
export declare const createQueryAutocompleter: (options?: Pick<CompletionOptions, "fields" | "serverVersion">) => CompletionSource;
|
|
8
8
|
//# sourceMappingURL=query-autocompleter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/query-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"query-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/query-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAS1D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAS,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,eAAe,CAAM,KAChE,gBA8CF,CAAC"}
|
|
@@ -2,25 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createQueryAutocompleter = void 0;
|
|
4
4
|
const autocompleter_1 = require("../autocompleter");
|
|
5
|
-
const ace_compat_autocompleter_1 = require("./ace-compat-autocompleter");
|
|
6
5
|
const utils_1 = require("./utils");
|
|
7
6
|
/**
|
|
8
|
-
* Autocompleter for
|
|
9
|
-
*
|
|
7
|
+
* Autocompleter for MongoDB queries, completes field names, query
|
|
8
|
+
* operators, and bson values based on the context.
|
|
10
9
|
*/
|
|
11
10
|
const createQueryAutocompleter = (options = {}) => {
|
|
12
|
-
const
|
|
13
|
-
meta: ['query', '
|
|
11
|
+
const fieldCompletions = (0, autocompleter_1.completer)('', {
|
|
12
|
+
meta: ['query', 'field:identifier'],
|
|
14
13
|
...options,
|
|
15
14
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
IdentifierLike({ prefix }) {
|
|
21
|
-
return (0, ace_compat_autocompleter_1.createCompletionResultForIdPrefix)({ prefix, completions });
|
|
22
|
-
},
|
|
15
|
+
const valueCompletions = (0, autocompleter_1.completer)('', {
|
|
16
|
+
meta: ['bson', 'bson-legacy-uuid'],
|
|
17
|
+
...options,
|
|
23
18
|
});
|
|
19
|
+
return (context) => {
|
|
20
|
+
const token = (0, utils_1.resolveTokenAtCursor)(context);
|
|
21
|
+
// Don't autocomplete while in a comment.
|
|
22
|
+
if (['BlockComment', 'LineComment'].includes(token.type.name)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const prefix = context.state
|
|
26
|
+
.sliceDoc(token.from, context.pos)
|
|
27
|
+
.replace(/^("|')/, '');
|
|
28
|
+
if (!prefix) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const isValueCompletion = (0, utils_1.isPropertyValue)(token);
|
|
32
|
+
if (isValueCompletion && token.type.name === 'String') {
|
|
33
|
+
return (0, utils_1.completeWordsInString)(context) ?? null;
|
|
34
|
+
}
|
|
35
|
+
const completions = isValueCompletion ? valueCompletions : fieldCompletions;
|
|
36
|
+
return {
|
|
37
|
+
from: token.from,
|
|
38
|
+
to: token.to,
|
|
39
|
+
options: completions
|
|
40
|
+
.filter((completion) => completion.value.toLowerCase().includes(prefix.toLowerCase()))
|
|
41
|
+
.map((completion) => (0, utils_1.mapMongoDBCompletionToCodemirrorCompletion)(completion)),
|
|
42
|
+
filter: false,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
24
45
|
};
|
|
25
46
|
exports.createQueryAutocompleter = createQueryAutocompleter;
|
|
26
47
|
//# sourceMappingURL=query-autocompleter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/query-autocompleter.ts"],"names":[],"mappings":";;;AAEA,oDAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"query-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/query-autocompleter.ts"],"names":[],"mappings":";;;AAEA,oDAA6C;AAC7C,mCAKiB;AAEjB;;;GAGG;AACI,MAAM,wBAAwB,GAAG,CACtC,UAA+D,EAAE,EAC/C,EAAE;IACpB,MAAM,gBAAgB,GAAG,IAAA,yBAAS,EAAC,EAAE,EAAE;QACrC,IAAI,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC;QACnC,GAAG,OAAO;KACX,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,IAAA,yBAAS,EAAC,EAAE,EAAE;QACrC,IAAI,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAClC,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,KAAK,GAAG,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC;QAE5C,yCAAyC;QACzC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK;aACzB,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;aACjC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAEzB,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,iBAAiB,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,iBAAiB,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtD,OAAO,IAAA,6BAAqB,EAAC,OAAO,CAAC,IAAI,IAAI,CAAC;QAChD,CAAC;QAED,MAAM,WAAW,GAAG,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAE5E,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,OAAO,EAAE,WAAW;iBACjB,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CACrB,UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAC9D;iBACA,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAClB,IAAA,kDAA0C,EAAC,UAAU,CAAC,CACvD;YACH,MAAM,EAAE,KAAK;SACd,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,wBAAwB,4BAgDnC"}
|
|
@@ -7,13 +7,13 @@ export type SavedQuery = {
|
|
|
7
7
|
[propertyName: string]: any;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
+
export declare function createQueryLabel(query: SavedQuery, propertyName: string): string;
|
|
11
|
+
export declare function createQueryDisplayLabel(query: SavedQuery): string;
|
|
10
12
|
export declare const createQueryHistoryAutocompleter: ({ savedQueries, onApply, queryProperty, theme, }: {
|
|
11
13
|
savedQueries: SavedQuery[];
|
|
12
14
|
onApply: (query: SavedQuery["queryProperties"]) => void;
|
|
13
15
|
queryProperty: string;
|
|
14
16
|
theme: CodemirrorThemeType;
|
|
15
17
|
}) => CompletionSource;
|
|
16
|
-
export declare function createQueryLabel(query: SavedQuery, propertyName: string): string;
|
|
17
|
-
export declare function createQueryDisplayLabel(query: SavedQuery): string;
|
|
18
18
|
export declare function scaleBetween(unscaledNum: number, newScaleMin: number, newScaleMax: number, originalScaleMin: number, originalScaleMax: number): number;
|
|
19
19
|
//# sourceMappingURL=query-history-autocompleter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-history-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/query-history-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAUlC,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,WAAW,CAAC;AAEtE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,IAAI,CAAC;IACnB,eAAe,EAAE;QACf,CAAC,YAAY,EAAE,MAAM,GAAG,GAAG,CAAC;KAC7B,CAAC;CACH,CAAC;
|
|
1
|
+
{"version":3,"file":"query-history-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/query-history-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAUlC,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,WAAW,CAAC;AAEtE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,IAAI,CAAC;IACnB,eAAe,EAAE;QACf,CAAC,YAAY,EAAE,MAAM,GAAG,GAAG,CAAC;KAC7B,CAAC;CACH,CAAC;AAiCF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,UAAU,EACjB,YAAY,EAAE,MAAM,GACnB,MAAM,CAaR;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAWjE;AAkJD,eAAO,MAAM,+BAA+B,GAAI,kDAK7C;IACD,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,mBAAmB,CAAC;CAC5B,KAAG,gBA6CH,CAAC;AAoEF,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CASR"}
|
|
@@ -9,9 +9,132 @@ const mongodb_query_parser_1 = require("mongodb-query-parser");
|
|
|
9
9
|
const editor_1 = require("../editor");
|
|
10
10
|
const highlight_1 = require("@lezer/highlight");
|
|
11
11
|
const editor_2 = require("../editor");
|
|
12
|
+
const MAX_RESULTS = 10;
|
|
13
|
+
const MAX_FIELDS = 10;
|
|
14
|
+
const MAX_VALUE_LENGTH = 200;
|
|
15
|
+
const queryLabelStyles = (0, compass_components_1.css)({
|
|
16
|
+
textTransform: 'capitalize',
|
|
17
|
+
fontWeight: 'bold',
|
|
18
|
+
fontFamily: compass_components_1.fontFamilies.default,
|
|
19
|
+
});
|
|
20
|
+
const queryCodeStyles = (0, compass_components_1.css)({
|
|
21
|
+
fontFamily: compass_components_1.fontFamilies.code,
|
|
22
|
+
margin: `${compass_components_1.spacing[50]}px`,
|
|
23
|
+
marginLeft: `${compass_components_1.spacing[100]}px`,
|
|
24
|
+
padding: 0,
|
|
25
|
+
whiteSpace: 'pre-wrap',
|
|
26
|
+
});
|
|
27
|
+
function createQueryLabel(query, propertyName) {
|
|
28
|
+
const queryProperty = query.queryProperties[propertyName];
|
|
29
|
+
if (queryProperty === '' ||
|
|
30
|
+
queryProperty === undefined ||
|
|
31
|
+
queryProperty === null) {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
// The autocompletion uses a fuzzy search on the label, we only want to
|
|
35
|
+
// auto complete property that is being edited, not all of them.
|
|
36
|
+
return (0, mongodb_query_parser_1.toJSString)(queryProperty) || '';
|
|
37
|
+
}
|
|
38
|
+
function createQueryDisplayLabel(query) {
|
|
39
|
+
return Object.entries(query.queryProperties)
|
|
40
|
+
.map(([key, value]) => {
|
|
41
|
+
const formattedQuery = (0, mongodb_query_parser_1.toJSString)(value, 1);
|
|
42
|
+
if (!formattedQuery)
|
|
43
|
+
return '';
|
|
44
|
+
// Hide the `filter` key in the display label as it's the default field.
|
|
45
|
+
const fieldKey = key === 'filter' ? '' : `${key}: `;
|
|
46
|
+
return `${fieldKey}${formattedQuery}`;
|
|
47
|
+
})
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.reduce((acc, curr) => (acc ? `${acc}, ${curr}` : curr), '');
|
|
50
|
+
}
|
|
12
51
|
function simplifyQueryStringForAutocomplete(queryString) {
|
|
13
52
|
return queryString.replace(/[\s'"\n\t{}},]/g, '').toLowerCase();
|
|
14
53
|
}
|
|
54
|
+
function prepareQueries(savedQueries, queryProperty) {
|
|
55
|
+
return savedQueries
|
|
56
|
+
.map((query) => {
|
|
57
|
+
const queryValue = query.queryProperties[queryProperty];
|
|
58
|
+
// Only some query properties are objects for instance limit is a scalar.
|
|
59
|
+
const isObject = typeof queryValue === 'object';
|
|
60
|
+
let scalarSimplified = '';
|
|
61
|
+
let fields = [];
|
|
62
|
+
if (queryProperty === '' ||
|
|
63
|
+
queryProperty === undefined ||
|
|
64
|
+
queryProperty === null) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (!isObject) {
|
|
68
|
+
if (queryValue?.length && queryValue?.length > MAX_VALUE_LENGTH) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const str = (0, mongodb_query_parser_1.toJSString)(queryValue) || '';
|
|
72
|
+
if (!str || str.length > MAX_VALUE_LENGTH) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
scalarSimplified = str ? simplifyQueryStringForAutocomplete(str) : '';
|
|
76
|
+
}
|
|
77
|
+
else if (queryValue) {
|
|
78
|
+
const queryIsArray = Array.isArray(queryValue);
|
|
79
|
+
// We only support autocompletion for objects and arrays of key value pairs.
|
|
80
|
+
if (queryIsArray &&
|
|
81
|
+
queryValue.some((value) => typeof value !== 'object' ||
|
|
82
|
+
Array.isArray(value) ||
|
|
83
|
+
value.length !== 2)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
// Sort can be an array of key values, or an object, we want to support both.
|
|
87
|
+
const queryIterable = queryIsArray
|
|
88
|
+
? queryValue
|
|
89
|
+
: Object.entries(queryValue);
|
|
90
|
+
fields = queryIterable
|
|
91
|
+
// Some queries can have a ton of fields, we slice to avoid long loops on each character typed.
|
|
92
|
+
.slice(0, MAX_FIELDS)
|
|
93
|
+
.map(([key, value]) => {
|
|
94
|
+
// We don't provide matching on array or object values, as they can be
|
|
95
|
+
// very long and we want to prioritize matching on field names.
|
|
96
|
+
const fieldValue = typeof value === 'object' || Array.isArray(value) ? '' : value;
|
|
97
|
+
const fieldString = (0, mongodb_query_parser_1.toJSString)({ [key]: fieldValue }) || '';
|
|
98
|
+
return {
|
|
99
|
+
simplified: simplifyQueryStringForAutocomplete(fieldString),
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
// Prioritize performance over showing every query.
|
|
103
|
+
if (fields.length === 0 ||
|
|
104
|
+
fields.some((field) => field.simplified.length > MAX_VALUE_LENGTH)) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
query,
|
|
110
|
+
label: createQueryLabel(query, queryProperty),
|
|
111
|
+
displayLabel: createQueryDisplayLabel(query),
|
|
112
|
+
isObject,
|
|
113
|
+
scalarSimplified,
|
|
114
|
+
fields,
|
|
115
|
+
};
|
|
116
|
+
})
|
|
117
|
+
.filter((query) => query !== null);
|
|
118
|
+
}
|
|
119
|
+
function matchesPreparedQuery(query, input) {
|
|
120
|
+
if (!query.isObject) {
|
|
121
|
+
return (query.scalarSimplified !== '' && query.scalarSimplified.startsWith(input));
|
|
122
|
+
}
|
|
123
|
+
let inputToMatch = input;
|
|
124
|
+
for (const field of query.fields) {
|
|
125
|
+
// Don't show an option if the user has typed the whole field.
|
|
126
|
+
if (input === field.simplified)
|
|
127
|
+
return false;
|
|
128
|
+
// When the user is typing their first field, we can return early.
|
|
129
|
+
if (field.simplified.startsWith(input))
|
|
130
|
+
return true;
|
|
131
|
+
const inputIndex = inputToMatch.indexOf(field.simplified);
|
|
132
|
+
if (inputIndex !== -1) {
|
|
133
|
+
inputToMatch = inputToMatch.replace(field.simplified, '');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return inputToMatch.length === 0;
|
|
137
|
+
}
|
|
15
138
|
/**
|
|
16
139
|
* Codemirror runs a fuzzy search on the completion item labels.
|
|
17
140
|
* Oftentimes the fuzzy search will match on too many query history items.
|
|
@@ -19,75 +142,45 @@ function simplifyQueryStringForAutocomplete(queryString) {
|
|
|
19
142
|
* We give suggestions of queries that either match at least one field,
|
|
20
143
|
* or that contain the prefix the user is typing.
|
|
21
144
|
*/
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
145
|
+
function getMatchingPreparedQueries(preparedQueries, input) {
|
|
146
|
+
const simplifiedInput = simplifyQueryStringForAutocomplete(input);
|
|
147
|
+
if (simplifiedInput.length === 0) {
|
|
25
148
|
// Everything matches when empty search.
|
|
26
|
-
return
|
|
149
|
+
return preparedQueries;
|
|
27
150
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
const queryValueSimplified = simplifyQueryStringForAutocomplete(queryValueString);
|
|
37
|
-
return queryValueSimplified.startsWith(input);
|
|
38
|
-
}
|
|
39
|
-
// We subtract parts of the string until there's nothing left.
|
|
40
|
-
// We know it's a possible match if the all of the input is found in the query.
|
|
41
|
-
let inputToMatch = input;
|
|
42
|
-
// We check each top level field as they can be in any order.
|
|
43
|
-
for (const [key, value] of Object.entries(queryValue).slice(0, 30 /* Some queries can have a ton of fields, we slice to avoid long loops on each character typed. */)) {
|
|
44
|
-
const fieldString = (0, mongodb_query_parser_1.toJSString)({ [key]: value }) || '';
|
|
45
|
-
const fieldStringSimplified = simplifyQueryStringForAutocomplete(fieldString);
|
|
46
|
-
if (input === fieldStringSimplified) {
|
|
47
|
-
// Don't show an option if the user has typed the whole field.
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
if (fieldStringSimplified.startsWith(input)) {
|
|
51
|
-
// When the user is typing their first field, we can return early.
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
const inputIndex = inputToMatch.indexOf(fieldStringSimplified);
|
|
55
|
-
if (inputIndex !== -1) {
|
|
56
|
-
inputToMatch = inputToMatch.replace(fieldStringSimplified, '');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (inputToMatch.length === 0) {
|
|
60
|
-
return true;
|
|
151
|
+
const results = [];
|
|
152
|
+
for (const query of preparedQueries) {
|
|
153
|
+
if (results.length >= MAX_RESULTS)
|
|
154
|
+
break;
|
|
155
|
+
if (matchesPreparedQuery(query, simplifiedInput)) {
|
|
156
|
+
results.push(query);
|
|
61
157
|
}
|
|
62
|
-
|
|
63
|
-
|
|
158
|
+
}
|
|
159
|
+
return results;
|
|
64
160
|
}
|
|
65
161
|
const createQueryHistoryAutocompleter = ({ savedQueries, onApply, queryProperty, theme, }) => {
|
|
162
|
+
const preparedQueries = prepareQueries(savedQueries, queryProperty);
|
|
66
163
|
return function queryCompletions(context) {
|
|
67
|
-
if (
|
|
164
|
+
if (preparedQueries.length === 0) {
|
|
68
165
|
return null;
|
|
69
166
|
}
|
|
70
167
|
const maxTime = savedQueries[savedQueries.length - 1].lastExecuted.getTime();
|
|
71
168
|
const minTime = savedQueries[0].lastExecuted.getTime();
|
|
72
169
|
const contextValue = context.state.sliceDoc(0, context.pos);
|
|
73
|
-
const matchedQueries =
|
|
74
|
-
savedQueries,
|
|
75
|
-
queryProperty,
|
|
76
|
-
input: contextValue,
|
|
77
|
-
});
|
|
170
|
+
const matchedQueries = getMatchingPreparedQueries(preparedQueries, contextValue);
|
|
78
171
|
const options = matchedQueries.map((query) => ({
|
|
79
172
|
// Use a display label to show the query property
|
|
80
173
|
// field names before their respective parts.
|
|
81
|
-
displayLabel:
|
|
82
|
-
label:
|
|
83
|
-
type: query.type === 'recent' ? 'query-history' : 'favorite',
|
|
84
|
-
detail: (0, compass_components_1.formatDate)(query.lastExecuted.getTime()),
|
|
85
|
-
info: () => createInfo(query, theme).dom,
|
|
174
|
+
displayLabel: query.displayLabel,
|
|
175
|
+
label: query.label,
|
|
176
|
+
type: query.query.type === 'recent' ? 'query-history' : 'favorite',
|
|
177
|
+
detail: (0, compass_components_1.formatDate)(query.query.lastExecuted.getTime()),
|
|
178
|
+
info: () => createInfo(query.query, theme).dom,
|
|
86
179
|
apply: () => {
|
|
87
|
-
onApply(query.queryProperties);
|
|
180
|
+
onApply(query.query.queryProperties);
|
|
88
181
|
},
|
|
89
182
|
// CodeMirror expects boost values to be between -99 and 99
|
|
90
|
-
boost: scaleBetween(query.lastExecuted.getTime(), -99, 99, minTime, maxTime),
|
|
183
|
+
boost: scaleBetween(query.query.lastExecuted.getTime(), -99, 99, minTime, maxTime),
|
|
91
184
|
}));
|
|
92
185
|
return {
|
|
93
186
|
from: context.pos,
|
|
@@ -96,39 +189,6 @@ const createQueryHistoryAutocompleter = ({ savedQueries, onApply, queryProperty,
|
|
|
96
189
|
};
|
|
97
190
|
};
|
|
98
191
|
exports.createQueryHistoryAutocompleter = createQueryHistoryAutocompleter;
|
|
99
|
-
const queryLabelStyles = (0, compass_components_1.css)({
|
|
100
|
-
textTransform: 'capitalize',
|
|
101
|
-
fontWeight: 'bold',
|
|
102
|
-
fontFamily: compass_components_1.fontFamilies.default,
|
|
103
|
-
});
|
|
104
|
-
const queryCodeStyles = (0, compass_components_1.css)({
|
|
105
|
-
fontFamily: compass_components_1.fontFamilies.code,
|
|
106
|
-
margin: `${compass_components_1.spacing[50]}px`,
|
|
107
|
-
marginLeft: `${compass_components_1.spacing[100]}px`,
|
|
108
|
-
padding: 0,
|
|
109
|
-
whiteSpace: 'pre-wrap',
|
|
110
|
-
});
|
|
111
|
-
function createQueryLabel(query, propertyName) {
|
|
112
|
-
if (!query.queryProperties[propertyName]) {
|
|
113
|
-
return '';
|
|
114
|
-
}
|
|
115
|
-
// The autocompletion uses a fuzzy search on the label, we only want to
|
|
116
|
-
// auto complete property that is being edited, not all of them.
|
|
117
|
-
return (0, mongodb_query_parser_1.toJSString)(query.queryProperties[propertyName]) || '';
|
|
118
|
-
}
|
|
119
|
-
function createQueryDisplayLabel(query) {
|
|
120
|
-
return Object.entries(query.queryProperties)
|
|
121
|
-
.map(([key, value]) => {
|
|
122
|
-
const formattedQuery = (0, mongodb_query_parser_1.toJSString)(value, 1);
|
|
123
|
-
if (!formattedQuery)
|
|
124
|
-
return '';
|
|
125
|
-
// Hide the `filter` key in the display label as it's the default field.
|
|
126
|
-
const fieldKey = key === 'filter' ? '' : `${key}: `;
|
|
127
|
-
return `${fieldKey}${formattedQuery}`;
|
|
128
|
-
})
|
|
129
|
-
.filter(Boolean)
|
|
130
|
-
.reduce((acc, curr) => (acc ? `${acc}, ${curr}` : curr), '');
|
|
131
|
-
}
|
|
132
192
|
const javascriptExpressionLanguageParser = editor_1.languages['javascript-expression']().language.parser;
|
|
133
193
|
function createInfo(query, theme) {
|
|
134
194
|
const customHighlighter = editor_2.highlightStyles[theme];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-history-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/query-history-autocompleter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"query-history-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/query-history-autocompleter.ts"],"names":[],"mappings":";;;AAsDA,4CAgBC;AAED,0DAWC;AA6QD,oCAeC;AA3WD,uEAKwC;AACxC,+DAAkD;AAClD,sCAAsC;AACtC,gDAAiD;AACjD,sCAAsE;AAuBtE,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,gBAAgB,GAA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d,OAAO,EAAE,GAAG,EAAE;YACZ,OAAO,SAAS,CAAC,UAAU,EAAE,CAAC;gBAC5B,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,SAAgB,YAAY,CAC1B,WAAmB,EACnB,WAAmB,EACnB,WAAmB,EACnB,gBAAwB,EACxB,gBAAwB;IAExB,+DAA+D;IAC/D,IAAI,gBAAgB,KAAK,gBAAgB;QACvC,OAAO,WAAW,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IACvD,OAAO,CACL,CAAC,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,WAAW,GAAG,gBAAgB,CAAC,CAAC;QAC9D,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACvC,WAAW,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/stage-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAS1D,eAAO,MAAM,wBAAwB,GAAI,sDAKtC,IAAI,CACL,iBAAiB,EACjB,QAAQ,GAAG,eAAe,GAAG,WAAW,GAAG,WAAW,CACvD,GAAG;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;CACnB,KAAG,
|
|
1
|
+
{"version":3,"file":"stage-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/stage-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAS1D,eAAO,MAAM,wBAAwB,GA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AC3B,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,uDAA4B,EAAC;QAClC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE;YACxB,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChC,OAAO,IAAA,4DAAiC,EAAC;oBACvC,MAAM;oBACN,WAAW,EAAE,0BAA0B;oBACvC,iDAAiD;oBACjD,MAAM,EAAE,OAAO;iBAChB,CAAC,CAAC;YACL,CAAC;YAED,OAAO,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAC;QACxC,CAAC;QACD,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE;YAChC,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;gBAC/B,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,IAAA,4DAAiC,EAAC;gBACvC,MAAM;gBACN,WAAW,EAAE,gBAAgB;aAC9B,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"stage-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/stage-autocompleter.ts"],"names":[],"mappings":";;;AAEA,oDAA6C;AAC7C,yEAGoC;AACpC,mCAAyD;AACzD,+DAAiE;AAE1D,MAAM,wBAAwB,GAAG,CAAC,EACvC,aAAa,EACb,SAAS,EACT,SAAS,EACT,GAAG,OAAO,KAMR,EAAE,EAAoB,EAAE;IAC1B,MAAM,kBAAkB,GAAG,IAAA,8CAAwB,EAAC,OAAO,CAAC,CAAC;IAE7D,MAAM,0BAA0B,GAAG,IAAA,yBAAS,EAAC,EAAE,EAAE;QAC/C,GAAG,OAAO;QACV,IAAI,EAAE,CAAC,iBAAiB,CAAC;KAC1B,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,IAAA,yBAAS,EAAC,EAAE,E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ACF,CAAC,CAAC;AACL,CAAC,CAAC;AAnEW,QAAA,wBAAwB,4BAmEnC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CompletionContext } from '@codemirror/autocomplete';
|
|
1
|
+
import type { Completion, CompletionContext } from '@codemirror/autocomplete';
|
|
2
2
|
import type { EditorState } from '@codemirror/state';
|
|
3
|
+
import type { CompletionResult as MongoDBCompletionResult } from '../autocompleter';
|
|
3
4
|
export declare const completeWordsInString: import("@codemirror/autocomplete").CompletionSource;
|
|
4
5
|
export declare function resolveTokenAtCursor(context: CompletionContext): import("@lezer/common").SyntaxNode;
|
|
5
6
|
export type Token = ReturnType<typeof resolveTokenAtCursor>;
|
|
@@ -19,4 +20,6 @@ export declare function getTokenText(editorState: EditorState, token: Token): st
|
|
|
19
20
|
* represented as `[0-9]`.
|
|
20
21
|
*/
|
|
21
22
|
export declare function getAncestryOfToken(token: Token, document: string): string[];
|
|
23
|
+
export declare function isPropertyValue(token: Token): boolean;
|
|
24
|
+
export declare function mapMongoDBCompletionToCodemirrorCompletion(completion: MongoDBCompletionResult, escape?: 'always' | 'never' | 'invalid'): Completion;
|
|
22
25
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/codemirror/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/codemirror/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,KAAK,EAAE,gBAAgB,IAAI,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEpF,eAAO,MAAM,qBAAqB,qDAAoC,CAAC;AAEvE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,sCAE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