use-vibes 0.4.0 → 0.4.3

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 (72) hide show
  1. package/README.md +1 -0
  2. package/dist/components/ControlsBar.d.ts +32 -0
  3. package/dist/components/ControlsBar.js +80 -0
  4. package/dist/components/ControlsBar.js.map +1 -0
  5. package/dist/components/ImgGen.css +523 -0
  6. package/dist/components/ImgGen.d.ts +36 -0
  7. package/dist/components/ImgGen.js +206 -0
  8. package/dist/components/ImgGen.js.map +1 -0
  9. package/dist/components/ImgGenUtils/ImgGenDisplay.d.ts +3 -0
  10. package/dist/components/ImgGenUtils/ImgGenDisplay.js +251 -0
  11. package/dist/components/ImgGenUtils/ImgGenDisplay.js.map +1 -0
  12. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.d.ts +3 -0
  13. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js +115 -0
  14. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +1 -0
  15. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +44 -0
  16. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js +127 -0
  17. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js.map +1 -0
  18. package/dist/components/ImgGenUtils/ImgGenError.d.ts +3 -0
  19. package/dist/components/ImgGenUtils/ImgGenError.js +9 -0
  20. package/dist/components/ImgGenUtils/ImgGenError.js.map +1 -0
  21. package/dist/components/ImgGenUtils/ImgGenModal.d.ts +31 -0
  22. package/dist/components/ImgGenUtils/ImgGenModal.js +31 -0
  23. package/dist/components/ImgGenUtils/ImgGenModal.js.map +1 -0
  24. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +7 -0
  25. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js +8 -0
  26. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js.map +1 -0
  27. package/dist/components/ImgGenUtils/index.d.ts +5 -0
  28. package/dist/components/ImgGenUtils/index.js +8 -0
  29. package/dist/components/ImgGenUtils/index.js.map +1 -0
  30. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.d.ts +10 -0
  31. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js +32 -0
  32. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js.map +1 -0
  33. package/dist/components/ImgGenUtils/overlays/ImageOverlay.d.ts +29 -0
  34. package/dist/components/ImgGenUtils/overlays/ImageOverlay.js +11 -0
  35. package/dist/components/ImgGenUtils/overlays/ImageOverlay.js.map +1 -0
  36. package/dist/components/ImgGenUtils/types.d.ts +37 -0
  37. package/dist/components/ImgGenUtils/types.js +2 -0
  38. package/dist/components/ImgGenUtils/types.js.map +1 -0
  39. package/dist/components/ImgGenUtils.d.ts +6 -0
  40. package/dist/components/ImgGenUtils.js +7 -0
  41. package/dist/components/ImgGenUtils.js.map +1 -0
  42. package/dist/components/PromptBar.d.ts +15 -0
  43. package/dist/components/PromptBar.js +23 -0
  44. package/dist/components/PromptBar.js.map +1 -0
  45. package/dist/hooks/image-gen/image-generator.d.ts +14 -0
  46. package/dist/hooks/image-gen/image-generator.js +78 -0
  47. package/dist/hooks/image-gen/image-generator.js.map +1 -0
  48. package/dist/hooks/image-gen/index.d.ts +6 -0
  49. package/dist/hooks/image-gen/index.js +6 -0
  50. package/dist/hooks/image-gen/index.js.map +1 -0
  51. package/dist/hooks/image-gen/types.d.ts +75 -0
  52. package/dist/hooks/image-gen/types.js +2 -0
  53. package/dist/hooks/image-gen/types.js.map +1 -0
  54. package/dist/hooks/image-gen/use-image-gen.d.ts +12 -0
  55. package/dist/hooks/image-gen/use-image-gen.js +573 -0
  56. package/dist/hooks/image-gen/use-image-gen.js.map +1 -0
  57. package/dist/hooks/image-gen/utils.d.ts +61 -0
  58. package/dist/hooks/image-gen/utils.js +241 -0
  59. package/dist/hooks/image-gen/utils.js.map +1 -0
  60. package/dist/hooks/use-image-gen.d.ts +5 -0
  61. package/dist/hooks/use-image-gen.js +7 -0
  62. package/dist/hooks/use-image-gen.js.map +1 -0
  63. package/dist/index.d.ts +5 -0
  64. package/dist/index.js +6 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/style-loader.d.ts +16 -0
  67. package/dist/style-loader.js +43 -0
  68. package/dist/style-loader.js.map +1 -0
  69. package/dist/utils/style-utils.d.ts +51 -0
  70. package/dist/utils/style-utils.js +42 -0
  71. package/dist/utils/style-utils.js.map +1 -0
  72. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ import { ImageDocument } from '../../hooks/image-gen/types';
