@powerhousedao/vetra 6.2.0-dev.20 → 6.2.0-dev.22
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/{editor-CM9tpwzR.js → editor-B560eld_.js} +15 -15
- package/dist/editor-B560eld_.js.map +1 -0
- package/dist/{editor-rYCWiter.js → editor-CAVHtR-v.js} +6 -6
- package/dist/editor-CAVHtR-v.js.map +1 -0
- package/dist/{editor-D-QqGEkw.js → editor-CVCLxUhe.js} +14 -14
- package/dist/editor-CVCLxUhe.js.map +1 -0
- package/dist/{editor-BamOOi9L.js → editor-DnG2Zzet.js} +10 -10
- package/dist/editor-DnG2Zzet.js.map +1 -0
- package/dist/{editor-Dz3cXtzn.js → editor-mor7dV6n.js} +56 -56
- package/dist/editor-mor7dV6n.js.map +1 -0
- package/dist/{editor-je4HFt2f.js → editor-xCnDas6c.js} +30 -30
- package/dist/editor-xCnDas6c.js.map +1 -0
- package/dist/editors/components/index.js +1 -1
- package/dist/editors/components/index.js.map +1 -1
- package/dist/editors/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{module-DvO77TZz.js → module-DySsSIQV.js} +7 -7
- package/dist/{module-DvO77TZz.js.map → module-DySsSIQV.js.map} +1 -1
- package/package.json +24 -10
- package/dist/editor-BamOOi9L.js.map +0 -1
- package/dist/editor-CM9tpwzR.js.map +0 -1
- package/dist/editor-D-QqGEkw.js.map +0 -1
- package/dist/editor-Dz3cXtzn.js.map +0 -1
- package/dist/editor-je4HFt2f.js.map +0 -1
- package/dist/editor-rYCWiter.js.map +0 -1
|
@@ -52,7 +52,7 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
52
52
|
/* @__PURE__ */ jsxs("div", {
|
|
53
53
|
className: "flex items-center justify-between",
|
|
54
54
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
55
|
-
className: "text-lg font-medium text-
|
|
55
|
+
className: "text-lg font-medium text-foreground",
|
|
56
56
|
children: "Processor Configuration"
|
|
57
57
|
}), /* @__PURE__ */ jsx(StatusPill, {
|
|
58
58
|
status: status === "CONFIRMED" ? "confirmed" : "draft",
|
|
@@ -61,7 +61,7 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
61
61
|
}),
|
|
62
62
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
63
63
|
htmlFor: "processor-name",
|
|
64
|
-
className: "mb-2 block text-sm font-medium text-
|
|
64
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
65
65
|
children: "Processor Name"
|
|
66
66
|
}), /* @__PURE__ */ jsx("input", {
|
|
67
67
|
id: "processor-name",
|
|
@@ -69,19 +69,19 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
69
69
|
value: processorName,
|
|
70
70
|
onChange: (e) => setProcessorName(e.target.value),
|
|
71
71
|
disabled: isReadOnly,
|
|
72
|
-
className: twMerge("w-full rounded-md border border-
|
|
72
|
+
className: twMerge("w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect", isReadOnly ? "cursor-not-allowed bg-muted text-muted-foreground" : ""),
|
|
73
73
|
placeholder: "Enter processor name"
|
|
74
74
|
})] }),
|
|
75
75
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
76
76
|
htmlFor: "processor-type",
|
|
77
|
-
className: "mb-2 block text-sm font-medium text-
|
|
77
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
78
78
|
children: "Type"
|
|
79
79
|
}), /* @__PURE__ */ jsxs("select", {
|
|
80
80
|
id: "processor-type",
|
|
81
81
|
value: processorType,
|
|
82
82
|
onChange: (e) => setProcessorType(e.target.value),
|
|
83
83
|
disabled: isReadOnly,
|
|
84
|
-
className: twMerge("w-full rounded-md border border-
|
|
84
|
+
className: twMerge("w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none", isReadOnly ? "cursor-not-allowed bg-muted" : ""),
|
|
85
85
|
children: [
|
|
86
86
|
/* @__PURE__ */ jsx("option", {
|
|
87
87
|
value: "",
|
|
@@ -99,7 +99,7 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
99
99
|
})] }),
|
|
100
100
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
101
101
|
htmlFor: "document-types",
|
|
102
|
-
className: "mb-2 block text-sm font-medium text-
|
|
102
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
103
103
|
children: "Document Types"
|
|
104
104
|
}), /* @__PURE__ */ jsxs("div", {
|
|
105
105
|
className: "space-y-2",
|
|
@@ -119,7 +119,7 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
119
119
|
}
|
|
120
120
|
setSelectedDocumentType("");
|
|
121
121
|
},
|
|
122
|
-
className: "w-full rounded-md border border-
|
|
122
|
+
className: "w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none",
|
|
123
123
|
children: [/* @__PURE__ */ jsx("option", {
|
|
124
124
|
value: "",
|
|
125
125
|
children: "Select a document type to add"
|
|
@@ -132,11 +132,11 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
132
132
|
children: documentTypes.map((type) => /* @__PURE__ */ jsxs("div", {
|
|
133
133
|
className: "flex items-center py-1",
|
|
134
134
|
children: [/* @__PURE__ */ jsx("span", {
|
|
135
|
-
className: "text-sm text-
|
|
135
|
+
className: "text-sm text-foreground",
|
|
136
136
|
children: type.documentType
|
|
137
137
|
}), !isReadOnly && /* @__PURE__ */ jsx("button", {
|
|
138
138
|
onClick: () => handleRemoveDocumentType(type.id),
|
|
139
|
-
className: "ml-2 text-
|
|
139
|
+
className: "ml-2 text-muted-foreground hover:hover-effect focus:outline-none",
|
|
140
140
|
children: "×"
|
|
141
141
|
})]
|
|
142
142
|
}, type.id))
|
|
@@ -144,7 +144,7 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
144
144
|
})] }),
|
|
145
145
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
146
146
|
htmlFor: "processor-apps",
|
|
147
|
-
className: "mb-2 block text-sm font-medium text-
|
|
147
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
148
148
|
children: "Processor Apps"
|
|
149
149
|
}), /* @__PURE__ */ jsxs("div", {
|
|
150
150
|
className: "space-y-2",
|
|
@@ -166,13 +166,13 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
166
166
|
}
|
|
167
167
|
}), /* @__PURE__ */ jsx("label", {
|
|
168
168
|
htmlFor: processorApp,
|
|
169
|
-
className: "text-
|
|
169
|
+
className: "text-foreground",
|
|
170
170
|
children: processorApp
|
|
171
171
|
})]
|
|
172
172
|
}, processorApp)) }), /* @__PURE__ */ jsx("div", {
|
|
173
173
|
className: "space-y-1",
|
|
174
174
|
children: isReadOnly && processorApps.map((processorApp) => /* @__PURE__ */ jsx("span", {
|
|
175
|
-
className: "text-sm text-
|
|
175
|
+
className: "text-sm text-foreground",
|
|
176
176
|
children: processorApp
|
|
177
177
|
}, processorApp))
|
|
178
178
|
})]
|
|
@@ -180,7 +180,7 @@ const ProcessorEditorForm = ({ processorName: initialProcessorName = "", process
|
|
|
180
180
|
!isReadOnly && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", {
|
|
181
181
|
onClick: handleConfirm,
|
|
182
182
|
disabled: !canConfirm,
|
|
183
|
-
className: "rounded-md bg-
|
|
183
|
+
className: "rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect",
|
|
184
184
|
children: "Confirm"
|
|
185
185
|
}) })
|
|
186
186
|
]
|
|
@@ -221,7 +221,7 @@ function Editor() {
|
|
|
221
221
|
dispatch(removeProcessorApp({ processorApp }));
|
|
222
222
|
}, [dispatch]);
|
|
223
223
|
return /* @__PURE__ */ jsxs("div", {
|
|
224
|
-
className: "bg-
|
|
224
|
+
className: "bg-background p-6",
|
|
225
225
|
children: [/* @__PURE__ */ jsx(DocumentToolbar, {}), /* @__PURE__ */ jsx(ProcessorEditorForm, {
|
|
226
226
|
onNameChange,
|
|
227
227
|
onTypeChange,
|
|
@@ -241,4 +241,4 @@ function Editor() {
|
|
|
241
241
|
//#endregion
|
|
242
242
|
export { Editor as default };
|
|
243
243
|
|
|
244
|
-
//# sourceMappingURL=editor-
|
|
244
|
+
//# sourceMappingURL=editor-B560eld_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-B560eld_.js","names":[],"sources":["../editors/processor-editor/components/ProcessorEditorForm.tsx","../editors/processor-editor/config.ts","../editors/processor-editor/editor.tsx"],"sourcesContent":["import {\n PROCESSOR_APPS,\n type ProcessorApp,\n type ProcessorApps,\n} from \"@powerhousedao/shared/processors\";\nimport { useEffect, useState } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport type { DocumentTypeItem } from \"../../../document-models/processor-module/index.js\";\nimport { StatusPill } from \"../../components/index.js\";\nimport { useAvailableDocumentTypes, useDebounce } from \"../../hooks/index.js\";\n\nexport interface ProcessorEditorFormProps {\n processorName?: string;\n processorType?: string;\n documentTypes?: DocumentTypeItem[];\n processorApps?: ProcessorApps;\n status?: string;\n onNameChange?: (name: string) => void;\n onTypeChange?: (type: string) => void;\n onAddDocumentType?: (id: string, documentType: string) => void;\n onRemoveDocumentType?: (id: string) => void;\n onAddProcessorApp?: (processorApp: ProcessorApp) => void;\n onRemoveProcessorApp?: (processorApp: ProcessorApp) => void;\n onConfirm?: () => void;\n}\n\nexport const ProcessorEditorForm: React.FC<ProcessorEditorFormProps> = ({\n processorName: initialProcessorName = \"\",\n processorType: initialProcessorType = \"\",\n documentTypes: initialDocumentTypes = [],\n processorApps: initialProcessorApps = [],\n status = \"DRAFT\",\n onNameChange,\n onTypeChange,\n onAddDocumentType,\n onRemoveDocumentType,\n onAddProcessorApp,\n onRemoveProcessorApp,\n onConfirm,\n}) => {\n const [processorName, setProcessorName] = useState(initialProcessorName);\n const [processorType, setProcessorType] = useState(initialProcessorType);\n const [documentTypes, setDocumentTypes] =\n useState<DocumentTypeItem[]>(initialDocumentTypes);\n const [selectedDocumentType, setSelectedDocumentType] = useState(\"\");\n const [processorApps, setProcessorApps] = useState(initialProcessorApps);\n const [isConfirmed, setIsConfirmed] = useState(false);\n\n // Get available document types from the hook (combines reactor and vetra drive)\n const availableDocumentTypes = useAvailableDocumentTypes();\n\n // Use the debounce hook for name and type changes\n useDebounce(processorName, onNameChange, 300);\n useDebounce(processorType, onTypeChange, 300);\n\n // Update local state when initial values change\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setProcessorName(initialProcessorName);\n }, [initialProcessorName]);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setProcessorType(initialProcessorType);\n }, [initialProcessorType]);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setDocumentTypes(initialDocumentTypes);\n }, [initialDocumentTypes]);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setProcessorApps(initialProcessorApps);\n }, [initialProcessorApps]);\n\n // Reset confirmation state if status changes back to DRAFT\n useEffect(() => {\n if (status === \"DRAFT\") {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsConfirmed(false);\n }\n }, [status]);\n\n // Check if form should be read-only\n const isReadOnly = isConfirmed || status === \"CONFIRMED\";\n\n const handleConfirm = () => {\n if (\n processorName.trim() &&\n processorType &&\n documentTypes.length > 0 &&\n processorApps.length > 0\n ) {\n setIsConfirmed(true); // Immediate UI update\n onConfirm?.();\n }\n };\n\n const handleRemoveDocumentType = (id: string) => {\n setDocumentTypes(documentTypes.filter((dt) => dt.id !== id));\n onRemoveDocumentType?.(id);\n };\n\n const canConfirm =\n !!processorName.trim() &&\n !!processorType &&\n documentTypes.length > 0 &&\n processorApps.length > 0;\n\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-lg font-medium text-foreground\">\n Processor Configuration\n </h2>\n <StatusPill\n status={status === \"CONFIRMED\" ? \"confirmed\" : \"draft\"}\n label={status === \"CONFIRMED\" ? \"Confirmed\" : \"Draft\"}\n />\n </div>\n\n {/* Processor Name Field */}\n <div>\n <label\n htmlFor=\"processor-name\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Processor Name\n </label>\n <input\n id=\"processor-name\"\n type=\"text\"\n value={processorName}\n onChange={(e) => setProcessorName(e.target.value)}\n disabled={isReadOnly}\n className={twMerge(\n \"w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect\",\n isReadOnly\n ? \"cursor-not-allowed bg-muted text-muted-foreground\"\n : \"\",\n )}\n placeholder=\"Enter processor name\"\n />\n </div>\n\n {/* Processor Type Dropdown */}\n <div>\n <label\n htmlFor=\"processor-type\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Type\n </label>\n <select\n id=\"processor-type\"\n value={processorType}\n onChange={(e) => setProcessorType(e.target.value)}\n disabled={isReadOnly}\n className={twMerge(\n \"w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none\",\n isReadOnly ? \"cursor-not-allowed bg-muted\" : \"\",\n )}\n >\n <option value=\"\">Select type...</option>\n <option value=\"analytics\">Analytics</option>\n <option value=\"relational\">Relational Database</option>\n </select>\n </div>\n\n {/* Document Types Field */}\n <div>\n <label\n htmlFor=\"document-types\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Document Types\n </label>\n <div className=\"space-y-2\">\n {!isReadOnly && availableDocumentTypes.length > 0 && (\n <select\n id=\"document-types\"\n value={selectedDocumentType}\n onChange={(e) => {\n const selectedValue = e.target.value;\n if (\n selectedValue &&\n !documentTypes.some((dt) => dt.documentType === selectedValue)\n ) {\n const id = Date.now().toString();\n const newType: DocumentTypeItem = {\n id,\n documentType: selectedValue,\n };\n setDocumentTypes([...documentTypes, newType]);\n onAddDocumentType?.(id, selectedValue);\n }\n setSelectedDocumentType(\"\");\n }}\n className=\"w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none\"\n >\n <option value=\"\">Select a document type to add</option>\n {availableDocumentTypes\n .filter(\n (docType) =>\n !documentTypes.some((dt) => dt.documentType === docType),\n )\n .map((docType) => (\n <option key={docType} value={docType}>\n {docType}\n </option>\n ))}\n </select>\n )}\n <div className=\"space-y-1\">\n {documentTypes.map((type) => (\n <div key={type.id} className=\"flex items-center py-1\">\n <span className=\"text-sm text-foreground\">\n {type.documentType}\n </span>\n {!isReadOnly && (\n <button\n onClick={() => handleRemoveDocumentType(type.id)}\n className=\"ml-2 text-muted-foreground hover:hover-effect focus:outline-none\"\n >\n ×\n </button>\n )}\n </div>\n ))}\n </div>\n </div>\n </div>\n {/* Processor Apps Field */}\n <div>\n <label\n htmlFor=\"processor-apps\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Processor Apps\n </label>\n <div className=\"space-y-2\">\n {!isReadOnly && (\n <>\n {PROCESSOR_APPS.map((processorApp) => (\n <div key={processorApp} className=\"flex gap-1\">\n <input\n type=\"checkbox\"\n name={processorApp}\n id={processorApp}\n checked={processorApps.includes(processorApp)}\n onChange={(event) => {\n const isChecked = event.target.checked;\n if (isChecked) {\n setProcessorApps((processorApps) => [\n ...new Set([...processorApps, processorApp]),\n ]);\n onAddProcessorApp?.(processorApp);\n } else {\n if (processorApps.length > 1) {\n setProcessorApps((processorApps) =>\n processorApps.filter((p) => p !== processorApp),\n );\n onRemoveProcessorApp?.(processorApp);\n }\n }\n }}\n />\n <label htmlFor={processorApp} className=\"text-foreground\">\n {processorApp}\n </label>\n </div>\n ))}\n </>\n )}\n <div className=\"space-y-1\">\n {isReadOnly &&\n processorApps.map((processorApp) => (\n <span key={processorApp} className=\"text-sm text-foreground\">\n {processorApp}\n </span>\n ))}\n </div>\n </div>\n </div>\n {/* Confirm Button - only show if not in read-only mode */}\n {!isReadOnly && (\n <div>\n <button\n onClick={handleConfirm}\n disabled={!canConfirm}\n className=\"rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect\"\n >\n Confirm\n </button>\n </div>\n )}\n </div>\n );\n};\n","import type { PHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\n\nexport const editorConfig: PHDocumentEditorConfig = {\n isExternalControlsEnabled: false,\n};\n","import { DocumentToolbar } from \"@powerhousedao/design-system/connect\";\nimport { useSetPHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\nimport type {\n ProcessorApp,\n ProcessorApps,\n} from \"@powerhousedao/shared/processors\";\nimport { useCallback } from \"react\";\nimport {\n addDocumentType,\n addProcessorApp,\n removeDocumentType,\n removeProcessorApp,\n setProcessorName,\n setProcessorStatus,\n setProcessorType,\n} from \"../../document-models/processor-module/index.js\";\nimport { useSelectedProcessorModuleDocument } from \"../hooks/useVetraDocument.js\";\nimport { ProcessorEditorForm } from \"./components/ProcessorEditorForm.js\";\nimport { editorConfig } from \"./config.js\";\n\nexport default function Editor() {\n useSetPHDocumentEditorConfig(editorConfig);\n const [document, dispatch] = useSelectedProcessorModuleDocument();\n\n const onConfirm = useCallback(() => {\n // Dispatch all actions at once\n dispatch([setProcessorStatus({ status: \"CONFIRMED\" })]);\n }, [dispatch]);\n\n const onNameChange = useCallback(\n (name: string) => {\n if (name === document.state.global.name) return;\n dispatch(setProcessorName({ name }));\n },\n [document.state.global.name, dispatch],\n );\n\n const onTypeChange = useCallback(\n (type: string) => {\n if (type === document.state.global.type) return;\n dispatch(setProcessorType({ type }));\n },\n [document.state.global.type, dispatch],\n );\n\n const onAddDocumentType = useCallback(\n (id: string, documentType: string) => {\n dispatch(addDocumentType({ id, documentType }));\n },\n [dispatch],\n );\n\n const onRemoveDocumentType = useCallback(\n (id: string) => {\n dispatch(removeDocumentType({ id }));\n },\n [dispatch],\n );\n\n const onAddProcessorApp = useCallback(\n (processorApp: ProcessorApp) => {\n dispatch(addProcessorApp({ processorApp }));\n },\n [dispatch],\n );\n\n const onRemoveProcessorApp = useCallback(\n (processorApp: ProcessorApp) => {\n dispatch(removeProcessorApp({ processorApp }));\n },\n [dispatch],\n );\n\n return (\n <div className=\"bg-background p-6\">\n <DocumentToolbar />\n <ProcessorEditorForm\n onNameChange={onNameChange}\n onTypeChange={onTypeChange}\n onAddDocumentType={onAddDocumentType}\n onRemoveDocumentType={onRemoveDocumentType}\n onAddProcessorApp={onAddProcessorApp}\n onRemoveProcessorApp={onRemoveProcessorApp}\n status={document.state.global.status}\n processorName={document.state.global.name ?? \"\"}\n processorType={document.state.global.type ?? \"\"}\n documentTypes={document.state.global.documentTypes ?? []}\n processorApps={document.state.global.processorApps as ProcessorApps}\n onConfirm={onConfirm}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AA0BA,MAAa,uBAA2D,EACtE,eAAe,uBAAuB,IACtC,eAAe,uBAAuB,IACtC,eAAe,uBAAuB,EAAE,EACxC,eAAe,uBAAuB,EAAE,EACxC,SAAS,SACT,cACA,cACA,mBACA,sBACA,mBACA,sBACA,gBACI;CACJ,MAAM,CAAC,eAAe,oBAAoB,SAAS,qBAAqB;CACxE,MAAM,CAAC,eAAe,oBAAoB,SAAS,qBAAqB;CACxE,MAAM,CAAC,eAAe,oBACpB,SAA6B,qBAAqB;CACpD,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,GAAG;CACpE,MAAM,CAAC,eAAe,oBAAoB,SAAS,qBAAqB;CACxE,MAAM,CAAC,aAAa,kBAAkB,S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;GAC7C,eAAe,SAAS,MAAM,OAAO,iBAAiB,EAAE;GACxD,eAAe,SAAS,MAAM,OAAO;GAC1B;GACX,CAAA,CACE"}
|
|
@@ -31,7 +31,7 @@ const SubgraphEditorForm = ({ subgraphName: initialSubgraphName = "", status = "
|
|
|
31
31
|
/* @__PURE__ */ jsxs("div", {
|
|
32
32
|
className: "flex items-center justify-between",
|
|
33
33
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
34
|
-
className: "text-lg font-medium text-
|
|
34
|
+
className: "text-lg font-medium text-foreground",
|
|
35
35
|
children: "Subgraph Configuration"
|
|
36
36
|
}), /* @__PURE__ */ jsx(StatusPill, {
|
|
37
37
|
status: status === "CONFIRMED" ? "confirmed" : "draft",
|
|
@@ -40,7 +40,7 @@ const SubgraphEditorForm = ({ subgraphName: initialSubgraphName = "", status = "
|
|
|
40
40
|
}),
|
|
41
41
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
42
42
|
htmlFor: "subgraph-name",
|
|
43
|
-
className: "mb-2 block text-sm font-medium text-
|
|
43
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
44
44
|
children: "Subgraph Name"
|
|
45
45
|
}), /* @__PURE__ */ jsx("input", {
|
|
46
46
|
id: "subgraph-name",
|
|
@@ -48,13 +48,13 @@ const SubgraphEditorForm = ({ subgraphName: initialSubgraphName = "", status = "
|
|
|
48
48
|
value: subgraphName,
|
|
49
49
|
onChange: (e) => setSubgraphName(e.target.value),
|
|
50
50
|
disabled: isReadOnly,
|
|
51
|
-
className: twMerge("w-full rounded-md border border-
|
|
51
|
+
className: twMerge("w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect", isReadOnly ? "cursor-not-allowed bg-muted" : ""),
|
|
52
52
|
placeholder: "Enter subgraph name"
|
|
53
53
|
})] }),
|
|
54
54
|
!isReadOnly && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", {
|
|
55
55
|
onClick: handleConfirm,
|
|
56
56
|
disabled: !subgraphName.trim(),
|
|
57
|
-
className: "rounded-md bg-
|
|
57
|
+
className: "rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect",
|
|
58
58
|
children: "Confirm"
|
|
59
59
|
}) })
|
|
60
60
|
]
|
|
@@ -76,7 +76,7 @@ function Editor() {
|
|
|
76
76
|
dispatch(setSubgraphStatus({ status: "CONFIRMED" }));
|
|
77
77
|
}, [dispatch]);
|
|
78
78
|
return /* @__PURE__ */ jsxs("div", {
|
|
79
|
-
className: "bg-
|
|
79
|
+
className: "bg-background p-6",
|
|
80
80
|
children: [/* @__PURE__ */ jsx(DocumentToolbar, {}), /* @__PURE__ */ jsx(SubgraphEditorForm, {
|
|
81
81
|
subgraphName: document.state.global.name ?? "",
|
|
82
82
|
status: document.state.global.status,
|
|
@@ -88,4 +88,4 @@ function Editor() {
|
|
|
88
88
|
//#endregion
|
|
89
89
|
export { Editor as default };
|
|
90
90
|
|
|
91
|
-
//# sourceMappingURL=editor-
|
|
91
|
+
//# sourceMappingURL=editor-CAVHtR-v.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-CAVHtR-v.js","names":[],"sources":["../editors/subgraph-editor/components/SubgraphEditorForm.tsx","../editors/subgraph-editor/config.ts","../editors/subgraph-editor/editor.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { StatusPill } from \"../../components/index.js\";\nimport { useDebounce } from \"../../hooks/index.js\";\n\nexport interface SubgraphEditorFormProps {\n subgraphName?: string;\n status?: string;\n onNameChange?: (name: string) => void;\n onConfirm?: () => void;\n}\n\nexport const SubgraphEditorForm: React.FC<SubgraphEditorFormProps> = ({\n subgraphName: initialSubgraphName = \"\",\n status = \"DRAFT\",\n onNameChange,\n onConfirm,\n}) => {\n const [subgraphName, setSubgraphName] = useState(initialSubgraphName);\n const [isConfirmed, setIsConfirmed] = useState(false);\n\n // Use the debounce hook for name changes\n useDebounce(subgraphName, onNameChange, 300);\n\n // Update local state when initialSubgraphName changes\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setSubgraphName(initialSubgraphName);\n }, [initialSubgraphName]);\n\n // Reset confirmation state if status changes back to DRAFT\n useEffect(() => {\n if (status === \"DRAFT\") {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsConfirmed(false);\n }\n }, [status]);\n\n // Check if form should be read-only\n const isReadOnly = isConfirmed || status === \"CONFIRMED\";\n\n const handleConfirm = () => {\n if (subgraphName.trim()) {\n setIsConfirmed(true); // Immediate UI update\n onConfirm?.();\n }\n };\n\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-lg font-medium text-foreground\">\n Subgraph Configuration\n </h2>\n <StatusPill\n status={status === \"CONFIRMED\" ? \"confirmed\" : \"draft\"}\n label={status === \"CONFIRMED\" ? \"Confirmed\" : \"Draft\"}\n />\n </div>\n\n {/* Subgraph Name Field */}\n <div>\n <label\n htmlFor=\"subgraph-name\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Subgraph Name\n </label>\n <input\n id=\"subgraph-name\"\n type=\"text\"\n value={subgraphName}\n onChange={(e) => setSubgraphName(e.target.value)}\n disabled={isReadOnly}\n className={twMerge(\n \"w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect\",\n isReadOnly ? \"cursor-not-allowed bg-muted\" : \"\",\n )}\n placeholder=\"Enter subgraph name\"\n />\n </div>\n\n {/* Confirm Button - only show if not in read-only mode */}\n {!isReadOnly && (\n <div>\n <button\n onClick={handleConfirm}\n disabled={!subgraphName.trim()}\n className=\"rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect\"\n >\n Confirm\n </button>\n </div>\n )}\n </div>\n );\n};\n","import type { PHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\n\nexport const editorConfig: PHDocumentEditorConfig = {\n isExternalControlsEnabled: false,\n};\n","import { DocumentToolbar } from \"@powerhousedao/design-system/connect\";\nimport { useSetPHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\nimport {\n setSubgraphName,\n setSubgraphStatus,\n} from \"@powerhousedao/vetra/document-models/subgraph-module\";\nimport { useCallback } from \"react\";\nimport { useSelectedSubgraphModuleDocument } from \"../hooks/useVetraDocument.js\";\nimport { SubgraphEditorForm } from \"./components/SubgraphEditorForm.js\";\nimport { editorConfig } from \"./config.js\";\n\nexport default function Editor() {\n useSetPHDocumentEditorConfig(editorConfig);\n const [document, dispatch] = useSelectedSubgraphModuleDocument();\n\n const onNameChange = useCallback(\n (name: string) => {\n if (name === document.state.global.name) return;\n dispatch(setSubgraphName({ name }));\n },\n [document.state.global.name, dispatch],\n );\n\n const onConfirm = useCallback(() => {\n dispatch(setSubgraphStatus({ status: \"CONFIRMED\" }));\n }, [dispatch]);\n\n return (\n <div className=\"bg-background p-6\">\n <DocumentToolbar />\n <SubgraphEditorForm\n subgraphName={document.state.global.name ?? \"\"}\n status={document.state.global.status}\n onNameChange={onNameChange}\n onConfirm={onConfirm}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAa,sBAAyD,EACpE,cAAc,sBAAsB,IACpC,SAAS,SACT,cACA,gBACI;CACJ,MAAM,CAAC,cAAc,mBAAmB,SAAS,oBAAoB;CACrE,MAAM,CAAC,aAAa,kBAAkB,SAAS,MAAM;AAGrD,aAAY,cAAc,cAAc,IAAI;AAG5C,iBAAgB;AAEd,kBAAgB,oBAAoB;IACnC,CAAC,oBAAoB,CAAC;AAGzB,iBAAgB;AACd,MAAI,WAAW,QAEb,gBAAe,MAAM;IAEt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E,oBAAC,iBAAD,EAAmB,CAAA,EACnB,oBAAC,oBAAD;GACE,cAAc,SAAS,MAAM,OAAO,QAAQ;GAC5C,QAAQ,SAAS,MAAM,OAAO;GAChB;GACH;GACX,CAAA,CACE"}
|
|
@@ -79,7 +79,7 @@ const AppEditorForm = () => {
|
|
|
79
79
|
/* @__PURE__ */ jsxs("div", {
|
|
80
80
|
className: "flex items-center justify-between",
|
|
81
81
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
82
|
-
className: "text-lg font-medium text-
|
|
82
|
+
className: "text-lg font-medium text-foreground",
|
|
83
83
|
children: "App Configuration"
|
|
84
84
|
}), /* @__PURE__ */ jsx(StatusPill, {
|
|
85
85
|
status: status === "CONFIRMED" ? "confirmed" : "draft",
|
|
@@ -88,7 +88,7 @@ const AppEditorForm = () => {
|
|
|
88
88
|
}),
|
|
89
89
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
90
90
|
htmlFor: "app-name",
|
|
91
|
-
className: "mb-2 block text-sm font-medium text-
|
|
91
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
92
92
|
children: "App Name"
|
|
93
93
|
}), /* @__PURE__ */ jsx("input", {
|
|
94
94
|
id: "app-name",
|
|
@@ -96,18 +96,18 @@ const AppEditorForm = () => {
|
|
|
96
96
|
value: appName,
|
|
97
97
|
onChange: (e) => handleSetAppName(e.target.value),
|
|
98
98
|
disabled: isReadOnly,
|
|
99
|
-
className: twMerge("w-full rounded-md border border-
|
|
99
|
+
className: twMerge("w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect", isReadOnly ? "cursor-not-allowed bg-muted" : ""),
|
|
100
100
|
placeholder: "Enter app name"
|
|
101
101
|
})] }),
|
|
102
102
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
103
103
|
htmlFor: "document-types",
|
|
104
|
-
className: "mb-2 block text-sm font-medium text-
|
|
104
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
105
105
|
children: "Document Types"
|
|
106
106
|
}), /* @__PURE__ */ jsxs("div", {
|
|
107
107
|
className: "space-y-2",
|
|
108
108
|
children: [!isReadOnly && /* @__PURE__ */ jsxs("select", {
|
|
109
109
|
onChange: (e) => handleDocumentTypeSelection(e.target.value),
|
|
110
|
-
className: "w-full rounded-md border border-
|
|
110
|
+
className: "w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none",
|
|
111
111
|
children: [
|
|
112
112
|
/* @__PURE__ */ jsx("option", { children: "Select a document type to add" }),
|
|
113
113
|
/* @__PURE__ */ jsx("option", { children: "--- Vetra drive document types ---" }),
|
|
@@ -139,21 +139,21 @@ const AppEditorForm = () => {
|
|
|
139
139
|
children: selectedDocumentTypes.length > 0 ? selectedDocumentTypes.map((type) => /* @__PURE__ */ jsxs("div", {
|
|
140
140
|
className: "flex items-center py-1",
|
|
141
141
|
children: [/* @__PURE__ */ jsx("span", {
|
|
142
|
-
className: "text-sm text-
|
|
142
|
+
className: "text-sm text-foreground",
|
|
143
143
|
children: type
|
|
144
144
|
}), !isReadOnly && /* @__PURE__ */ jsx("button", {
|
|
145
145
|
onClick: () => handleRemoveDocumentType(type),
|
|
146
|
-
className: "ml-2 text-
|
|
146
|
+
className: "ml-2 text-muted-foreground hover:hover-effect focus:outline-none",
|
|
147
147
|
children: "×"
|
|
148
148
|
})]
|
|
149
149
|
}, type)) : /* @__PURE__ */ jsx("span", {
|
|
150
|
-
className: "text-sm text-
|
|
150
|
+
className: "text-sm text-foreground",
|
|
151
151
|
children: "All documents (*)"
|
|
152
152
|
})
|
|
153
153
|
})]
|
|
154
154
|
})] }),
|
|
155
155
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
156
|
-
className: "mb-4 text-base font-medium text-
|
|
156
|
+
className: "mb-4 text-base font-medium text-foreground",
|
|
157
157
|
children: "Drag and Drop Settings"
|
|
158
158
|
}), /* @__PURE__ */ jsx("div", {
|
|
159
159
|
className: "mb-4",
|
|
@@ -166,9 +166,9 @@ const AppEditorForm = () => {
|
|
|
166
166
|
checked: isDragAndDropEnabled,
|
|
167
167
|
onChange: (e) => onDragAndDropToggle(e.target.checked),
|
|
168
168
|
disabled: isReadOnly,
|
|
169
|
-
className: twMerge("mr-2 size-4 rounded-sm border-
|
|
169
|
+
className: twMerge("mr-2 size-4 rounded-sm border-border text-info focus:ring-ring", isReadOnly ? "cursor-not-allowed" : "")
|
|
170
170
|
}), /* @__PURE__ */ jsx("span", {
|
|
171
|
-
className: "text-sm font-medium text-
|
|
171
|
+
className: "text-sm font-medium text-foreground",
|
|
172
172
|
children: "Enable drag and drop"
|
|
173
173
|
})]
|
|
174
174
|
})
|
|
@@ -176,7 +176,7 @@ const AppEditorForm = () => {
|
|
|
176
176
|
!isReadOnly && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", {
|
|
177
177
|
onClick: handleConfirm,
|
|
178
178
|
disabled: !appName.trim(),
|
|
179
|
-
className: "rounded-md bg-
|
|
179
|
+
className: "rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect",
|
|
180
180
|
children: "Confirm"
|
|
181
181
|
}) })
|
|
182
182
|
]
|
|
@@ -190,11 +190,11 @@ const editorConfig = { isExternalControlsEnabled: false };
|
|
|
190
190
|
function Editor() {
|
|
191
191
|
useSetPHDocumentEditorConfig(editorConfig);
|
|
192
192
|
return /* @__PURE__ */ jsxs("div", {
|
|
193
|
-
className: "bg-
|
|
193
|
+
className: "bg-background p-6",
|
|
194
194
|
children: [/* @__PURE__ */ jsx(DocumentToolbar, {}), /* @__PURE__ */ jsx(AppEditorForm, {})]
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
//#endregion
|
|
198
198
|
export { Editor as default };
|
|
199
199
|
|
|
200
|
-
//# sourceMappingURL=editor-
|
|
200
|
+
//# sourceMappingURL=editor-CVCLxUhe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-CVCLxUhe.js","names":[],"sources":["../editors/app-editor/components/AppEditorForm.tsx","../editors/app-editor/config.ts","../editors/app-editor/editor.tsx"],"sourcesContent":["import {\n useDocumentTypesInSelectedDrive,\n useSupportedDocumentTypesInReactor,\n} from \"@powerhousedao/reactor-browser\";\nimport {\n addDocumentType,\n removeDocumentType,\n setAppName,\n setAppStatus,\n setDocumentTypes,\n setDragAndDropEnabled,\n} from \"@powerhousedao/vetra/document-models/app-module\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { useSelectedAppModuleDocument } from \"../../../document-models/app-module/index.js\";\nimport { StatusPill } from \"../../components/index.js\";\nimport { useDebounce } from \"../../hooks/index.js\";\n\nconst ALL_IN_DRIVE = \"all-in-drive\";\nconst ALL_IN_REACTOR = \"all-in-reactor\";\nconst ALLOW_ANY = \"allow-any\";\n\nexport const AppEditorForm = () => {\n const [document, dispatch] = useSelectedAppModuleDocument();\n const documentName = document.state.global.name;\n const status = document.state.global.status;\n const isDragAndDropEnabled = document.state.global.isDragAndDropEnabled;\n const allowedDocumentTypes = document.state.global.allowedDocumentTypes;\n const [appName, handleSetAppName] = useState(documentName);\n const [isConfirmed, setIsConfirmed] = useState(status === \"CONFIRMED\");\n const documentTypesInSelectedDrive = useDocumentTypesInSelectedDrive();\n const supportedDocumentTypesInReactor = useSupportedDocumentTypesInReactor();\n const [selectedDocumentTypes, setSelectedDocumentTypes] = useState(\n allowedDocumentTypes ?? [],\n );\n\n // Use the debounce hook for name changes\n\n const onNameChange = useCallback(\n (name: string) => {\n if (name === documentName) return;\n console.log(\"onNameChange\", name);\n dispatch(setAppName({ name }));\n },\n [documentName, dispatch],\n );\n\n useDebounce(appName, onNameChange, 300);\n\n const onConfirm = () => {\n dispatch(setAppStatus({ status: \"CONFIRMED\" }));\n };\n\n const onDragAndDropToggle = (enabled: boolean) => {\n if (enabled === isDragAndDropEnabled) return;\n dispatch(setDragAndDropEnabled({ enabled }));\n };\n\n // Reset confirmation state if status changes back to DRAFT\n useEffect(() => {\n if (status === \"DRAFT\") {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsConfirmed(false);\n }\n }, [status]);\n\n // Check if form should be read-only\n const isReadOnly = isConfirmed || status === \"CONFIRMED\";\n\n const handleConfirm = () => {\n if (appName.trim()) {\n setIsConfirmed(true); // Immediate UI update\n onConfirm();\n }\n };\n\n const handleAddDocumentType = (documentType: string) => {\n if (!documentType || selectedDocumentTypes.includes(documentType)) return;\n setSelectedDocumentTypes([...selectedDocumentTypes, documentType]);\n dispatch(addDocumentType({ documentType }));\n };\n\n const handleRemoveDocumentType = (documentType: string) => {\n setSelectedDocumentTypes(\n selectedDocumentTypes.filter((dt) => dt !== documentType),\n );\n dispatch(removeDocumentType({ documentType }));\n };\n\n const handleAddAllDocumentTypesInDrive = () => {\n const newDocumentTypes = [\n ...new Set([\n ...selectedDocumentTypes,\n ...(documentTypesInSelectedDrive ?? []),\n ]),\n ];\n setSelectedDocumentTypes(newDocumentTypes);\n dispatch(setDocumentTypes({ documentTypes: newDocumentTypes }));\n };\n\n const handleAddAllDocumentTypesInReactor = () => {\n const newDocumentTypes = [\n ...new Set([\n ...selectedDocumentTypes,\n ...(supportedDocumentTypesInReactor ?? []),\n ]),\n ];\n setSelectedDocumentTypes(newDocumentTypes);\n dispatch(setDocumentTypes({ documentTypes: newDocumentTypes }));\n };\n\n const handleAllowAnyDocumentType = () => {\n setSelectedDocumentTypes([]);\n dispatch(setDocumentTypes({ documentTypes: [] }));\n };\n\n const handleDocumentTypeSelection = (selectedValue: string) => {\n if (selectedValue === ALL_IN_DRIVE) {\n handleAddAllDocumentTypesInDrive();\n } else if (selectedValue === ALL_IN_REACTOR) {\n handleAddAllDocumentTypesInReactor();\n } else if (selectedValue === ALLOW_ANY) {\n handleAllowAnyDocumentType();\n } else {\n handleAddDocumentType(selectedValue);\n }\n };\n\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-lg font-medium text-foreground\">\n App Configuration\n </h2>\n <StatusPill\n status={status === \"CONFIRMED\" ? \"confirmed\" : \"draft\"}\n label={status === \"CONFIRMED\" ? \"Confirmed\" : \"Draft\"}\n />\n </div>\n\n {/* App Name Field */}\n <div>\n <label\n htmlFor=\"app-name\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n App Name\n </label>\n <input\n id=\"app-name\"\n type=\"text\"\n value={appName}\n onChange={(e) => handleSetAppName(e.target.value)}\n disabled={isReadOnly}\n className={twMerge(\n \"w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect\",\n isReadOnly ? \"cursor-not-allowed bg-muted\" : \"\",\n )}\n placeholder=\"Enter app name\"\n />\n </div>\n\n {/* Document Types Field */}\n <div>\n <label\n htmlFor=\"document-types\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Document Types\n </label>\n <div className=\"space-y-2\">\n {!isReadOnly && (\n <select\n onChange={(e) => handleDocumentTypeSelection(e.target.value)}\n className=\"w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none\"\n >\n <option>Select a document type to add</option>\n <option>--- Vetra drive document types ---</option>\n <option value={ALL_IN_DRIVE}>\n Add all document types in Vetra drive\n </option>\n {documentTypesInSelectedDrive\n ?.filter((dt) => !selectedDocumentTypes.includes(dt))\n .map((docType) => (\n <option key={docType} value={docType}>\n {docType}\n </option>\n ))}\n <option>--- Reactor document types ---</option>\n <option value={ALL_IN_REACTOR}>\n Add all document types in Reactor\n </option>\n {supportedDocumentTypesInReactor\n ?.filter((dt) => !selectedDocumentTypes.includes(dt))\n .map((docType) => (\n <option key={docType} value={docType}>\n {docType}\n </option>\n ))}\n <option>--- Allow any document type ---</option>\n <option value={ALLOW_ANY}>Allow any document type</option>\n </select>\n )}\n <div className=\"space-y-1\">\n {selectedDocumentTypes.length > 0 ? (\n selectedDocumentTypes.map((type) => (\n <div key={type} className=\"flex items-center py-1\">\n <span className=\"text-sm text-foreground\">{type}</span>\n {!isReadOnly && (\n <button\n onClick={() => handleRemoveDocumentType(type)}\n className=\"ml-2 text-muted-foreground hover:hover-effect focus:outline-none\"\n >\n ×\n </button>\n )}\n </div>\n ))\n ) : (\n <span className=\"text-sm text-foreground\">All documents (*)</span>\n )}\n </div>\n </div>\n </div>\n\n {/* Drag and Drop Settings */}\n <div>\n <h3 className=\"mb-4 text-base font-medium text-foreground\">\n Drag and Drop Settings\n </h3>\n\n {/* Enable/Disable Switch */}\n <div className=\"mb-4\">\n <label htmlFor=\"drag-and-drop-enabled\" className=\"flex items-center\">\n <input\n id=\"drag-and-drop-enabled\"\n type=\"checkbox\"\n checked={isDragAndDropEnabled}\n onChange={(e) => onDragAndDropToggle(e.target.checked)}\n disabled={isReadOnly}\n className={twMerge(\n \"mr-2 size-4 rounded-sm border-border text-info focus:ring-ring\",\n isReadOnly ? \"cursor-not-allowed\" : \"\",\n )}\n />\n <span className=\"text-sm font-medium text-foreground\">\n Enable drag and drop\n </span>\n </label>\n </div>\n </div>\n\n {/* Confirm Button - only show if not in read-only mode */}\n {!isReadOnly && (\n <div>\n <button\n onClick={handleConfirm}\n disabled={!appName.trim()}\n className=\"rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect\"\n >\n Confirm\n </button>\n </div>\n )}\n </div>\n );\n};\n","import type { PHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\n\nexport const editorConfig: PHDocumentEditorConfig = {\n isExternalControlsEnabled: false,\n};\n","import { DocumentToolbar } from \"@powerhousedao/design-system/connect\";\nimport { useSetPHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\nimport { AppEditorForm } from \"./components/AppEditorForm.js\";\nimport { editorConfig } from \"./config.js\";\n\nexport default function Editor() {\n useSetPHDocumentEditorConfig(editorConfig);\n\n return (\n <div className=\"bg-background p-6\">\n <DocumentToolbar />\n <AppEditorForm />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,eAAe;AACrB,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAElB,MAAa,sBAAsB;CACjC,MAAM,CAAC,UAAU,YAAY,8BAA8B;CAC3D,MAAM,eAAe,SAAS,MAAM,OAAO;CAC3C,MAAM,SAAS,SAAS,MAAM,OAAO;CACrC,MAAM,uBAAuB,SAAS,MAAM,OAAO;CACnD,MAAM,uBAAuB,SAAS,MAAM,OAAO;CACnD,MAAM,CAAC,SAAS,oBAAoB,SAAS,aAAa;CAC1D,MAAM,CAAC,aAAa,kBAAkB,SAAS,WAAW,YAAY;CACtE,MAAM,+BAA+B,iCAAiC;CACtE,MAAM,kCAAkC,oCAAoC;CAC5E,MAAM,CAAC,uBAAuB,4BAA4B,SACxD,wBAAwB,EAAE,CAC3B;AAaD,aAAY,SATS,aAClB,SAAiB;AAChB,MAAI,SAAS,aAAc;AAC3B,UAAQ,IAAI,gBAAgB,KAAK;AACjC,WAAS,WAAW,EAAE,MAAM,CAAC,CAAC;IAEhC,CAAC,cAAc,SAAS,CACzB,EAEkC,IAAI;CAEvC,MAAM,kBAAkB;AACtB,WAAS,aAAa,EAAE,QAAQ,aAAa,CAAC,CAAC;;CAGjD,MAAM,uBAAuB,YAAqB;AAChD,MAAI,YAAY,qBAAsB;AACtC,WAAS,sBAAsB,EAAE,SAAS,CAAC,CAAC;;AAI9C,iBAAgB;AACd,MAAI,WAAW,QAEb,gBAAe,MAAM;IAEtB,CAAC,OAAO,CAAC;CAGZ,MAAM,aAAa,eAAe,WAAW;CAE7C,MAAM,sBAAsB;AAC1B,MAAI,QAAQ,MAAM,EAAE;AAClB,kBA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,WAAU;iBAA2B;OAAY,CAAA,EACtD,CAAC,cACA,oBAAC,UAAD;OACE,eAAe,yBAAyB,KAAK;OAC7C,WAAU;iBACX;OAEQ,CAAA,CAEP;QAVI,KAUJ,CACN,GAEF,oBAAC,QAAD;MAAM,WAAU;gBAA0B;MAAwB,CAAA;KAEhE,CAAA,CACF;MACF,EAAA,CAAA;GAGN,qBAAC,OAAD,EAAA,UAAA,CACE,oBAAC,MAAD;IAAI,WAAU;cAA6C;IAEtD,CAAA,EAGL,oBAAC,OAAD;IAAK,WAAU;cACb,qBAAC,SAAD;KAAO,SAAQ;KAAwB,WAAU;eAAjD,CACE,oBAAC,SAAD;MACE,IAAG;MACH,MAAK;MACL,SAAS;MACT,WAAW,MAAM,oBAAoB,EAAE,OAAO,QAAQ;MACtD,UAAU;MACV,WAAW,QACT,kEACA,aAAa,uBAAuB,GACrC;MACD,CAAA,EACF,oBAAC,QAAD;MAAM,WAAU;gBAAsC;MAE/C,CAAA,CACD;;IACJ,CAAA,CACF,EAAA,CAAA;GAGL,CAAC,cACA,oBAAC,OAAD,EAAA,UACE,oBAAC,UAAD;IACE,SAAS;IACT,UAAU,CAAC,QAAQ,MAAM;IACzB,WAAU;cACX;IAEQ,CAAA,EACL,CAAA;GAEJ;;;;;ACtQV,MAAa,eAAuC,EAClD,2BAA2B,OAC5B;;;ACCD,SAAwB,SAAS;AAC/B,8BAA6B,aAAa;AAE1C,QACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,oBAAC,iBAAD,EAAmB,CAAA,EACnB,oBAAC,eAAD,EAAiB,CAAA,CACb"}
|
|
@@ -11,7 +11,7 @@ import { DocumentToolbar } from "@powerhousedao/design-system/connect";
|
|
|
11
11
|
function DocumentTypeSelectUI(props) {
|
|
12
12
|
return /* @__PURE__ */ jsxs("select", {
|
|
13
13
|
id: "supported-document-types",
|
|
14
|
-
className: "w-full rounded-md border border-
|
|
14
|
+
className: "w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none",
|
|
15
15
|
...props,
|
|
16
16
|
children: [/* @__PURE__ */ jsx("option", {
|
|
17
17
|
value: "",
|
|
@@ -74,7 +74,7 @@ const DocumentEditorForm = ({ editorName: initialEditorName = "", documentTypes:
|
|
|
74
74
|
/* @__PURE__ */ jsxs("div", {
|
|
75
75
|
className: "flex items-center justify-between",
|
|
76
76
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
77
|
-
className: "text-lg font-medium text-
|
|
77
|
+
className: "text-lg font-medium text-foreground",
|
|
78
78
|
children: "Editor Configuration"
|
|
79
79
|
}), /* @__PURE__ */ jsx(StatusPill, {
|
|
80
80
|
status: status === "CONFIRMED" ? "confirmed" : "draft",
|
|
@@ -83,7 +83,7 @@ const DocumentEditorForm = ({ editorName: initialEditorName = "", documentTypes:
|
|
|
83
83
|
}),
|
|
84
84
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
85
85
|
htmlFor: "editor-name",
|
|
86
|
-
className: "mb-2 block text-sm font-medium text-
|
|
86
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
87
87
|
children: "Editor Name"
|
|
88
88
|
}), /* @__PURE__ */ jsx("input", {
|
|
89
89
|
id: "editor-name",
|
|
@@ -91,11 +91,11 @@ const DocumentEditorForm = ({ editorName: initialEditorName = "", documentTypes:
|
|
|
91
91
|
value: editorName,
|
|
92
92
|
onChange: (e) => setEditorName(e.target.value),
|
|
93
93
|
disabled: isReadOnly,
|
|
94
|
-
className: twMerge("w-full rounded-md border border-
|
|
94
|
+
className: twMerge("w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect", isReadOnly ? "cursor-not-allowed bg-muted" : "")
|
|
95
95
|
})] }),
|
|
96
96
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
97
97
|
htmlFor: "supported-document-types",
|
|
98
|
-
className: "mb-2 block text-sm font-medium text-
|
|
98
|
+
className: "mb-2 block text-sm font-medium text-foreground",
|
|
99
99
|
children: "Supported Document Types"
|
|
100
100
|
}), /* @__PURE__ */ jsxs("div", {
|
|
101
101
|
className: "space-y-2",
|
|
@@ -112,14 +112,14 @@ const DocumentEditorForm = ({ editorName: initialEditorName = "", documentTypes:
|
|
|
112
112
|
children: documentTypes.map((type) => /* @__PURE__ */ jsxs("div", {
|
|
113
113
|
className: "flex items-center py-1",
|
|
114
114
|
children: [/* @__PURE__ */ jsx("span", {
|
|
115
|
-
className: "text-sm text-
|
|
115
|
+
className: "text-sm text-foreground",
|
|
116
116
|
children: type.documentType
|
|
117
117
|
}), !isReadOnly && /* @__PURE__ */ jsx("button", {
|
|
118
118
|
onClick: () => {
|
|
119
119
|
setDocumentTypes([]);
|
|
120
120
|
onRemoveDocumentType?.({ id: type.id });
|
|
121
121
|
},
|
|
122
|
-
className: "ml-2 text-
|
|
122
|
+
className: "ml-2 text-muted-foreground hover:hover-effect focus:outline-none",
|
|
123
123
|
children: "×"
|
|
124
124
|
})]
|
|
125
125
|
}, type.id))
|
|
@@ -128,7 +128,7 @@ const DocumentEditorForm = ({ editorName: initialEditorName = "", documentTypes:
|
|
|
128
128
|
!isReadOnly && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", {
|
|
129
129
|
onClick: handleConfirm,
|
|
130
130
|
disabled: !editorName.trim() || documentTypes.length === 0,
|
|
131
|
-
className: "rounded-md bg-
|
|
131
|
+
className: "rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect",
|
|
132
132
|
children: "Confirm"
|
|
133
133
|
}) })
|
|
134
134
|
]
|
|
@@ -157,7 +157,7 @@ function Editor() {
|
|
|
157
157
|
dispatch(setEditorStatus({ status: "CONFIRMED" }));
|
|
158
158
|
}, [dispatch]);
|
|
159
159
|
return /* @__PURE__ */ jsxs("div", {
|
|
160
|
-
className: "bg-
|
|
160
|
+
className: "bg-background p-6",
|
|
161
161
|
children: [/* @__PURE__ */ jsx(DocumentToolbar, {}), /* @__PURE__ */ jsx(DocumentEditorForm, {
|
|
162
162
|
status: document.state.global.status,
|
|
163
163
|
editorName: document.state.global.name ?? "",
|
|
@@ -172,4 +172,4 @@ function Editor() {
|
|
|
172
172
|
//#endregion
|
|
173
173
|
export { Editor as default };
|
|
174
174
|
|
|
175
|
-
//# sourceMappingURL=editor-
|
|
175
|
+
//# sourceMappingURL=editor-DnG2Zzet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-DnG2Zzet.js","names":[],"sources":["../editors/document-editor/components/DocumentEditorForm.tsx","../editors/document-editor/config.ts","../editors/document-editor/editor.tsx"],"sourcesContent":["import { Suspense, useEffect, useState } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport type {\n AddDocumentTypeInput,\n DocumentTypeItem,\n RemoveDocumentTypeInput,\n} from \"../../../document-models/document-editor/index.js\";\nimport { StatusPill } from \"../../components/index.js\";\nimport { useAvailableDocumentTypes, useDebounce } from \"../../hooks/index.js\";\n\nexport interface DocumentEditorFormProps {\n editorName?: string;\n documentTypes?: DocumentTypeItem[];\n status?: string;\n onEditorNameChange?: (name: string) => void;\n onAddDocumentType?: (input: AddDocumentTypeInput) => void;\n onRemoveDocumentType?: (input: RemoveDocumentTypeInput) => void;\n onConfirm?: () => void;\n}\n\nfunction DocumentTypeSelectUI(\n props: React.SelectHTMLAttributes<HTMLSelectElement>,\n) {\n return (\n <select\n id=\"supported-document-types\"\n className=\"w-full rounded-md border border-border px-3 py-2 text-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none\"\n {...props}\n >\n <option value=\"\">Select a document type</option>\n {props.children}\n </select>\n );\n}\n\nfunction DocumentTypeSelect({\n documentTypes,\n setDocumentTypes,\n onAddDocumentType,\n onRemoveDocumentType,\n}: {\n setDocumentTypes: (documentTypes: DocumentTypeItem[]) => void;\n} & Pick<\n DocumentEditorFormProps,\n \"documentTypes\" | \"onAddDocumentType\" | \"onRemoveDocumentType\"\n>) {\n // Get available document types from the hook (vetra drive only for document editor)\n const availableDocumentTypes = useAvailableDocumentTypes(true);\n const [selectedDocumentType, setSelectedDocumentType] = useState(\"\");\n\n return (\n <DocumentTypeSelectUI\n value={selectedDocumentType}\n onChange={(e) => {\n const selectedValue = e.target.value;\n if (selectedValue) {\n // Remove existing document type if any\n\n const existingType = documentTypes?.at(0);\n if (existingType) {\n onRemoveDocumentType?.({ id: existingType.id });\n }\n\n // Add the new document type\n const newTypeInput: AddDocumentTypeInput = {\n id: Date.now().toString(), // Generate a unique ID\n documentType: selectedValue,\n };\n const newType: DocumentTypeItem = {\n id: newTypeInput.id,\n documentType: newTypeInput.documentType,\n };\n setDocumentTypes([newType]); // Replace with single item array\n onAddDocumentType?.(newTypeInput);\n }\n setSelectedDocumentType(\"\");\n }}\n >\n {availableDocumentTypes.map((docType) => (\n <option key={docType} value={docType}>\n {docType}\n </option>\n ))}\n </DocumentTypeSelectUI>\n );\n}\n\nexport const DocumentEditorForm: React.FC<DocumentEditorFormProps> = ({\n editorName: initialEditorName = \"\",\n documentTypes: initialDocumentTypes = [],\n status = \"DRAFT\",\n onEditorNameChange,\n onAddDocumentType,\n onRemoveDocumentType,\n onConfirm,\n}) => {\n const [editorName, setEditorName] = useState(initialEditorName);\n const [documentTypes, setDocumentTypes] =\n useState<DocumentTypeItem[]>(initialDocumentTypes);\n const [isConfirmed, setIsConfirmed] = useState(false);\n\n // Use the debounce hook for name changes\n useDebounce(editorName, onEditorNameChange, 300);\n\n // Update local state when initial values change\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setEditorName(initialEditorName);\n }, [initialEditorName]);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setDocumentTypes(initialDocumentTypes);\n }, [initialDocumentTypes]);\n\n // Reset confirmation state if status changes back to DRAFT\n useEffect(() => {\n if (status === \"DRAFT\") {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsConfirmed(false);\n }\n }, [status]);\n\n // Check if form should be read-only\n const isReadOnly = isConfirmed || status === \"CONFIRMED\";\n\n const handleConfirm = () => {\n if (editorName.trim() && documentTypes.length > 0) {\n setIsConfirmed(true); // Immediate UI update\n onConfirm?.();\n }\n };\n\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-lg font-medium text-foreground\">\n Editor Configuration\n </h2>\n <StatusPill\n status={status === \"CONFIRMED\" ? \"confirmed\" : \"draft\"}\n label={status === \"CONFIRMED\" ? \"Confirmed\" : \"Draft\"}\n />\n </div>\n\n {/* Editor Name Field */}\n <div>\n <label\n htmlFor=\"editor-name\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Editor Name\n </label>\n <input\n id=\"editor-name\"\n type=\"text\"\n value={editorName}\n onChange={(e) => setEditorName(e.target.value)}\n disabled={isReadOnly}\n className={twMerge(\n \"w-full rounded-md border border-border px-3 py-2 text-foreground placeholder:text-muted-foreground focus:border-transparent focus:ring-2 focus:ring-ring focus:outline-none disabled:disabled-effect\",\n isReadOnly ? \"cursor-not-allowed bg-muted\" : \"\",\n )}\n />\n </div>\n\n {/* Supported Document Types Field */}\n <div>\n <label\n htmlFor=\"supported-document-types\"\n className=\"mb-2 block text-sm font-medium text-foreground\"\n >\n Supported Document Types\n </label>\n <div className=\"space-y-2\">\n {!isReadOnly && (\n <Suspense fallback={<DocumentTypeSelectUI />}>\n <DocumentTypeSelect\n documentTypes={documentTypes}\n setDocumentTypes={setDocumentTypes}\n onAddDocumentType={onAddDocumentType}\n onRemoveDocumentType={onRemoveDocumentType}\n />\n </Suspense>\n )}\n <div className=\"space-y-1\">\n {documentTypes.map((type) => (\n <div key={type.id} className=\"flex items-center py-1\">\n <span className=\"text-sm text-foreground\">\n {type.documentType}\n </span>\n {!isReadOnly && (\n <button\n onClick={() => {\n setDocumentTypes([]);\n onRemoveDocumentType?.({ id: type.id });\n }}\n className=\"ml-2 text-muted-foreground hover:hover-effect focus:outline-none\"\n >\n ×\n </button>\n )}\n </div>\n ))}\n </div>\n </div>\n </div>\n\n {/* Confirm Button - only show if not in read-only mode */}\n {!isReadOnly && (\n <div>\n <button\n onClick={handleConfirm}\n disabled={!editorName.trim() || documentTypes.length === 0}\n className=\"rounded-md bg-primary px-4 py-2 text-primary-foreground hover:hover-effect focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-none disabled:disabled-effect\"\n >\n Confirm\n </button>\n </div>\n )}\n </div>\n );\n};\n","import type { PHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\n\nexport const editorConfig: PHDocumentEditorConfig = {\n isExternalControlsEnabled: false,\n};\n","import { DocumentToolbar } from \"@powerhousedao/design-system/connect\";\nimport { useSetPHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\nimport { useCallback } from \"react\";\nimport { useSelectedDocumentEditorDocument } from \"../../document-models/document-editor/index.js\";\nimport {\n addDocumentType,\n removeDocumentType,\n setEditorName,\n setEditorStatus,\n type AddDocumentTypeInput,\n type RemoveDocumentTypeInput,\n} from \"../../document-models/document-editor/index.js\";\nimport { DocumentEditorForm } from \"./components/DocumentEditorForm.js\";\nimport { editorConfig } from \"./config.js\";\n\nexport default function Editor() {\n useSetPHDocumentEditorConfig(editorConfig);\n const [document, dispatch] = useSelectedDocumentEditorDocument();\n\n const onEditorNameChange = useCallback(\n (name: string) => {\n if (!document.state.global.name && !name) return;\n if (name === document.state.global.name) return;\n\n dispatch(setEditorName({ name }));\n },\n [document.state.global.name, dispatch],\n );\n\n const onAddDocumentType = useCallback(\n (input: AddDocumentTypeInput) => {\n dispatch(addDocumentType(input));\n },\n [dispatch],\n );\n\n const onRemoveDocumentType = useCallback(\n (input: RemoveDocumentTypeInput) => {\n dispatch(removeDocumentType(input));\n },\n [dispatch],\n );\n\n const onConfirm = useCallback(() => {\n dispatch(setEditorStatus({ status: \"CONFIRMED\" }));\n }, [dispatch]);\n\n return (\n <div className=\"bg-background p-6\">\n <DocumentToolbar />\n <DocumentEditorForm\n status={document.state.global.status}\n editorName={document.state.global.name ?? \"\"}\n documentTypes={document.state.global.documentTypes}\n onEditorNameChange={onEditorNameChange}\n onAddDocumentType={onAddDocumentType}\n onRemoveDocumentType={onRemoveDocumentType}\n onConfirm={onConfirm}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAoBA,SAAS,qBACP,OACA;AACA,QACE,qBAAC,UAAD;EACE,IAAG;EACH,WAAU;EACV,GAAI;YAHN,CAKE,oBAAC,UAAD;GAAQ,OAAM;aAAG;GAA+B,CAAA,EAC/C,MAAM,SACA;;;AAIb,SAAS,mBAAmB,EAC1B,eACA,kBACA,mBACA,wBAMC;CAED,MAAM,yBAAyB,0BAA0B,KAAK;CAC9D,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,GAAG;AAEpE,QACE,oBAAC,sBAAD;EACE,OAAO;EACP,WAAW,MAAM;GACf,MAAM,gBAAgB,EAAE,OAAO;AAC/B,OAAI,eAAe;IAGjB,MAAM,eAAe,eAAe,GAAG,EAAE;AACzC,QAAI,aACF,wBAAuB,EAAE,IAAI,aAAa,IAAI,CAAC;IAIjD,MAAM,eAAqC;KACzC,IAAI,KAAK,KAAK,CAAC,UAAU;KACzB,cAAc;KACf;AAKD,qBAAiB,CAJiB;KAChC,IAAI,aAAa;KACjB,cAAc,aAAa;KAC5B,CACyB,CAAC;AAC3B,wBAAoB,aAAa;;AAEnC,2BAAwB,GAAG;;YAG5B,uBAAuB,KAAK,YAC3B,oBAAC,UAAD;GAAsB,OAAO;aAC1B;GACM,EAFI,QAEJ,CACT;EACmB,CAAA;;AAI3B,MAAa,sBAAyD,EACpE,YAAY,oBAAoB,IAChC,eAAe,uBAAuB,EAAE,EACxC,SAAS,SACT,oBACA,mBACA,sBACA,gBACI;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAAS,kBAAkB;CAC/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