@cellarnode/ui 0.187.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.
Files changed (56) hide show
  1. package/dist/brand/brand-assets-api.d.ts +58 -0
  2. package/dist/brand/brand-assets-api.d.ts.map +1 -0
  3. package/dist/brand/brand-assets-api.js +160 -0
  4. package/dist/brand/brand-assets-api.js.map +1 -0
  5. package/dist/brand/brand-generation-client.d.ts +8 -0
  6. package/dist/brand/brand-generation-client.d.ts.map +1 -1
  7. package/dist/brand/brand-generation-client.js +1 -1
  8. package/dist/brand/brand-generation-client.js.map +1 -1
  9. package/dist/brand/brand-generation-start.d.ts +49 -0
  10. package/dist/brand/brand-generation-start.d.ts.map +1 -0
  11. package/dist/brand/brand-generation-start.js +48 -0
  12. package/dist/brand/brand-generation-start.js.map +1 -0
  13. package/dist/brand/brand-image-chooser.d.ts +3 -1
  14. package/dist/brand/brand-image-chooser.d.ts.map +1 -1
  15. package/dist/brand/brand-image-chooser.js +7 -1
  16. package/dist/brand/brand-image-chooser.js.map +1 -1
  17. package/dist/brand/brand-image-choosers.d.ts +37 -0
  18. package/dist/brand/brand-image-choosers.d.ts.map +1 -0
  19. package/dist/brand/brand-image-choosers.js +76 -0
  20. package/dist/brand/brand-image-choosers.js.map +1 -0
  21. package/dist/brand/brand-workspace-change-notice.d.ts +20 -0
  22. package/dist/brand/brand-workspace-change-notice.d.ts.map +1 -0
  23. package/dist/brand/brand-workspace-change-notice.js +19 -0
  24. package/dist/brand/brand-workspace-change-notice.js.map +1 -0
  25. package/dist/brand/index.d.ts +17 -0
  26. package/dist/brand/index.d.ts.map +1 -1
  27. package/dist/brand/index.js +14 -0
  28. package/dist/brand/index.js.map +1 -1
  29. package/dist/brand/use-brand-image-operation-result.d.ts +43 -0
  30. package/dist/brand/use-brand-image-operation-result.d.ts.map +1 -0
  31. package/dist/brand/use-brand-image-operation-result.js +162 -0
  32. package/dist/brand/use-brand-image-operation-result.js.map +1 -0
  33. package/dist/brand/use-brand-profile-acceptance.d.ts +38 -0
  34. package/dist/brand/use-brand-profile-acceptance.d.ts.map +1 -0
  35. package/dist/brand/use-brand-profile-acceptance.js +84 -0
  36. package/dist/brand/use-brand-profile-acceptance.js.map +1 -0
  37. package/dist/brand/use-brand-public-visibility.d.ts +59 -0
  38. package/dist/brand/use-brand-public-visibility.d.ts.map +1 -0
  39. package/dist/brand/use-brand-public-visibility.js +69 -0
  40. package/dist/brand/use-brand-public-visibility.js.map +1 -0
  41. package/dist/brand/use-brand-workspace-concurrency.d.ts +132 -0
  42. package/dist/brand/use-brand-workspace-concurrency.d.ts.map +1 -0
  43. package/dist/brand/use-brand-workspace-concurrency.js +255 -0
  44. package/dist/brand/use-brand-workspace-concurrency.js.map +1 -0
  45. package/dist/brand/use-brand-workspace-image-candidates.d.ts +19 -0
  46. package/dist/brand/use-brand-workspace-image-candidates.d.ts.map +1 -0
  47. package/dist/brand/use-brand-workspace-image-candidates.js +39 -0
  48. package/dist/brand/use-brand-workspace-image-candidates.js.map +1 -0
  49. package/dist/moderation/moderation-event.d.ts +2 -0
  50. package/dist/moderation/moderation-event.d.ts.map +1 -1
  51. package/dist/moderation/moderation-event.js +7 -0
  52. package/dist/moderation/moderation-event.js.map +1 -1
  53. package/dist/moderation/moderation-store.d.ts.map +1 -1
  54. package/dist/moderation/moderation-store.js +4 -2
  55. package/dist/moderation/moderation-store.js.map +1 -1
  56. package/package.json +1 -1
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { BrandImageChooser } from "./brand-image-chooser.js";
4
+ import { candidateAssetSlot } from "./use-brand-workspace-image-candidates.js";
5
+ import { useBrandImageOperationResult, } from "./use-brand-image-operation-result.js";
6
+ export const DEFAULT_BRAND_IMAGE_CHOOSERS_COPY = {
7
+ avatarLabel: "Profile picture",
8
+ bannerLabel: "Banner",
9
+ uploadRequiresProfile: "Save your brand profile once before adding images.",
10
+ uploadFailed: "Upload failed. Please try again.",
11
+ logoUploaded: "Logo uploaded",
12
+ bannerUploaded: "Banner updated",
13
+ };
14
+ function targetDefaultSlot(target) {
15
+ return target === "banner" ? "banner" : "primary";
16
+ }
17
+ function sourceFileName(source) {
18
+ const raw = source.kind === "upload"
19
+ ? source.file.name.replace(/\.[^./\\]+$/, "")
20
+ : source.candidate.sourceLabel || source.candidate.role;
21
+ const slug = raw
22
+ .trim()
23
+ .toLowerCase()
24
+ .replace(/[^a-z0-9]+/g, "-")
25
+ .replace(/^-+|-+$/g, "");
26
+ return slug || "brand-image";
27
+ }
28
+ /**
29
+ * CEL-2127 — the logo + banner choosers of the brand workspace. Mount with a
30
+ * `key` of the profile id so a profile switch (org switch, or the target
31
+ * flipping between approved profile and generated draft) remounts it and no
32
+ * stale "checking"/"saved" moderation state leaks across profiles.
33
+ *
34
+ * It owns persistence (the upload call) and correlating the moderation verdict
35
+ * back to the chooser. It must sit inside a `ModerationVerdictProvider`.
36
+ */
37
+ export function BrandImageChoosers({ brandProfileId, avatarCandidateSet, bannerCandidateSet, allowedImageOrigins, assetsApi, notify, copy, }) {
38
+ const text = { ...DEFAULT_BRAND_IMAGE_CHOOSERS_COPY, ...copy };
39
+ const avatarLabelId = useId();
40
+ const bannerLabelId = useId();
41
+ const avatarOperation = useBrandImageOperationResult(assetsApi.fetchModeration);
42
+ const bannerOperation = useBrandImageOperationResult(assetsApi.fetchModeration);
43
+ const applyImage = async (target, operation, result) => {
44
+ // No profile exists yet in the manual-create flow. Fail fast: no network
45
+ // call and no operationId the chooser could never resolve (a chooser stuck
46
+ // "saved"/"checking" forever), plus a clear reason for the user.
47
+ if (!brandProfileId) {
48
+ notify?.({ tone: "error", message: text.uploadRequiresProfile });
49
+ throw new Error("Cannot upload a brand image before a brand profile exists");
50
+ }
51
+ const slot = result.source.kind === "candidate"
52
+ ? candidateAssetSlot(result.source.candidate)
53
+ : targetDefaultSlot(target);
54
+ const file = new File([result.blob], `${sourceFileName(result.source)}.webp`, {
55
+ type: result.blob.type || "image/webp",
56
+ });
57
+ // Snapshot before the request goes out, so an inline verdict published
58
+ // while it is in flight is honoured instead of gated out as pre-existing.
59
+ const startSeq = operation.beginOperation();
60
+ try {
61
+ const asset = await assetsApi.upload({ profileId: brandProfileId, slot, file });
62
+ operation.startOperation(asset.id, { brandProfileId, slot }, startSeq);
63
+ notify?.({
64
+ tone: "success",
65
+ message: slot === "banner" ? text.bannerUploaded : text.logoUploaded,
66
+ });
67
+ return { operationId: asset.id };
68
+ }
69
+ catch (error) {
70
+ notify?.({ tone: "error", message: text.uploadFailed });
71
+ throw error;
72
+ }
73
+ };
74
+ return (_jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [_jsxs("section", { "aria-labelledby": avatarLabelId, children: [_jsx("p", { id: avatarLabelId, className: "mb-2 text-sm font-medium text-foreground", children: text.avatarLabel }), _jsx(BrandImageChooser, { target: "profilePicture", candidates: avatarCandidateSet.available, unavailableCandidates: avatarCandidateSet.unavailable, allowedImageOrigins: allowedImageOrigins, copy: text.chooser, cropAspect: 1, cropCircularMask: true, cropOutput: { type: "image/webp", quality: 0.9, maxDimension: 2048 }, onApply: (result) => applyImage("profilePicture", avatarOperation, result), operationResult: avatarOperation.operationResult, onRetry: avatarOperation.reset, onDismiss: avatarOperation.reset })] }), _jsxs("section", { "aria-labelledby": bannerLabelId, children: [_jsx("p", { id: bannerLabelId, className: "mb-2 text-sm font-medium text-foreground", children: text.bannerLabel }), _jsx(BrandImageChooser, { target: "banner", candidates: bannerCandidateSet.available, unavailableCandidates: bannerCandidateSet.unavailable, allowedImageOrigins: allowedImageOrigins, copy: text.chooser, cropAspect: 3, cropOutput: { type: "image/webp", quality: 0.9, maxDimension: 2048 }, onApply: (result) => applyImage("banner", bannerOperation, result), operationResult: bannerOperation.operationResult, onRetry: bannerOperation.reset, onDismiss: bannerOperation.reset })] })] }));
75
+ }
76
+ //# sourceMappingURL=brand-image-choosers.js.map
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Ae,CAAC,KAAK,EAC9B,SAAS,EAAE,eAAe,CAAC,KAAK,GAChC,IACM,EACV,sCAA0B,aAAa,aACrC,YAAG,EAAE,EAAE,aAAa,EAAE,SAAS,EAAC,0CAA0C,YACvE,IAAI,CAAC,WAAW,GACf,EACJ,KAAC,iBAAiB,IAChB,MAAM,EAAC,QAAQ,EACf,UAAU,EAAE,kBAAkB,CAAC,SAAS,EACxC,qBAAqB,EAAE,kBAAkB,CAAC,WAAW,EACrD,mBAAmB,EAAE,mBAAmB,EACxC,IAAI,EAAE,IAAI,CAAC,OAAO,EAClB,UAAU,EAAE,CAAC,EACb,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EACpE,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC,EAClE,eAAe,EAAE,eAAe,CAAC,eAAe,EAChD,OAAO,EAAE,eAAe,CAAC,KAAK,EAC9B,SAAS,EAAE,eAAe,CAAC,KAAK,GAChC,IACM,IACN,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ export interface BrandWorkspaceChangeNoticeCopy {
2
+ readonly message: string;
3
+ readonly reloadAction: string;
4
+ }
5
+ export declare const DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY: BrandWorkspaceChangeNoticeCopy;
6
+ export interface BrandWorkspaceChangeNoticeProps {
7
+ /** `serverChanged` from `useBrandWorkspaceConcurrency`. Renders nothing when false. */
8
+ readonly visible: boolean;
9
+ readonly onReload: () => void;
10
+ /** Disables the action while a write or a reload is in flight. */
11
+ readonly disabled?: boolean;
12
+ readonly copy?: Partial<BrandWorkspaceChangeNoticeCopy>;
13
+ }
14
+ /**
15
+ * CEL-2127 — shown above an open brand workspace when the server's profile
16
+ * moved underneath it. Saving is blocked until the user reloads, so the form
17
+ * never silently overwrites a newer version.
18
+ */
19
+ export declare function BrandWorkspaceChangeNotice({ visible, onReload, disabled, copy, }: BrandWorkspaceChangeNoticeProps): import("react/jsx-runtime").JSX.Element | null;
20
+ //# sourceMappingURL=brand-workspace-change-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand-workspace-change-notice.d.ts","sourceRoot":"","sources":["../../src/brand/brand-workspace-change-notice.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,0CAA0C,EAAE,8BAGxD,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,uFAAuF;IACvF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;CACzD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,OAAO,EACP,QAAQ,EACR,QAAgB,EAChB,IAAI,GACL,EAAE,+BAA+B,kDAiBjC"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { TriangleAlertIcon } from "lucide-react";
3
+ import { Button } from "../components/button.js";
4
+ export const DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY = {
5
+ message: "Brand profile changed elsewhere. Review latest values before saving.",
6
+ reloadAction: "Reload latest",
7
+ };
8
+ /**
9
+ * CEL-2127 — shown above an open brand workspace when the server's profile
10
+ * moved underneath it. Saving is blocked until the user reloads, so the form
11
+ * never silently overwrites a newer version.
12
+ */
13
+ export function BrandWorkspaceChangeNotice({ visible, onReload, disabled = false, copy, }) {
14
+ if (!visible)
15
+ return null;
16
+ const resolved = { ...DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY, ...copy };
17
+ return (_jsxs("div", { role: "status", className: "flex flex-wrap items-center justify-between gap-3 rounded-lg border border-[var(--tone-warning-fg)]/30 bg-[var(--tone-warning-soft)] px-3 py-2 text-sm/6 text-[var(--tone-warning-fg)]", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [_jsx(TriangleAlertIcon, { "aria-hidden": "true", className: "size-5 shrink-0" }), resolved.message] }), _jsx(Button, { outline: true, onClick: onReload, disabled: disabled, children: resolved.reloadAction })] }));
18
+ }
19
+ //# sourceMappingURL=brand-workspace-change-notice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand-workspace-change-notice.js","sourceRoot":"","sources":["../../src/brand/brand-workspace-change-notice.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAO9C,MAAM,CAAC,MAAM,0CAA0C,GAAmC;IACxF,OAAO,EAAE,sEAAsE;IAC/E,YAAY,EAAE,eAAe;CAC9B,CAAC;AAWF;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,EACzC,OAAO,EACP,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,IAAI,GAC4B;IAChC,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,QAAQ,GAAG,EAAE,GAAG,0CAA0C,EAAE,GAAG,IAAI,EAAE,CAAC;IAC5E,OAAO,CACL,eACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,wLAAwL,aAElM,gBAAM,SAAS,EAAC,iCAAiC,aAC/C,KAAC,iBAAiB,mBAAa,MAAM,EAAC,SAAS,EAAC,iBAAiB,GAAG,EACnE,QAAQ,CAAC,OAAO,IACZ,EACP,KAAC,MAAM,IAAC,OAAO,QAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,YAClD,QAAQ,CAAC,YAAY,GACf,IACL,CACP,CAAC;AACJ,CAAC"}
@@ -57,4 +57,21 @@ export type { BrandImageOperationResult, BrandImageOperationStatus, } from "./br
57
57
  export { BRAND_PALETTE_MAX_COLORS } from "./brand-visual-form-values.js";
