@brotu/ai 0.6.0 → 0.8.0
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 +62 -2
- package/dist/adapters/brotu.adapter.d.ts.map +1 -1
- package/dist/adapters/estimate.d.ts.map +1 -1
- package/dist/adapters/kie.adapter.d.ts +62 -0
- package/dist/adapters/kie.adapter.d.ts.map +1 -0
- package/dist/catalog.cjs +9 -0
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +1 -1
- package/dist/{chunk-QQIHMDJC.js → chunk-OISTBZ64.js} +9 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/helpers/result.d.ts +6 -0
- package/dist/helpers/result.d.ts.map +1 -1
- package/dist/index.cjs +443 -64
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +432 -65
- package/dist/lib/hooks.d.ts +2 -0
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/webhook.d.ts +2 -0
- package/dist/lib/webhook.d.ts.map +1 -1
- package/dist/ports/content-generator.port.d.ts +14 -0
- package/dist/ports/content-generator.port.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ Every public call returns `{ data, error }`. `data` is unusable until you narrow
|
|
|
79
79
|
| `ai.jobs` | `poll` / `wait` |
|
|
80
80
|
| `ai.webhook` | `set` / `clear` / `get` |
|
|
81
81
|
| `hooks` | constructor option: your own code on start, success and failure |
|
|
82
|
-
| `ai.estimateCost` | units, and USD when verified |
|
|
82
|
+
| `ai.estimateCost` | units, credits from the catalog, and USD when verified |
|
|
83
83
|
| `ai.kling` | `motionControl`, `omniVideo`, `avatar`, `outpainting`, `imageOmni` |
|
|
84
84
|
| `ai.google` | `omniVideo` (conversational refine) |
|
|
85
85
|
|
|
@@ -102,6 +102,50 @@ ai.audio.list();
|
|
|
102
102
|
|
|
103
103
|
With a Brotu key alone that is 41 image and 74 video models, and the 31 speech and text models listed with the key they are waiting on. Models you cannot reach stay in the list on purpose: hiding them would hide the gap. `ai.models()` is the filtered view, only what runs.
|
|
104
104
|
|
|
105
|
+
## kie, one key for every model
|
|
106
|
+
|
|
107
|
+
kie resells every vendor in this catalog. Configure it and it serves any model your own vendor keys do not, ahead of the Brotu fallback:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const ai = brotu({
|
|
111
|
+
apiKey: process.env.BROTU_API_KEY!,
|
|
112
|
+
providers: {
|
|
113
|
+
kie: { apiKey: process.env.KIE_API_KEY! },
|
|
114
|
+
kling: { apiKey: process.env.KLING_API_KEY! }, // this one still runs on Kling
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Routing order per model: its own vendor key → kie → Brotu credits. So a model moves off kie the day you get its official key, with no code change.
|
|
120
|
+
|
|
121
|
+
Give it a callback and nothing has to be polled — kie POSTs your endpoint when the task settles, and `parseKieCallback` turns that body into the same result a poll returns:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { kieSnapshot, parseKieCallback } from "@brotu/ai";
|
|
125
|
+
|
|
126
|
+
ai.webhook.set("https://my.app/hooks/kie"); // becomes kie's callBackUrl
|
|
127
|
+
|
|
128
|
+
const { data: job } = await ai.video.submit({ model: "kling/v2-6", prompt: "a cat" });
|
|
129
|
+
// store `job` — it is plain JSON
|
|
130
|
+
|
|
131
|
+
// in your endpoint
|
|
132
|
+
const settled = parseKieCallback(await request.text());
|
|
133
|
+
const snapshot = kieSnapshot(settled, job.model);
|
|
134
|
+
// { status: "succeeded", result: { outputs: [{ url, mimeType }], creditsUsed } }
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
kie names the same field differently per family — kling wants a string `duration` and `sound`, seedance an integer and `generate_audio`. Those two are mapped; every other model gets the common keys (`prompt`, `image_url`, `resolution`, `aspect_ratio`, …). Anything that does not fit goes in `providerOptions.kie`, merged last:
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
await ai.video.submit({
|
|
141
|
+
model: "wan2.6-i2v",
|
|
142
|
+
prompt: "x",
|
|
143
|
+
providerOptions: { kie: { enable_prompt_expansion: false } },
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
A model whose catalog entry carries `endpoint` (`"/market/<kie model>"`) uses that id, so a catalog of your own routes through kie without touching the SDK. That is also the fix when kie names a model differently from this catalog and the built-in table does not cover it — kie answers an unknown model with an error rather than a wrong generation.
|
|
148
|
+
|
|
105
149
|
## Video
|
|
106
150
|
|
|
107
151
|
`submit` returns a job handle. `generate` waits. Video takes minutes, so do not `generate` inside a request handler.
|
|
@@ -242,7 +286,7 @@ const ai = brotu({
|
|
|
242
286
|
|
|
243
287
|
One optional callback per kind and stage — `on{Image,Video,Audio,Text}{Loading,Success,Error}`, twelve typed names. `Loading` fires once the model is routed, before the provider is called; `Success` and `Error` fire wherever the webhook fires, deduped by job id. A hook that throws never fails the generation.
|
|
244
288
|
|
|
245
|
-
The event is `HookEvent`: `kind`, `stage`, `provider`, `model`, `jobId`, `outputs`, `error`, `metadata`, `processingTimeMs`, `at`.
|
|
289
|
+
The event is `HookEvent`: `kind`, `stage`, `provider`, `model`, `jobId`, `outputs`, `error`, `metadata`, `creditsUsed`, `processingTimeMs`, `at`.
|
|
246
290
|
|
|
247
291
|
## Motion control, avatars, omni
|
|
248
292
|
|
|
@@ -315,6 +359,22 @@ const { data } = await ai.estimateCost("video", {
|
|
|
315
359
|
});
|
|
316
360
|
```
|
|
317
361
|
|
|
362
|
+
`data.credits` is the catalog's credit price for that request, or null where the model carries no rate.
|
|
363
|
+
|
|
364
|
+
To bill your own users per generation, pass `credits` on the request. It comes back as `creditsUsed` on the result, the hook and the webhook, so your ledger debits one number instead of recomputing it per model — nothing is debited here.
|
|
365
|
+
|
|
366
|
+
```ts
|
|
367
|
+
const estimate = await ai.estimateCost("video", { model: "kling/v3", prompt: "x", duration: 5 });
|
|
368
|
+
|
|
369
|
+
await ai.video.generate({
|
|
370
|
+
model: "kling/v3",
|
|
371
|
+
prompt: "x",
|
|
372
|
+
duration: 5,
|
|
373
|
+
credits: estimate.data?.credits ?? 0,
|
|
374
|
+
metadata: { userId: "u_1" },
|
|
375
|
+
});
|
|
376
|
+
```
|
|
377
|
+
|
|
318
378
|
Provider URLs expire. Pass `storage` (any S3 API) and outputs land in your bucket. `outputs[].url` is your copy; `sourceUrl` is the original. `@aws-sdk/client-s3` is an optional peer.
|
|
319
379
|
|
|
320
380
|
```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brotu.adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/brotu.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,GAAG,EACR,KAAK,WAAW,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,MAAM,iCAAiC,CAAC;AAGzC,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAMD;;;GAGG;AACH,QAAA,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAO9C,CAAC;AAuBF,qBAAa,YAAa,YAAW,oBAAoB;IAM5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IALjC,QAAQ,CAAC,YAAY,WAAW;IAChC,QAAQ,CAAC,cAAc,EAAE,cAAc,EAAE,CAA8B;IAEvE,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAElC,YAA6B,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AM,CAAC;QAAC,IAAI,EAAE,cAAc,CAAA;KAAE,EAAE,CAEzE;CACD;AA2BD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../src/adapters/estimate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC,YAAY,
|
|
1
|
+
{"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../src/adapters/estimate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC,YAAY,CA6Dd"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Job, type JobSnapshot } from "../lib/jobs";
|
|
2
|
+
import type { AudioGenerationParams, ContentGeneratorPort, CostEstimate, GenerationOutput, GenerationParams, GenerationResult, GenerationType, ImageGenerationParams, TextGenerationParams, VideoGenerationParams } from "../ports/content-generator.port";
|
|
3
|
+
export interface KieAdapterOptions {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
/** Origin plus `/api/v1`, no trailing slash. Defaults to the public API. */
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
maxPollAttempts?: number;
|
|
8
|
+
/**
|
|
9
|
+
* URL kie POSTs when a task settles, for every request that names none.
|
|
10
|
+
* With one set, `submit` never has to be polled — read the callback with
|
|
11
|
+
* `parseKieCallback` and finish the job from it.
|
|
12
|
+
*/
|
|
13
|
+
callbackUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
/** What a settled kie task produced, whether it arrived by poll or callback. */
|
|
16
|
+
export interface KieTaskResult {
|
|
17
|
+
taskId: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
status: "pending" | "succeeded" | "failed";
|
|
20
|
+
outputs: GenerationOutput[];
|
|
21
|
+
creditsUsed: number;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class KieAdapter implements ContentGeneratorPort {
|
|
25
|
+
private readonly opts;
|
|
26
|
+
readonly providerName = "kie";
|
|
27
|
+
readonly supportedTypes: GenerationType[];
|
|
28
|
+
constructor(opts: KieAdapterOptions);
|
|
29
|
+
private get origin();
|
|
30
|
+
private request;
|
|
31
|
+
/** Which market model serves this request. */
|
|
32
|
+
private marketModel;
|
|
33
|
+
private callbackFor;
|
|
34
|
+
private createTask;
|
|
35
|
+
/** Ask kie about one task. The same shape a callback carries. */
|
|
36
|
+
task(taskId: string): Promise<KieTaskResult>;
|
|
37
|
+
private run;
|
|
38
|
+
completeJob(job: Job): Promise<JobSnapshot>;
|
|
39
|
+
generateImage(params: ImageGenerationParams): Promise<GenerationResult>;
|
|
40
|
+
generateVideo(params: VideoGenerationParams): Promise<GenerationResult>;
|
|
41
|
+
generateText(params: TextGenerationParams): Promise<GenerationResult>;
|
|
42
|
+
generateAudio(params: AudioGenerationParams): Promise<GenerationResult>;
|
|
43
|
+
estimateCost(type: GenerationType, params: GenerationParams): Promise<CostEstimate>;
|
|
44
|
+
supportsModel(): boolean;
|
|
45
|
+
getAvailableModels(): {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
type: GenerationType;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Turn a callback kie POSTed to your endpoint into the same result a poll
|
|
53
|
+
* returns, so the job finishes without asking kie anything.
|
|
54
|
+
*
|
|
55
|
+
* Takes the raw body, parsed or not. It accepts both the enveloped shape
|
|
56
|
+
* (`{ code, data: {…} }`) and a bare record, because a callback and a
|
|
57
|
+
* `recordInfo` answer differ only by that wrapper.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseKieCallback(body: string | unknown): KieTaskResult;
|
|
60
|
+
/** The snapshot a job store wants, from a task kie has already answered for. */
|
|
61
|
+
export declare function kieSnapshot(settled: KieTaskResult, model?: string): JobSnapshot;
|
|
62
|
+
//# sourceMappingURL=kie.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kie.adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/kie.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,GAAG,EACR,KAAK,WAAW,EAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACX,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,iCAAiC,CAAC;AAGzC,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAoDD,gFAAgF;AAChF,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC3C,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE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,aAAa,EACtB,KAAK,CAAC,EAAE,MAAM,GACZ,WAAW,CAEb"}
|
package/dist/catalog.cjs
CHANGED
|
@@ -1099,6 +1099,7 @@ var PROVIDER_BASE_URLS = {
|
|
|
1099
1099
|
openai: "https://api.openai.com",
|
|
1100
1100
|
qwen: "https://dashscope-intl.aliyuncs.com",
|
|
1101
1101
|
topaz: "https://api.topazlabs.com",
|
|
1102
|
+
kie: "https://api.kie.ai/api/v1",
|
|
1102
1103
|
brotu: "https://api.brotu.app"
|
|
1103
1104
|
};
|
|
1104
1105
|
var DEFAULT_BROTU_API_URL = PROVIDER_BASE_URLS.brotu;
|
|
@@ -1174,6 +1175,14 @@ function resolveProvider(modelId, options) {
|
|
|
1174
1175
|
}
|
|
1175
1176
|
return { id, apiKey: configured.apiKey, baseUrl: baseUrl.replace(/\/$/, "") };
|
|
1176
1177
|
}
|
|
1178
|
+
const kie = vendorProviders(options).kie;
|
|
1179
|
+
if (kie && id !== "kie") {
|
|
1180
|
+
return {
|
|
1181
|
+
id: "kie",
|
|
1182
|
+
apiKey: kie.apiKey,
|
|
1183
|
+
baseUrl: (kie.baseUrl ?? PROVIDER_BASE_URLS.kie).replace(/\/$/, "")
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1177
1186
|
const platformKey = brotuApiKey(options);
|
|
1178
1187
|
if (platformKey) {
|
|
1179
1188
|
return {
|
package/dist/catalog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAW9E,OAAO,KAAK,EAAE,cAAc,EAAkB,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aA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
1262
|
topaz: "https://api.topazlabs.com",
|
|
1263
|
+
kie: "https://api.kie.ai/api/v1",
|
|
1263
1264
|
brotu: "https://api.brotu.app"
|
|
1264
1265
|
};
|
|
1265
1266
|
var DEFAULT_BROTU_API_URL = PROVIDER_BASE_URLS.brotu;
|
|
@@ -1335,6 +1336,14 @@ function resolveProvider(modelId, options) {
|
|
|
1335
1336
|
}
|
|
1336
1337
|
return { id, apiKey: configured.apiKey, baseUrl: baseUrl.replace(/\/$/, "") };
|
|
1337
1338
|
}
|
|
1339
|
+
const kie = vendorProviders(options).kie;
|
|
1340
|
+
if (kie && id !== "kie") {
|
|
1341
|
+
return {
|
|
1342
|
+
id: "kie",
|
|
1343
|
+
apiKey: kie.apiKey,
|
|
1344
|
+
baseUrl: (kie.baseUrl ?? PROVIDER_BASE_URLS.kie).replace(/\/$/, "")
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1338
1347
|
const platformKey = brotuApiKey(options);
|
|
1339
1348
|
if (platformKey) {
|
|
1340
1349
|
return {
|
package/dist/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { AudioGenerationParams, CostEstimate, GenerationOutput, GenerationP
|
|
|
7
7
|
import { type AvatarInput, type ImageOmniInput, type MotionControlInput, type OmniVideoInput, type OutpaintingInput } from "./providers/kling.models";
|
|
8
8
|
import type { BrotuAIOptions } from "./types";
|
|
9
9
|
/** Providers this package ships an adapter for. */
|
|
10
|
-
export declare const NATIVE_PROVIDERS: readonly ["byteplus", "elevenlabs", "google", "kling", "openai", "qwen", "topaz"];
|
|
10
|
+
export declare const NATIVE_PROVIDERS: readonly ["byteplus", "elevenlabs", "google", "kie", "kling", "openai", "qwen", "topaz"];
|
|
11
11
|
export interface BrotuAI {
|
|
12
12
|
image: {
|
|
13
13
|
/** Queue the work and return a handle. Only the submit is awaited. */
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client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CAAC;IAC1B;;;;OAIG;IACH,YAAY,CACX,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,gBAAgB,GACtB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;CACjC;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAorBtD;AAED,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/helpers/result.d.ts
CHANGED
|
@@ -48,6 +48,12 @@ export interface Generation {
|
|
|
48
48
|
provider: string;
|
|
49
49
|
model: string;
|
|
50
50
|
processingTimeMs: number;
|
|
51
|
+
/**
|
|
52
|
+
* Credits this generation cost. The `credits` you passed on the request when
|
|
53
|
+
* you passed one, otherwise what the platform charged — 0 on a vendor key,
|
|
54
|
+
* which bills you in dollars, not credits.
|
|
55
|
+
*/
|
|
56
|
+
creditsUsed: number;
|
|
51
57
|
/** The tags the request carried, handed straight back. */
|
|
52
58
|
metadata?: Record<string, string>;
|
|
53
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/helpers/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,WAAW;AACtB,0CAA0C;AACxC,eAAe;AACjB,+DAA+D;GAC7D,aAAa;AACf,0CAA0C;GACxC,sBAAsB;AACxB,kEAAkE;GAChE,iBAAiB;AACnB,yEAAyE;GACvE,gBAAgB;AAClB,2EAA2E;GACzE,SAAS,CAAC;AAEb,MAAM,WAAW,OAAO;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,KAAK,CAAC,EAAE,OA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