@elizaos/plugin-line 2.0.0-alpha.7 → 2.0.3-beta.2
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/LICENSE +21 -0
- package/README.md +185 -0
- package/package.json +28 -12
- package/dist/accounts.d.ts +0 -152
- package/dist/accounts.d.ts.map +0 -1
- package/dist/accounts.js +0 -258
- package/dist/accounts.js.map +0 -1
- package/dist/actions/index.d.ts +0 -7
- package/dist/actions/index.d.ts.map +0 -1
- package/dist/actions/index.js +0 -7
- package/dist/actions/index.js.map +0 -1
- package/dist/actions/sendFlexMessage.d.ts +0 -6
- package/dist/actions/sendFlexMessage.d.ts.map +0 -1
- package/dist/actions/sendFlexMessage.js +0 -204
- package/dist/actions/sendFlexMessage.js.map +0 -1
- package/dist/actions/sendLocation.d.ts +0 -6
- package/dist/actions/sendLocation.d.ts.map +0 -1
- package/dist/actions/sendLocation.js +0 -181
- package/dist/actions/sendLocation.js.map +0 -1
- package/dist/actions/sendMessage.d.ts +0 -6
- package/dist/actions/sendMessage.d.ts.map +0 -1
- package/dist/actions/sendMessage.js +0 -172
- package/dist/actions/sendMessage.js.map +0 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -49
- package/dist/index.js.map +0 -1
- package/dist/messaging.d.ts +0 -142
- package/dist/messaging.d.ts.map +0 -1
- package/dist/messaging.js +0 -357
- package/dist/messaging.js.map +0 -1
- package/dist/providers/chatContext.d.ts +0 -6
- package/dist/providers/chatContext.d.ts.map +0 -1
- package/dist/providers/chatContext.js +0 -86
- package/dist/providers/chatContext.js.map +0 -1
- package/dist/providers/index.d.ts +0 -6
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -6
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/userContext.d.ts +0 -6
- package/dist/providers/userContext.d.ts.map +0 -1
- package/dist/providers/userContext.js +0 -71
- package/dist/providers/userContext.js.map +0 -1
- package/dist/service.d.ts +0 -102
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -433
- package/dist/service.js.map +0 -1
- package/dist/types.d.ts +0 -279
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -106
- package/dist/types.js.map +0 -1
package/dist/types.d.ts
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE Channel Types
|
|
3
|
-
*
|
|
4
|
-
* Type definitions for LINE messaging channel data structures.
|
|
5
|
-
*
|
|
6
|
-
* @module line/types
|
|
7
|
-
*/
|
|
8
|
-
export declare const LINE_SERVICE_NAME: "line";
|
|
9
|
-
export declare const MAX_LINE_BATCH_SIZE = 5;
|
|
10
|
-
export declare const LineEventTypes: {
|
|
11
|
-
readonly CONNECTION_READY: "line:connection_ready";
|
|
12
|
-
readonly MESSAGE_RECEIVED: "line:message_received";
|
|
13
|
-
readonly MESSAGE_SENT: "line:message_sent";
|
|
14
|
-
readonly FOLLOW: "line:follow";
|
|
15
|
-
readonly UNFOLLOW: "line:unfollow";
|
|
16
|
-
readonly JOIN_GROUP: "line:join_group";
|
|
17
|
-
readonly LEAVE_GROUP: "line:leave_group";
|
|
18
|
-
readonly POSTBACK: "line:postback";
|
|
19
|
-
};
|
|
20
|
-
export declare class LineConfigurationError extends Error {
|
|
21
|
-
field?: string | undefined;
|
|
22
|
-
constructor(message: string, field?: string | undefined);
|
|
23
|
-
}
|
|
24
|
-
export declare class LineApiError extends Error {
|
|
25
|
-
statusCode?: number | undefined;
|
|
26
|
-
constructor(message: string, statusCode?: number | undefined);
|
|
27
|
-
}
|
|
28
|
-
export interface LineSettings {
|
|
29
|
-
channelAccessToken: string;
|
|
30
|
-
channelSecret: string;
|
|
31
|
-
webhookPath: string;
|
|
32
|
-
dmPolicy: "open" | "pairing" | "allowlist" | "disabled";
|
|
33
|
-
groupPolicy: "open" | "allowlist" | "disabled";
|
|
34
|
-
allowFrom: string[];
|
|
35
|
-
enabled: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface LineUser {
|
|
38
|
-
userId: string;
|
|
39
|
-
displayName: string;
|
|
40
|
-
pictureUrl?: string;
|
|
41
|
-
statusMessage?: string;
|
|
42
|
-
language?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface LineGroup {
|
|
45
|
-
groupId: string;
|
|
46
|
-
groupName?: string;
|
|
47
|
-
pictureUrl?: string;
|
|
48
|
-
memberCount?: number;
|
|
49
|
-
type: "group" | "room";
|
|
50
|
-
}
|
|
51
|
-
export interface LineSendResult {
|
|
52
|
-
success: boolean;
|
|
53
|
-
messageId?: string;
|
|
54
|
-
chatId?: string;
|
|
55
|
-
error?: string;
|
|
56
|
-
}
|
|
57
|
-
export interface LineMessageSendOptions {
|
|
58
|
-
quickReplyItems?: LineQuickReplyItem[];
|
|
59
|
-
notificationDisabled?: boolean;
|
|
60
|
-
}
|
|
61
|
-
export interface ILineService {
|
|
62
|
-
isConnected(): boolean;
|
|
63
|
-
sendMessage(to: string, text: string, options?: LineMessageSendOptions): Promise<LineSendResult>;
|
|
64
|
-
sendFlexMessage(to: string, flex: LineFlexMessage): Promise<LineSendResult>;
|
|
65
|
-
sendTemplateMessage(to: string, template: LineTemplateMessage): Promise<LineSendResult>;
|
|
66
|
-
sendLocationMessage(to: string, location: LineLocationMessage): Promise<LineSendResult>;
|
|
67
|
-
replyMessage(replyToken: string, messages: Array<{
|
|
68
|
-
type: string;
|
|
69
|
-
[key: string]: unknown;
|
|
70
|
-
}>): Promise<LineSendResult>;
|
|
71
|
-
getUserProfile(userId: string): Promise<LineUser | null>;
|
|
72
|
-
getGroupInfo(groupId: string): Promise<LineGroup | null>;
|
|
73
|
-
getBotInfo(): Promise<LineUser | null>;
|
|
74
|
-
}
|
|
75
|
-
export declare function isValidLineId(id: string): boolean;
|
|
76
|
-
export declare function normalizeLineTarget(target: string): string | null;
|
|
77
|
-
/**
|
|
78
|
-
* LINE location message data.
|
|
79
|
-
*/
|
|
80
|
-
export interface LineLocationData {
|
|
81
|
-
title: string;
|
|
82
|
-
address: string;
|
|
83
|
-
latitude: number;
|
|
84
|
-
longitude: number;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* LINE template action types.
|
|
88
|
-
*/
|
|
89
|
-
export type LineActionType = "message" | "postback" | "uri";
|
|
90
|
-
/**
|
|
91
|
-
* LINE template action.
|
|
92
|
-
*/
|
|
93
|
-
export interface LineTemplateAction {
|
|
94
|
-
type: LineActionType;
|
|
95
|
-
label: string;
|
|
96
|
-
data?: string;
|
|
97
|
-
uri?: string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* LINE template message base.
|
|
101
|
-
*/
|
|
102
|
-
export interface LineTemplateMessageBase {
|
|
103
|
-
altText: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* LINE confirm template content.
|
|
107
|
-
*/
|
|
108
|
-
export interface LineConfirmTemplateContent {
|
|
109
|
-
type: "confirm";
|
|
110
|
-
text: string;
|
|
111
|
-
actions: LineTemplateAction[];
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* LINE buttons template content.
|
|
115
|
-
*/
|
|
116
|
-
export interface LineButtonsTemplateContent {
|
|
117
|
-
type: "buttons";
|
|
118
|
-
title?: string;
|
|
119
|
-
text: string;
|
|
120
|
-
thumbnailImageUrl?: string;
|
|
121
|
-
actions: LineTemplateAction[];
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* LINE template content union type.
|
|
125
|
-
*/
|
|
126
|
-
export type LineTemplateContent = LineConfirmTemplateContent | LineButtonsTemplateContent;
|
|
127
|
-
/**
|
|
128
|
-
* LINE template message (wrapper for sending).
|
|
129
|
-
*/
|
|
130
|
-
export interface LineTemplateMessage extends LineTemplateMessageBase {
|
|
131
|
-
/** The template content */
|
|
132
|
-
template: LineTemplateContent;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* LINE Flex Message content (simplified).
|
|
136
|
-
*/
|
|
137
|
-
export interface LineFlexContents {
|
|
138
|
-
type: string;
|
|
139
|
-
[key: string]: unknown;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* LINE Flex Message data.
|
|
143
|
-
*/
|
|
144
|
-
export interface LineFlexMessage {
|
|
145
|
-
altText: string;
|
|
146
|
-
contents: LineFlexContents;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* LINE quick reply item.
|
|
150
|
-
*/
|
|
151
|
-
export interface LineQuickReplyItem {
|
|
152
|
-
type: "action";
|
|
153
|
-
action: {
|
|
154
|
-
type: "message" | "postback";
|
|
155
|
-
label: string;
|
|
156
|
-
text?: string;
|
|
157
|
-
data?: string;
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* LINE channel-specific data embedded in reply payloads.
|
|
162
|
-
*/
|
|
163
|
-
export interface LineChannelData {
|
|
164
|
-
/** Quick reply options (text strings converted to quick reply items) */
|
|
165
|
-
quickReplies?: string[];
|
|
166
|
-
/** Location message */
|
|
167
|
-
location?: LineLocationData;
|
|
168
|
-
/** Template message (confirm, buttons, etc.) */
|
|
169
|
-
templateMessage?: LineTemplateMessage;
|
|
170
|
-
/** Flex message for rich content */
|
|
171
|
-
flexMessage?: LineFlexMessage;
|
|
172
|
-
/** Raw sticker data */
|
|
173
|
-
sticker?: {
|
|
174
|
-
packageId: string;
|
|
175
|
-
stickerId: string;
|
|
176
|
-
};
|
|
177
|
-
/** Image map message */
|
|
178
|
-
imagemap?: unknown;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* LINE message common properties.
|
|
182
|
-
*/
|
|
183
|
-
export interface LineMessageBase {
|
|
184
|
-
/** Message type */
|
|
185
|
-
type: string;
|
|
186
|
-
/** Quick reply */
|
|
187
|
-
quickReply?: {
|
|
188
|
-
items: LineQuickReplyItem[];
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* LINE text message.
|
|
193
|
-
*/
|
|
194
|
-
export interface LineTextMessage extends LineMessageBase {
|
|
195
|
-
type: "text";
|
|
196
|
-
text: string;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* LINE image message.
|
|
200
|
-
*/
|
|
201
|
-
export interface LineImageMessage extends LineMessageBase {
|
|
202
|
-
type: "image";
|
|
203
|
-
originalContentUrl: string;
|
|
204
|
-
previewImageUrl: string;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* LINE sticker message.
|
|
208
|
-
*/
|
|
209
|
-
export interface LineStickerMessage extends LineMessageBase {
|
|
210
|
-
type: "sticker";
|
|
211
|
-
packageId: string;
|
|
212
|
-
stickerId: string;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* LINE location message.
|
|
216
|
-
*/
|
|
217
|
-
export interface LineLocationMessage extends LineMessageBase {
|
|
218
|
-
type: "location";
|
|
219
|
-
title: string;
|
|
220
|
-
address: string;
|
|
221
|
-
latitude: number;
|
|
222
|
-
longitude: number;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* LINE Flex message for sending.
|
|
226
|
-
*/
|
|
227
|
-
export interface LineFlexMessageSend extends LineMessageBase {
|
|
228
|
-
type: "flex";
|
|
229
|
-
altText: string;
|
|
230
|
-
contents: LineFlexContents;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* LINE template message for sending.
|
|
234
|
-
*/
|
|
235
|
-
export interface LineTemplateMessageSend extends LineMessageBase {
|
|
236
|
-
type: "template";
|
|
237
|
-
altText: string;
|
|
238
|
-
template: unknown;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Union type of all LINE message types for sending.
|
|
242
|
-
*/
|
|
243
|
-
export type LineSendMessage = LineTextMessage | LineImageMessage | LineStickerMessage | LineLocationMessage | LineFlexMessageSend | LineTemplateMessageSend;
|
|
244
|
-
/**
|
|
245
|
-
* LINE received message type (from webhook events).
|
|
246
|
-
*/
|
|
247
|
-
export interface LineMessage {
|
|
248
|
-
/** Unique message ID */
|
|
249
|
-
id: string;
|
|
250
|
-
/** Message type */
|
|
251
|
-
type: "text" | "image" | "sticker" | "location" | "flex" | "template" | "video" | "audio" | "file";
|
|
252
|
-
/** User ID of the sender */
|
|
253
|
-
userId: string;
|
|
254
|
-
/** Message timestamp */
|
|
255
|
-
timestamp: number;
|
|
256
|
-
/** Reply token for responding to this message */
|
|
257
|
-
replyToken?: string;
|
|
258
|
-
/** Text content (for text messages) */
|
|
259
|
-
text?: string;
|
|
260
|
-
/** Mention data (for text messages) */
|
|
261
|
-
mention?: unknown;
|
|
262
|
-
/** Group ID (if message is from a group) */
|
|
263
|
-
groupId?: string;
|
|
264
|
-
/** Room ID (if message is from a room) */
|
|
265
|
-
roomId?: string;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* LINE chat type: user, group, or room.
|
|
269
|
-
*/
|
|
270
|
-
export type LineChatType = "user" | "group" | "room";
|
|
271
|
-
/**
|
|
272
|
-
* Determines the chat type from a LINE ID.
|
|
273
|
-
*/
|
|
274
|
-
export declare function getChatTypeFromId(id: string): LineChatType;
|
|
275
|
-
/**
|
|
276
|
-
* Splits text into chunks that fit within LINE's message limit.
|
|
277
|
-
*/
|
|
278
|
-
export declare function splitMessageForLine(text: string): string[];
|
|
279
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,eAAO,MAAM,iBAAiB,EAAG,MAAe,CAAC;AACjD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAGrC,eAAO,MAAM,cAAc;;;;;;;;;CASjB,CAAC;AAGX,qBAAa,sBAAuB,SAAQ,KAAK;IAGtC,KAAK,CAAC,EAAE,MAAM;gBADrB,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA;CAKxB;AAED,qBAA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106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE Channel Types
|
|
3
|
-
*
|
|
4
|
-
* Type definitions for LINE messaging channel data structures.
|
|
5
|
-
*
|
|
6
|
-
* @module line/types
|
|
7
|
-
*/
|
|
8
|
-
// Constants
|
|
9
|
-
export const LINE_SERVICE_NAME = "line";
|
|
10
|
-
export const MAX_LINE_BATCH_SIZE = 5;
|
|
11
|
-
// Event types
|
|
12
|
-
export const LineEventTypes = {
|
|
13
|
-
CONNECTION_READY: "line:connection_ready",
|
|
14
|
-
MESSAGE_RECEIVED: "line:message_received",
|
|
15
|
-
MESSAGE_SENT: "line:message_sent",
|
|
16
|
-
FOLLOW: "line:follow",
|
|
17
|
-
UNFOLLOW: "line:unfollow",
|
|
18
|
-
JOIN_GROUP: "line:join_group",
|
|
19
|
-
LEAVE_GROUP: "line:leave_group",
|
|
20
|
-
POSTBACK: "line:postback",
|
|
21
|
-
};
|
|
22
|
-
// Error classes
|
|
23
|
-
export class LineConfigurationError extends Error {
|
|
24
|
-
field;
|
|
25
|
-
constructor(message, field) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.field = field;
|
|
28
|
-
this.name = "LineConfigurationError";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export class LineApiError extends Error {
|
|
32
|
-
statusCode;
|
|
33
|
-
constructor(message, statusCode) {
|
|
34
|
-
super(message);
|
|
35
|
-
this.statusCode = statusCode;
|
|
36
|
-
this.name = "LineApiError";
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// Validation helpers
|
|
40
|
-
export function isValidLineId(id) {
|
|
41
|
-
if (!id || typeof id !== "string") {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
// LINE user IDs start with U, group IDs with C, room IDs with R
|
|
45
|
-
const prefixes = ["U", "u", "C", "c", "R", "r"];
|
|
46
|
-
return prefixes.some((p) => id.startsWith(p)) && id.length >= 30;
|
|
47
|
-
}
|
|
48
|
-
export function normalizeLineTarget(target) {
|
|
49
|
-
if (!target || typeof target !== "string") {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const trimmed = target.trim();
|
|
53
|
-
if (isValidLineId(trimmed)) {
|
|
54
|
-
return trimmed;
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Determines the chat type from a LINE ID.
|
|
60
|
-
*/
|
|
61
|
-
export function getChatTypeFromId(id) {
|
|
62
|
-
if (id.startsWith("C") || id.startsWith("c")) {
|
|
63
|
-
return "group";
|
|
64
|
-
}
|
|
65
|
-
else if (id.startsWith("R") || id.startsWith("r")) {
|
|
66
|
-
return "room";
|
|
67
|
-
}
|
|
68
|
-
return "user";
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* LINE message character limit (5000 characters per message).
|
|
72
|
-
*/
|
|
73
|
-
const LINE_MAX_MESSAGE_LENGTH = 5000;
|
|
74
|
-
/**
|
|
75
|
-
* Splits text into chunks that fit within LINE's message limit.
|
|
76
|
-
*/
|
|
77
|
-
export function splitMessageForLine(text) {
|
|
78
|
-
if (!text || text.length === 0) {
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
if (text.length <= LINE_MAX_MESSAGE_LENGTH) {
|
|
82
|
-
return [text];
|
|
83
|
-
}
|
|
84
|
-
const chunks = [];
|
|
85
|
-
let remaining = text;
|
|
86
|
-
while (remaining.length > 0) {
|
|
87
|
-
if (remaining.length <= LINE_MAX_MESSAGE_LENGTH) {
|
|
88
|
-
chunks.push(remaining);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
// Try to split at the last newline or space before the limit
|
|
92
|
-
let splitIndex = LINE_MAX_MESSAGE_LENGTH;
|
|
93
|
-
const lastNewline = remaining.lastIndexOf("\n", LINE_MAX_MESSAGE_LENGTH);
|
|
94
|
-
const lastSpace = remaining.lastIndexOf(" ", LINE_MAX_MESSAGE_LENGTH);
|
|
95
|
-
if (lastNewline > LINE_MAX_MESSAGE_LENGTH / 2) {
|
|
96
|
-
splitIndex = lastNewline + 1;
|
|
97
|
-
}
|
|
98
|
-
else if (lastSpace > LINE_MAX_MESSAGE_LENGTH / 2) {
|
|
99
|
-
splitIndex = lastSpace + 1;
|
|
100
|
-
}
|
|
101
|
-
chunks.push(remaining.substring(0, splitIndex).trim());
|
|
102
|
-
remaining = remaining.substring(splitIndex);
|
|
103
|
-
}
|
|
104
|
-
return chunks.filter(Boolean);
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY;AACZ,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAe,CAAC;AACjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,cAAc;AACd,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,gBAAgB,EAAE,uBAAuB;IACzC,gBAAgB,EAAE,uBAAuB;IACzC,YAAY,EAAE,mBAAmB;IACjC,MAAM,EAAE,aAAa;IACrB,QAAQ,EAAE,eAAe;IACzB,UAAU,EAAE,iBAAiB;IAC7B,WAAW,EAAE,kBAAkB;IAC/B,QAAQ,EAAE,eAAe;CACjB,CAAC;AAEX,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAGtC;IAFT,YACE,OAAe,EACR,KAAc;QAErB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,UAAK,GAAL,KAAK,CAAS;QAGrB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IAG5B;IAFT,YACE,OAAe,EACR,UAAmB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,eAAU,GAAV,UAAU,CAAS;QAG1B,IAAI,CAAC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