@vxrn/compiler 1.12.2 → 1.12.4

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.
@@ -1,284 +0,0 @@
1
- /*! Copyright (c) Meta Platforms, Inc. and affiliates. **/
2
- const REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_MEMO_TYPE = Symbol.for("react.memo");
3
- let allFamiliesByID = /* @__PURE__ */ new Map(), allFamiliesByType = /* @__PURE__ */ new WeakMap(), allSignaturesByType = /* @__PURE__ */ new WeakMap();
4
- const updatedFamiliesByType = /* @__PURE__ */ new WeakMap();
5
- let pendingUpdates = [];
6
- const helpersByRendererID = /* @__PURE__ */ new Map(), helpersByRoot = /* @__PURE__ */ new Map(), mountedRoots = /* @__PURE__ */ new Set(), failedRoots = /* @__PURE__ */ new Set();
7
- let rootElements = /* @__PURE__ */ new WeakMap(), isPerformingRefresh = !1;
8
- function computeFullKey(signature) {
9
- if (signature.fullKey !== null)
10
- return signature.fullKey;
11
- let fullKey = signature.ownKey, hooks2;
12
- try {
13
- hooks2 = signature.getCustomHooks();
14
- } catch {
15
- return signature.forceReset = !0, signature.fullKey = fullKey, fullKey;
16
- }
17
- for (let i = 0; i < hooks2.length; i++) {
18
- const hook = hooks2[i];
19
- if (typeof hook != "function")
20
- return signature.forceReset = !0, signature.fullKey = fullKey, fullKey;
21
- const nestedHookSignature = allSignaturesByType.get(hook);
22
- if (nestedHookSignature === void 0)
23
- continue;
24
- const nestedHookKey = computeFullKey(nestedHookSignature);
25
- nestedHookSignature.forceReset && (signature.forceReset = !0), fullKey += `
26
- ---
27
- ` + nestedHookKey;
28
- }
29
- return signature.fullKey = fullKey, fullKey;
30
- }
31
- function haveEqualSignatures(prevType, nextType) {
32
- const prevSignature = allSignaturesByType.get(prevType), nextSignature = allSignaturesByType.get(nextType);
33
- return prevSignature === void 0 && nextSignature === void 0 ? !0 : !(prevSignature === void 0 || nextSignature === void 0 || computeFullKey(prevSignature) !== computeFullKey(nextSignature) || nextSignature.forceReset);
34
- }
35
- function isReactClass(type) {
36
- return type.prototype && type.prototype.isReactComponent;
37
- }
38
- function canPreserveStateBetween(prevType, nextType) {
39
- return isReactClass(prevType) || isReactClass(nextType) ? !1 : !!haveEqualSignatures(prevType, nextType);
40
- }
41
- function resolveFamily(type) {
42
- return updatedFamiliesByType.get(type);
43
- }
44
- function getProperty(object, property) {
45
- try {
46
- return object[property];
47
- } catch {
48
- return;
49
- }
50
- }
51
- function performReactRefresh() {
52
- if (pendingUpdates.length === 0 || isPerformingRefresh)
53
- return null;
54
- isPerformingRefresh = !0;
55
- try {
56
- const staleFamilies = /* @__PURE__ */ new Set(), updatedFamilies = /* @__PURE__ */ new Set(), updates = pendingUpdates;
57
- pendingUpdates = [], updates.forEach(([family, nextType]) => {
58
- const prevType = family.current;
59
- updatedFamiliesByType.set(prevType, family), updatedFamiliesByType.set(nextType, family), family.current = nextType, canPreserveStateBetween(prevType, nextType) ? updatedFamilies.add(family) : staleFamilies.add(family);
60
- });
61
- const update = {
62
- updatedFamilies,
63
- // Families that will re-render preserving state
64
- staleFamilies
65
- // Families that will be remounted
66
- };
67
- helpersByRendererID.forEach((helpers) => {
68
- helpers.setRefreshHandler(resolveFamily);
69
- });
70
- let didError = !1, firstError = null;
71
- const failedRootsSnapshot = new Set(failedRoots), mountedRootsSnapshot = new Set(mountedRoots), helpersByRootSnapshot = new Map(helpersByRoot);
72
- if (failedRootsSnapshot.forEach((root) => {
73
- const helpers = helpersByRootSnapshot.get(root);
74
- if (helpers === void 0)
75
- throw new Error(
76
- "Could not find helpers for a root. This is a bug in React Refresh."
77
- );
78
- if (failedRoots.has(root), rootElements === null || !rootElements.has(root))
79
- return;
80
- const element = rootElements.get(root);
81
- try {
82
- helpers.scheduleRoot(root, element);
83
- } catch (err) {
84
- didError || (didError = !0, firstError = err);
85
- }
86
- }), mountedRootsSnapshot.forEach((root) => {
87
- const helpers = helpersByRootSnapshot.get(root);
88
- if (helpers === void 0)
89
- throw new Error(
90
- "Could not find helpers for a root. This is a bug in React Refresh."
91
- );
92
- mountedRoots.has(root);
93
- try {
94
- helpers.scheduleRefresh(root, update);
95
- } catch (err) {
96
- didError || (didError = !0, firstError = err);
97
- }
98
- }), didError)
99
- throw firstError;
100
- return update;
101
- } finally {
102
- isPerformingRefresh = !1;
103
- }
104
- }
105
- function register(type, id) {
106
- if (type === null || typeof type != "function" && typeof type != "object" || allFamiliesByType.has(type))
107
- return;
108
- let family = allFamiliesByID.get(id);
109
- if (family === void 0 ? (family = { current: type }, allFamiliesByID.set(id, family)) : pendingUpdates.push([family, type]), allFamiliesByType.set(type, family), typeof type == "object" && type !== null)
110
- switch (getProperty(type, "$$typeof")) {
111
- case REACT_FORWARD_REF_TYPE:
112
- register(type.render, id + "$render");
113
- break;
114
- case REACT_MEMO_TYPE:
115
- register(type.type, id + "$type");
116
- break;
117
- }
118
- }
119
- function setSignature(type, key, forceReset, getCustomHooks) {
120
- if (allSignaturesByType.has(type) || allSignaturesByType.set(type, {
121
- forceReset,
122
- ownKey: key,
123
- fullKey: null,
124
- getCustomHooks: getCustomHooks || (() => [])
125
- }), typeof type == "object" && type !== null)
126
- switch (getProperty(type, "$$typeof")) {
127
- case REACT_FORWARD_REF_TYPE:
128
- setSignature(type.render, key, forceReset, getCustomHooks);
129
- break;
130
- case REACT_MEMO_TYPE:
131
- setSignature(type.type, key, forceReset, getCustomHooks);
132
- break;
133
- }
134
- }
135
- function collectCustomHooksForSignature(type) {
136
- const signature = allSignaturesByType.get(type);
137
- signature !== void 0 && computeFullKey(signature);
138
- }
139
- function injectIntoGlobalHook(globalObject) {
140
- let hook = globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__;
141
- if (hook === void 0) {
142
- let nextID = 0;
143
- globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
144
- renderers: /* @__PURE__ */ new Map(),
145
- supportsFiber: !0,
146
- inject: (injected) => nextID++,
147
- onScheduleFiberRoot: (id, root, children) => {
148
- },
149
- onCommitFiberRoot: (id, root, maybePriorityLevel, didError) => {
150
- },
151
- onCommitFiberUnmount() {
152
- }
153
- };
154
- }
155
- if (hook.isDisabled) {
156
- console.warn(
157
- "Something has shimmed the React DevTools global hook (__REACT_DEVTOOLS_GLOBAL_HOOK__). Fast Refresh is not compatible with this shim and will be disabled."
158
- );
159
- return;
160
- }
161
- const oldInject = hook.inject;
162
- hook.inject = function(injected) {
163
- const id = oldInject.apply(this, arguments);
164
- return typeof injected.scheduleRefresh == "function" && typeof injected.setRefreshHandler == "function" && helpersByRendererID.set(id, injected), id;
165
- }, hook.renderers.forEach((injected, id) => {
166
- typeof injected.scheduleRefresh == "function" && typeof injected.setRefreshHandler == "function" && helpersByRendererID.set(id, injected);
167
- });
168
- const oldOnCommitFiberRoot = hook.onCommitFiberRoot, oldOnScheduleFiberRoot = hook.onScheduleFiberRoot || (() => {
169
- });
170
- hook.onScheduleFiberRoot = function(id, root, children) {
171
- return isPerformingRefresh || (failedRoots.delete(root), rootElements !== null && rootElements.set(root, children)), oldOnScheduleFiberRoot.apply(this, arguments);
172
- }, hook.onCommitFiberRoot = function(id, root, maybePriorityLevel, didError) {
173
- const helpers = helpersByRendererID.get(id);
174
- if (helpers !== void 0) {
175
- helpersByRoot.set(root, helpers);
176
- const current = root.current, alternate = current.alternate;
177
- if (alternate !== null) {
178
- const wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null && mountedRoots.has(root), isMounted = current.memoizedState != null && current.memoizedState.element != null;
179
- !wasMounted && isMounted ? (mountedRoots.add(root), failedRoots.delete(root)) : wasMounted && isMounted || (wasMounted && !isMounted ? (mountedRoots.delete(root), didError ? failedRoots.add(root) : helpersByRoot.delete(root)) : !wasMounted && !isMounted && didError && failedRoots.add(root));
180
- } else
181
- mountedRoots.add(root);
182
- }
183
- return oldOnCommitFiberRoot.apply(this, arguments);
184
- };
185
- }
186
- function createSignatureFunctionForTransform() {
187
- let savedType, hasCustomHooks, didCollectHooks = !1;
188
- return (type, key, forceReset, getCustomHooks) => {
189
- if (typeof key == "string")
190
- return savedType || (savedType = type, hasCustomHooks = typeof getCustomHooks == "function"), type != null && (typeof type == "function" || typeof type == "object") && setSignature(type, key, forceReset, getCustomHooks), type;
191
- !didCollectHooks && hasCustomHooks && (didCollectHooks = !0, collectCustomHooksForSignature(savedType));
192
- };
193
- }
194
- function isLikelyComponentType(type) {
195
- switch (typeof type) {
196
- case "function": {
197
- if (type.prototype != null) {
198
- if (type.prototype.isReactComponent)
199
- return !0;
200
- const ownNames = Object.getOwnPropertyNames(type.prototype);
201
- if (ownNames.length > 1 || ownNames[0] !== "constructor" || type.prototype.__proto__ !== Object.prototype)
202
- return !1;
203
- }
204
- const name = type.name || type.displayName;
205
- return typeof name == "string" && /^[A-Z]/.test(name);
206
- }
207
- case "object": {
208
- if (type != null)
209
- switch (getProperty(type, "$$typeof")) {
210
- case REACT_FORWARD_REF_TYPE:
211
- case REACT_MEMO_TYPE:
212
- return !0;
213
- default:
214
- return !1;
215
- }
216
- return !1;
217
- }
218
- default:
219
- return !1;
220
- }
221
- }
222
- function getRefreshReg(filename) {
223
- return (type, id) => register(type, filename + " " + id);
224
- }
225
- function registerExportsForReactRefresh(filename, moduleExports) {
226
- for (const key in moduleExports) {
227
- if (key === "__esModule") continue;
228
- const exportValue = moduleExports[key];
229
- isLikelyComponentType(exportValue) && register(exportValue, filename + " export " + key);
230
- }
231
- }
232
- function debounce(fn, delay) {
233
- let handle;
234
- return () => {
235
- clearTimeout(handle), handle = setTimeout(fn, delay);
236
- };
237
- }
238
- const hooks = [];
239
- window.__registerBeforePerformReactRefresh = (cb) => {
240
- hooks.push(cb);
241
- };
242
- const enqueueUpdate = debounce(async () => {
243
- hooks.length && await Promise.all(hooks.map((cb) => cb())), performReactRefresh();
244
- }, 16);
245
- function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
246
- const ignoredExports = ["sitemap", "loader", "generateStaticParams"];
247
- if (predicateOnExport(ignoredExports, prevExports, (key) => key in nextExports) !== !0)
248
- return "Could not Fast Refresh (export removed)";
249
- if (predicateOnExport(ignoredExports, nextExports, (key) => key in prevExports) !== !0)
250
- return "Could not Fast Refresh (new export)";
251
- let hasExports = !1;
252
- const allExportsAreComponentsOrUnchanged = predicateOnExport(
253
- ignoredExports,
254
- nextExports,
255
- (key, value) => (hasExports = !0, isLikelyComponentType(value) ? !0 : prevExports[key] === nextExports[key])
256
- );
257
- if (hasExports && allExportsAreComponentsOrUnchanged === !0)
258
- enqueueUpdate();
259
- else
260
- return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react-swc#consistent-components-exports`;
261
- }
262
- function predicateOnExport(ignoredExports, moduleExports, predicate) {
263
- for (const key in moduleExports) {
264
- if (key === "__esModule" || ignoredExports.includes(key)) continue;
265
- const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
266
- if (desc && desc.get || !predicate(key, moduleExports[key])) return key;
267
- }
268
- return !0;
269
- }
270
- const __hmr_import = (module) => import(
271
- /* @vite-ignore */
272
- module
273
- );
274
- var refresh_runtime_default = { injectIntoGlobalHook };
275
- export {
276
- __hmr_import,
277
- createSignatureFunctionForTransform,
278
- refresh_runtime_default as default,
279
- getRefreshReg,
280
- injectIntoGlobalHook,
281
- registerExportsForReactRefresh,
282
- validateRefreshBoundaryAndEnqueueUpdate
283
- };
284
- //# sourceMappingURL=refresh-runtime.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/refresh-runtime.js"],
4
- "mappings": "AAAA;AAOA,MAAM,yBAAyB,OAAO,IAAI,mBAAmB,GACvD,kBAAkB,OAAO,IAAI,YAAY;AAI/C,IAAI,kBAAkB,oBAAI,IAAI,GAC1B,oBAAoB,oBAAI,QAAQ,GAChC,sBAAsB,oBAAI,QAAQ;AAItC,MAAM,wBAAwB,oBAAI,QAAQ;AAI1C,IAAI,iBAAiB,CAAC;AAGtB,MAAM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AO,WAAW,MAAM;AAEhF,WAAO;AAET,MACE,kBAAkB,gBAAgB,aAAa,CAAC,QAAQ,OAAO,WAAW,MAAM;AAEhF,WAAO;AAGT,MAAI,aAAa;AACjB,QAAM,qCAAqC;AAAA,IACzC;AAAA,IACA;AAAA,IACA,CAAC,KAAK,WACJ,aAAa,IACT,sBAAsB,KAAK,IAAU,KAClC,YAAY,GAAG,MAAM,YAAY,GAAG;AAAA,EAE/C;AACA,MAAI,cAAc,uCAAuC;AACvD,kBAAc;AAAA;AAEd,WAAO,4BAA4B,kCAAkC;AAEzE;AAEA,SAAS,kBAAkB,gBAAgB,eAAe,WAAW;AACnE,aAAW,OAAO,eAAe;AAE/B,QADI,QAAQ,gBACR,eAAe,SAAS,GAAG,EAAG;AAClC,UAAM,OAAO,OAAO,yBAAyB,eAAe,GAAG;AAE/D,QADI,QAAQ,KAAK,OACb,CAAC,UAAU,KAAK,cAAc,GAAG,CAAC,EAAG,QAAO;AAAA,EAClD;AACA,SAAO;AACT;AAIO,MAAM,eAAe,CAAC,WAAW;AAAA;AAAA,EAA0B;AAAA;AAGlE,IAAO,0BAAQ,EAAE,qBAAqB;",
5
- "names": ["hooks"]
6
- }
@@ -1,133 +0,0 @@
1
- import { extname, relative } from "node:path";
2
- import babel from "@babel/core";
3
- import { resolvePath } from "@vxrn/utils";
4
- import { configuration } from "./configure";
5
- import { asyncGeneratorRegex, debug } from "./constants";
6
- function getBabelOptions(props) {
7
- return props.userSetting === "babel" ? getOptions(props, !0) : typeof props.userSetting > "u" || typeof props.userSetting == "object" && props.userSetting.transform === "babel" ? props.userSetting?.excludeDefaultPlugins ? props.userSetting : getOptions(props) : null;
8
- }
9
- const getOptions = (props, force = !1) => {
10
- let plugins = [];
11
- (force || shouldBabelGenerators(props)) && (plugins = getBasePlugins(props));
12
- const enableNativewind = configuration.enableNativewind && (props.environment === "ios" || props.environment === "android") && // if reanimated gets wrapped in transform it causes circular dep issues
13
- !/node_modules/.test(props.id) && // only needed for createElement calls, so be a bit conservative
14
- props.code.includes("createElement");
15
- return enableNativewind && (props.id.includes("node_modules") || plugins.push(resolvePath("react-native-css-interop/dist/babel-plugin.js"))), (enableNativewind || shouldBabelReanimated(props)) && (debug?.(`Using babel reanimated on file ${props.id}`), plugins.push(
16
- // TODO make this configurable
17
- process.env.VXRN_WORKLET_PLUGIN ? "react-native-worklets/plugin" : "react-native-reanimated/plugin"
18
- )), shouldBabelReactCompiler(props) && (debug?.("Using babel react compiler on file"), plugins.push(getBabelReactCompilerPlugin(props))), shouldBabelReactNativeCodegen(props) && (debug?.("Using babel @react-native/babel-plugin-codegen on file"), plugins.push("@react-native/babel-plugin-codegen")), plugins.length ? { plugins } : null;
19
- };
20
- async function transformBabel(id, code, options) {
21
- const extension = extname(id), isTSX = extension === ".tsx", babelOptions = {
22
- filename: id,
23
- compact: !1,
24
- babelrc: !1,
25
- configFile: !1,
26
- sourceMaps: !1,
27
- minified: !1,
28
- ...options,
29
- presets: [
30
- isTSX || extension === ".ts" ? [
31
- "@babel/preset-typescript",
32
- {
33
- isTSX,
34
- allExtensions: isTSX
35
- }
36
- ] : "",
37
- ...options.presets || []
38
- ].filter(Boolean)
39
- };
40
- try {
41
- return await new Promise((res, rej) => {
42
- babel.transform(code, babelOptions, (err, result) => {
43
- if (!result || err)
44
- return rej(err || "no res");
45
- res(result);
46
- });
47
- });
48
- } catch (err) {
49
- console.error(
50
- "[vxrn:compiler] babel transform error",
51
- err,
52
- "with options",
53
- babelOptions
54
- ), console.error("code", code), console.error("id", id);
55
- }
56
- }
57
- const getBasePlugins = ({ development }) => [
58
- ["@babel/plugin-transform-destructuring"],
59
- ["@babel/plugin-transform-react-jsx", { development }],
60
- ["@babel/plugin-transform-async-generator-functions"],
61
- ["@babel/plugin-transform-async-to-generator"],
62
- [
63
- "@babel/plugin-transform-runtime",
64
- {
65
- helpers: !0,
66
- // NOTE THIS WAS SPELLED WRONG BEFOER THIS COMMIT MAYBE IT WAS UNINTENTIONALLY WORKING
67
- regenerator: !1
68
- }
69
- ]
70
- ], NATIVE_COMPONENT_RE = /NativeComponent\.[jt]sx?$/, SPEC_FILE_RE = /[/\\]specs?[/\\]/, shouldBabelReactNativeCodegen = ({ id, environment }) => (environment === "ios" || environment === "android") && (NATIVE_COMPONENT_RE.test(id) || SPEC_FILE_RE.test(id)), shouldBabelReactCompiler = (props) => {
71
- if (props.environment === "ssr" || !configuration.enableCompiler)
72
- return !1;
73
- const { enableCompiler } = configuration;
74
- if (typeof enableCompiler == "object" && !Array.isArray(enableCompiler) && !(enableCompiler instanceof RegExp)) {
75
- const filter = props.environment === "ios" || props.environment === "android" ? enableCompiler.native : enableCompiler.web;
76
- return filter ? applyCompilerFilter(filter, props) : !1;
77
- }
78
- return typeof enableCompiler == "function" ? enableCompiler(props.id, props.environment) : enableCompiler instanceof RegExp ? enableCompiler.test(props.id) : Array.isArray(enableCompiler) && !enableCompiler.includes(props.environment) ? !1 : applyDefaultFilters(props);
79
- };
80
- function applyCompilerFilter(filter, props) {
81
- return typeof filter == "function" ? filter(props.id, props.environment) : filter instanceof RegExp ? filter.test(props.id) : filter === !0 ? applyDefaultFilters(props) : !1;
82
- }
83
- function applyDefaultFilters(props) {
84
- return !(!/(\.tsx?)$/.test(props.id) || props.id.includes("node_modules") || props.id.includes("+api.") || props.code.startsWith("// disable-compiler"));
85
- }
86
- const getBabelReactCompilerPlugin = (props) => ["babel-plugin-react-compiler", { target: props.reactForRNVersion === "18" && (props.environment === "ios" || props.environment === "android") ? "18" : "19" }];
87
- function shouldBabelGenerators({ code }) {
88
- if (process.env.VXRN_USE_BABEL_FOR_GENERATORS)
89
- return asyncGeneratorRegex.test(code);
90
- }
91
- const REANIMATED_AUTOWORKLETIZATION_KEYWORDS = [
92
- "worklet",
93
- "useAnimatedGestureHandler",
94
- "useAnimatedScrollHandler",
95
- "useFrameCallback",
96
- "useAnimatedStyle",
97
- "useAnimatedProps",
98
- "createAnimatedPropAdapter",
99
- "useDerivedValue",
100
- "useAnimatedReaction",
101
- "useWorkletCallback",
102
- "withTiming",
103
- "withSpring",
104
- "withDecay",
105
- "withRepeat",
106
- "runOnUI",
107
- "executeOnUIRuntimeSync"
108
- ], REANIMATED_REGEX = new RegExp(REANIMATED_AUTOWORKLETIZATION_KEYWORDS.join("|")), REANIMATED_IGNORED_PATHS = [
109
- // Prebuilt/vendored react-native that shouldn't be transformed
110
- "react-native-prebuilt",
111
- "node_modules/.vxrn/react-native",
112
- // Known false positives - they mention worklet keywords in comments/strings but don't use them
113
- "node_modules/react/",
114
- "node_modules/react-dom/",
115
- "node_modules/react-native/",
116
- "node_modules/react-native-web/"
117
- ], REANIMATED_IGNORED_PATHS_REGEX = new RegExp(
118
- REANIMATED_IGNORED_PATHS.map((s) => s.replace(/\//g, "/")).join("|")
119
- );
120
- function shouldBabelReanimated({ code, id }) {
121
- if (!configuration.enableReanimated || REANIMATED_IGNORED_PATHS_REGEX.test(id))
122
- return !1;
123
- if (REANIMATED_REGEX.test(code)) {
124
- const location = id.includes("node_modules") ? "node_modules" : "user-code";
125
- return debug?.(` \u{1FA84} [reanimated/${location}] ${relative(process.cwd(), id)}`), !0;
126
- }
127
- return !1;
128
- }
129
- export {
130
- getBabelOptions,
131
- transformBabel
132
- };
133
- //# sourceMappingURL=transformBabel.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/transformBabel.ts"],
4
- "mappings": "AAAA,SAAS,SAAS,gBAAgB;AAClC,OAAO,WAAW;AAClB,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB,aAAa;AAOpC,SAAS,gBAAgB,OAA6C;AAC3E,SAAI,MAAM,gBAAgB,UACjB,WAAW,OAAO,EAAI,IAG7B,OAAO,MAAM,cAAgB,OAC5B,OAAO,MAAM,eAAgB,YAAY,MAAM,YAAY,cAAc,UAEtE,MAAM,aAAa,wBACd,MAAM,cAER,WAAW,KAAK,IAElB;AACT;AAEA,MAAM,aAAa,CAAC,OAAc,QAA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