58
58
  export type { BrandManualTypographyPatch, BrandTypographyFormValues, } from "./brand-visual-form-values.js";
59
59
  export type { BrandVisualFormCopy } from "./brand-profile-form-visual.js";
60
+ export { classifyBrandProfileApiError, useBrandWorkspaceConcurrency, } from "./use-brand-workspace-concurrency.js";
61
+ export type { BrandWorkspaceEvent, BrandWorkspaceSaveFailure, BrandWorkspaceSnapshot, BrandWorkspaceTarget, BrandWorkspaceWriteBody, UseBrandWorkspaceConcurrencyOptions, UseBrandWorkspaceConcurrencyResult, } from "./use-brand-workspace-concurrency.js";
62
+ export { BrandWorkspaceChangeNotice, DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY, } from "./brand-workspace-change-notice.js";
63
+ export type { BrandWorkspaceChangeNoticeCopy, BrandWorkspaceChangeNoticeProps, } from "./brand-workspace-change-notice.js";
64
+ export { useBrandPublicVisibility } from "./use-brand-public-visibility.js";
65
+ export type { BrandPublicVisibilityApi, BrandPublicVisibilityEvent, BrandPublicVisibilityWrite, BrandVisibilityProfile, UseBrandPublicVisibilityOptions, } from "./use-brand-public-visibility.js";
66
+ export { BrandAssetsRequestError, createBrandAssetsClient, resolveBrandAssetMimeType, } from "./brand-assets-api.js";
67
+ export type { BrandAssetModeration, BrandAssetRecord, BrandAssetsApi, BrandAssetsClientOptions, UploadBrandAssetArgs, } from "./brand-assets-api.js";
68
+ export { candidateAssetSlot, useBrandWorkspaceImageCandidates, } from "./use-brand-workspace-image-candidates.js";
69
+ export { useBrandImageOperationResult } from "./use-brand-image-operation-result.js";
70
+ export type { BrandImageOperationController } from "./use-brand-image-operation-result.js";
71
+ export { BrandImageChoosers, DEFAULT_BRAND_IMAGE_CHOOSERS_COPY } from "./brand-image-choosers.js";
72
+ export type { BrandImageChoosersCopy, BrandImageChoosersProps } from "./brand-image-choosers.js";
73
+ export { BrandGenerationStart, DEFAULT_BRAND_GENERATION_START_COPY, } from "./brand-generation-start.js";
74
+ export type { BrandGenerationStartCopy, BrandGenerationStartProps } from "./brand-generation-start.js";
75
+ export { DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY, useBrandProfileAcceptance, } from "./use-brand-profile-acceptance.js";
76
+ export type { BrandProfileAcceptanceCopy, BrandWorkspaceNotice, UseBrandProfileAcceptanceOptions, } from "./use-brand-profile-acceptance.js";
60
77
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/brand/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC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enerationCopy } from "./brand-
48
48
  export { BrandImageChooser } from "./brand-image-chooser.js";
