js-bao-wss-client 2.0.3 → 2.0.5
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/README.md +242 -39
- package/dist/JsBaoClient.d.ts +199 -16
- package/dist/JsBaoClient.d.ts.map +1 -1
- package/dist/JsBaoClient.js +240 -4
- package/dist/JsBaoClient.js.map +1 -1
- package/dist/api/blobBucketsApi.d.ts +29 -1
- package/dist/api/blobBucketsApi.d.ts.map +1 -1
- package/dist/api/blobBucketsApi.js +5 -3
- package/dist/api/blobBucketsApi.js.map +1 -1
- package/dist/api/collectionsApi.d.ts +9 -1
- package/dist/api/collectionsApi.d.ts.map +1 -1
- package/dist/api/collectionsApi.js.map +1 -1
- package/dist/api/databasesApi.d.ts +18 -1
- package/dist/api/databasesApi.d.ts.map +1 -1
- package/dist/api/databasesApi.js +8 -0
- package/dist/api/databasesApi.js.map +1 -1
- package/dist/api/documentsApi.d.ts +15 -5
- package/dist/api/documentsApi.d.ts.map +1 -1
- package/dist/api/documentsApi.js +19 -20
- package/dist/api/documentsApi.js.map +1 -1
- package/dist/api/geminiApi.d.ts.map +1 -1
- package/dist/api/geminiApi.js +11 -14
- package/dist/api/geminiApi.js.map +1 -1
- package/dist/api/groupsApi.d.ts +20 -4
- package/dist/api/groupsApi.d.ts.map +1 -1
- package/dist/api/groupsApi.js +9 -1
- package/dist/api/groupsApi.js.map +1 -1
- package/dist/api/notificationsApi.d.ts +134 -0
- package/dist/api/notificationsApi.d.ts.map +1 -0
- package/dist/api/notificationsApi.js +52 -0
- package/dist/api/notificationsApi.js.map +1 -0
- package/dist/api/resourceMetadataApi.d.ts +163 -0
- package/dist/api/resourceMetadataApi.d.ts.map +1 -0
- package/dist/api/resourceMetadataApi.js +56 -0
- package/dist/api/resourceMetadataApi.js.map +1 -0
- package/dist/browser.umd.js +514 -58
- package/dist/browser.umd.js.map +1 -1
- package/dist/errors.d.ts +34 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +56 -0
- package/dist/errors.js.map +1 -1
- package/dist/internal/authController.d.ts +10 -0
- package/dist/internal/authController.d.ts.map +1 -1
- package/dist/internal/authController.js +14 -2
- package/dist/internal/authController.js.map +1 -1
- package/dist/internal/httpClient.d.ts +8 -0
- package/dist/internal/httpClient.d.ts.map +1 -1
- package/dist/internal/httpClient.js +34 -5
- package/dist/internal/httpClient.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// ── API ──
|
|
2
|
+
/**
|
|
3
|
+
* Sub-API for the notification inbox (`client.notifications.*`).
|
|
4
|
+
*
|
|
5
|
+
* Inbox reads/writes act on the signed-in user's own notifications. `send()`
|
|
6
|
+
* requires app admin permission. Live updates arrive as the `notification`
|
|
7
|
+
* client event (`client.on("notification", ...)`).
|
|
8
|
+
*/
|
|
9
|
+
export class NotificationsAPI {
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
/** List the caller's notifications, newest first. */
|
|
14
|
+
async list(options) {
|
|
15
|
+
const params = new URLSearchParams();
|
|
16
|
+
if (options?.limit !== undefined)
|
|
17
|
+
params.set("limit", String(options.limit));
|
|
18
|
+
if (options?.cursor)
|
|
19
|
+
params.set("cursor", options.cursor);
|
|
20
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
21
|
+
return this.client.makeRequest("GET", `/notifications${query}`);
|
|
22
|
+
}
|
|
23
|
+
/** Count the caller's unread notifications. */
|
|
24
|
+
async unreadCount() {
|
|
25
|
+
return this.client.makeRequest("GET", "/notifications/unread-count");
|
|
26
|
+
}
|
|
27
|
+
/** Mark one of the caller's notifications as read. */
|
|
28
|
+
async markRead(notificationId) {
|
|
29
|
+
return this.client.makeRequest("PATCH", `/notifications/${encodeURIComponent(notificationId)}/read`, {});
|
|
30
|
+
}
|
|
31
|
+
/** Mark all of the caller's notifications as read. */
|
|
32
|
+
async markAllRead() {
|
|
33
|
+
return this.client.makeRequest("POST", "/notifications/read-all", {});
|
|
34
|
+
}
|
|
35
|
+
/** Send a notification to an app user (requires app admin permission). */
|
|
36
|
+
async send(params) {
|
|
37
|
+
return this.client.makeRequest("POST", "/notifications/send", params);
|
|
38
|
+
}
|
|
39
|
+
/** Register (upsert) the calling user's device push token. */
|
|
40
|
+
async registerDevice(params) {
|
|
41
|
+
return this.client.makeRequest("POST", "/me/push-tokens", params);
|
|
42
|
+
}
|
|
43
|
+
/** List the calling user's registered push devices. */
|
|
44
|
+
async listDevices() {
|
|
45
|
+
return this.client.makeRequest("GET", "/me/push-tokens");
|
|
46
|
+
}
|
|
47
|
+
/** Unregister one of the calling user's device push tokens (e.g. on logout). */
|
|
48
|
+
async unregisterDevice(token) {
|
|
49
|
+
return this.client.makeRequest("DELETE", `/me/push-tokens/${encodeURIComponent(token)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=notificationsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notificationsApi.js","sourceRoot":"","sources":["../../api/notificationsApi.ts"],"names":[],"mappings":"AAuGA,YAAY;AAEZ;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAC3B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD,qDAAqD;IACrD,KAAK,CAAC,IAAI,CACR,OAAiC;QAEjC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7E,IAAI,OAAO,EAAE,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,C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rC,CAAC;CACF"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { JsBaoClient } from "../JsBaoClient";
|
|
2
|
+
/**
|
|
3
|
+
* Result of a single-category metadata read (`resourceMetadata.get`). When no
|
|
4
|
+
* row has been written yet the read still succeeds with `exists: false` and an
|
|
5
|
+
* empty `data` object.
|
|
6
|
+
*/
|
|
7
|
+
export interface ResourceMetadataReadResult {
|
|
8
|
+
resourceType: string;
|
|
9
|
+
resourceId: string;
|
|
10
|
+
category: string;
|
|
11
|
+
/** The stored metadata object (`{}` when nothing has been written yet). */
|
|
12
|
+
data: Record<string, unknown>;
|
|
13
|
+
/** Schema version the stored data was validated against (`null` when `exists` is false). */
|
|
14
|
+
schemaVersion: number | null;
|
|
15
|
+
/** Whether a stored row exists for this resource and category. */
|
|
16
|
+
exists: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Result of a metadata write (`resourceMetadata.set` — a full replace). */
|
|
19
|
+
export interface ResourceMetadataWriteResult {
|
|
20
|
+
resourceType: string;
|
|
21
|
+
resourceId: string;
|
|
22
|
+
category: string;
|
|
23
|
+
/** The stored metadata object as validated and persisted. */
|
|
24
|
+
data: Record<string, unknown>;
|
|
25
|
+
/** Schema version the write was validated against. */
|
|
26
|
+
schemaVersion: number;
|
|
27
|
+
/** Stored size of the serialized data, in bytes. */
|
|
28
|
+
size: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One item of a batch read request. `categories` is required and must be
|
|
32
|
+
* non-empty — there is no expand-to-all; an item that omits it comes back as a
|
|
33
|
+
* per-item error with `status: 400`.
|
|
34
|
+
*/
|
|
35
|
+
export interface ResourceMetadataBatchRequestItem {
|
|
36
|
+
resourceType: string;
|
|
37
|
+
resourceId: string;
|
|
38
|
+
/** Explicit categories to read for this resource. */
|
|
39
|
+
categories: string[];
|
|
40
|
+
}
|
|
41
|
+
/** Parameters for `resourceMetadata.getBatch`. */
|
|
42
|
+
export interface ResourceMetadataBatchParams {
|
|
43
|
+
/**
|
|
44
|
+
* Up to 50 resource entries, and up to 200 expanded resource/category pairs
|
|
45
|
+
* per call. Exceeding either limit fails the whole call with `400
|
|
46
|
+
* BATCH_TOO_LARGE`.
|
|
47
|
+
*/
|
|
48
|
+
requests: ResourceMetadataBatchRequestItem[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Per-category result inside a batch read — a discriminated union on `ok`. A
|
|
52
|
+
* success carries the same fields as the single read (`data`, `schemaVersion`,
|
|
53
|
+
* `exists`); a failure carries `status`/`code`/`message` and never `data`.
|
|
54
|
+
*/
|
|
55
|
+
export type ResourceMetadataBatchCategoryResult = {
|
|
56
|
+
ok: true;
|
|
57
|
+
data: Record<string, unknown>;
|
|
58
|
+
schemaVersion: number | null;
|
|
59
|
+
exists: boolean;
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
status: number;
|
|
63
|
+
code: string;
|
|
64
|
+
message: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Per-resource result inside a batch read. `ok: true` carries a per-category
|
|
68
|
+
* map; `ok: false` is an item-level fault (malformed segment, or missing
|
|
69
|
+
* `categories`) that applies to the whole item.
|
|
70
|
+
*/
|
|
71
|
+
export type ResourceMetadataBatchResourceResult = {
|
|
72
|
+
resourceType: string;
|
|
73
|
+
resourceId: string;
|
|
74
|
+
ok: true;
|
|
75
|
+
categories: Record<string, ResourceMetadataBatchCategoryResult>;
|
|
76
|
+
} | {
|
|
77
|
+
resourceType: string;
|
|
78
|
+
resourceId: string;
|
|
79
|
+
ok: false;
|
|
80
|
+
status: number;
|
|
81
|
+
code: string;
|
|
82
|
+
message: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Result of `resourceMetadata.getBatch`. The call itself succeeds (HTTP 200)
|
|
86
|
+
* even when individual items fail — check each entry's `ok` discriminant.
|
|
87
|
+
*/
|
|
88
|
+
export interface ResourceMetadataBatchResult {
|
|
89
|
+
/** One entry per request item, in request order. */
|
|
90
|
+
results: ResourceMetadataBatchResourceResult[];
|
|
91
|
+
}
|
|
92
|
+
/** One stored category in a resource metadata listing (`resourceMetadata.list`). */
|
|
93
|
+
export interface ResourceMetadataListEntry {
|
|
94
|
+
category: string;
|
|
95
|
+
/** The stored metadata object for this category. */
|
|
96
|
+
data: Record<string, unknown>;
|
|
97
|
+
/** Schema version the stored data was validated against (`null` if unknown). */
|
|
98
|
+
schemaVersion: number | null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Result of `resourceMetadata.list`. Only categories the caller may read are
|
|
102
|
+
* returned: each is gated by its `readRule` with the app-level owner/admin
|
|
103
|
+
* bypass, so an admin sees every category while a plain member sees only the
|
|
104
|
+
* ones their rule permits. A resource with no metadata returns an empty list.
|
|
105
|
+
*/
|
|
106
|
+
export interface ResourceMetadataListResult {
|
|
107
|
+
resourceType: string;
|
|
108
|
+
resourceId: string;
|
|
109
|
+
categories: ResourceMetadataListEntry[];
|
|
110
|
+
}
|
|
111
|
+
/** Result of `resourceMetadata.delete` (idempotent — an absent item is not an error). */
|
|
112
|
+
export interface ResourceMetadataDeleteResult {
|
|
113
|
+
resourceType: string;
|
|
114
|
+
resourceId: string;
|
|
115
|
+
category: string;
|
|
116
|
+
/** `false` when no stored item existed (still a success, not a 404). */
|
|
117
|
+
deleted: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Sub-API for reading and writing typed resource metadata (values only —
|
|
121
|
+
* category definitions are managed by app admins, not through this client).
|
|
122
|
+
* Reads are gated per category by its `readRule` and writes by its
|
|
123
|
+
* `writeRule`, with an app-level owner/admin bypass; a resource-level
|
|
124
|
+
* permission never bypasses. A denial surfaces as an HTTP 403
|
|
125
|
+
* error on the single calls and as a per-item `ok: false` entry in the batch.
|
|
126
|
+
*/
|
|
127
|
+
export declare class ResourceMetadataAPI {
|
|
128
|
+
private client;
|
|
129
|
+
constructor(client: JsBaoClient);
|
|
130
|
+
/**
|
|
131
|
+
* Read one resource's metadata for one category. Succeeds with
|
|
132
|
+
* `exists: false` and empty `data` when nothing has been written yet;
|
|
133
|
+
* fails with 404 when the category is not defined for the resource type,
|
|
134
|
+
* or 403 when the category's `readRule` denies the caller.
|
|
135
|
+
*/
|
|
136
|
+
get(resourceType: string, resourceId: string, category: string): Promise<ResourceMetadataReadResult>;
|
|
137
|
+
/**
|
|
138
|
+
* Write (full replace) one resource's metadata for one category. The data
|
|
139
|
+
* is validated against the category's schema; the category's `writeRule`
|
|
140
|
+
* gates the write (403 on denial).
|
|
141
|
+
*/
|
|
142
|
+
set(resourceType: string, resourceId: string, category: string, data: Record<string, unknown>): Promise<ResourceMetadataWriteResult>;
|
|
143
|
+
/**
|
|
144
|
+
* Read metadata for many resources in one call (bounded: 50 resources /
|
|
145
|
+
* 200 resource-category pairs). Partial success: per-item 403/404 errors
|
|
146
|
+
* are returned as structured entries and do not fail the call.
|
|
147
|
+
*/
|
|
148
|
+
getBatch(params: ResourceMetadataBatchParams): Promise<ResourceMetadataBatchResult>;
|
|
149
|
+
/**
|
|
150
|
+
* List every stored metadata category on one resource. Only categories the
|
|
151
|
+
* caller may read are returned (each gated by its `readRule`, with the
|
|
152
|
+
* app-level owner/admin bypass); a resource with no metadata comes back with
|
|
153
|
+
* an empty `categories` array.
|
|
154
|
+
*/
|
|
155
|
+
list(resourceType: string, resourceId: string): Promise<ResourceMetadataListResult>;
|
|
156
|
+
/**
|
|
157
|
+
* Delete one resource's metadata for one category. The category's `writeRule`
|
|
158
|
+
* gates the delete (403 on denial). Idempotent: deleting an item that does
|
|
159
|
+
* not exist succeeds with `deleted: false` rather than failing with 404.
|
|
160
|
+
*/
|
|
161
|
+
delete(resourceType: string, resourceId: string, category: string): Promise<ResourceMetadataDeleteResult>;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=resourceMetadataApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceMetadataApi.d.ts","sourceRoot":"","sources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;;OAKG;IACG,GAAG,CACP,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,0BAA0B,CAAC;IAStC;;;;OAIG;IACG,GAAG,CACP,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,2BAA2B,CAAC;IAUvC;;;;OAIG;IACG,QAAQ,CACZ,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IAQvC;;;;;OAKG;IACG,IAAI,CACR,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,0BAA0B,CAAC;IAStC;;;;OAIG;IACG,MAAM,CACV,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,4BAA4B,CAAC;CAQzC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sub-API for reading and writing typed resource metadata (values only —
|
|
3
|
+
* category definitions are managed by app admins, not through this client).
|
|
4
|
+
* Reads are gated per category by its `readRule` and writes by its
|
|
5
|
+
* `writeRule`, with an app-level owner/admin bypass; a resource-level
|
|
6
|
+
* permission never bypasses. A denial surfaces as an HTTP 403
|
|
7
|
+
* error on the single calls and as a per-item `ok: false` entry in the batch.
|
|
8
|
+
*/
|
|
9
|
+
export class ResourceMetadataAPI {
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Read one resource's metadata for one category. Succeeds with
|
|
15
|
+
* `exists: false` and empty `data` when nothing has been written yet;
|
|
16
|
+
* fails with 404 when the category is not defined for the resource type,
|
|
17
|
+
* or 403 when the category's `readRule` denies the caller.
|
|
18
|
+
*/
|
|
19
|
+
async get(resourceType, resourceId, category) {
|
|
20
|
+
return this.client.makeRequest("GET", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata/${encodeURIComponent(category)}`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Write (full replace) one resource's metadata for one category. The data
|
|
24
|
+
* is validated against the category's schema; the category's `writeRule`
|
|
25
|
+
* gates the write (403 on denial).
|
|
26
|
+
*/
|
|
27
|
+
async set(resourceType, resourceId, category, data) {
|
|
28
|
+
return this.client.makeRequest("PUT", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata/${encodeURIComponent(category)}`, { data });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Read metadata for many resources in one call (bounded: 50 resources /
|
|
32
|
+
* 200 resource-category pairs). Partial success: per-item 403/404 errors
|
|
33
|
+
* are returned as structured entries and do not fail the call.
|
|
34
|
+
*/
|
|
35
|
+
async getBatch(params) {
|
|
36
|
+
return this.client.makeRequest("POST", "/resources/metadata/batch", params);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List every stored metadata category on one resource. Only categories the
|
|
40
|
+
* caller may read are returned (each gated by its `readRule`, with the
|
|
41
|
+
* app-level owner/admin bypass); a resource with no metadata comes back with
|
|
42
|
+
* an empty `categories` array.
|
|
43
|
+
*/
|
|
44
|
+
async list(resourceType, resourceId) {
|
|
45
|
+
return this.client.makeRequest("GET", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Delete one resource's metadata for one category. The category's `writeRule`
|
|
49
|
+
* gates the delete (403 on denial). Idempotent: deleting an item that does
|
|
50
|
+
* not exist succeeds with `deleted: false` rather than failing with 404.
|
|
51
|
+
*/
|
|
52
|
+
async delete(resourceType, resourceId, category) {
|
|
53
|
+
return this.client.makeRequest("DELETE", `/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/metadata/${encodeURIComponent(category)}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=resourceMetadataApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceMetadataApi.js","sourceRoot":"","sources":["../../api/resourceMetadataApi.ts"],"names":[],"mappings":"AAgIA;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;IAC9B,YAAoB,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAE3C;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,YAAoB,EACpB,UAAkB,EAClB,QAAgB;QAEhB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,KAAK,EACL,cAAc,kBAAkB,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAClE,UAAU,CACX,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAC7C,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CACP,YAAoB,EACpB,UAAkB,EAClB,QAAgB,EAChB,IAA6B;QAE7B,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,KAAK,EACL,cAAc,kBAAkB,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAClE,UAAU,CACX,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE,EAC5C,EAAE,IAAI,EAAE,CACT,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CACZ,MAAmC;QAEnC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,MAAM,EACN,2BAA2B,EAC3B,MAAM,CACP,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CACR,YAAoB,EACpB,UAAkB;QAElB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAC5B,KAAK,EACL,cAAc,kBAAkB,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAClE,U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