@sheinx/hooks 3.5.1-beta.5 → 3.5.1-beta.6
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/use-tree/use-tree.d.ts +1 -0
- package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +17 -4
- package/cjs/components/use-tree/use-tree.type.d.ts +2 -2
- package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.d.ts +1 -0
- package/esm/components/use-tree/use-tree.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.js +18 -5
- package/esm/components/use-tree/use-tree.type.d.ts +2 -2
- package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/package.json +1 -1
@@ -23,6 +23,7 @@ export declare const MODE: {
|
|
23
23
|
MODE_4: number;
|
24
24
|
};
|
25
25
|
declare const useTree: <DataItem>(props: BaseTreeProps<DataItem>) => {
|
26
|
+
inited: boolean;
|
26
27
|
datum: TreeDatum<DataItem>;
|
27
28
|
expanded: KeygenResult[] | undefined;
|
28
29
|
onExpand: (value: KeygenResult[]) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO
|
1
|
+
{"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CA4bZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -12,10 +12,14 @@ var _is = require("../../utils/is");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
13
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
14
14
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
15
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
16
15
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
17
16
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
20
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
21
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
19
23
|
function toArray(value) {
|
20
24
|
if (!value) return [];
|
21
25
|
if (!Array.isArray(value)) return [value];
|
@@ -64,6 +68,10 @@ var useTree = function useTree(props) {
|
|
64
68
|
unmatch = props.unmatch,
|
65
69
|
isControlled = props.isControlled,
|
66
70
|
onExpandProp = props.onExpand;
|
71
|
+
var _useState = (0, _react.useState)(false),
|
72
|
+
_useState2 = _slicedToArray(_useState, 2),
|
73
|
+
inited = _useState2[0],
|
74
|
+
setInited = _useState2[1];
|
67
75
|
var _useInputAble = (0, _useInputAble2.useInputAble)({
|
68
76
|
value: expandedProp,
|
69
77
|
defaultValue: defaultExpanded,
|
@@ -189,10 +197,12 @@ var useTree = function useTree(props) {
|
|
189
197
|
if (oroginData) {
|
190
198
|
return oroginData;
|
191
199
|
}
|
192
|
-
if (!unmatch) return null;
|
200
|
+
// if (!unmatch) return null;
|
201
|
+
// if (!unmatch) return { IS_NOT_MATCHED_VALUE: true, value: null};
|
202
|
+
// return { IS_NOT_MATCHED_VALUE: true, value: !unmatch ? null : id };
|
193
203
|
return {
|
194
204
|
IS_NOT_MATCHED_VALUE: true,
|
195
|
-
value: id
|
205
|
+
value: !unmatch ? null : id
|
196
206
|
};
|
197
207
|
};
|
198
208
|
var getDataByValues = function getDataByValues(values) {
|
@@ -229,7 +239,6 @@ var useTree = function useTree(props) {
|
|
229
239
|
console.error("There is already a key \"".concat(id, "\" exists. The key must be unique."));
|
230
240
|
continue;
|
231
241
|
}
|
232
|
-
|
233
242
|
// 制作 data mapping
|
234
243
|
context.dataMap.set(id, item);
|
235
244
|
var _isDisabled = !!disabled;
|
@@ -407,6 +416,9 @@ var useTree = function useTree(props) {
|
|
407
416
|
if (props.datum) return;
|
408
417
|
setValue(value);
|
409
418
|
}, [value]);
|
419
|
+
(0, _react.useEffect)(function () {
|
420
|
+
setInited(true);
|
421
|
+
}, []);
|
410
422
|
var datum = (0, _useLatestObj.default)({
|
411
423
|
get: get,
|
412
424
|
set: set,
|
@@ -431,6 +443,7 @@ var useTree = function useTree(props) {
|
|
431
443
|
updateMap: context.updateMap
|
432
444
|
});
|
433
445
|
return {
|
446
|
+
inited: inited,
|
434
447
|
datum: props.datum || datum,
|
435
448
|
expanded: expanded,
|
436
449
|
onExpand: onExpand
|
@@ -114,7 +114,7 @@ export interface TreeDatum<DataItem> {
|
|
114
114
|
getValue: () => KeygenResult[];
|
115
115
|
getChecked: (id: KeygenResult) => boolean | 'indeterminate';
|
116
116
|
getKey: (item: DataItem, id?: KeygenResult, index?: number) => KeygenResult;
|
117
|
-
getDataByValues: (values: KeygenResult[] | KeygenResult) => DataItem | DataItem[] | null;
|
117
|
+
getDataByValues: (values: KeygenResult[] | KeygenResult) => DataItem | (DataItem | null)[] | null;
|
118
118
|
setValue: (value?: KeygenResult[]) => void;
|
119
119
|
setData: (data?: DataItem[]) => void;
|
120
120
|
isDisabled: (id: KeygenResult) => boolean;
|
@@ -124,7 +124,7 @@ export interface TreeDatum<DataItem> {
|
|
124
124
|
};
|
125
125
|
getDataById: (id: KeygenResult) => DataItem | {
|
126
126
|
IS_NOT_MATCHED_VALUE: boolean;
|
127
|
-
value: KeygenResult;
|
127
|
+
value: KeygenResult | null;
|
128
128
|
} | null;
|
129
129
|
bindUpdate: (id: KeygenResult, update: () => void) => void;
|
130
130
|
unBindUpdate: (id: KeygenResult) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-tree.type.d.ts","sourceRoot":"","sources":["use-tree.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpF,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,WAAW,CAAC,QAAQ;IACnC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAC/C,iBAAiB,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjC,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzC,cAAc,EAAE,GAAG,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,CAAC;IAC9C,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,cAAc,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,EAAE,CAAC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CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IACrC,UAAU,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC;IAC1C,QAAQ,EAAE,CACR,EAAE,EAAE,YAAY,EAChB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,KACX;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5C,WAAW,EAAE,CACX,EAAE,EAAE,YAAY,KACb,QAAQ,GAAG;QAAE,oBAAoB,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACrF,UAAU,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAC3D,YAAY,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,IAAI,CAAC;IACzC,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IACpC,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;CAChD"}
|
@@ -23,6 +23,7 @@ export declare const MODE: {
|
|
23
23
|
MODE_4: number;
|
24
24
|
};
|
25
25
|
declare const useTree: <DataItem>(props: BaseTreeProps<DataItem>) => {
|
26
|
+
inited: boolean;
|
26
27
|
datum: TreeDatum<DataItem>;
|
27
28
|
expanded: KeygenResult[] | undefined;
|
28
29
|
onExpand: (value: KeygenResult[]) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO
|
1
|
+
{"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CA4bZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -1,10 +1,14 @@
|
|
1
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
2
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
4
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
5
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
6
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
7
|
-
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
11
|
+
import { useState, useEffect, useRef } from 'react';
|
8
12
|
import useLatestObj from "../../common/use-latest-obj";
|
9
13
|
import { useInputAble } from "../../common/use-input-able";
|
10
14
|
import { usePersistFn } from "../../common/use-persist-fn";
|
@@ -57,6 +61,10 @@ var useTree = function useTree(props) {
|
|
57
61
|
unmatch = props.unmatch,
|
58
62
|
isControlled = props.isControlled,
|
59
63
|
onExpandProp = props.onExpand;
|
64
|
+
var _useState = useState(false),
|
65
|
+
_useState2 = _slicedToArray(_useState, 2),
|
66
|
+
inited = _useState2[0],
|
67
|
+
setInited = _useState2[1];
|
60
68
|
var _useInputAble = useInputAble({
|
61
69
|
value: expandedProp,
|
62
70
|
defaultValue: defaultExpanded,
|
@@ -182,10 +190,12 @@ var useTree = function useTree(props) {
|
|
182
190
|
if (oroginData) {
|
183
191
|
return oroginData;
|
184
192
|
}
|
185
|
-
if (!unmatch) return null;
|
193
|
+
// if (!unmatch) return null;
|
194
|
+
// if (!unmatch) return { IS_NOT_MATCHED_VALUE: true, value: null};
|
195
|
+
// return { IS_NOT_MATCHED_VALUE: true, value: !unmatch ? null : id };
|
186
196
|
return {
|
187
197
|
IS_NOT_MATCHED_VALUE: true,
|
188
|
-
value: id
|
198
|
+
value: !unmatch ? null : id
|
189
199
|
};
|
190
200
|
};
|
191
201
|
var getDataByValues = function getDataByValues(values) {
|
@@ -222,7 +232,6 @@ var useTree = function useTree(props) {
|
|
222
232
|
console.error("There is already a key \"".concat(id, "\" exists. The key must be unique."));
|
223
233
|
continue;
|
224
234
|
}
|
225
|
-
|
226
235
|
// 制作 data mapping
|
227
236
|
context.dataMap.set(id, item);
|
228
237
|
var _isDisabled = !!disabled;
|
@@ -400,6 +409,9 @@ var useTree = function useTree(props) {
|
|
400
409
|
if (props.datum) return;
|
401
410
|
setValue(value);
|
402
411
|
}, [value]);
|
412
|
+
useEffect(function () {
|
413
|
+
setInited(true);
|
414
|
+
}, []);
|
403
415
|
var datum = useLatestObj({
|
404
416
|
get: get,
|
405
417
|
set: set,
|
@@ -424,6 +436,7 @@ var useTree = function useTree(props) {
|
|
424
436
|
updateMap: context.updateMap
|
425
437
|
});
|
426
438
|
return {
|
439
|
+
inited: inited,
|
427
440
|
datum: props.datum || datum,
|
428
441
|
expanded: expanded,
|
429
442
|
onExpand: onExpand
|
@@ -114,7 +114,7 @@ export interface TreeDatum<DataItem> {
|
|
114
114
|
getValue: () => KeygenResult[];
|
115
115
|
getChecked: (id: KeygenResult) => boolean | 'indeterminate';
|
116
116
|
getKey: (item: DataItem, id?: KeygenResult, index?: number) => KeygenResult;
|
117
|
-
getDataByValues: (values: KeygenResult[] | KeygenResult) => DataItem | DataItem[] | null;
|
117
|
+
getDataByValues: (values: KeygenResult[] | KeygenResult) => DataItem | (DataItem | null)[] | null;
|
118
118
|
setValue: (value?: KeygenResult[]) => void;
|
119
119
|
setData: (data?: DataItem[]) => void;
|
120
120
|
isDisabled: (id: KeygenResult) => boolean;
|
@@ -124,7 +124,7 @@ export interface TreeDatum<DataItem> {
|
|
124
124
|
};
|
125
125
|
getDataById: (id: KeygenResult) => DataItem | {
|
126
126
|
IS_NOT_MATCHED_VALUE: boolean;
|
127
|
-
value: KeygenResult;
|
127
|
+
value: KeygenResult | null;
|
128
128
|
} | null;
|
129
129
|
bindUpdate: (id: KeygenResult, update: () => void) => void;
|
130
130
|
unBindUpdate: (id: KeygenResult) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-tree.type.d.ts","sourceRoot":"","sources":["use-tree.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpF,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,WAAW,CAAC,QAAQ;IACnC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAA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