49
49
  export { isBrandImageOperationFailed, isBrandImageOperationIndeterminate, isBrandImageOperationSettled, } from "./brand-image-chooser-types.js";
50
50
  export { BRAND_PALETTE_MAX_COLORS } from "./brand-visual-form-values.js";
51
+ // CEL-2127 lift 2: the rest of producer's brand workspace. Concurrency (409
52
+ // reload / keep-mine, TARGET_MISMATCH, server-changed detection), the public
53
+ // visibility toggle handler, the logo/banner choosers with their assets API,
54
+ // the idle start form and generated-profile acceptance. The data layer is
55
+ // injected and every string is a prop with an English default.
56
+ export { classifyBrandProfileApiError, useBrandWorkspaceConcurrency, } from "./use-brand-workspace-concurrency.js";
57
+ export { BrandWorkspaceChangeNotice, DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY, } from "./brand-workspace-change-notice.js";
58
+ export { useBrandPublicVisibility } from "./use-brand-public-visibility.js";
59
+ export { BrandAssetsRequestError, createBrandAssetsClient, resolveBrandAssetMimeType, } from "./brand-assets-api.js";
60
+ export { candidateAssetSlot, useBrandWorkspaceImageCandidates, } from "./use-brand-workspace-image-candidates.js";
61
+ export { useBrandImageOperationResult } from "./use-brand-image-operation-result.js";
62
+ export { BrandImageChoosers, DEFAULT_BRAND_IMAGE_CHOOSERS_COPY } from "./brand-image-choosers.js";
63
+ export { BrandGenerationStart, DEFAULT_BRAND_GENERATION_START_COPY, } from "./brand-generation-start.js";
64
+ export { DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY, useBrandProfileAcceptance, } from "./use-brand-profile-acceptance.js";
51
65
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/brand/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,qCAAqC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACr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6EAA6E;AAC7E,6EAA6E;AAC7E,0EAA0E;AAC1E,+DAA+D;AAC/D,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,mCAAmC,CAAC;AAU3C,OAAO,EACL,0BAA0B,EAC1B,0CAA0C,GAC3C,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAQzE,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EACL,kBAAkB,EAClB,gCAAgC,GACjC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EACL,oBAAoB,EACpB,mCAAmC,GACpC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,qCAAqC,EACrC,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type ModerationPersistedRead, type ModerationSubjectMatch } from "../moderation/index.js";
2
+ import type { BrandImageOperationResult } from "./brand-image-chooser-types.js";
3
+ export interface BrandImageOperationController {
4
+ /** `null` when no operation has started yet — the chooser's own idle
5
+ * default. */
6
+ readonly operationResult: BrandImageOperationResult | null;
7
+ /**
8
+ * Call once `onApply`'s upload/candidate-select call has been accepted by
9
+ * the backend: a caller-generated id that correlates a later verdict back
10
+ * to THIS call (never a previous operation on the same subject slot), and
11
+ * the subject to watch. The subject is passed HERE rather than fixed at
12
+ * the hook call site because it depends on which slot the upload actually
13
+ * landed in — a candidate's OWN role can route it to a different slot than
14
+ * the chooser instance's own target (e.g. a favicon-role candidate picked
15
+ * through the "profile picture" chooser still saves to the favicon slot;
16
+ * see `candidateAssetSlot` in `useBrandImageCandidates.ts`). Also marks the
17
+ * subject "checking" in the shared moderation store so every OTHER surface
18
+ * watching it (e.g. `BrandAssetsSection`'s `ModerationSurfaceNotice`) sees
19
+ * it too.
20
+ */
21
+ readonly startOperation: (operationId: string, subject: ModerationSubjectMatch, startSeq?: number) => void;
22
+ /**
23
+ * Call BEFORE issuing the upload request and pass the result to
24
+ * `startOperation`. The backend can publish a verdict for the asset while
25
+ * the upload's HTTP response is still in flight; without this snapshot that
26
+ * event is gated out as "pre-existing" and the operation hangs at
27
+ * `checking` until it gives up.
28
+ */
29
+ readonly beginOperation: () => number;
30
+ /** Drops tracking — e.g. when the chooser is dismissed/closed. */
31
+ readonly reset: () => void;
32
+ }
33
+ /**
34
+ * Owns the chooser's current upload identity and adapts the shared moderation
35
+ * operation (including its exact-asset durable read) to the chooser result.
36
+ */
37
+ export declare function useBrandImageOperationResult(
38
+ /**
39
+ * The durable, asset-id-keyed read (`BrandAssetsApi.fetchModeration`) used
40
+ * when no live verdict event arrives.
41
+ */
42
+ fetchModeration: (profileId: string, assetId: string) => Promise<ModerationPersistedRead | null>): BrandImageOperationController;
43
+ //# sourceMappingURL=use-brand-image-operation-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-brand-image-operation-result.d.ts","sourceRoot":"","sources":["../../src/brand/use-brand-image-operation-result.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,6BAA6B,CAAC;AAmCrC,MAAM,WAAW,6BAA6B;IAC5C;kBACc;IACd,QAAQ,CAAC,eAAe,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC3D;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,cAAc,EAAE,CACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,CAAC,EAAE,MAAM,KACd,IAAI,CAAC;IACV;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,MAAM,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B;AAC1C;;;GAGG;AACH,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,GAC/F,6BAA6B,CA0I/B"}
@@ -0,0 +1,162 @@
1
+ import { useCallback, useMemo, useRef, useState } from "react";
2
+ import { GIVE_UP_AFTER_MS, useModerationCheckControls, useModerationOperation, } from "../moderation/index.js";
3
+ /**
4
+ * CEL-2127 (from producer, CEL-1682/CEL-1681) — maps the CEL-1320 moderation read model's 8-state
5
+ * `ModerationStatus` (checking/passed/rejected/in-review/
6
+ * approved-after-review/changes-requested/unpublished/escalated) onto
7
+ * `BrandImageChooser`'s narrower `BrandImageOperationStatus` contract
8
+ * (saved/checking/passed/rejected/unknown/error). A future backend status
9
+ * this map doesn't know about degrades to "unknown" rather than being
10
+ * dropped, mirroring the shared event parser's forward-compatibility
11
+ * stance.
12
+ */
13
+ function mapModerationStatus(status) {
14
+ switch (status) {
15
+ case "checking":
16
+ case "in-review":
17
+ return "checking";
18
+ case "passed":
19
+ case "approved-after-review":
20
+ return "passed";
21
+ case "rejected":
22
+ case "changes-requested":
23
+ return "rejected";
24
+ default:
25
+ return "unknown";
26
+ }
27
+ }
28
+ /**
29
+ * A server verdict may be stamped slightly before the client's own clock. Kept
30
+ * small: it is also the window in which a leftover verdict for a previous
31
+ * upload could be mistaken for this one when the event carries no `assetId`.
32
+ */
33
+ const CLOCK_SKEW_TOLERANCE_MS = 2_000;
34
+ /**
35
+ * Owns the chooser's current upload identity and adapts the shared moderation
36
+ * operation (including its exact-asset durable read) to the chooser result.
37
+ */
38
+ export function useBrandImageOperationResult(
39
+ /**
40
+ * The durable, asset-id-keyed read (`BrandAssetsApi.fetchModeration`) used
41
+ * when no live verdict event arrives.
42
+ */
43
+ fetchModeration) {
44
+ const [operation, setOperation] = useState(null);
45
+ const { markChecking, clearChecking, beginOperation: beginStoreOperation, } = useModerationCheckControls();
46
+ const beganAtRef = useRef(null);
47
+ // Read through a ref: an inline `fetchModeration` must not change
48
+ // `fetchPersisted`'s identity every render and restart the durable poll.
49
+ const fetchModerationRef = useRef(fetchModeration);
50
+ fetchModerationRef.current = fetchModeration;
51
+ const fetchPersisted = useMemo(() => {
52
+ const profileId = operation?.subject.brandProfileId;
53
+ return profileId && operation
54
+ ? () => fetchModerationRef.current(profileId, operation.id)
55
+ : undefined;
56
+ }, [operation]);
57
+ const subjectState = useModerationOperation({
58
+ match: operation?.subject ?? null,
59
+ identity: operation?.id,
60
+ fetchPersisted,
61
+ });
62
+ const startOperation = useCallback((operationId, subject, startSeq) => {
63
+ const now = Date.now();
64
+ // An inline verdict is published while the upload request is in flight,
65
+ // i.e. BEFORE `now`; anchor staleness at when the request began (minus
66
+ // clock skew), not at when its response came back.
67
+ // Only a begin that this start is paired with (it carries the store's
68
+ // `startSeq`) counts; a begin whose upload failed must not leak into
69
+ // a later, unrelated operation.
70
+ const began = startSeq !== undefined ? (beganAtRef.current ?? now) : now;
71
+ beganAtRef.current = null;
72
+ setOperation({
73
+ id: operationId,
74
+ subject,
75
+ appliedAt: now,
76
+ notBefore: began - CLOCK_SKEW_TOLERANCE_MS,
77
+ });
78
+ markChecking(subject, operationId, startSeq);
79
+ }, [markChecking]);
80
+ const beginOperation = useCallback(() => {
81
+ beganAtRef.current = Date.now();
82
+ return beginStoreOperation();
83
+ }, [beginStoreOperation]);
84
+ const reset = useCallback(() => {
85
+ setOperation((current) => {
86
+ if (current)
87
+ clearChecking(current.subject);
88
+ return null;
89
+ });
90
+ }, [clearChecking]);
91
+ const operationResult = useMemo(() => {
92
+ if (!operation)
93
+ return null;
94
+ // A verdict landed for this subject. Guard against a STALE result from a
95
+ // PREVIOUS operation on the same slot (e.g. re-uploading a rejected
96
+ // banner) — the chooser's own contract: "old verdict cannot complete
97
+ // newer upload." An event older than this operation's start is ignored,
98
+ // falling through to the in-flight branches below. CEL-1682 review
99
+ // fixup (reviewer A, P3): an UNPARSEABLE `occurredAt` must also count as
100
+ // stale — `Number.isFinite(NaN)` is `false`, so the original
101
+ // `finite && older` test let a malformed prior verdict slip through as
102
+ // "not stale" and complete a newer, still-in-flight upload.
103
+ if (subjectState.event) {
104
+ const event = subjectState.event;
105
+ // A verdict that names its asset is matched EXACTLY: it belongs to this
106
+ // operation iff it is this asset's, whatever the clocks say. A verdict
107
+ // that does not (the wire cannot always carry it) is matched on slot
108
+ // alone, so it must also not predate this operation: one older than the
109
+ // upload's start is a leftover from a PREVIOUS upload into the same slot
110
+ // ("old verdict cannot complete newer upload"). An unparseable
111
+ // `occurredAt` counts as stale for the same reason.
112
+ let isStale;
113
+ if (event.subject?.assetId !== undefined) {
114
+ isStale = event.subject.assetId !== operation.id;
115
+ }
116
+ else {
117
+ const eventTime = Date.parse(event.occurredAt);
118
+ isStale = !Number.isFinite(eventTime) || eventTime < operation.notBefore;
119
+ }
120
+ if (!isStale) {
121
+ const status = mapModerationStatus(subjectState.event.state);
122
+ return {
123
+ status,
124
+ operationId: operation.id,
125
+ reason: status === "rejected"
126
+ ? (subjectState.event.detail ?? subjectState.event.headline ?? null)
127
+ : undefined,
128
+ };
129
+ }
130
+ }
131
+ if (subjectState.status === "checking") {
132
+ return {
133
+ status: subjectState.slow ? "unknown" : "checking",
134
+ operationId: operation.id,
135
+ };
136
+ }
137
+ // A durable, asset-id-keyed read may resolve without a live event. The
138
+ // shared operation reconciler gives that answer precedence over a stale
139
+ // same-slot event; the chooser receives only the coarse status here.
140
+ if (subjectState.persistedOnly && subjectState.status) {
141
+ return { status: mapModerationStatus(subjectState.status), operationId: operation.id };
142
+ }
143
+ if (subjectState.status === "unknown" && !subjectState.event) {
144
+ return { status: "unknown", operationId: operation.id };
145
+ }
146
+ // No event yet, no local pending mark. Either `markChecking` hasn't run
147
+ // yet (a same-tick gap right after `startOperation`) or the store gave
148
+ // up waiting after GIVE_UP_AFTER_MS and dropped the mark — the store
149
+ // itself no longer distinguishes those, so use this operation's own
150
+ // `appliedAt` timestamp to tell them apart. This is a `useMemo`, so
151
+ // noticing the GIVE_UP transition depends on getting a fresh render —
152
+ // in practice the shared store's sweep interval delivers one while any
153
+ // check is pending, including the tick that drops the mark. This never polls
154
+ // `Date.now()` on its own between renders.
155
+ if (Date.now() - operation.appliedAt > GIVE_UP_AFTER_MS) {
156
+ return { status: "unknown", operationId: operation.id };
157
+ }
158
+ return { status: "saved", operationId: operation.id };
159
+ }, [operation, subjectState]);
160
+ return { operationResult, startOperation, beginOperation, reset };
161
+ }
162
+ //# sourceMappingURL=use-brand-image-operation-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-brand-image-operation-result.js","sourceRoot":"","sources":["../../src/brand/use-brand-image-operation-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,GAGvB,MAAM,eAAe,CAAC;AAMvB;;;;;;;;;GASG;AACH,SAAS,mBAAmB,CAAC,MAAc;IACzC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,UAAU,CAAC;QACpB,KAAK,QAAQ,CAAC;QACd,KAAK,uBAAuB;YAC1B,OAAO,QAAQ,CAAC;QAClB,KAAK,UAAU,CAAC;QAChB,KAAK,mBAAmB;YACtB,OAAO,UAAU,CAAC;QACpB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAqCtC;;;GAGG;AACH,MAAM,UAAU,4BAA4B;AAC1C;;;GAGG;AACH,eAAgG;IAEhG,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC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EAAE,CAAC;QAC1D,CAAC;QAED,wEAAwE;QACxE,uEAAuE;QACvE,qEAAqE;QACrE,oEAAoE;QACpE,oEAAoE;QACpE,sEAAsE;QACtE,uEAAuE;QACvE,6EAA6E;QAC7E,2CAA2C;QAC3C,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,SAAS,GAAG,gBAAgB,EAAE,CAAC;YACxD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;QAC1D,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;IACxD,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAE9B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { UseBrandGenerationResult } from "./use-brand-generation.js";
2
+ export interface BrandWorkspaceNotice {
3
+ readonly tone: "success" | "error" | "info";
4
+ readonly message: string;
5
+ }
6
+ export interface BrandProfileAcceptanceCopy {
7
+ readonly acceptFailed: string;
8
+ readonly acceptEarlyRequested: string;
9
+ readonly acceptRunIncomplete: string;
10
+ readonly accepted: string;
11
+ }
12
+ export declare const DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY: BrandProfileAcceptanceCopy;
13
+ export interface UseBrandProfileAcceptanceOptions {
14
+ readonly orgId: string;
15
+ readonly brandGeneration: Pick<UseBrandGenerationResult, "job" | "accept" | "reset">;
16
+ /**
17
+ * Approves the generated draft (the injected data layer). With TanStack
18
+ * Query: `(handlers) => approve.mutate(undefined, handlers)`.
19
+ */
20
+ readonly approve: (handlers: {
21
+ onSuccess: () => void;
22
+ onError: () => void;
23
+ }) => void;
24
+ readonly notify?: (notice: BrandWorkspaceNotice) => void;
25
+ readonly copy?: Partial<BrandProfileAcceptanceCopy>;
26
+ }
27
+ /**
28
+ * CEL-2127 — "Accept profile" for a generated draft, shared by producer and
29
+ * importer. While the run is still going it asks the backend to wrap up
30
+ * (early accept); once completed it approves the draft and resets the flow.
31
+ * Either path is single-flight per org and never reports into another org's
32
+ * session after an org switch.
33
+ */
34
+ export declare function useBrandProfileAcceptance({ orgId, brandGeneration, approve, notify, copy, }: UseBrandProfileAcceptanceOptions): {
35
+ accept: () => void;
36
+ signalPending: boolean;
37
+ };
38
+ //# sourceMappingURL=use-brand-profile-acceptance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-brand-profile-acceptance.d.ts","sourceRoot":"","sources":["../../src/brand/use-brand-profile-acceptance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,qCAAqC,EAAE,0BAMnD,CAAC;AAEF,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,wBAAwB,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC;IACrF;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAAE,SAAS,EAAE,MAAM,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;CACrD;AAID;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,KAAK,EACL,eAAe,EACf,OAAO,EACP,MAAM,EACN,IAAI,GACL,EAAE,gCAAgC;;;EA4DlC"}
@@ -0,0 +1,84 @@
1
+ import { useRef, useState } from "react";
2
+ import { isTerminalStatus } from "./brand-generation-keys.js";
3
+ export const DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY = {
4
+ acceptFailed: "Failed to accept profile",
5
+ acceptEarlyRequested: "Wrapping up the current run",
6
+ acceptRunIncomplete: "This run did not finish, so there is no new profile to accept. Retry generation.",
7
+ accepted: "Profile accepted",
8
+ };
9
+ /**
10
+ * CEL-2127 — "Accept profile" for a generated draft, shared by producer and
11
+ * importer. While the run is still going it asks the backend to wrap up
12
+ * (early accept); once completed it approves the draft and resets the flow.
13
+ * Either path is single-flight per org and never reports into another org's
14
+ * session after an org switch.
15
+ */
16
+ export function useBrandProfileAcceptance({ orgId, brandGeneration, approve, notify, copy, }) {
17
+ const text = { ...DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY, ...copy };
18
+ const [signalPendingState, setSignalPendingState] = useState(null);
19
+ const pendingActionRef = useRef(null);
20
+ const currentOrgIdRef = useRef(orgId);
21
+ currentOrgIdRef.current = orgId;
22
+ const signalPending = signalPendingState?.orgId === orgId;
23
+ const beginPendingAction = () => {
24
+ if (pendingActionRef.current?.orgId === orgId)
25
+ return null;
26
+ const action = { orgId };
27
+ pendingActionRef.current = action;
28
+ setSignalPendingState(action);
29
+ return action;
30
+ };
31
+ const finishPendingAction = (action) => {
32
+ if (pendingActionRef.current === action)
33
+ pendingActionRef.current = null;
34
+ setSignalPendingState((pending) => (pending === action ? null : pending));
35
+ };
36
+ const stillCurrent = (action) => currentOrgIdRef.current === action.orgId;
37
+ const accept = () => {
38
+ const job = brandGeneration.job;
39
+ if (job && !isTerminalStatus(job.status)) {
40
+ const action = beginPendingAction();
41
+ if (!action)
42
+ return;
43
+ brandGeneration
44
+ .accept()
45
+ .then((accepted) => {
46
+ if (!stillCurrent(action))
47
+ return;
48
+ if (accepted === false)
49
+ notify?.({ tone: "error", message: text.acceptFailed });
50
+ else
51
+ notify?.({ tone: "info", message: text.acceptEarlyRequested });
52
+ })
53
+ .catch(() => {
54
+ if (stillCurrent(action))
55
+ notify?.({ tone: "error", message: text.acceptFailed });
56
+ })
57
+ .finally(() => finishPendingAction(action));
58
+ return;
59
+ }
60
+ if (job && job.status !== "completed") {
61
+ notify?.({ tone: "error", message: text.acceptRunIncomplete });
62
+ return;
63
+ }
64
+ const action = beginPendingAction();
65
+ if (!action)
66
+ return;
67
+ approve({
68
+ onSuccess: () => {
69
+ finishPendingAction(action);
70
+ if (!stillCurrent(action))
71
+ return;
72
+ notify?.({ tone: "success", message: text.accepted });
73
+ brandGeneration.reset();
74
+ },
75
+ onError: () => {
76
+ finishPendingAction(action);
77
+ if (stillCurrent(action))
78
+ notify?.({ tone: "error", message: text.acceptFailed });
79
+ },
80
+ });
81
+ };
82
+ return { accept, signalPending };
83
+ }
84
+ //# sourceMappingURL=use-brand-profile-acceptance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-brand-profile-acceptance.js","sourceRoot":"","sources":["../../src/brand/use-brand-profile-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAe3D,MAAM,CAAC,MAAM,qCAAqC,GAA+B;IAC/E,YAAY,EAAE,0BAA0B;IACxC,oBAAoB,EAAE,6BAA6B;IACnD,mBAAmB,EACjB,kFAAkF;IACpF,QAAQ,EAAE,kBAAkB;CAC7B,CAAC;AA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AC,CAAC;gBAC5B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;oBAAE,OAAO;gBAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACtD,eAAe,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;YACD,OAAO,EAAE,GAAG,EAAE;gBACZ,mBAAmB,CAAC,MAAM,CAAC,CAAC;gBAC5B,IAAI,YAAY,CAAC,MAAM,CAAC;oBAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;YACpF,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { BrandWorkspaceTarget } from "./use-brand-workspace-concurrency.js";
2
+ import type { BrandPublicField } from "./brand-profile-review.js";
3
+ /** The profile a visibility write is compare-and-swapped against. */
4
+ export interface BrandVisibilityProfile {
5
+ readonly id: string;
6
+ readonly status: string;
7
+ readonly revision?: number | null;
8
+ }
9
+ export interface BrandPublicVisibilityWrite {
10
+ readonly expectedProfileId: string;
11
+ readonly expectedStatus: string;
12
+ readonly expectedRevision: number | undefined;
13
+ readonly publicVisibility: Readonly<Partial<Record<BrandPublicField, boolean>>>;
14
+ }
15
+ /**
16
+ * The injected data layer: persist one field's visibility on the approved
17
+ * profile or on the generated draft, resolving with the saved profile.
18
+ */
19
+ export interface BrandPublicVisibilityApi {
20
+ save: (write: BrandPublicVisibilityWrite, target: BrandWorkspaceTarget) => Promise<{
21
+ readonly revision?: number | null;
22
+ } | null | undefined | void>;
23
+ }
24
+ export type BrandPublicVisibilityEvent = {
25
+ readonly kind: "reload-before-saving";
26
+ } | {
27
+ readonly kind: "wait-for-save";
28
+ } | {
29
+ readonly kind: "save-failed";
30
+ };
31
+ export interface UseBrandPublicVisibilityOptions {
32
+ readonly orgId: string | null;
33
+ readonly api: BrandPublicVisibilityApi;
34
+ /** The approved profile. */
35
+ readonly profile: BrandVisibilityProfile | null | undefined;
36
+ /** The generated draft under review; wins over `profile` when present. */
37
+ readonly generatedDraftProfile: BrandVisibilityProfile | null | undefined;
38
+ /** `requiresReload` from `useBrandWorkspaceConcurrency`. */
39
+ readonly requiresReload: boolean;
40
+ /** A profile write (save, approve, discard) in flight. */
41
+ readonly profileWritePending: boolean;
42
+ /** A 409 REVISION_CONFLICT / TARGET_MISMATCH: wire to `markServerChanged`. */
43
+ readonly onConflict: () => void;
44
+ /** Wire to `noteOwnWrite` so the refetch is not read as a remote change. */
45
+ readonly onOwnWrite?: (saved: {
46
+ readonly revision?: number | null;
47
+ } | null | undefined) => void;
48
+ readonly notify?: (event: BrandPublicVisibilityEvent) => void;
49
+ /** Same duck-typed check as the concurrency hook's default classifier. */
50
+ readonly isConflict?: (error: unknown) => boolean;
51
+ }
52
+ /**
53
+ * CEL-2127 — the public-visibility toggle handler for the brand workspace.
54
+ * One in-flight write per org+field; refuses while a reload is required or a
55
+ * profile write is pending; a CAS conflict marks the server as changed rather
56
+ * than retrying (the user must see the latest values first).
57
+ */
58
+ export declare function useBrandPublicVisibility(options: UseBrandPublicVisibilityOptions): (field: BrandPublicField, next: boolean) => void;
59
+ //# sourceMappingURL=use-brand-public-visibility.d.ts.map