@equinor/fusion-framework-module-context 0.4.1 → 0.5.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.
- package/CHANGELOG.md +10 -0
- package/dist/esm/client/ContextClient.js +7 -7
- package/dist/esm/client/ContextClient.js.map +1 -1
- package/dist/esm/configurator.js +22 -8
- package/dist/esm/configurator.js.map +1 -1
- package/dist/esm/index.js +9 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/provider.js +56 -37
- package/dist/esm/provider.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/client/ContextClient.d.ts +1 -1
- package/dist/types/configurator.d.ts +6 -7
- package/dist/types/index.d.ts +2 -1
- package/dist/types/module.d.ts +2 -2
- package/dist/types/provider.d.ts +2 -0
- package/dist/types/types.d.ts +2 -2
- package/package.json +3 -3
- package/src/configurator.ts +34 -22
- package/src/index.ts +17 -3
- package/src/provider.ts +27 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.5.1 (2022-11-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @equinor/fusion-framework-module-context
|
|
9
|
+
|
|
10
|
+
## [0.5.0](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module-context@0.4.1...@equinor/fusion-framework-module-context@0.5.0) (2022-11-16)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **module-context:** allow query filter ([1a89ee5](https://github.com/equinor/fusion-framework/commit/1a89ee57277af3853ce802da9b5e0956bff8ceaa))
|
|
15
|
+
|
|
6
16
|
## 0.4.1 (2022-11-14)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @equinor/fusion-framework-module-context
|
|
@@ -14,13 +14,6 @@ import { Observable, BehaviorSubject, EMPTY } from 'rxjs';
|
|
|
14
14
|
import { catchError, map } from 'rxjs/operators';
|
|
15
15
|
import { Query } from '@equinor/fusion-observable/query';
|
|
16
16
|
export class ContextClient extends Observable {
|
|
17
|
-
constructor(options) {
|
|
18
|
-
super((observer) => __classPrivateFieldGet(this, _ContextClient_currentContext$, "f").subscribe(observer));
|
|
19
|
-
_ContextClient_client.set(this, void 0);
|
|
20
|
-
_ContextClient_currentContext$.set(this, void 0);
|
|
21
|
-
__classPrivateFieldSet(this, _ContextClient_client, new Query(options.query), "f");
|
|
22
|
-
__classPrivateFieldSet(this, _ContextClient_currentContext$, new BehaviorSubject(options.initial), "f");
|
|
23
|
-
}
|
|
24
17
|
get currentContext() {
|
|
25
18
|
return __classPrivateFieldGet(this, _ContextClient_currentContext$, "f").value;
|
|
26
19
|
}
|
|
@@ -30,6 +23,13 @@ export class ContextClient extends Observable {
|
|
|
30
23
|
get client() {
|
|
31
24
|
return __classPrivateFieldGet(this, _ContextClient_client, "f");
|
|
32
25
|
}
|
|
26
|
+
constructor(options) {
|
|
27
|
+
super((observer) => __classPrivateFieldGet(this, _ContextClient_currentContext$, "f").subscribe(observer));
|
|
28
|
+
_ContextClient_client.set(this, void 0);
|
|
29
|
+
_ContextClient_currentContext$.set(this, void 0);
|
|
30
|
+
__classPrivateFieldSet(this, _ContextClient_client, new Query(options.query), "f");
|
|
31
|
+
__classPrivateFieldSet(this, _ContextClient_currentContext$, new BehaviorSubject(options.initial), "f");
|
|
32
|
+
}
|
|
33
33
|
setCurrentContext(idOrItem) {
|
|
34
34
|
if (typeof idOrItem === 'string') {
|
|
35
35
|
this.resolveContext(idOrItem)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextClient.js","sourceRoot":"","sources":["../../../src/client/ContextClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAA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C7B,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAA,IAAI,sCAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;SAEhE;aAAM,IAAI,QAAQ,KAAK,uBAAA,IAAI,sCAAiB,CAAC,KAAK,EAAE;YACjD,uBAAA,IAAI,sCAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACxC;IACL,CAAC;IAEM,cAAc,CAAC,EAAU;QAC5B,OAAO,uBAAA,IAAI,6BAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC;CACJ;;AAED,eAAe,aAAa,CAAC"}
|
package/dist/esm/configurator.js
CHANGED
|
@@ -12,10 +12,9 @@ export class ContextModuleConfigurator {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
this.defaultExpireTime = 1 * 60 * 1000;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
_createContextClientGet(apiProvider) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const
|
|
18
|
-
const contextClient = yield provider.createContextClient('json$');
|
|
17
|
+
const contextClient = yield apiProvider.createContextClient('json$');
|
|
19
18
|
return {
|
|
20
19
|
fn: (args) => {
|
|
21
20
|
return contextClient.get('v1', args, { selector: getContextSelector });
|
|
@@ -23,10 +22,9 @@ export class ContextModuleConfigurator {
|
|
|
23
22
|
};
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
_createContextClientQuery(apiProvider) {
|
|
27
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const
|
|
29
|
-
const contextClient = yield provider.createContextClient('json$');
|
|
27
|
+
const contextClient = yield apiProvider.createContextClient('json$');
|
|
30
28
|
return {
|
|
31
29
|
fn: (query) => {
|
|
32
30
|
return contextClient.query('v1', { query }, { selector: queryContextSelector });
|
|
@@ -34,18 +32,34 @@ export class ContextModuleConfigurator {
|
|
|
34
32
|
};
|
|
35
33
|
});
|
|
36
34
|
}
|
|
35
|
+
_getServiceProvider(init) {
|
|
36
|
+
var _a;
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (init.hasModule('services')) {
|
|
39
|
+
return init.requireInstance('services');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const parentServiceModule = (_a = init.ref) === null || _a === void 0 ? void 0 : _a.services;
|
|
43
|
+
if (parentServiceModule) {
|
|
44
|
+
return parentServiceModule;
|
|
45
|
+
}
|
|
46
|
+
throw Error('no service services provider configures [ServicesModule]');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
37
50
|
createConfig(init) {
|
|
38
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const apiProvider = yield this._getServiceProvider(init);
|
|
39
53
|
const config = {
|
|
40
54
|
getContext: {
|
|
41
55
|
query: {
|
|
42
|
-
client: yield this.
|
|
56
|
+
client: yield this._createContextClientGet(apiProvider),
|
|
43
57
|
key: ({ id }) => id,
|
|
44
58
|
expire: this.defaultExpireTime,
|
|
45
59
|
},
|
|
46
60
|
},
|
|
47
61
|
queryContext: {
|
|
48
|
-
client: yield this.
|
|
62
|
+
client: yield this._createContextClientQuery(apiProvider),
|
|
49
63
|
key: (args) => JSON.stringify(args),
|
|
50
64
|
expire: this.defaultExpireTime,
|
|
51
65
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurator.js","sourceRoot":"","sources":["../../src/configurator.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"configurator.js","sourceRoot":"","sources":["../../src/configurator.ts"],"names":[],"mappings":";;;;;;;;;AASA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAmBvE,MAAM,OAAO,yBAAyB;IAAtC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AE,MAAM,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC;wBACvD,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE;wBACnB,MAAM,EAAE,IAAI,CAAC,iBAAiB;qBACjC;iBACJ;gBACD,YAAY,EAAE;oBACV,MAAM,EAAE,MAAM,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC;oBACzD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;oBACnC,MAAM,EAAE,IAAI,CAAC,iBAAiB;iBACjC;aACJ,CAAC;YAEF,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;KAAA;IAEM,aAAa,CAAC,MAA4B;QAC7C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAED,eAAe,yBAAyB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { module } from './module';
|
|
2
|
-
export const enableContext = (
|
|
3
|
-
|
|
2
|
+
export const enableContext = (configurator, options) => {
|
|
3
|
+
configurator.addConfig({
|
|
4
|
+
module,
|
|
5
|
+
configure: (contextConfigurator) => {
|
|
6
|
+
contextConfigurator.processConfig = (config) => {
|
|
7
|
+
return Object.assign(Object.assign({}, config), options);
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
});
|
|
4
11
|
};
|
|
5
12
|
export { ContextModuleConfigurator, } from './configurator';
|
|
6
13
|
export { ContextProvider } from './provider';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,MAAM,CAAC,MAAM,aAAa,GAAG,CACzB,YAAkC,EAClC,OAAqE,EACjE,EAAE;IACN,YAAY,CAAC,SAAS,CAAC;QACnB,MAAM;QACN,SAAS,EAAE,CAAC,mBAAmB,EAAE,EAAE;YAC/B,mBAAmB,CAAC,aAAa,GAAG,CAAC,MAAM,EAAE,EAAE;gBAC3C,uCACO,MAAM,GACN,OAAO,EACZ;YACN,CAAC,CAAC;QACN,CAAC;KACJ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EACH,yBAAyB,GAG5B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAoB,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EACH,OAAO,EAEP,MAAM,IAAI,aAAa,EACvB,SAAS,IAAI,gBAAgB,GAChC,MAAM,UAAU,CAAC;AAElB,cAAc,SAAS,CAAC"}
|
package/dist/esm/provider.js
CHANGED
|
@@ -1,54 +1,40 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
1
6
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
7
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
8
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
11
|
};
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _ContextProvider_contextClient, _ContextProvider_contextQuery, _ContextProvider_event, _ContextProvider_subscriptions;
|
|
13
|
-
import { pairwise, Subscription } from 'rxjs';
|
|
12
|
+
var _ContextProvider_contextClient, _ContextProvider_contextQuery, _ContextProvider_event, _ContextProvider_subscriptions, _ContextProvider_contextType, _ContextProvider_contextFilter;
|
|
13
|
+
import { lastValueFrom, Subscription } from 'rxjs';
|
|
14
|
+
import { map, pairwise } from 'rxjs/operators';
|
|
14
15
|
import { ContextClient } from './client/ContextClient';
|
|
15
16
|
import Query from '@equinor/fusion-observable/query';
|
|
16
17
|
export class ContextProvider {
|
|
17
|
-
constructor(args) {
|
|
18
|
-
_ContextProvider_contextClient.set(this, void 0);
|
|
19
|
-
_ContextProvider_contextQuery.set(this, void 0);
|
|
20
|
-
_ContextProvider_event.set(this, void 0);
|
|
21
|
-
_ContextProvider_subscriptions.set(this, new Subscription());
|
|
22
|
-
const { config, event, parentContext } = args;
|
|
23
|
-
__classPrivateFieldSet(this, _ContextProvider_contextClient, new ContextClient(config.getContext), "f");
|
|
24
|
-
__classPrivateFieldSet(this, _ContextProvider_contextQuery, new Query(config.queryContext), "f");
|
|
25
|
-
if (event) {
|
|
26
|
-
__classPrivateFieldSet(this, _ContextProvider_event, event, "f");
|
|
27
|
-
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").add(__classPrivateFieldGet(this, _ContextProvider_contextClient, "f").currentContext$
|
|
28
|
-
.pipe(pairwise())
|
|
29
|
-
.subscribe(([previous, next]) => {
|
|
30
|
-
event.dispatchEvent('onCurrentContextChanged', {
|
|
31
|
-
source: this,
|
|
32
|
-
canBubble: true,
|
|
33
|
-
detail: { previous, next },
|
|
34
|
-
});
|
|
35
|
-
}));
|
|
36
|
-
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").add(event.addEventListener('onCurrentContextChanged', (e) => {
|
|
37
|
-
if (e.source !== this) {
|
|
38
|
-
this.currentContext = e.detail.next;
|
|
39
|
-
}
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
if (parentContext) {
|
|
43
|
-
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").add(parentContext.contextClient.currentContext$.subscribe((next) => (this.currentContext = next)));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
18
|
get contextClient() {
|
|
47
19
|
return __classPrivateFieldGet(this, _ContextProvider_contextClient, "f");
|
|
48
20
|
}
|
|
49
21
|
get queryClient() {
|
|
50
22
|
return __classPrivateFieldGet(this, _ContextProvider_contextQuery, "f");
|
|
51
23
|
}
|
|
24
|
+
queryContext(search) {
|
|
25
|
+
const query$ = this.queryClient
|
|
26
|
+
.query({
|
|
27
|
+
search,
|
|
28
|
+
filter: {
|
|
29
|
+
type: __classPrivateFieldGet(this, _ContextProvider_contextType, "f"),
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.pipe(map((x) => x.value));
|
|
33
|
+
return __classPrivateFieldGet(this, _ContextProvider_contextFilter, "f") ? query$.pipe(map(__classPrivateFieldGet(this, _ContextProvider_contextFilter, "f"))) : query$;
|
|
34
|
+
}
|
|
35
|
+
queryContextAsync(search) {
|
|
36
|
+
return lastValueFrom(this.queryContext(search));
|
|
37
|
+
}
|
|
52
38
|
get currentContext$() {
|
|
53
39
|
return __classPrivateFieldGet(this, _ContextProvider_contextClient, "f").currentContext$;
|
|
54
40
|
}
|
|
@@ -74,10 +60,43 @@ export class ContextProvider {
|
|
|
74
60
|
__classPrivateFieldGet(this, _ContextProvider_contextClient, "f").setCurrentContext(context);
|
|
75
61
|
}
|
|
76
62
|
}
|
|
63
|
+
constructor(args) {
|
|
64
|
+
_ContextProvider_contextClient.set(this, void 0);
|
|
65
|
+
_ContextProvider_contextQuery.set(this, void 0);
|
|
66
|
+
_ContextProvider_event.set(this, void 0);
|
|
67
|
+
_ContextProvider_subscriptions.set(this, new Subscription());
|
|
68
|
+
_ContextProvider_contextType.set(this, void 0);
|
|
69
|
+
_ContextProvider_contextFilter.set(this, void 0);
|
|
70
|
+
const { config, event, parentContext } = args;
|
|
71
|
+
__classPrivateFieldSet(this, _ContextProvider_contextType, config.contextType, "f");
|
|
72
|
+
__classPrivateFieldSet(this, _ContextProvider_contextFilter, config.contextFilter, "f");
|
|
73
|
+
__classPrivateFieldSet(this, _ContextProvider_contextClient, new ContextClient(config.getContext), "f");
|
|
74
|
+
__classPrivateFieldSet(this, _ContextProvider_contextQuery, new Query(config.queryContext), "f");
|
|
75
|
+
if (event) {
|
|
76
|
+
__classPrivateFieldSet(this, _ContextProvider_event, event, "f");
|
|
77
|
+
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").add(__classPrivateFieldGet(this, _ContextProvider_contextClient, "f").currentContext$
|
|
78
|
+
.pipe(pairwise())
|
|
79
|
+
.subscribe(([previous, next]) => {
|
|
80
|
+
event.dispatchEvent('onCurrentContextChanged', {
|
|
81
|
+
source: this,
|
|
82
|
+
canBubble: true,
|
|
83
|
+
detail: { previous, next },
|
|
84
|
+
});
|
|
85
|
+
}));
|
|
86
|
+
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").add(event.addEventListener('onCurrentContextChanged', (e) => {
|
|
87
|
+
if (e.source !== this) {
|
|
88
|
+
this.currentContext = e.detail.next;
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
if (parentContext) {
|
|
93
|
+
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").add(parentContext.contextClient.currentContext$.subscribe((next) => (this.currentContext = next)));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
77
96
|
dispose() {
|
|
78
97
|
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").unsubscribe();
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
|
-
_ContextProvider_contextClient = new WeakMap(), _ContextProvider_contextQuery = new WeakMap(), _ContextProvider_event = new WeakMap(), _ContextProvider_subscriptions = new WeakMap();
|
|
100
|
+
_ContextProvider_contextClient = new WeakMap(), _ContextProvider_contextQuery = new WeakMap(), _ContextProvider_event = new WeakMap(), _ContextProvider_subscriptions = new WeakMap(), _ContextProvider_contextType = new WeakMap(), _ContextProvider_contextFilter = new WeakMap();
|
|
82
101
|
export default ContextProvider;
|
|
83
102
|
//# sourceMappingURL=provider.js.map
|
package/dist/esm/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAc,YAAY,EAAE,MAAM,MAAM,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQvD,OAAO,KAAK,MAAM,kCAAkC,CAAC;AAgBrD,MAAM,OAAO,eAAe;IAWxB,IAAW,aAAa;QACpB,OAAO,uBAAA,IAAI,sCAAe,CAAC;IAC/B,CAAC;IAED,IAAW,WAAW;QAClB,OAAO,uBAAA,IAAI,qCAAc,CAAC;IAC9B,CAAC;IAEM,YAAY,CAAC,MAAc;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW;aAC1B,KAAK,CAAC;YACH,MAAM;YACN,MAAM,EAAE;gBACJ,IAAI,EAAE,uBAAA,IAAI,oCAAa;aAC1B;SACJ,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAE/B,OAAO,uBAAA,IAAI,sCAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAA,IAAI,sCAAe,CAAC,C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