@amplytools/react-native-amply-sdk 0.3.0 → 0.4.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/AmplyReactNative.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/tools/amply/sdk/reactnative/AmplyModule.kt +62 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/core/AmplyClient.kt +35 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/core/DefaultAmplyClient.kt +134 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/model/CampaignPresentPayload.kt +16 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/model/DeepLinkPayload.kt +15 -0
- package/android/src/newarch/java/tools/amply/sdk/reactnative/NativeAmplyModuleSpec.java +16 -0
- package/android/src/newarch/jni/AmplyReactNative-generated.cpp +19 -0
- package/dist/src/__tests__/campaignResolved.test.d.ts +2 -0
- package/dist/src/__tests__/campaignResolved.test.d.ts.map +1 -0
- package/dist/src/__tests__/campaignResolved.test.js +137 -0
- package/dist/src/index.d.ts +57 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +84 -0
- package/dist/src/nativeSpecs/NativeAmplyModule.d.ts +56 -0
- package/dist/src/nativeSpecs/NativeAmplyModule.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ios/Sources/AmplyReactNative/AmplyModule.mm +156 -1
- package/ios/Sources/AmplyReactNative/AmplyReactNative/AmplyReactNative-generated.mm +26 -0
- package/ios/Sources/AmplyReactNative/AmplyReactNative/AmplyReactNative.h +8 -0
- package/package.json +1 -1
- package/src/__tests__/campaignResolved.test.ts +180 -0
- package/src/index.ts +157 -0
- package/src/nativeSpecs/NativeAmplyModule.ts +58 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { useAmplySystemEvents } from './hooks/useAmplySystemEvents';
|
|
2
2
|
export { formatSystemEventLabel } from './systemEventUtils';
|
|
3
3
|
export type { FormatOptions } from './systemEventUtils';
|
|
4
|
-
import type { AmplyInitializationConfig, DataSetSnapshot, DataSetType, DeepLinkEvent, EventRecord, LogLevel, TrackEventPayload } from './nativeSpecs/NativeAmplyModule';
|
|
4
|
+
import type { CampaignResult, AmplyInitializationConfig, DataSetSnapshot, DataSetType, DeepLinkEvent, EventRecord, LogLevel, CampaignPresentEvent, TrackEventPayload } from './nativeSpecs/NativeAmplyModule';
|
|
5
5
|
export declare function initialize(config: AmplyInitializationConfig): Promise<void>;
|
|
6
6
|
/**
|
|
7
7
|
* Set the user ID for analytics. Pass null to clear.
|
|
@@ -20,6 +20,59 @@ export declare function setLogLevel(level: LogLevel): void;
|
|
|
20
20
|
export declare function getLogLevel(): LogLevel;
|
|
21
21
|
export declare function isInitialized(): boolean;
|
|
22
22
|
export declare function track(payload: TrackEventPayload): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Continuation hooks for the gating form of {@link trackEvent}.
|
|
25
|
+
*
|
|
26
|
+
* `onProceed` is "what to do next" (run exactly once when the gate resolves in
|
|
27
|
+
* favor of proceeding). `onCancel` is an OPTIONAL local-UI cleanup hook, invoked
|
|
28
|
+
* only when a campaign's blocking action is user-dismissed under an `onAbort=cancel`
|
|
29
|
+
* policy. Never put business logic in `onCancel`.
|
|
30
|
+
*
|
|
31
|
+
* The raw campaign result is deliberately not exposed — app code must never branch
|
|
32
|
+
* on which action ran or how it resolved.
|
|
33
|
+
*/
|
|
34
|
+
export type TrackEventContinuation = {
|
|
35
|
+
onProceed: () => void;
|
|
36
|
+
onCancel?: () => void;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Possible results a campaign presenter can report. Re-exported from the
|
|
40
|
+
* native spec for app presenters.
|
|
41
|
+
*/
|
|
42
|
+
export type { CampaignResult };
|
|
43
|
+
/**
|
|
44
|
+
* A capability presenter for a campaign present (blocking) action. Keyed by deeplink
|
|
45
|
+
* URL semantics, NOT by event — the app is a registry of capabilities. Returns (or
|
|
46
|
+
* resolves) the terminal {@link CampaignResult}. Throwing / rejecting is treated as
|
|
47
|
+
* `'Unavailable'` (fail-open).
|
|
48
|
+
*/
|
|
49
|
+
export type CampaignPresenter = (url: string, info: Record<string, unknown>) => CampaignResult | Promise<CampaignResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Fire-and-forget analytics track. Records the event and lets any matching NORMAL
|
|
52
|
+
* campaign action dispatch as usual. A blocking action matched here will NOT fire —
|
|
53
|
+
* there is no continuation to gate.
|
|
54
|
+
*/
|
|
55
|
+
export declare function trackEvent(event: string, properties?: Record<string, unknown> | null): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Continuation (gating) form. Records the event; if a blocking campaign action
|
|
58
|
+
* matches AND a presenter is registered, the SDK dispatches it and awaits its result
|
|
59
|
+
* before resolving the continuation:
|
|
60
|
+
* - proceed (completed / unavailable / timeout / dismissed+proceed) → `onProceed`
|
|
61
|
+
* - user dismiss against an `onAbort=cancel` action → `onCancel`
|
|
62
|
+
*
|
|
63
|
+
* Fails open: any error path runs `onProceed`. Passing a continuation is the gating
|
|
64
|
+
* switch — the same event tracked elsewhere without one is a valid, non-gating call.
|
|
65
|
+
*/
|
|
66
|
+
export declare function trackEvent(event: string, properties: Record<string, unknown> | null | undefined, continuation: TrackEventContinuation): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Register a capability presenter for campaign present (blocking) actions. The presenter
|
|
69
|
+
* is invoked when a blocking action is dispatched; it must report a terminal
|
|
70
|
+
* {@link CampaignResult} (returned or resolved). The SDK collapses multi-step ad
|
|
71
|
+
* lifecycles into the single result you report. Throwing/rejecting → `'Unavailable'`.
|
|
72
|
+
*
|
|
73
|
+
* @returns an unsubscribe function.
|
|
74
|
+
*/
|
|
75
|
+
export declare function registerCampaignPresenter(presenter: CampaignPresenter): Promise<() => void>;
|
|
23
76
|
export declare function getRecentEvents(limit: number): Promise<EventRecord[]>;
|
|
24
77
|
export declare function getDataSetSnapshot(type: DataSetType): Promise<DataSetSnapshot>;
|
|
25
78
|
export declare function addDeepLinkListener(listener: (event: DeepLinkEvent) => void): Promise<() => void>;
|
|
@@ -55,7 +108,7 @@ export declare function removeCustomProperty(key: string): void;
|
|
|
55
108
|
*/
|
|
56
109
|
export declare function clearCustomProperties(): void;
|
|
57
110
|
export declare function removeAllListeners(): void;
|
|
58
|
-
export type { AmplyInitializationConfig, DataSetSnapshot, DataSetType, DeepLinkEvent, EventRecord, LogLevel, TrackEventPayload, };
|
|
111
|
+
export type { AmplyInitializationConfig, DataSetSnapshot, DataSetType, DeepLinkEvent, EventRecord, LogLevel, CampaignPresentEvent, TrackEventPayload, };
|
|
59
112
|
export declare function addSystemEventsListener(listener: (event: EventRecord) => void): Promise<() => void>;
|
|
60
113
|
export declare const systemEvents: {
|
|
61
114
|
addListener: typeof addSystemEventsListener;
|
|
@@ -64,6 +117,8 @@ declare const _default: {
|
|
|
64
117
|
initialize: typeof initialize;
|
|
65
118
|
isInitialized: typeof isInitialized;
|
|
66
119
|
track: typeof track;
|
|
120
|
+
trackEvent: typeof trackEvent;
|
|
121
|
+
registerCampaignPresenter: typeof registerCampaignPresenter;
|
|
67
122
|
getRecentEvents: typeof getRecentEvents;
|
|
68
123
|
getDataSetSnapshot: typeof getDataSetSnapshot;
|
|
69
124
|
addDeepLinkListener: typeof addDeepLinkListener;
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,iBAAiB,EAClB,MAAM,i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AC,mBAAmB,GAAG,IAAI,CAAC,CAIxF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAkBzC;AAED,YAAY,EACV,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,GAClB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACrC,OAAO,CAAC,MAAM,IAAI,CAAC,CAErB;AAED,eAAO,MAAM,YAAY;;CAExB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,wBAqBE"}
|
package/dist/src/index.js
CHANGED
|
@@ -4,7 +4,9 @@ export { useAmplySystemEvents } from './hooks/useAmplySystemEvents';
|
|
|
4
4
|
export { formatSystemEventLabel } from './systemEventUtils';
|
|
5
5
|
let deepLinkRegistered = false;
|
|
6
6
|
let debugLogListenerRegistered = false;
|
|
7
|
+
let campaignPresenterRegistered = false;
|
|
7
8
|
const deepLinkSubscriptions = new Set();
|
|
9
|
+
const campaignPresenterSubscriptions = new Set();
|
|
8
10
|
/**
|
|
9
11
|
* Format a debug log entry for console output using new format.
|
|
10
12
|
*/
|
|
@@ -107,6 +109,77 @@ export function isInitialized() {
|
|
|
107
109
|
export async function track(payload) {
|
|
108
110
|
await getNativeModule().track(payload);
|
|
109
111
|
}
|
|
112
|
+
export async function trackEvent(event, properties, continuation) {
|
|
113
|
+
var _a;
|
|
114
|
+
const props = properties !== null && properties !== void 0 ? properties : {};
|
|
115
|
+
if (!continuation) {
|
|
116
|
+
await getNativeModule().track({ name: event, properties: props });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let decision;
|
|
120
|
+
try {
|
|
121
|
+
decision = await getNativeModule().trackEventGated(event, props);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
// Fail open: any bridge/SDK failure must proceed, never strand the app.
|
|
125
|
+
console.warn('[Amply] trackEvent continuation failed; proceeding (fail-open)', error);
|
|
126
|
+
continuation.onProceed();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (decision === 'cancel') {
|
|
130
|
+
// A deliberate user-dismiss under an onAbort=cancel action. Only the local-UI
|
|
131
|
+
// cleanup hook runs; the continuation is suppressed.
|
|
132
|
+
(_a = continuation.onCancel) === null || _a === void 0 ? void 0 : _a.call(continuation);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// 'complete' and any unexpected value fail open to onProceed.
|
|
136
|
+
continuation.onProceed();
|
|
137
|
+
}
|
|
138
|
+
async function ensureCampaignPresenterRegistration() {
|
|
139
|
+
if (!campaignPresenterRegistered) {
|
|
140
|
+
getNativeModule().registerCampaignPresenter();
|
|
141
|
+
campaignPresenterRegistered = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function trackCampaignPresenterSubscription(subscription) {
|
|
145
|
+
let removed = false;
|
|
146
|
+
const unsubscribe = () => {
|
|
147
|
+
var _a;
|
|
148
|
+
if (removed) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
removed = true;
|
|
152
|
+
(_a = subscription === null || subscription === void 0 ? void 0 : subscription.remove) === null || _a === void 0 ? void 0 : _a.call(subscription);
|
|
153
|
+
campaignPresenterSubscriptions.delete(unsubscribe);
|
|
154
|
+
};
|
|
155
|
+
campaignPresenterSubscriptions.add(unsubscribe);
|
|
156
|
+
return unsubscribe;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Register a capability presenter for campaign present (blocking) actions. The presenter
|
|
160
|
+
* is invoked when a blocking action is dispatched; it must report a terminal
|
|
161
|
+
* {@link CampaignResult} (returned or resolved). The SDK collapses multi-step ad
|
|
162
|
+
* lifecycles into the single result you report. Throwing/rejecting → `'Unavailable'`.
|
|
163
|
+
*
|
|
164
|
+
* @returns an unsubscribe function.
|
|
165
|
+
*/
|
|
166
|
+
export async function registerCampaignPresenter(presenter) {
|
|
167
|
+
await ensureCampaignPresenterRegistration();
|
|
168
|
+
const nativeModule = getNativeModule();
|
|
169
|
+
const subscription = nativeModule.onCampaignPresent((event) => {
|
|
170
|
+
const { url, info, mediationId } = event;
|
|
171
|
+
void Promise.resolve()
|
|
172
|
+
.then(() => presenter(url, info))
|
|
173
|
+
.then(result => {
|
|
174
|
+
nativeModule.resolveCampaign(mediationId, result);
|
|
175
|
+
}, error => {
|
|
176
|
+
// Presenter failure is an infra failure, never a user dismiss → Unavailable.
|
|
177
|
+
console.warn('[Amply] campaign presenter failed; reporting Unavailable', error);
|
|
178
|
+
nativeModule.resolveCampaign(mediationId, 'Unavailable');
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
return trackCampaignPresenterSubscription(subscription);
|
|
182
|
+
}
|
|
110
183
|
export async function getRecentEvents(limit) {
|
|
111
184
|
return getNativeModule().getRecentEvents(limit);
|
|
112
185
|
}
|
|
@@ -170,6 +243,15 @@ export function removeAllListeners() {
|
|
|
170
243
|
}
|
|
171
244
|
});
|
|
172
245
|
deepLinkSubscriptions.clear();
|
|
246
|
+
campaignPresenterSubscriptions.forEach(unsubscribe => {
|
|
247
|
+
try {
|
|
248
|
+
unsubscribe();
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
console.warn('[Amply] Failed to remove campaign presenter', error);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
campaignPresenterSubscriptions.clear();
|
|
173
255
|
}
|
|
174
256
|
export function addSystemEventsListener(listener) {
|
|
175
257
|
return addSystemEventListener(listener);
|
|
@@ -181,6 +263,8 @@ export default {
|
|
|
181
263
|
initialize,
|
|
182
264
|
isInitialized,
|
|
183
265
|
track,
|
|
266
|
+
trackEvent,
|
|
267
|
+
registerCampaignPresenter,
|
|
184
268
|
getRecentEvents,
|
|
185
269
|
getDataSetSnapshot,
|
|
186
270
|
addDeepLinkListener,
|
|
@@ -78,10 +78,65 @@ export type DeepLinkEvent = {
|
|
|
78
78
|
info: JsonMap;
|
|
79
79
|
consumed: boolean;
|
|
80
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Terminal result reported by a campaign presenter back to the SDK.
|
|
83
|
+
*
|
|
84
|
+
* - 'Completed': the presenter satisfied the campaign condition (e.g. rewarded ad
|
|
85
|
+
* watched to completion). The continuation proceeds.
|
|
86
|
+
* - 'Dismissed': a USER-INITIATED dismiss without satisfying the condition. With an
|
|
87
|
+
* `onAbort=cancel` action this suppresses the continuation; with `onAbort=proceed`
|
|
88
|
+
* it proceeds. Reserved strictly for user intent — never infra failures.
|
|
89
|
+
* - 'Unavailable': any non-user failure (no-fill, failed-to-show, not-ready, missing
|
|
90
|
+
* precondition). Always fails open and proceeds.
|
|
91
|
+
*
|
|
92
|
+
* NOTE: this raw result is intentionally NOT surfaced to app continuation code —
|
|
93
|
+
* the public `trackEvent` continuation only ever sees `onProceed`/`onCancel`.
|
|
94
|
+
*/
|
|
95
|
+
export type CampaignResult = 'Completed' | 'Dismissed' | 'Unavailable';
|
|
96
|
+
/**
|
|
97
|
+
* Payload delivered to JS when a campaign dispatches a present (blocking) action.
|
|
98
|
+
* The JS handler must eventually report a {@link CampaignResult} for `mediationId`
|
|
99
|
+
* via `resolveCampaign`.
|
|
100
|
+
*/
|
|
101
|
+
export type CampaignPresentEvent = {
|
|
102
|
+
url: string;
|
|
103
|
+
/**
|
|
104
|
+
* Enriched, decoupled action info:
|
|
105
|
+
* `{ url, campaignId, campaignName, triggeringEvent, triggeringProperties, content }`.
|
|
106
|
+
*/
|
|
107
|
+
info: JsonMap;
|
|
108
|
+
mediationId: string;
|
|
109
|
+
};
|
|
81
110
|
export interface Spec extends TurboModule {
|
|
82
111
|
initialize(config: AmplyInitializationConfig): Promise<void>;
|
|
83
112
|
isInitialized(): boolean;
|
|
84
113
|
track(payload: TrackEventPayload): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Gated form of track: records the event, evaluates campaigns, and — if a
|
|
116
|
+
* blocking action matches and a presenter is registered — dispatches the campaign
|
|
117
|
+
* present and awaits its result. Resolves with the continuation decision:
|
|
118
|
+
* - 'complete': the continuation should proceed (onProceed).
|
|
119
|
+
* - 'cancel': the continuation should be suppressed (onCancel) — only ever
|
|
120
|
+
* returned for a user `Dismissed` against an `onAbort=cancel` action.
|
|
121
|
+
*
|
|
122
|
+
* The raw {@link CampaignResult} is never returned to JS; it is collapsed natively
|
|
123
|
+
* into this 'complete' | 'cancel' decision so app code can't branch on results.
|
|
124
|
+
* Every failure path fails open to 'complete'.
|
|
125
|
+
*/
|
|
126
|
+
trackEventGated(event: string, properties: JsonMap): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Report the terminal result of a campaign present dispatched to JS via the
|
|
129
|
+
* `onCampaignPresent` event. Idempotent natively — late/duplicate calls are ignored.
|
|
130
|
+
* @param mediationId The id carried by the matching `onCampaignPresent` event.
|
|
131
|
+
* @param result One of {@link CampaignResult} ('Completed' | 'Dismissed' | 'Unavailable').
|
|
132
|
+
*/
|
|
133
|
+
resolveCampaign(mediationId: string, result: string): void;
|
|
134
|
+
/**
|
|
135
|
+
* Register the JS side as the recipient of campaign present dispatches. Wiring of
|
|
136
|
+
* the actual per-URL-pattern routing happens natively; JS receives every dispatch
|
|
137
|
+
* via the `onCampaignPresent` event and replies through `resolveCampaign`.
|
|
138
|
+
*/
|
|
139
|
+
registerCampaignPresenter(): void;
|
|
85
140
|
getRecentEvents(limit: number): Promise<EventRecord[]>;
|
|
86
141
|
getDataSetSnapshot(type: DataSetType): Promise<DataSetSnapshot>;
|
|
87
142
|
registerDeepLinkListener(): void;
|
|
@@ -122,6 +177,7 @@ export interface Spec extends TurboModule {
|
|
|
122
177
|
clearCustomProperties(): void;
|
|
123
178
|
readonly onSystemEvent: EventEmitter<SystemEventPayload>;
|
|
124
179
|
readonly onDeepLink: EventEmitter<DeepLinkEvent>;
|
|
180
|
+
readonly onCampaignPresent: EventEmitter<CampaignPresentEvent>;
|
|
125
181
|
addListener(eventName: string): void;
|
|
126
182
|
removeListeners(count: number): void;
|
|
127
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeAmplyModule.d.ts","sourceRoot":"","sources":["../../../src/nativeSpecs/NativeAmplyModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,2CAA2C,CAAC;AAE5E,KAAK,OAAO,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,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