2
+ export interface EnhancedVersionInfo {
3
+ id: string;
4
+ created?: number;
5
+ promptKey?: string;
6
+ prompt?: string;
7
+ }
8
+ type VersionInfoResult = {
9
+ versions: EnhancedVersionInfo[];
10
+ currentVersion: number;
11
+ };
12
+ /**
13
+ * Get version information from document or create defaults
14
+ */
15
+ export declare function getVersionInfo(document: ImageDocument & {
16
+ _id: string;
17
+ }): VersionInfoResult;
18
+ /**
19
+ * Get prompt information from the document
20
+ * @param document The image document
21
+ * @param versionIndex Optional index of the version to get prompt for
22
+ */
23
+ export declare function getPromptInfo(document: ImageDocument & {
24
+ _id: string;
25
+ }, versionIndex?: number): {
26
+ currentPrompt: string;
27
+ prompts: Record<string, import("../../hooks/image-gen/types").PromptEntry>;
28
+ currentPromptKey: string;
29
+ } | {
30
+ currentPrompt: string;
31
+ prompts: {
32
+ legacy: {
33
+ text: string;
34
+ };
35
+ };
36
+ currentPromptKey: string;
37
+ };
38
+ /**
39
+ * Get the current version file key
40
+ */
41
+ export declare function getCurrentFileKey(document: ImageDocument & {
42
+ _id: string;
43
+ }, versionIndex: number, versions: EnhancedVersionInfo[]): string | null;
44
+ export {};
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Get version information from document or create defaults
3
+ */
4
+ export function getVersionInfo(document) {
5
+ // Check if document has proper version structure
6
+ if (document?.versions && document.versions.length > 0) {
7
+ // Convert to enhanced version info with possible prompt fields
8
+ // Define type for document version entries to avoid using 'any'
9
+ const enhancedVersions = document.versions.map((v) => {
10
+ // Check if this version has a direct prompt property (legacy format)
11
+ // Use our typed interface for legacy format
12
+ const versionWithPrompt = v;
13
+ const prompt = versionWithPrompt.prompt || undefined;
14
+ return {
15
+ ...v,
16
+ prompt,
17
+ };
18
+ });
19
+ return {
20
+ versions: enhancedVersions,
21
+ // Use currentVersion directly (now 0-based) or default to last version
22
+ currentVersion: typeof document.currentVersion === 'number'
23
+ ? document.currentVersion
24
+ : document.versions.length - 1,
25
+ };
26
+ }
27
+ // Legacy document with just an 'image' file - treat as single version
28
+ if (document?._files && document._files.image) {
29
+ return {
30
+ versions: [{ id: 'image', created: document.created || Date.now() }],
31
+ currentVersion: 0, // Now 0-based
32
+ };
33
+ }
34
+ // No versions found
35
+ return { versions: [], currentVersion: 0 };
36
+ }
37
+ /**
38
+ * Get prompt information from the document
39
+ * @param document The image document
40
+ * @param versionIndex Optional index of the version to get prompt for
41
+ */
42
+ export function getPromptInfo(document, versionIndex) {
43
+ try {
44
+ // If versionIndex is provided, try to get the version-specific prompt
45
+ if (typeof versionIndex === 'number') {
46
+ const { versions } = getVersionInfo(document);
47
+ // Make sure we have valid data
48
+ if (versions &&
49
+ Array.isArray(versions) &&
50
+ versionIndex >= 0 &&
51
+ versionIndex < versions.length) {
52
+ const version = versions[versionIndex];
53
+ // APPROACH 1: Check if this version has a promptKey defined
54
+ const promptKey = version.promptKey || 'p1';
55
+ // First check if we have prompts and this version's promptKey
56
+ if (document?.prompts && promptKey && document.prompts[promptKey]) {
57
+ return {
58
+ currentPrompt: document.prompts[promptKey].text || '',
59
+ prompts: document.prompts,
60
+ currentPromptKey: promptKey,
61
+ };
62
+ }
63
+ // APPROACH 2: Check for version.prompt in EnhancedVersionInfo
64
+ if (version.prompt) {
65
+ return {
66
+ currentPrompt: version.prompt,
67
+ prompts: { ...(document.prompts || {}), legacy: { text: version.prompt } },
68
+ currentPromptKey: 'legacy',
69
+ };
70
+ }
71
+ // APPROACH 3: Check for promptMap in the document (legacy format)
72
+ // Use our typed interface for legacy format
73
+ const docWithPromptMap = document;
74
+ if (docWithPromptMap.promptMap && version.id && docWithPromptMap.promptMap[version.id]) {
75
+ const legacyPrompt = docWithPromptMap.promptMap[version.id];
76
+ return {
77
+ currentPrompt: legacyPrompt,
78
+ prompts: { legacy: { text: legacyPrompt } },
79
+ currentPromptKey: 'legacy',
80
+ };
81
+ }
82
+ }
83
+ }
84
+ }
85
+ catch (e) {
86
+ console.error('Error getting version-specific prompt:', e);
87
+ }
88
+ // If we don't have a specific version prompt or there was an error, fall back to default behavior
89
+ // If we have the new prompts structure
90
+ if (document?.prompts && document.currentPromptKey) {
91
+ return {
92
+ currentPrompt: document.prompts[document.currentPromptKey]?.text || '',
93
+ prompts: document.prompts,
94
+ currentPromptKey: document.currentPromptKey,
95
+ };
96
+ }
97
+ // Legacy document with just a prompt field
98
+ if (document?.prompt) {
99
+ return {
100
+ currentPrompt: document.prompt,
101
+ prompts: { p1: { text: document.prompt, created: document.created || Date.now() } },
102
+ currentPromptKey: 'p1',
103
+ };
104
+ }
105
+ // No prompt found
106
+ return { currentPrompt: '', prompts: {}, currentPromptKey: '' };
107
+ }
108
+ /**
109
+ * Get the current version file key
110
+ */
111
+ export function getCurrentFileKey(document, versionIndex, versions) {
112
+ if (!versions || versions.length === 0)
113
+ return null;
114
+ // If we have versions, use the ID from the current version index
115
+ if (versions.length > versionIndex) {
116
+ const versionId = versions[versionIndex].id;
117
+ if (document._files && document._files[versionId]) {
118
+ return versionId;
119
+ }
120
+ }
121
+ // Fallback to 'image' for legacy docs
122
+ if (document._files && document._files.image) {
123
+ return 'image';
124
+ }
125
+ return null;
126
+ }
127
+ //# sourceMappingURL=ImgGenDisplayUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenDisplayUtils.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/ImgGenDisplayUtils.ts"],"names":[],"mappings":"AAgCA;;GAEG;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AAC;QAAE,OAAO,IAAI,CAAC;IAEpD,iEAAiE;IACjE,IAAI,QAAQ,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;QAC5C,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAClD,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,sCAAsC;IACtC,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { ImgGenErrorProps } from './types';
3
+ export declare function ImgGenError({ message, className, classes }: ImgGenErrorProps): React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { combineClasses, defaultClasses } from '../../utils/style-utils';
3
+ // Component for displaying errors
4
+ export function ImgGenError({ message, className, classes = defaultClasses }) {
5
+ return (React.createElement("div", { className: combineClasses('imggen-error', className, classes.error) },
6
+ React.createElement("h3", { className: "imggen-error-title" }, "Error"),
7
+ React.createElement("p", { className: "imggen-error-message" }, message || 'Failed to render image')));
8
+ }
9
+ //# sourceMappingURL=ImgGenError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenError.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/ImgGenError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzE,kCAAkC;AAClC,MAAM,UAAU,WAAW,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,cAAc,EAAoB;IAC5F,OAAO,CACL,6BAAK,SAAS,EAAE,cAAc,CAAC,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC;QACtE,4BAAI,SAAS,EAAC,oBAAoB,YAAW;QAC7C,2BAAG,SAAS,EAAC,sBAAsB,IAAE,OAAO,IAAI,wBAAwB,CAAK,CACzE,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ export interface ImgGenModalProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ currentFile: File | undefined;
6
+ alt?: string;
7
+ promptText: string;
8
+ editedPrompt: string | null;
9
+ setEditedPrompt: (_editedPrompt: string | null) => void;
10
+ handlePromptEdit: (_newPrompt: string) => void;
11
+ handleDeleteConfirm: () => void;
12
+ handlePrevVersion: () => void;
13
+ handleNextVersion: () => void;
14
+ handleRegen: () => void;
15
+ versionIndex: number;
16
+ totalVersions: number;
17
+ progress: number;
18
+ /** Whether to show a flash effect on the version indicator - used when a new version is added */
19
+ versionFlash?: boolean;
20
+ isRegenerating?: boolean;
21
+ /** Error if image generation failed */
22
+ error?: Error | null;
23
+ classes?: {
24
+ root?: string;
25
+ image?: string;
26
+ controls?: string;
27
+ overlay?: string;
28
+ modal?: string;
29
+ };
30
+ }
31
+ export declare function ImgGenModal({ isOpen, onClose, currentFile, alt, promptText, editedPrompt, setEditedPrompt, handlePromptEdit, handleDeleteConfirm, handlePrevVersion, handleNextVersion, handleRegen, versionIndex, totalVersions, progress, versionFlash, isRegenerating, error, classes, }: ImgGenModalProps): React.ReactPortal | null;
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ import { ImgFile } from 'use-fireproof';
3
+ import { createPortal } from 'react-dom';
4
+ import { ImageOverlay } from './overlays/ImageOverlay';
5
+ import { ImgGenError } from './ImgGenError';
6
+ import { defaultClasses } from '../../utils/style-utils';
7
+ export function ImgGenModal({ isOpen, onClose, currentFile, alt, promptText, editedPrompt, setEditedPrompt, handlePromptEdit, handleDeleteConfirm, handlePrevVersion, handleNextVersion, handleRegen, versionIndex, totalVersions, progress, versionFlash = false, isRegenerating = false, error = null, classes = defaultClasses, }) {
8
+ // ESC handling while modal is open
9
+ React.useEffect(() => {
10
+ const handleEsc = (e) => {
11
+ if (e.key === 'Escape') {
12
+ onClose();
13
+ }
14
+ };
15
+ if (isOpen) {
16
+ window.addEventListener('keydown', handleEsc);
17
+ return () => window.removeEventListener('keydown', handleEsc);
18
+ }
19
+ }, [isOpen, onClose]);
20
+ if (!isOpen || !currentFile) {
21
+ return null;
22
+ }
23
+ // Determine what prompt to show in the modal
24
+ const effectivePromptText = promptText;
25
+ return createPortal(React.createElement("div", { className: "imggen-backdrop", onClick: onClose, role: "presentation" },
26
+ React.createElement("figure", { className: "imggen-full-wrapper", onClick: (e) => e.stopPropagation() },
27
+ error ? (React.createElement("div", { className: "imggen-backdrop-error" },
28
+ React.createElement(ImgGenError, { message: error.message }))) : (React.createElement(ImgFile, { file: currentFile, className: "imggen-backdrop-image", alt: alt || 'Generated image' })),
29
+ React.createElement(ImageOverlay, { promptText: effectivePromptText, editedPrompt: editedPrompt, setEditedPrompt: setEditedPrompt, handlePromptEdit: handlePromptEdit, handleDeleteConfirm: handleDeleteConfirm, handlePrevVersion: handlePrevVersion, handleNextVersion: handleNextVersion, handleRegen: handleRegen, versionIndex: versionIndex, totalVersions: totalVersions, progress: progress, versionFlash: versionFlash, isRegenerating: isRegenerating, classes: classes, showDelete: true }))), globalThis.document.body);
30
+ }
31
+ //# sourceMappingURL=ImgGenModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenModal.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/ImgGenModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD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E,KAAK,CAAC,CAAC,CAAC,CACP,6BAAK,SAAS,EAAC,uBAAuB;gBACpC,oBAAC,WAAW,IAAC,OAAO,EAAE,KAAK,CAAC,OAAO,GAAI,CACnC,CACP,CAAC,CAAC,CAAC,CACF,oBAAC,OAAO,IACN,IAAI,EAAE,WAAW,EACjB,SAAS,EAAC,uBAAuB,EACjC,GAAG,EAAE,GAAG,IAAI,iBAAiB,GAC7B,CACH;YAED,oBAAC,YAAY,IACX,UAAU,EAAE,mBAAmB,EAC/B,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,IAAI,GAChB,CACK,CACL,EACN,UAAU,CAAC,QAAQ,CAAC,IAAI,CACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import '../ImgGen.css';
3
+ import { ImgGenClasses } from '../../utils/style-utils';
4
+ export declare function ImgGenPromptWaiting({ className, classes, }: {
5
+ className?: string;
6
+ classes?: ImgGenClasses;
7
+ }): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import '../ImgGen.css';
3
+ import { combineClasses, defaultClasses } from '../../utils/style-utils';
4
+ // Component for when neither prompt nor _id is provided
5
+ export function ImgGenPromptWaiting({ className, classes = defaultClasses, }) {
6
+ return (React.createElement("div", { className: combineClasses('imggen-placeholder', className, classes.placeholder) }, "Waiting for prompt"));
7
+ }
8
+ //# sourceMappingURL=ImgGenPromptWaiting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenPromptWaiting.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/ImgGenPromptWaiting.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,yBAAyB,CAAC;AAExF,wDAAwD;AACxD,MAAM,UAAU,mBAAmB,CAAC,EAClC,SAAS,EACT,OAAO,GAAG,cAAc,GAIzB;IACC,OAAO,CACL,6BAAK,SAAS,EAAE,cAAc,CAAC,oBAAoB,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,yBAE9E,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { ImgGenPromptWaiting } from './ImgGenPromptWaiting';
2
+ export { ImgGenError } from './ImgGenError';
3
+ export { ImgGenDisplayPlaceholder } from './ImgGenDisplayPlaceholder';
4
+ export { ImgGenDisplay } from './ImgGenDisplay';
5
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ // Export all components from the ImgGenUtils directory
2
+ export { ImgGenPromptWaiting } from './ImgGenPromptWaiting';
3
+ export { ImgGenError } from './ImgGenError';
4
+ export { ImgGenDisplayPlaceholder } from './ImgGenDisplayPlaceholder';
5
+ export { ImgGenDisplay } from './ImgGenDisplay';
6
+ // Export types
7
+ export * from './types';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,eAAe;AACf,cAAc,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { ImgGenClasses } from '../../../utils/style-utils';
3
+ interface DeleteConfirmationOverlayProps {
4
+ handleDeleteConfirm: () => void;
5
+ handleCancelDelete: () => void;
6
+ /** Custom CSS classes for styling component parts */
7
+ classes?: ImgGenClasses;
8
+ }
9
+ export declare function DeleteConfirmationOverlay({ handleDeleteConfirm, handleCancelDelete, classes, }: DeleteConfirmationOverlayProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ import { combineClasses, defaultClasses } from '../../../utils/style-utils';
3
+ export function DeleteConfirmationOverlay({ handleDeleteConfirm, handleCancelDelete, classes = defaultClasses, }) {
4
+ // Using React's useEffect to automatically dismiss the confirmation after 3 seconds
5
+ React.useEffect(() => {
6
+ const timeoutId = setTimeout(() => {
7
+ handleCancelDelete();
8
+ }, 3000); // Auto-dismiss after 3 seconds
9
+ return () => clearTimeout(timeoutId);
10
+ }, [handleCancelDelete]);
11
+ return (React.createElement("div", { className: combineClasses('imggen-delete-message', classes.overlay), style: {
12
+ display: 'flex',
13
+ alignItems: 'center',
14
+ justifyContent: 'center',
15
+ backgroundColor: 'rgba(255, 0, 0, 0.1)',
16
+ borderRadius: 'var(--imggen-border-radius)',
17
+ padding: '10px 15px',
18
+ marginBottom: '8px',
19
+ textAlign: 'center',
20
+ width: 'auto',
21
+ boxSizing: 'border-box',
22
+ border: '1px solid var(--imggen-error-border)',
23
+ cursor: 'pointer',
24
+ }, onClick: handleDeleteConfirm, "aria-label": "Confirm delete" },
25
+ React.createElement("p", { style: {
26
+ color: '#ff3333',
27
+ fontSize: '14px',
28
+ margin: 0,
29
+ fontWeight: 'bold',
30
+ } }, "Confirm delete? This action cannot be undone.")));
31
+ }
32
+ //# sourceMappingURL=DeleteConfirmationOverlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteConfirmationOverlay.js","sourceRoot":"","sources":["../../../../src/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,4BAA4B,CAAC;AAS3F,MAAM,UAAU,yBAAyB,CAAC,EACxC,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,GAAG,cAAc,GACO;IAC/B,oFAAoF;IACpF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,kBAAkB,EAAE,CAAC;QACvB,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,+BAA+B;QAEzC,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,6BACE,SAAS,EAAE,cAAc,CAAC,uBAAuB,EAAE,OAAO,CAAC,OAAO,CAAC,EACnE,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,eAAe,EAAE,sBAAsB;YACvC,YAAY,EAAE,6BAA6B;YAC3C,OAAO,EAAE,WAAW;YACpB,YAAY,EAAE,KAAK;YACnB,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,YAAY;YACvB,MAAM,EAAE,sCAAsC;YAC9C,MAAM,EAAE,SAAS;SAClB,EACD,OAAO,EAAE,mBAAmB,gBACjB,gBAAgB;QAE3B,2BACE,KAAK,EAAE;gBACL,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE,MAAM;gBAChB,MAAM,EAAE,CAAC;gBACT,UAAU,EAAE,MAAM;aACnB,oDAGC,CACA,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ import * as React from 'react';
2
+ import { ImgGenClasses } from '../../../utils/style-utils';
3
+ interface ImageOverlayProps {
4
+ promptText: string;
5
+ editedPrompt: string | null;
6
+ setEditedPrompt: (prompt: string | null) => void;
7
+ handlePromptEdit: (prompt: string) => void;
8
+ /** Function to handle deletion confirmation */
9
+ handleDeleteConfirm: () => void;
10
+ handlePrevVersion: () => void;
11
+ handleNextVersion: () => void;
12
+ handleRegen: () => void;
13
+ versionIndex: number;
14
+ totalVersions: number;
15
+ /** Custom CSS classes for styling component parts */
16
+ classes?: ImgGenClasses;
17
+ /** Show control buttons (defaults to true) */
18
+ showControls?: boolean;
19
+ /** Progress value for generation (0-100), shows progress bar when < 100 */
20
+ progress?: number;
21
+ /** Show delete button (defaults to true) */
22
+ showDelete?: boolean;
23
+ /** Whether to show a flash effect on the version indicator - used when a new version is added */
24
+ versionFlash?: boolean;
25
+ /** Whether regeneration is currently in progress */
26
+ isRegenerating?: boolean;
27
+ }
28
+ export declare function ImageOverlay({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, handleDeleteConfirm, handlePrevVersion, handleNextVersion, handleRegen, versionIndex, totalVersions, classes, showControls, progress, showDelete, versionFlash, isRegenerating, }: ImageOverlayProps): React.JSX.Element;
29
+ export {};
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { combineClasses, defaultClasses } from '../../../utils/style-utils';
3
+ import { PromptBar } from '../../../components/PromptBar';
4
+ import { ControlsBar } from '../../../components/ControlsBar';
5
+ export function ImageOverlay({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, handleDeleteConfirm, handlePrevVersion, handleNextVersion, handleRegen, versionIndex, totalVersions, classes = defaultClasses, showControls = true, progress = 100, showDelete = true, versionFlash = false, isRegenerating = false, }) {
6
+ // Normal overlay content regardless of delete confirmation state
7
+ return (React.createElement("div", { className: combineClasses('imggen-overlay', classes.overlay), style: { position: 'relative' } }, React.createElement(React.Fragment, null,
8
+ React.createElement(PromptBar, { promptText: promptText, editedPrompt: editedPrompt, setEditedPrompt: setEditedPrompt, handlePromptEdit: handlePromptEdit, classes: classes }),
9
+ React.createElement(ControlsBar, { handleDeleteConfirm: handleDeleteConfirm, handlePrevVersion: handlePrevVersion, handleNextVersion: handleNextVersion, handleRegen: handleRegen, versionIndex: versionIndex, totalVersions: totalVersions, classes: classes, showControls: showControls, showDelete: showDelete, editedPrompt: editedPrompt, promptText: promptText, progress: progress, versionFlash: versionFlash, isRegenerating: isRegenerating }))));
10
+ }
11
+ //# sourceMappingURL=ImageOverlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageOverlay.js","sourceRoot":"","sources":["../../../../src/components/ImgGenUtils/overlays/ImageOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AA8B9D,MAAM,UAAU,YAAY,CAAC,EAC3B,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,OAAO,GAAG,cAAc,EACxB,YAAY,GAAG,IAAI,EACnB,QAAQ,GAAG,GAAG,EACd,UAAU,GAAG,IAAI,EACjB,YAAY,GAAG,KAAK,EACpB,cAAc,GAAG,KAAK,GACJ;IAClB,iEAAiE;IACjE,OAAO,CACL,6BACE,SAAS,EAAE,cAAc,CAAC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,EAC5D,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,IAG7B;QAEE,oBAAC,SAAS,IACR,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,OAAO,GAChB;QAGF,oBAAC,WAAW,IACV,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,GAC9B,CACD,CAED,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { ImageDocument } from '../../hooks/image-gen/types';
2
+ import { ImgGenClasses } from '../../utils/style-utils';
3
+ export interface ImgGenPlaceholderProps {
4
+ className?: string;
5
+ alt?: string;
6
+ prompt?: string;
7
+ progress: number;
8
+ error?: Error | null;
9
+ classes?: ImgGenClasses;
10
+ }
11
+ export interface ImgGenDisplayProps {
12
+ document: ImageDocument & {
13
+ _id: string;
14
+ };
15
+ className?: string;
16
+ alt?: string;
17
+ /** Callback when delete is confirmed - receives document ID */
18
+ onDelete?: (id: string) => void;
19
+ /** Callback when regeneration is requested - receives document ID */
20
+ onRegen?: (id: string) => void;
21
+ /** Callback when prompt is edited - receives document ID and new prompt */
22
+ onPromptEdit?: (id: string, newPrompt: string) => void;
23
+ /** Custom CSS classes for styling component parts */
24
+ classes?: ImgGenClasses;
25
+ /** Whether the component is currently loading */
26
+ loading?: boolean;
27
+ /** Error if image generation failed */
28
+ error?: Error | null;
29
+ }
30
+ export interface ImgGenErrorProps {
31
+ /** Optional error message to display */
32
+ message?: string;
33
+ /** Optional CSS class name */
34
+ className?: string;
35
+ /** Custom CSS classes for styling component parts */
36
+ classes?: ImgGenClasses;
37
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Re-export all components from the ImgGenUtils directory
3
+ * This maintains backwards compatibility with existing imports
4
+ */
5
+ export { ImgGenPromptWaiting, ImgGenError, ImgGenDisplayPlaceholder, ImgGenDisplay, } from './ImgGenUtils/index';
6
+ export * from './ImgGenUtils/types';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Re-export all components from the ImgGenUtils directory
3
+ * This maintains backwards compatibility with existing imports
4
+ */
5
+ export { ImgGenPromptWaiting, ImgGenError, ImgGenDisplayPlaceholder, ImgGenDisplay, } from './ImgGenUtils/index';
6
+ export * from './ImgGenUtils/types';
7
+ //# sourceMappingURL=ImgGenUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenUtils.js","sourceRoot":"","sources":["../../src/components/ImgGenUtils.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,wBAAwB,EACxB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { ImgGenClasses } from '../utils/style-utils';
3
+ interface PromptBarProps {
4
+ promptText: string;
5
+ editedPrompt: string | null;
6
+ setEditedPrompt: (prompt: string | null) => void;
7
+ handlePromptEdit: (prompt: string) => void;
8
+ /** Custom CSS classes for styling component parts */
9
+ classes?: ImgGenClasses;
10
+ }
11
+ /**
12
+ * PromptBar component - Displays and allows editing of the prompt text
13
+ */
14
+ export declare function PromptBar({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, classes, }: PromptBarProps): React.JSX.Element;
15
+ export {};
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { combineClasses, defaultClasses } from '../utils/style-utils';
3
+ /**
4
+ * PromptBar component - Displays and allows editing of the prompt text
5
+ */
6
+ export function PromptBar({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, classes = defaultClasses, }) {
7
+ return (React.createElement("div", { className: "imggen-top-line" },
8
+ React.createElement("div", { className: combineClasses('imggen-prompt', classes.prompt) }, editedPrompt !== null ? (React.createElement("input", { type: "text", value: editedPrompt, onChange: (e) => setEditedPrompt(e.target.value), onKeyDown: (e) => {
9
+ if (e.key === 'Enter') {
10
+ e.preventDefault();
11
+ handlePromptEdit(editedPrompt);
12
+ }
13
+ else if (e.key === 'Escape') {
14
+ setEditedPrompt(null); // Exit edit mode
15
+ }
16
+ },
17
+ // Removed onBlur handler to prevent edit mode from being exited when clicking buttons
18
+ autoFocus: true, className: "imggen-prompt-input imggen-edit-mode", "aria-label": "Edit prompt" })) : (React.createElement("div", { onClick: () => {
19
+ // Enter edit mode on single click
20
+ setEditedPrompt(promptText);
21
+ }, className: "imggen-prompt-text imggen-truncate", title: "Click to edit prompt" }, promptText)))));
22
+ }
23
+ //# sourceMappingURL=PromptBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromptBar.js","sourceRoot":"","sources":["../../src/components/PromptBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AAarF;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,OAAO,GAAG,cAAc,GACT;IACf,OAAO,CACL,6BAAK,SAAS,EAAC,iBAAiB;QAC9B,6BAAK,SAAS,EAAE,cAAc,CAAC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,IAC5D,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,CACvB,+BACE,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAChD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;gBACf,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;oBACtB,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBACjC,CAAC;qBAAM,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;oBAC9B,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB;gBAC1C,CAAC;YACH,CAAC;YACD,sFAAsF;YACtF,SAAS,QACT,SAAS,EAAC,sCAAsC,gBACrC,aAAa,GACxB,CACH,CAAC,CAAC,CAAC,CACF,6BACE,OAAO,EAAE,GAAG,EAAE;gBACZ,kCAAkC;gBAClC,eAAe,CAAC,UAAU,CAAC,CAAC;YAC9B,CAAC,EACD,SAAS,EAAC,oCAAoC,EAC9C,KAAK,EAAC,sBAAsB,IAE3B,UAAU,CACP,CACP,CACG,CACF,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { ImageGenOptions as BaseImageGenOptions, ImageResponse } from 'call-ai';
2
+ interface ImageGenOptions extends BaseImageGenOptions {
3
+ _regenerationId?: number;
4
+ }
5
+ /**
6
+ * Wrapper for imageGen that prevents duplicate calls
7
+ * This function maintains a module-level cache to prevent duplicate API calls
8
+ */
9
+ export declare function imageGen(prompt: string, options?: ImageGenOptions): Promise<ImageResponse>;
10
+ /**
11
+ * Create a wrapper function for generating images with logging and tracking
12
+ */
13
+ export declare function createImageGenerator(requestHash: string): (promptText: string, genOptions?: ImageGenOptions) => Promise<ImageResponse>;
14
+ export {};
@@ -0,0 +1,78 @@
1
+ import { imageGen as originalImageGen, } from 'call-ai';
2
+ import { MODULE_STATE, getRelevantOptions } from './utils';
3
+ /**
4
+ * Wrapper for imageGen that prevents duplicate calls
5
+ * This function maintains a module-level cache to prevent duplicate API calls
6
+ */
7
+ export function imageGen(prompt, options) {
8
+ // Get the relevant options to form a stable key
9
+ const relevantOptions = getRelevantOptions(options);
10
+ // Track regeneration requests when an ID is provided
11
+ // This was previously used for logging, which has been removed
12
+ // Create a stable key for the request cache
13
+ // Include regeneration ID if present to ensure unique keys for regeneration requests
14
+ const stableKey = options?._regenerationId
15
+ ? `${prompt}-${JSON.stringify(relevantOptions)}-regen-${options._regenerationId}`
16
+ : `${prompt}-${JSON.stringify(relevantOptions)}`;
17
+ // Create a unique ID for this specific request instance (for logging)
18
+ const requestId = ++MODULE_STATE.requestCounter;
19
+ // Check if this prompt+options combination is already being processed
20
+ if (MODULE_STATE.pendingPrompts.has(stableKey)) {
21
+ // Return the existing promise for this prompt+options combination
22
+ if (MODULE_STATE.pendingImageGenCalls.has(stableKey)) {
23
+ return MODULE_STATE.pendingImageGenCalls.get(stableKey);
24
+ }
25
+ }
26
+ // Mark this prompt+options as being processed
27
+ MODULE_STATE.pendingPrompts.add(stableKey);
28
+ MODULE_STATE.processingRequests.add(stableKey);
29
+ MODULE_STATE.requestTimestamps.set(stableKey, Date.now());
30
+ let promise;
31
+ try {
32
+ // Direct import from call-ai - this works consistently with test mocks
33
+ promise = originalImageGen(prompt, options);
34
+ }
35
+ catch (e) {
36
+ console.error(`[ImgGen Debug] Error with imageGen for request #${requestId}:`, e);
37
+ promise = Promise.reject(e);
38
+ }
39
+ // Store the promise so other requests for the same prompt+options can use it
40
+ MODULE_STATE.pendingImageGenCalls.set(stableKey, promise);
41
+ // Clean up after the promise resolves or rejects
42
+ promise
43
+ .then((response) => {
44
+ // Remove from processing set but KEEP in pendingPrompts to ensure deduplication persists
45
+ // until page reload
46
+ MODULE_STATE.processingRequests.delete(stableKey);
47
+ return response;
48
+ })
49
+ .catch((error) => {
50
+ console.error(`[ImgGen Debug] Request #${requestId} failed [key:${stableKey.slice(0, 12)}...]: ${error}`);
51
+ // Even on failure, we'll keep the key in pendingPrompts to prevent repeated failures
52
+ // but remove it from processing to allow potential retries after page reload
53
+ MODULE_STATE.processingRequests.delete(stableKey);
54
+ return Promise.reject(error);
55
+ });
56
+ return promise;
57
+ }
58
+ /**
59
+ * Create a wrapper function for generating images with logging and tracking
60
+ */
61
+ export function createImageGenerator(requestHash) {
62
+ return async (promptText, genOptions) => {
63
+ // Options key no longer used for logging
64
+ JSON.stringify(getRelevantOptions(genOptions)); // Still generate to maintain behavior
65
+ // Log detailed information about this request - including request hash and options
66
+ try {
67
+ const response = await imageGen(promptText, genOptions);
68
+ // Time tracking no longer used
69
+ // Previously: const duration = Date.now() - startTime;
70
+ return response;
71
+ }
72
+ catch (error) {
73
+ console.error(`[ImgGen Debug] Failed request [ID:${requestHash}]: ${error}`);
74
+ throw error;
75
+ }
76
+ };
77
+ }
78
+ //# sourceMappingURL=image-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-generator.js","sourceRoot":"","sources":["../../../src/hooks/image-gen/image-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,IAAI,gBAAgB,GAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAO3D;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,OAAyB;IAChE,gDAAgD;IAChD,MAAM,eAAe,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAEpD,qDAAqD;IACrD,+DAA+D;IAE/D,4CAA4C;IAC5C,qFAAqF;IACrF,MAAM,SAAS,GAAG,OAAO,EAAE,eAAe;QACxC,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,UAAU,OAAO,CAAC,eAAe,EAAE;QACjF,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;IAEnD,sEAAsE;IACtE,MAAM,SAAS,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC;IAEhD,sEAAsE;IACtE,IAAI,YAAY,CAAC,cAAc,CAAC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