@tamagui/collection 2.0.0-rc.3 → 2.0.0-rc.31
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/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/package.json +12 -15
- package/dist/cjs/Collection.js +0 -73
- package/dist/cjs/Collection.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/Collection.js +0 -53
- package/dist/esm/Collection.js.map +0 -6
- package/dist/jsx/Collection.js +0 -53
- package/dist/jsx/Collection.js.map +0 -6
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Collection";
|
|
1
|
+
export * from "./Collection.mjs";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
package/dist/jsx/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Collection";
|
|
1
|
+
export * from "./Collection.mjs";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/jsx/index.js.map
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/collection",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.31",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -19,15 +19,12 @@
|
|
|
19
19
|
"./package.json": "./package.json",
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./types/index.d.ts",
|
|
22
|
-
"react-native":
|
|
23
|
-
|
|
24
|
-
"import": "./dist/esm/index.native.js",
|
|
25
|
-
"require": "./dist/cjs/index.native.js"
|
|
26
|
-
},
|
|
22
|
+
"react-native": "./dist/esm/index.native.js",
|
|
23
|
+
"browser": "./dist/esm/index.mjs",
|
|
27
24
|
"module": "./dist/esm/index.mjs",
|
|
28
25
|
"import": "./dist/esm/index.mjs",
|
|
29
26
|
"require": "./dist/cjs/index.cjs",
|
|
30
|
-
"default": "./dist/
|
|
27
|
+
"default": "./dist/esm/index.mjs"
|
|
31
28
|
}
|
|
32
29
|
},
|
|
33
30
|
"publishConfig": {
|
|
@@ -40,16 +37,16 @@
|
|
|
40
37
|
"clean:build": "tamagui-build clean:build"
|
|
41
38
|
},
|
|
42
39
|
"dependencies": {
|
|
43
|
-
"@tamagui/compose-refs": "2.0.0-rc.
|
|
44
|
-
"@tamagui/constants": "2.0.0-rc.
|
|
45
|
-
"@tamagui/core": "2.0.0-rc.
|
|
46
|
-
"@tamagui/create-context": "2.0.0-rc.
|
|
47
|
-
"@tamagui/polyfill-dev": "2.0.0-rc.
|
|
48
|
-
"@tamagui/stacks": "2.0.0-rc.
|
|
49
|
-
"@tamagui/use-controllable-state": "2.0.0-rc.
|
|
40
|
+
"@tamagui/compose-refs": "2.0.0-rc.31",
|
|
41
|
+
"@tamagui/constants": "2.0.0-rc.31",
|
|
42
|
+
"@tamagui/core": "2.0.0-rc.31",
|
|
43
|
+
"@tamagui/create-context": "2.0.0-rc.31",
|
|
44
|
+
"@tamagui/polyfill-dev": "2.0.0-rc.31",
|
|
45
|
+
"@tamagui/stacks": "2.0.0-rc.31",
|
|
46
|
+
"@tamagui/use-controllable-state": "2.0.0-rc.31"
|
|
50
47
|
},
|
|
51
48
|
"devDependencies": {
|
|
52
|
-
"@tamagui/build": "2.0.0-rc.
|
|
49
|
+
"@tamagui/build": "2.0.0-rc.31",
|
|
53
50
|
"react": ">=19"
|
|
54
51
|
},
|
|
55
52
|
"peerDependencies": {
|
package/dist/cjs/Collection.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var Collection_exports = {};
|
|
24
|
-
__export(Collection_exports, {
|
|
25
|
-
createCollection: () => createCollection
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(Collection_exports);
|
|
28
|
-
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_react = __toESM(require("react"), 1), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
function createCollection(name) {
|
|
30
|
-
const { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = (0, import_core.createStyledContext)(
|
|
31
|
-
{
|
|
32
|
-
collectionRef: { current: void 0 },
|
|
33
|
-
itemMap: /* @__PURE__ */ new Map()
|
|
34
|
-
},
|
|
35
|
-
"Toast"
|
|
36
|
-
), CollectionProvider = (props) => {
|
|
37
|
-
const { scope, children } = props, ref = import_react.default.useRef(void 0), itemMap = import_react.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
38
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
39
|
-
};
|
|
40
|
-
CollectionProvider.displayName = "CollectionProvider";
|
|
41
|
-
const COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = import_react.default.forwardRef((props, forwardedRef) => {
|
|
42
|
-
const { scope, children } = props, context = useCollectionContext(scope), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
|
|
43
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Slot, { ref: composedRefs, children });
|
|
44
|
-
});
|
|
45
|
-
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
46
|
-
const ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = import_react.default.forwardRef((props, forwardedRef) => {
|
|
47
|
-
const { scope, children, ...itemData } = props, ref = import_react.default.useRef(void 0), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref), context = useCollectionContext(scope);
|
|
48
|
-
return import_react.default.useEffect(() => (context.itemMap.set(ref, { ref, ...itemData }), () => {
|
|
49
|
-
context.itemMap.delete(ref);
|
|
50
|
-
})), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Slot, { [ITEM_DATA_ATTR]: "", ref: composedRefs, children });
|
|
51
|
-
});
|
|
52
|
-
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
53
|
-
function useCollection(scope) {
|
|
54
|
-
const context = useCollectionContext(scope);
|
|
55
|
-
return import_react.default.useCallback(() => {
|
|
56
|
-
if (!import_constants.isWeb)
|
|
57
|
-
return [];
|
|
58
|
-
const collectionNode = context.collectionRef.current;
|
|
59
|
-
if (!collectionNode) return [];
|
|
60
|
-
const orderedNodes = Array.from(
|
|
61
|
-
collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)
|
|
62
|
-
);
|
|
63
|
-
return Array.from(context.itemMap.values()).sort(
|
|
64
|
-
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
65
|
-
);
|
|
66
|
-
}, [context.collectionRef, context.itemMap]);
|
|
67
|
-
}
|
|
68
|
-
return [
|
|
69
|
-
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
70
|
-
useCollection
|
|
71
|
-
];
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=Collection.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC,kCAChC,mBAAsB,+BAEtB,cAA0C,0BAC1C,eAAkB,8BAkDZ;AAvCN,SAAS,iBACP,MACA;AAmBA,QAAM,EAAE,UAAU,wBAAwB,kBAAkB,qBAAqB,QAC/E;AAAA,IACE;AAAA,MACE,eAAe,EAAE,SAAS,OAAU;AAAA,MACpC,SAAS,oBAAI,IAAI;AAAA,IACnB;AAAA,IACA;AAAA,EACF,GAEI,qBAIF,CAAC,UAAU;AACb,UAAM,EAAE,OAAO,SAAS,IAAI,OACtB,MAAM,aAAAA,QAAM,OAA0B,MAAS,GAC/C,UAAU,aAAAA,QAAM,OAAgC,oBAAI,IAAI,CAAC,EAAE;AACjE,WACE,4CAAC,0BAAuB,OAAc,SAAkB,eAAe,KACpE,UACH;AAAA,EAEJ;AAEA,qBAAmB,cAAc;AAMjC,QAA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AAG,CAAC,QAAQ,eAAe,QAAQ,OAAO,CAAC;AAAA,EAG7C;AAEA,SAAO;AAAA,IACL,EAAE,UAAU,oBAAoB,MAAM,gBAAgB,UAAU,mBAAmB;AAAA,IACnF;AAAA,EACF;AACF;",
|
|
5
|
-
"names": ["React"]
|
|
6
|
-
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var index_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(index_exports);
|
|
14
|
-
__reExport(index_exports, require("./Collection"), module.exports);
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
package/dist/esm/Collection.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { isWeb } from "@tamagui/constants";
|
|
3
|
-
import { Slot, createStyledContext } from "@tamagui/core";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
function createCollection(name) {
|
|
7
|
-
const { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = createStyledContext(
|
|
8
|
-
{
|
|
9
|
-
collectionRef: { current: void 0 },
|
|
10
|
-
itemMap: /* @__PURE__ */ new Map()
|
|
11
|
-
},
|
|
12
|
-
"Toast"
|
|
13
|
-
), CollectionProvider = (props) => {
|
|
14
|
-
const { scope, children } = props, ref = React.useRef(void 0), itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
15
|
-
return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
16
|
-
};
|
|
17
|
-
CollectionProvider.displayName = "CollectionProvider";
|
|
18
|
-
const COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = React.forwardRef((props, forwardedRef) => {
|
|
19
|
-
const { scope, children } = props, context = useCollectionContext(scope), composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
20
|
-
return /* @__PURE__ */ jsx(Slot, { ref: composedRefs, children });
|
|
21
|
-
});
|
|
22
|
-
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
23
|
-
const ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = React.forwardRef((props, forwardedRef) => {
|
|
24
|
-
const { scope, children, ...itemData } = props, ref = React.useRef(void 0), composedRefs = useComposedRefs(forwardedRef, ref), context = useCollectionContext(scope);
|
|
25
|
-
return React.useEffect(() => (context.itemMap.set(ref, { ref, ...itemData }), () => {
|
|
26
|
-
context.itemMap.delete(ref);
|
|
27
|
-
})), /* @__PURE__ */ jsx(Slot, { [ITEM_DATA_ATTR]: "", ref: composedRefs, children });
|
|
28
|
-
});
|
|
29
|
-
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
30
|
-
function useCollection(scope) {
|
|
31
|
-
const context = useCollectionContext(scope);
|
|
32
|
-
return React.useCallback(() => {
|
|
33
|
-
if (!isWeb)
|
|
34
|
-
return [];
|
|
35
|
-
const collectionNode = context.collectionRef.current;
|
|
36
|
-
if (!collectionNode) return [];
|
|
37
|
-
const orderedNodes = Array.from(
|
|
38
|
-
collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)
|
|
39
|
-
);
|
|
40
|
-
return Array.from(context.itemMap.values()).sort(
|
|
41
|
-
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
42
|
-
);
|
|
43
|
-
}, [context.collectionRef, context.itemMap]);
|
|
44
|
-
}
|
|
45
|
-
return [
|
|
46
|
-
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
47
|
-
useCollection
|
|
48
|
-
];
|
|
49
|
-
}
|
|
50
|
-
export {
|
|
51
|
-
createCollection
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=Collection.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,aAAa;AAEtB,SAAS,MAAM,2BAA2B;AAC1C,OAAO,WAAW;AAkDZ;AAvCN,SAAS,iBACP,MACA;AAmBA,QAAM,EAAE,UAAU,wBAAwB,kBAAkB,qBAAqB,IAC/E;AAAA,IACE;AAAA,MACE,eAAe,EAAE,SAAS,OAAU;AAAA,MACpC,SAAS,oBAAI,IAAI;AAAA,IACnB;AAAA,IACA;AAAA,EACF,GAEI,qBAIF,CAAC,UAAU;AACb,UAAM,EAAE,OAAO,SAAS,IAAI,OACtB,MAAM,MAAM,OAA0B,MAAS,GAC/C,UAAU,MAAM,OAAgC,oBAAI,IAAI,CAAC,EAAE;AACjE,WACE,oBAAC,0BAAuB,OAAc,SAAkB,eAAe,KACpE,UACH;AAAA,EAEJ;AAEA,qBAAmB,cAAc;AAMjC,QAAM,uBAAuB,OAAO,kBAE9B,iBAAiB,MAAM,WAG3B,CAAC,OAAO,iBAAiB;AACzB,UAAM,EAAE,OAAO,SAAS,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F;AAAA,EACF;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/jsx/Collection.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { isWeb } from "@tamagui/constants";
|
|
3
|
-
import { Slot, createStyledContext } from "@tamagui/core";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
function createCollection(name) {
|
|
7
|
-
const { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = createStyledContext(
|
|
8
|
-
{
|
|
9
|
-
collectionRef: { current: void 0 },
|
|
10
|
-
itemMap: /* @__PURE__ */ new Map()
|
|
11
|
-
},
|
|
12
|
-
"Toast"
|
|
13
|
-
), CollectionProvider = (props) => {
|
|
14
|
-
const { scope, children } = props, ref = React.useRef(void 0), itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
15
|
-
return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
16
|
-
};
|
|
17
|
-
CollectionProvider.displayName = "CollectionProvider";
|
|
18
|
-
const COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = React.forwardRef((props, forwardedRef) => {
|
|
19
|
-
const { scope, children } = props, context = useCollectionContext(scope), composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
20
|
-
return /* @__PURE__ */ jsx(Slot, { ref: composedRefs, children });
|
|
21
|
-
});
|
|
22
|
-
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
23
|
-
const ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = React.forwardRef((props, forwardedRef) => {
|
|
24
|
-
const { scope, children, ...itemData } = props, ref = React.useRef(void 0), composedRefs = useComposedRefs(forwardedRef, ref), context = useCollectionContext(scope);
|
|
25
|
-
return React.useEffect(() => (context.itemMap.set(ref, { ref, ...itemData }), () => {
|
|
26
|
-
context.itemMap.delete(ref);
|
|
27
|
-
})), /* @__PURE__ */ jsx(Slot, { [ITEM_DATA_ATTR]: "", ref: composedRefs, children });
|
|
28
|
-
});
|
|
29
|
-
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
30
|
-
function useCollection(scope) {
|
|
31
|
-
const context = useCollectionContext(scope);
|
|
32
|
-
return React.useCallback(() => {
|
|
33
|
-
if (!isWeb)
|
|
34
|
-
return [];
|
|
35
|
-
const collectionNode = context.collectionRef.current;
|
|
36
|
-
if (!collectionNode) return [];
|
|
37
|
-
const orderedNodes = Array.from(
|
|
38
|
-
collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)
|
|
39
|
-
);
|
|
40
|
-
return Array.from(context.itemMap.values()).sort(
|
|
41
|
-
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
42
|
-
);
|
|
43
|
-
}, [context.collectionRef, context.itemMap]);
|
|
44
|
-
}
|
|
45
|
-
return [
|
|
46
|
-
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
47
|
-
useCollection
|
|
48
|
-
];
|
|
49
|
-
}
|
|
50
|
-
export {
|
|
51
|
-
createCollection
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=Collection.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,aAAa;AAEtB,SAAS,MAAM,2BAA2B;AAC1C,OAAO,WAAW;AAkDZ;AAvCN,SAAS,iBACP,MACA;AAmBA,QAAM,EAAE,UAAU,wBAAwB,kBAAkB,qBAAqB,IAC/E;AAAA,IACE;AAAA,MACE,eAAe,EAAE,SAAS,OAAU;AAAA,MACpC,SAAS,oBAAI,IAAI;AAAA,IACnB;AAAA,IACA;AAAA,EACF,GAE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