@cellarnode/ui 0.186.0 → 0.188.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/dist/brand/brand-assets-api.d.ts +58 -0
- package/dist/brand/brand-assets-api.d.ts.map +1 -0
- package/dist/brand/brand-assets-api.js +160 -0
- package/dist/brand/brand-assets-api.js.map +1 -0
- package/dist/brand/brand-generation-api.d.ts +44 -0
- package/dist/brand/brand-generation-api.d.ts.map +1 -0
- package/dist/brand/brand-generation-api.js +2 -0
- package/dist/brand/brand-generation-api.js.map +1 -0
- package/dist/brand/brand-generation-client.d.ts +36 -0
- package/dist/brand/brand-generation-client.d.ts.map +1 -0
- package/dist/brand/brand-generation-client.js +107 -0
- package/dist/brand/brand-generation-client.js.map +1 -0
- package/dist/brand/brand-generation-copy.d.ts +44 -0
- package/dist/brand/brand-generation-copy.d.ts.map +1 -0
- package/dist/brand/brand-generation-copy.js +70 -0
- package/dist/brand/brand-generation-copy.js.map +1 -0
- package/dist/brand/brand-generation-fixtures.d.ts +32 -0
- package/dist/brand/brand-generation-fixtures.d.ts.map +1 -0
- package/dist/brand/brand-generation-fixtures.js +88 -0
- package/dist/brand/brand-generation-fixtures.js.map +1 -0
- package/dist/brand/brand-generation-flow.d.ts +34 -0
- package/dist/brand/brand-generation-flow.d.ts.map +1 -0
- package/dist/brand/brand-generation-flow.js +34 -0
- package/dist/brand/brand-generation-flow.js.map +1 -0
- package/dist/brand/brand-generation-keys.d.ts +16 -0
- package/dist/brand/brand-generation-keys.d.ts.map +1 -0
- package/dist/brand/brand-generation-keys.js +16 -0
- package/dist/brand/brand-generation-keys.js.map +1 -0
- package/dist/brand/brand-generation-progress.d.ts +27 -0
- package/dist/brand/brand-generation-progress.d.ts.map +1 -0
- package/dist/brand/brand-generation-progress.js +61 -0
- package/dist/brand/brand-generation-progress.js.map +1 -0
- package/dist/brand/brand-generation-recovery-error.d.ts +8 -0
- package/dist/brand/brand-generation-recovery-error.d.ts.map +1 -0
- package/dist/brand/brand-generation-recovery-error.js +7 -0
- package/dist/brand/brand-generation-recovery-error.js.map +1 -0
- package/dist/brand/brand-generation-response.d.ts +86 -0
- package/dist/brand/brand-generation-response.d.ts.map +1 -0
- package/dist/brand/brand-generation-response.js +261 -0
- package/dist/brand/brand-generation-response.js.map +1 -0
- package/dist/brand/brand-generation-sse-parser.d.ts +14 -0
- package/dist/brand/brand-generation-sse-parser.d.ts.map +1 -0
- package/dist/brand/brand-generation-sse-parser.js +92 -0
- package/dist/brand/brand-generation-sse-parser.js.map +1 -0
- package/dist/brand/brand-generation-start.d.ts +49 -0
- package/dist/brand/brand-generation-start.d.ts.map +1 -0
- package/dist/brand/brand-generation-start.js +48 -0
- package/dist/brand/brand-generation-start.js.map +1 -0
- package/dist/brand/brand-generation-steps.d.ts +4 -0
- package/dist/brand/brand-generation-steps.d.ts.map +1 -0
- package/dist/brand/brand-generation-steps.js +29 -0
- package/dist/brand/brand-generation-steps.js.map +1 -0
- package/dist/brand/brand-generation-surface.d.ts +50 -0
- package/dist/brand/brand-generation-surface.d.ts.map +1 -0
- package/dist/brand/brand-generation-surface.js +25 -0
- package/dist/brand/brand-generation-surface.js.map +1 -0
- package/dist/brand/brand-generation-url.d.ts +6 -0
- package/dist/brand/brand-generation-url.d.ts.map +1 -0
- package/dist/brand/brand-generation-url.js +4 -0
- package/dist/brand/brand-generation-url.js.map +1 -0
- package/dist/brand/brand-image-chooser.d.ts +3 -1
- package/dist/brand/brand-image-chooser.d.ts.map +1 -1
- package/dist/brand/brand-image-chooser.js +7 -1
- package/dist/brand/brand-image-chooser.js.map +1 -1
- package/dist/brand/brand-image-choosers.d.ts +37 -0
- package/dist/brand/brand-image-choosers.d.ts.map +1 -0
- package/dist/brand/brand-image-choosers.js +76 -0
- package/dist/brand/brand-image-choosers.js.map +1 -0
- package/dist/brand/brand-workspace-change-notice.d.ts +20 -0
- package/dist/brand/brand-workspace-change-notice.d.ts.map +1 -0
- package/dist/brand/brand-workspace-change-notice.js +19 -0
- package/dist/brand/brand-workspace-change-notice.js.map +1 -0
- package/dist/brand/index.d.ts +37 -0
- package/dist/brand/index.d.ts.map +1 -1
- package/dist/brand/index.js +29 -0
- package/dist/brand/index.js.map +1 -1
- package/dist/brand/resume-brand-generation.d.ts +17 -0
- package/dist/brand/resume-brand-generation.d.ts.map +1 -0
- package/dist/brand/resume-brand-generation.js +22 -0
- package/dist/brand/resume-brand-generation.js.map +1 -0
- package/dist/brand/use-brand-generation-discovery.d.ts +14 -0
- package/dist/brand/use-brand-generation-discovery.d.ts.map +1 -0
- package/dist/brand/use-brand-generation-discovery.js +61 -0
- package/dist/brand/use-brand-generation-discovery.js.map +1 -0
- package/dist/brand/use-brand-generation-transport.d.ts +16 -0
- package/dist/brand/use-brand-generation-transport.d.ts.map +1 -0
- package/dist/brand/use-brand-generation-transport.js +182 -0
- package/dist/brand/use-brand-generation-transport.js.map +1 -0
- package/dist/brand/use-brand-generation.d.ts +35 -0
- package/dist/brand/use-brand-generation.d.ts.map +1 -0
- package/dist/brand/use-brand-generation.js +225 -0
- package/dist/brand/use-brand-generation.js.map +1 -0
- package/dist/brand/use-brand-image-operation-result.d.ts +43 -0
- package/dist/brand/use-brand-image-operation-result.d.ts.map +1 -0
- package/dist/brand/use-brand-image-operation-result.js +162 -0
- package/dist/brand/use-brand-image-operation-result.js.map +1 -0
- package/dist/brand/use-brand-profile-acceptance.d.ts +38 -0
- package/dist/brand/use-brand-profile-acceptance.d.ts.map +1 -0
- package/dist/brand/use-brand-profile-acceptance.js +84 -0
- package/dist/brand/use-brand-profile-acceptance.js.map +1 -0
- package/dist/brand/use-brand-public-visibility.d.ts +59 -0
- package/dist/brand/use-brand-public-visibility.d.ts.map +1 -0
- package/dist/brand/use-brand-public-visibility.js +69 -0
- package/dist/brand/use-brand-public-visibility.js.map +1 -0
- package/dist/brand/use-brand-workspace-concurrency.d.ts +132 -0
- package/dist/brand/use-brand-workspace-concurrency.d.ts.map +1 -0
- package/dist/brand/use-brand-workspace-concurrency.js +255 -0
- package/dist/brand/use-brand-workspace-concurrency.js.map +1 -0
- package/dist/brand/use-brand-workspace-image-candidates.d.ts +19 -0
- package/dist/brand/use-brand-workspace-image-candidates.d.ts.map +1 -0
- package/dist/brand/use-brand-workspace-image-candidates.js +39 -0
- package/dist/brand/use-brand-workspace-image-candidates.js.map +1 -0
- package/dist/brand/use-org-scoped-state.d.ts +3 -0
- package/dist/brand/use-org-scoped-state.d.ts.map +1 -0
- package/dist/brand/use-org-scoped-state.js +22 -0
- package/dist/brand/use-org-scoped-state.js.map +1 -0
- package/dist/components/multi-step-loader.d.ts +4 -0
- package/dist/components/multi-step-loader.d.ts.map +1 -1
- package/dist/components/multi-step-loader.js +4 -3
- package/dist/components/multi-step-loader.js.map +1 -1
- package/dist/moderation/moderation-event.d.ts +2 -0
- package/dist/moderation/moderation-event.d.ts.map +1 -1
- package/dist/moderation/moderation-event.js +7 -0
- package/dist/moderation/moderation-event.js.map +1 -1
- package/dist/moderation/moderation-store.d.ts.map +1 -1
- package/dist/moderation/moderation-store.js +4 -2
- package/dist/moderation/moderation-store.js.map +1 -1
- package/dist/realtime/job-status/schemas.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Fixtures for the generation flow's tests and stories. Not a public export. */
|
|
2
|
+
export const IDLE_ELIGIBILITY = {
|
|
3
|
+
canStart: true,
|
|
4
|
+
reason: null,
|
|
5
|
+
nextEligibleAt: null,
|
|
6
|
+
lastUsefulDraftAt: null,
|
|
7
|
+
retriesRemainingToday: 3,
|
|
8
|
+
};
|
|
9
|
+
export function makeJob(overrides = {}) {
|
|
10
|
+
return {
|
|
11
|
+
id: "job-1",
|
|
12
|
+
workflowId: "wf-1",
|
|
13
|
+
status: "running",
|
|
14
|
+
progress: {},
|
|
15
|
+
error: null,
|
|
16
|
+
createdAt: "2026-10-01T10:00:00.000Z",
|
|
17
|
+
updatedAt: "2026-10-01T10:00:00.000Z",
|
|
18
|
+
...overrides,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function makeProgress(phase, extra = {}) {
|
|
22
|
+
return { phase, ...extra };
|
|
23
|
+
}
|
|
24
|
+
/** One `text/event-stream` frame for a job update. */
|
|
25
|
+
export function sseFrame(update) {
|
|
26
|
+
return `data: ${JSON.stringify(update)}\n\n`;
|
|
27
|
+
}
|
|
28
|
+
/** A closed or aborted stream rejects further writes; a test driving it after that is a no-op. */
|
|
29
|
+
function safely(action) {
|
|
30
|
+
try {
|
|
31
|
+
action();
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// stream already closed or errored
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** A controllable SSE endpoint: one open stream per `fetch` call, driven by the test. */
|
|
38
|
+
export function createFakeStream(options = {}) {
|
|
39
|
+
const calls = [];
|
|
40
|
+
let controller = null;
|
|
41
|
+
let wasAborted = false;
|
|
42
|
+
const encoder = new TextEncoder();
|
|
43
|
+
const fakeFetch = ((input, init) => {
|
|
44
|
+
calls.push({ url: String(input), init });
|
|
45
|
+
if (options.fetchError)
|
|
46
|
+
return Promise.reject(options.fetchError);
|
|
47
|
+
init?.signal?.addEventListener("abort", () => {
|
|
48
|
+
wasAborted = true;
|
|
49
|
+
try {
|
|
50
|
+
controller?.error(new DOMException("aborted", "AbortError"));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// stream already closed
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const body = new ReadableStream({
|
|
57
|
+
start(c) {
|
|
58
|
+
controller = c;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
return Promise.resolve(new Response(body, {
|
|
62
|
+
status: options.status ?? 200,
|
|
63
|
+
headers: { "Content-Type": "text/event-stream" },
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
fetch: fakeFetch,
|
|
68
|
+
calls,
|
|
69
|
+
push: (frame) => safely(() => controller?.enqueue(encoder.encode(frame))),
|
|
70
|
+
end: () => safely(() => controller?.close()),
|
|
71
|
+
fail: (error) => safely(() => controller?.error(error)),
|
|
72
|
+
aborted: () => wasAborted,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** A `BrandGenerationApi` whose every method is a configurable stub. */
|
|
76
|
+
export function createFakeApi(overrides = {}) {
|
|
77
|
+
const idle = { job: null, eligibility: IDLE_ELIGIBILITY };
|
|
78
|
+
return {
|
|
79
|
+
start: async () => ({ jobId: "job-1", workflowId: "wf-1", reused: false }),
|
|
80
|
+
getActive: async () => idle,
|
|
81
|
+
getStatus: async () => makeJob(),
|
|
82
|
+
cancel: async () => makeJob({ status: "cancelled", outcome: "cancelled" }),
|
|
83
|
+
prioritizeUrl: async () => makeJob(),
|
|
84
|
+
accept: async () => makeJob({ status: "completed" }),
|
|
85
|
+
...overrides,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=brand-generation-fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-fixtures.js","sourceRoot":"","sources":["../../src/brand/brand-generation-fixtures.ts"],"names":[],"mappings":"AAQA,iFAAiF;AAEjF,MAAM,CAAC,MAAM,gBAAgB,GAA+B;IAC1D,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,IAAI;IACZ,cAAc,EAAE,IAAI;IACpB,iBAAiB,EAAE,IAAI;IACvB,qBAAqB,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,UAAU,OAAO,CAAC,YAAyC,EAAE;IACjE,OAAO;QACL,EAAE,EAAE,OAAO;QACX,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,0BAA0B;QACrC,SAAS,EAAE,0BAA0B;QACrC,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,KAAuD,E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AAC;QAC1E,aAAa,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,EAAE;QACpC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QACpD,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BrandGenerationJob } from "./brand-generation-response.js";
|
|
2
|
+
interface BrandGenerationFlowInput<TProfile extends {
|
|
3
|
+
readonly status?: string;
|
|
4
|
+
}, TDraft extends {
|
|
5
|
+
readonly generatedFromJobId?: string | null;
|
|
6
|
+
}> {
|
|
7
|
+
readonly brandGeneration: {
|
|
8
|
+
readonly job: BrandGenerationJob | null;
|
|
9
|
+
readonly isGenerating: boolean;
|
|
10
|
+
};
|
|
11
|
+
readonly profile: TProfile | null | undefined;
|
|
12
|
+
readonly draftProfile: TDraft | null | undefined;
|
|
13
|
+
readonly profileError: boolean;
|
|
14
|
+
readonly draftError: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Decides whether the page is inside the generation flow (progress, recovery or
|
|
18
|
+
* draft review) or showing the settled profile. Pure, so every consumer derives
|
|
19
|
+
* the same answer from the same hook state and queries.
|
|
20
|
+
*/
|
|
21
|
+
export declare function deriveBrandGenerationFlow<TProfile extends {
|
|
22
|
+
readonly status?: string;
|
|
23
|
+
}, TDraft extends {
|
|
24
|
+
readonly generatedFromJobId?: string | null;
|
|
25
|
+
}>({ brandGeneration, profile, draftProfile, profileError, draftError, }: BrandGenerationFlowInput<TProfile, TDraft>): {
|
|
26
|
+
generatedDraftProfile: TDraft | null;
|
|
27
|
+
terminalDraftProfile: TDraft | null;
|
|
28
|
+
terminalJobOwnsDraft: boolean;
|
|
29
|
+
recoveredDraft: boolean;
|
|
30
|
+
inGenerationFlow: boolean;
|
|
31
|
+
workspaceProfile: TProfile | TDraft | null | undefined;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=brand-generation-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-flow.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,UAAU,wBAAwB,CAChC,QAAQ,SAAS;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7C,MAAM,SAAS;IAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;IAE9D,QAAQ,CAAC,eAAe,EAAE;QACxB,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAAC;QACxC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,SAAS;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7C,MAAM,SAAS;IAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAC9D,EACA,eAAe,EACf,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,UAAU,GACX,EAAE,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC;;;;;;;EA8B5C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isTerminalStatus } from "./brand-generation-keys.js";
|
|
2
|
+
/**
|
|
3
|
+
* Decides whether the page is inside the generation flow (progress, recovery or
|
|
4
|
+
* draft review) or showing the settled profile. Pure, so every consumer derives
|
|
5
|
+
* the same answer from the same hook state and queries.
|
|
6
|
+
*/
|
|
7
|
+
export function deriveBrandGenerationFlow({ brandGeneration, profile, draftProfile, profileError, draftError, }) {
|
|
8
|
+
const generatedDraftProfile = draftProfile?.generatedFromJobId ? draftProfile : null;
|
|
9
|
+
const activeJob = brandGeneration.job && !isTerminalStatus(brandGeneration.job.status)
|
|
10
|
+
? brandGeneration.job
|
|
11
|
+
: null;
|
|
12
|
+
const terminalDraftProfile = generatedDraftProfile;
|
|
13
|
+
const terminalJobOwnsDraft = brandGeneration.job?.status === "completed" &&
|
|
14
|
+
terminalDraftProfile !== null &&
|
|
15
|
+
terminalDraftProfile.generatedFromJobId === brandGeneration.job.id;
|
|
16
|
+
const recoveredDraft = brandGeneration.job === null && Boolean(generatedDraftProfile);
|
|
17
|
+
const inGenerationFlow = brandGeneration.isGenerating ||
|
|
18
|
+
Boolean(activeJob) ||
|
|
19
|
+
profile?.status === "generating" ||
|
|
20
|
+
terminalJobOwnsDraft ||
|
|
21
|
+
brandGeneration.job?.status === "failed" ||
|
|
22
|
+
brandGeneration.job?.status === "cancelled" ||
|
|
23
|
+
(brandGeneration.job?.status === "completed" && (profileError || draftError)) ||
|
|
24
|
+
recoveredDraft;
|
|
25
|
+
return {
|
|
26
|
+
generatedDraftProfile,
|
|
27
|
+
terminalDraftProfile,
|
|
28
|
+
terminalJobOwnsDraft,
|
|
29
|
+
recoveredDraft,
|
|
30
|
+
inGenerationFlow,
|
|
31
|
+
workspaceProfile: generatedDraftProfile ?? profile,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=brand-generation-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-flow.js","sourceRoot":"","sources":["../../src/brand/brand-generation-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;A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"./brand-generation-response.js";
|
|
2
|
+
declare const brandGenerationErrorKinds: readonly ["start", "cancel", "prioritize", "accept", "resume"];
|
|
3
|
+
export type BrandGenerationErrorKind = (typeof brandGenerationErrorKinds)[number];
|
|
4
|
+
/**
|
|
5
|
+
* TanStack Query keys owned by the shared generation flow. Namespaced under
|
|
6
|
+
* `"brand-generation"` and scoped by org so they cannot collide with a
|
|
7
|
+
* consumer's own keys (CEL-2146). Consumers must not reuse this namespace.
|
|
8
|
+
*/
|
|
9
|
+
export declare const brandGenerationKeys: {
|
|
10
|
+
all: readonly ["brand-generation"];
|
|
11
|
+
active: (orgId: string) => readonly ["brand-generation", string, "active"];
|
|
12
|
+
latestTerminal: (orgId: string) => readonly ["brand-generation", string, "latest-terminal"];
|
|
13
|
+
};
|
|
14
|
+
export declare function isTerminalStatus(status: BrandGenerationJobStatus | undefined): boolean;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=brand-generation-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-keys.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAG5E,QAAA,MAAM,yBAAyB,gEAAiE,CAAC;AAEjG,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;oBAEd,MAAM;4BACE,MAAM;CAC/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,GAAG,OAAO,CAEtF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const terminalStatuses = ["completed", "failed", "cancelled"];
|
|
2
|
+
const brandGenerationErrorKinds = ["start", "cancel", "prioritize", "accept", "resume"];
|
|
3
|
+
/**
|
|
4
|
+
* TanStack Query keys owned by the shared generation flow. Namespaced under
|
|
5
|
+
* `"brand-generation"` and scoped by org so they cannot collide with a
|
|
6
|
+
* consumer's own keys (CEL-2146). Consumers must not reuse this namespace.
|
|
7
|
+
*/
|
|
8
|
+
export const brandGenerationKeys = {
|
|
9
|
+
all: ["brand-generation"],
|
|
10
|
+
active: (orgId) => ["brand-generation", orgId, "active"],
|
|
11
|
+
latestTerminal: (orgId) => ["brand-generation", orgId, "latest-terminal"],
|
|
12
|
+
};
|
|
13
|
+
export function isTerminalStatus(status) {
|
|
14
|
+
return status !== undefined && terminalStatuses.includes(status);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=brand-generation-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-keys.js","sourceRoot":"","sources":["../../src/brand/brand-generation-keys.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAwC,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AACnG,MAAM,yBAAyB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAIjG;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,CAAC,kBAAkB,CAAU;IAClC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,kBAAkB,EAAE,KAAK,EAAE,QAAQ,CAAU;IACzE,cAAc,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAU;CAC3F,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,MAA4C;IAC3E,OAAO,MAAM,KAAK,SAAS,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type BrandGenerationCopy } from "./brand-generation-copy.js";
|
|
2
|
+
import type { BrandGenerationErrorKind } from "./brand-generation-keys.js";
|
|
3
|
+
import type { BrandGenerationContext, BrandGenerationEligibility, BrandGenerationJob } from "./brand-generation-response.js";
|
|
4
|
+
import type { BrandPersona } from "./types.js";
|
|
5
|
+
export interface BrandGenerationProgressProps {
|
|
6
|
+
readonly job: BrandGenerationJob | null;
|
|
7
|
+
readonly eligibility?: BrandGenerationEligibility | null;
|
|
8
|
+
readonly transportDegraded: boolean;
|
|
9
|
+
readonly error: BrandGenerationErrorKind | null;
|
|
10
|
+
/** The homepage URL a retry starts with. Empty hides the retry action. */
|
|
11
|
+
readonly resolvedUrl: string;
|
|
12
|
+
readonly onStart: (url: string, context?: BrandGenerationContext) => void;
|
|
13
|
+
readonly onCancel: () => void;
|
|
14
|
+
readonly onReset: () => void;
|
|
15
|
+
/** Persona picks the default wording; `copy` overrides any string. */
|
|
16
|
+
readonly persona?: BrandPersona;
|
|
17
|
+
readonly copy?: Partial<BrandGenerationCopy>;
|
|
18
|
+
/** Formats the ISO dates the recovery surface shows (cooldown). Required: locale is the caller's. */
|
|
19
|
+
readonly formatDateTime: (iso: string) => string;
|
|
20
|
+
readonly idPrefix?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Progress, failure and recovery for one brand-generation attempt. Pure
|
|
24
|
+
* presentation: state comes from `useBrandGeneration`, strings from `copy`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function BrandGenerationProgress({ job, eligibility, transportDegraded, error, resolvedUrl, onStart, onCancel, onReset, persona, copy, formatDateTime, idPrefix, }: BrandGenerationProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
//# sourceMappingURL=brand-generation-progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-progress.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-progress.tsx"],"names":[],"mappings":"AAOA,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC/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+1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BrandProfilePageChecklist } from "../components/brand-profile-page-checklist.js";
|
|
3
|
+
import { Button } from "../components/button.js";
|
|
4
|
+
import { MultiStepLoader, MultiStepLoaderSkeleton, multiStepLoaderBrandCrawlPresetV2, } from "../components/multi-step-loader.js";
|
|
5
|
+
import { resolveBrandGenerationCopy } from "./brand-generation-copy.js";
|
|
6
|
+
import { BrandGenerationRecovery } from "./brand-generation-recovery.js";
|
|
7
|
+
import { buildBrandGenerationSteps } from "./brand-generation-steps.js";
|
|
8
|
+
/**
|
|
9
|
+
* Returns `undefined` when every field is blank, so a plain "Retry" click
|
|
10
|
+
* without touching the optional context panel calls `onStart` with exactly one
|
|
11
|
+
* argument rather than an empty `context: {}`.
|
|
12
|
+
*/
|
|
13
|
+
function toGenerationContext(input) {
|
|
14
|
+
const context = {
|
|
15
|
+
...(input.businessName.trim() ? { businessName: input.businessName.trim() } : {}),
|
|
16
|
+
...(input.businessType.trim() ? { businessType: input.businessType.trim() } : {}),
|
|
17
|
+
...(input.locale.trim() ? { locale: input.locale.trim() } : {}),
|
|
18
|
+
...(input.focusUrls.length > 0
|
|
19
|
+
? { focusUrls: input.focusUrls.filter((url) => url.trim().length > 0) }
|
|
20
|
+
: {}),
|
|
21
|
+
...(input.corrections.trim() ? { corrections: input.corrections.trim() } : {}),
|
|
22
|
+
};
|
|
23
|
+
return Object.keys(context).length > 0 ? context : undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Progress, failure and recovery for one brand-generation attempt. Pure
|
|
27
|
+
* presentation: state comes from `useBrandGeneration`, strings from `copy`.
|
|
28
|
+
*/
|
|
29
|
+
export function BrandGenerationProgress({ job, eligibility, transportDegraded, error, resolvedUrl, onStart, onCancel, onReset, persona = "producer", copy, formatDateTime, idPrefix = "brand-generation-progress", }) {
|
|
30
|
+
const text = resolveBrandGenerationCopy(persona, copy);
|
|
31
|
+
// Transport `status` ("failed"/"cancelled") is NOT outcome (contracts §2:
|
|
32
|
+
// "Transport completion is not outcome"). Prefer the real `job.outcome`;
|
|
33
|
+
// fall back to the transport status for a job that predates the field.
|
|
34
|
+
const outcome = job?.outcome ??
|
|
35
|
+
(job?.status === "failed" || job?.status === "cancelled" ? job.status : undefined);
|
|
36
|
+
const isFailed = outcome === "failed";
|
|
37
|
+
const isCancelled = outcome === "cancelled";
|
|
38
|
+
const isNoResult = outcome === "no_result";
|
|
39
|
+
const isTerminalBadOutcome = isFailed || isCancelled || isNoResult;
|
|
40
|
+
const activePhase = job?.progress?.phase;
|
|
41
|
+
const steps = buildBrandGenerationSteps(multiStepLoaderBrandCrawlPresetV2.map((step) => ({
|
|
42
|
+
...step,
|
|
43
|
+
label: text.phaseLabels[step.id] ?? step.label,
|
|
44
|
+
})), job?.progress, isFailed, text.passLabel);
|
|
45
|
+
const canRetry = resolvedUrl.length > 0 && (eligibility?.canStart ?? true);
|
|
46
|
+
const errorMessage = error === null ? null : text.errors[error];
|
|
47
|
+
const generationProgress = activePhase === undefined ? null : (_jsxs(_Fragment, { children: [_jsx(MultiStepLoader, { steps: steps, activeId: activePhase, variant: "list", monotonic: true, runKey: job?.id ?? "", copy: text.stepper }), _jsx(BrandProfilePageChecklist, { progress: { ...job?.progress, phase: activePhase }, copy: text.checklist })] }));
|
|
48
|
+
return (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: text.title }), _jsx("p", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: text.subtitle })] }), _jsxs("div", { className: "rounded-2xl border border-border bg-card p-6", children: [!job || job.status === "pending" || (!activePhase && !isTerminalBadOutcome) ? (_jsx(MultiStepLoaderSkeleton, { steps: 5, label: text.loadingStepsLabel })) : (generationProgress), transportDegraded && !isTerminalBadOutcome && (_jsx("p", { className: "mt-3 text-xs text-muted-foreground", children: text.transportDegraded })), errorMessage && (_jsx("p", { role: "alert", className: "mt-3 text-sm text-destructive", children: errorMessage })), isTerminalBadOutcome && (_jsxs("div", { className: "mt-6", children: [_jsx(BrandGenerationRecovery, { outcome: outcome, eligibility: eligibility ?? undefined, initialContext: job?.context ?? undefined,
|
|
49
|
+
// No URL to retry with: omit `onRetry` so no enabled-looking
|
|
50
|
+
// button silently no-ops.
|
|
51
|
+
onRetry: canRetry
|
|
52
|
+
? (context) => {
|
|
53
|
+
const generationContext = toGenerationContext(context);
|
|
54
|
+
if (generationContext === undefined)
|
|
55
|
+
onStart(resolvedUrl);
|
|
56
|
+
else
|
|
57
|
+
onStart(resolvedUrl, generationContext);
|
|
58
|
+
}
|
|
59
|
+
: undefined, onCreateManually: onReset, showRetryContext: true, formatDateTime: formatDateTime, copy: text.recovery, idPrefix: idPrefix }, job?.id ?? "none"), eligibility && !eligibility.canStart && !eligibility.reason ? (_jsx("p", { role: "status", className: "mt-3 text-sm/6 text-muted-foreground", children: text.eligibilityUnavailable })) : null] })), !isTerminalBadOutcome && (_jsx("div", { className: "mt-6 flex justify-end", children: _jsx(Button, { outline: true, onClick: onCancel, children: text.cancelAction }) }))] })] }));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=brand-generation-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-progress.js","sourceRoot":"","sources":["../../src/brand/brand-generation-progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,iCAAiC,GAClC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAA4B,MAAM,yBAAyB,CAAC;AAE/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAMtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0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EAChB,WAAW,EAAE,WAAW,IAAI,SAAS,EACrC,cAAc,EAAE,GAAG,EAAE,OAAO,IAAI,SAAS;gCACzC,6DAA6D;gCAC7D,0BAA0B;gCAC1B,OAAO,EACL,QAAQ;oCACN,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE;wCACV,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;wCACvD,IAAI,iBAAiB,KAAK,SAAS;4CAAE,OAAO,CAAC,WAAW,CAAC,CAAC;;4CACrD,OAAO,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;oCAC/C,CAAC;oCACH,CAAC,CAAC,SAAS,EAEf,gBAAgB,EAAE,OAAO,EACzB,gBAAgB,QAChB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,IAAI,CAAC,QAAQ,EACnB,QAAQ,EAAE,QAAQ,IAnBb,GAAG,EAAE,EAAE,IAAI,MAAM,CAoBtB,EACD,WAAW,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAC7D,YAAG,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,sCAAsC,YAC9D,IAAI,CAAC,sBAAsB,GAC1B,CACL,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,EACA,CAAC,oBAAoB,IAAI,CACxB,cAAK,SAAS,EAAC,uBAAuB,YACpC,KAAC,MAAM,IAAC,OAAO,QAAC,OAAO,EAAE,QAAQ,YAC9B,IAAI,CAAC,YAAY,GACX,GACL,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type BrandGenerationCopy } from "./brand-generation-copy.js";
|
|
2
|
+
import type { BrandPersona } from "./types.js";
|
|
3
|
+
/** Inline alert for a failed in-progress-job recovery (`discoveryError`). */
|
|
4
|
+
export declare function BrandGenerationRecoveryError({ persona, copy, }: {
|
|
5
|
+
readonly persona?: BrandPersona;
|
|
6
|
+
readonly copy?: Partial<BrandGenerationCopy>;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=brand-generation-recovery-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-recovery-error.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-recovery-error.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,6EAA6E;AAC7E,wBAAgB,4BAA4B,CAAC,EAC3C,OAAoB,EACpB,IAAI,GACL,EAAE;IACD,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC9C,2CAMA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { resolveBrandGenerationCopy } from "./brand-generation-copy.js";
|
|
3
|
+
/** Inline alert for a failed in-progress-job recovery (`discoveryError`). */
|
|
4
|
+
export function BrandGenerationRecoveryError({ persona = "producer", copy, }) {
|
|
5
|
+
return (_jsx("p", { role: "alert", className: "text-sm text-destructive", children: resolveBrandGenerationCopy(persona, copy).recoveryFailed }));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=brand-generation-recovery-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-recovery-error.js","sourceRoot":"","sources":["../../src/brand/brand-generation-recovery-error.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,0BAA0B,EAA4B,MAAM,yBAAyB,CAAC;AAG/F,6EAA6E;AAC7E,MAAM,UAAU,4BAA4B,CAAC,EAC3C,OAAO,GAAG,UAAU,EACpB,IAAI,GAIL;IACC,OAAO,CACL,YAAG,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,0BAA0B,YACjD,0BAA0B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,cAAc,GACvD,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { BrandGenerationEligibility } from "./brand-generation-types.js";
|
|
2
|
+
export type { BrandGenerationEligibility } from "./brand-generation-types.js";
|
|
3
|
+
declare const JOB_PHASES: readonly ["mapping", "selecting", "crawling", "consolidating", "finalizing"];
|
|
4
|
+
declare const JOB_STATUSES: readonly ["pending", "running", "completed", "failed", "cancelled"];
|
|
5
|
+
declare const PAGE_STATUSES: readonly ["pending", "active", "done", "failed"];
|
|
6
|
+
declare const OUTCOMES: readonly ["useful_draft", "partial_draft", "no_result", "failed", "cancelled"];
|
|
7
|
+
export type BrandGenerationPhase = (typeof JOB_PHASES)[number];
|
|
8
|
+
export type BrandGenerationJobStatus = (typeof JOB_STATUSES)[number];
|
|
9
|
+
export type BrandGenerationPageStatus = (typeof PAGE_STATUSES)[number];
|
|
10
|
+
export type BrandGenerationJobOutcome = (typeof OUTCOMES)[number] | null;
|
|
11
|
+
/** Optional operator-supplied context for a generation start or retry
|
|
12
|
+
* (contracts §2 "Start"). Persisted with the attempt and returned on retry
|
|
13
|
+
* so the UI can prefill it. */
|
|
14
|
+
export type BrandGenerationContext = {
|
|
15
|
+
readonly businessName?: string;
|
|
16
|
+
readonly businessType?: string;
|
|
17
|
+
readonly locale?: string;
|
|
18
|
+
readonly focusUrls?: readonly string[];
|
|
19
|
+
readonly corrections?: string;
|
|
20
|
+
};
|
|
21
|
+
export type BrandGenerationPageProgress = {
|
|
22
|
+
readonly url: string;
|
|
23
|
+
readonly round: number;
|
|
24
|
+
readonly status: BrandGenerationPageStatus;
|
|
25
|
+
};
|
|
26
|
+
export type BrandGenerationJobProgress = {
|
|
27
|
+
readonly phase?: BrandGenerationPhase;
|
|
28
|
+
readonly iteration?: number;
|
|
29
|
+
readonly currentUrl?: string | null;
|
|
30
|
+
readonly completenessScore?: number;
|
|
31
|
+
readonly message?: string;
|
|
32
|
+
readonly urlsDiscovered?: number;
|
|
33
|
+
readonly urlsCrawled?: number;
|
|
34
|
+
readonly cost?: {
|
|
35
|
+
readonly firecrawlCredits: number;
|
|
36
|
+
readonly llmInputTokens: number;
|
|
37
|
+
readonly llmOutputTokens: number;
|
|
38
|
+
};
|
|
39
|
+
readonly round?: number;
|
|
40
|
+
readonly pagesTotal?: number;
|
|
41
|
+
readonly pagesDone?: number;
|
|
42
|
+
readonly pageProgress?: BrandGenerationPageProgress[];
|
|
43
|
+
};
|
|
44
|
+
export type BrandGenerationJob = {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly homepageUrl?: string;
|
|
47
|
+
readonly status: BrandGenerationJobStatus;
|
|
48
|
+
readonly progress: BrandGenerationJobProgress;
|
|
49
|
+
readonly error: string | null;
|
|
50
|
+
readonly workflowId: string;
|
|
51
|
+
readonly createdAt: string;
|
|
52
|
+
readonly updatedAt: string;
|
|
53
|
+
readonly outcome?: BrandGenerationJobOutcome;
|
|
54
|
+
readonly context?: BrandGenerationContext | null;
|
|
55
|
+
readonly eligibility?: BrandGenerationEligibility;
|
|
56
|
+
};
|
|
57
|
+
export type BrandGenerationActiveJob = BrandGenerationJob & {
|
|
58
|
+
readonly homepageUrl: string;
|
|
59
|
+
};
|
|
60
|
+
export type BrandGenerationStartResponse = {
|
|
61
|
+
readonly jobId: string;
|
|
62
|
+
readonly workflowId: string;
|
|
63
|
+
readonly reused: boolean;
|
|
64
|
+
};
|
|
65
|
+
export type BrandGenerationEnvelope = {
|
|
66
|
+
readonly data?: unknown;
|
|
67
|
+
readonly error?: unknown;
|
|
68
|
+
readonly response?: Response;
|
|
69
|
+
readonly status?: number;
|
|
70
|
+
};
|
|
71
|
+
export declare class BrandGenerationResponseError extends Error {
|
|
72
|
+
readonly status: number;
|
|
73
|
+
readonly code = "INVALID_BRAND_GENERATION_RESPONSE";
|
|
74
|
+
constructor(status: number);
|
|
75
|
+
}
|
|
76
|
+
export declare function parseEligibility(value: unknown): BrandGenerationEligibility | null;
|
|
77
|
+
export declare function asEnvelope(value: unknown): BrandGenerationEnvelope;
|
|
78
|
+
export declare function responseStatus(envelope: BrandGenerationEnvelope): number;
|
|
79
|
+
export declare function parseJob(value: unknown, requireHomepageUrl: boolean): BrandGenerationJob | null;
|
|
80
|
+
export type BrandGenerationActiveResult = {
|
|
81
|
+
readonly job: BrandGenerationActiveJob | null;
|
|
82
|
+
readonly eligibility: BrandGenerationEligibility | null;
|
|
83
|
+
};
|
|
84
|
+
export declare function parseActiveEnvelope(value: unknown): BrandGenerationActiveResult | null;
|
|
85
|
+
export declare function parseStart(value: unknown): BrandGenerationStartResponse | null;
|
|
86
|
+
//# sourceMappingURL=brand-generation-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-response.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAE3B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAQ3E,QAAA,MAAM,UAAU,8EAA+E,CAAC;AAChG,QAAA,MAAM,YAAY,qEAAsE,CAAC;AACzF,QAAA,MAAM,aAAa,kDAAmD,CAAC;AAMvE,QAAA,MAAM,QAAQ,gFAAiF,CAAC;AAEhG,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/D,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AACrE,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,C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