import { b as generateId } from "./dist-uUUuTqM0.js";
import "./module-RiCpyFsE.js";
import "./creators-1UUtt16O.js";
import { _ as deleteAccount, h as addAccount, v as updateAccount, y as updateKycStatus } from "./module-DJjNH-7f.js";
import "./upgrade-manifest-0aQdR1Ni.js";
import "./upgrade-manifest-Cg4wvNM9.js";
import { D as useParentFolderForSelectedNode, c as setSelectedNode, h as useDocumentOfType, j as useSelectedDrive, k as useSelectedDocumentId } from "./dist-mx7YTOSV.js";
import "./chunk-VBDAOXYI-DjbP4DfS.js";
import { n as isValidEthereumAddress } from "./alchemyHelpers-CvNseqvu.js";
import "./account-transactions-DeAsdH8B.js";
import "./accounts-BPRp-Roc.js";
import { c as toast$1, ct as Provider, i as DocumentToolbar } from "./connect-MjNGHHUz-BfDIyhte.js";
import { t as Button } from "./button-DVsyzSgU.js";
import { t as Tooltip } from "./tooltip-DCro2_Kh.js";
import "./alchemyIntegration-DsK1H6XE.js";
import { t as createLucideIcon } from "./createLucideIcon-CTPs49Dw.js";
import { t as ChevronDown } from "./chevron-down-H8gEAPEz.js";
import { n as ChevronUp, t as RefreshCw } from "./refresh-cw-dMMeNfPX.js";
import { t as Info } from "./info-y-Tex5Aw.js";
import { t as Plus } from "./plus-BjHbY4gp.js";
import { t as X } from "./x-G7-4slQo.js";
import { t as accountTransactionsService } from "./accountTransactionsService-DL9yTuR9.js";
import { useState } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
const CircleQuestionMark = createLucideIcon("circle-question-mark", [
	["circle", {
		cx: "12",
		cy: "12",
		r: "10",
		key: "1mglay"
	}],
	["path", {
		d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",
		key: "1u773s"
	}],
	["path", {
		d: "M12 17h.01",
		key: "p32p05"
	}]
]);
//#endregion
//#region editors/hooks/useAccountsDocument.ts
function useAccountsDocument(documentId) {
	return useDocumentOfType(documentId, "powerhouse/accounts");
}
function useSelectedAccountsDocument() {
	return useAccountsDocument(useSelectedDocumentId());
}
//#endregion
//#region editors/accounts-editor/components/AccountForm.tsx
function AccountForm({ account, onSubmit, onCancel }) {
	const [formData, setFormData] = useState({
		account: account?.account || "",
		name: account?.name || "",
		budgetPath: account?.budgetPath || "",
		accountTransactionsId: account?.accountTransactionsId || "",
		chain: account?.chain?.join(", ") || "",
		type: account?.type || "",
		owners: account?.owners?.join(", ") || "",
		KycAmlStatus: account?.KycAmlStatus || ""
	});
	const [accountError, setAccountError] = useState("");
	function validateAccount(address) {
		if (!address || address.trim() === "") {
			setAccountError("Account address is required");
			return false;
		}
		if (!isValidEthereumAddress(address.trim())) {
			setAccountError("Invalid Ethereum address format. Must be 0x followed by 40 hexadecimal characters.");
			return false;
		}
		setAccountError("");
		return true;
	}
	function handleSubmit(e) {
		e.preventDefault();
		if (!validateAccount(formData.account)) {
			const accountInput = e.currentTarget.querySelector("input[name=\"account\"]");
			if (accountInput) accountInput.focus();
			return;
		}
		const chain = formData.chain.split(",").map((c) => c.trim()).filter((c) => c);
		const owners = formData.owners.split(",").map((o) => o.trim()).filter((o) => o);
		const typeSelect = e.currentTarget.querySelector("select[name=\"accountType\"]");
		if (!formData.type) {
			if (typeSelect) {
				typeSelect.setCustomValidity("Please select an Account Type");
				typeSelect.reportValidity();
			} else toast$1("Account Type is required", { type: "warning" });
			return;
		} else if (typeSelect) typeSelect.setCustomValidity("");
		onSubmit({
			...account?.id && { id: account.id },
			account: formData.account.trim(),
			name: formData.name,
			budgetPath: formData.budgetPath || void 0,
			accountTransactionsId: formData.accountTransactionsId || void 0,
			chain: chain.length > 0 ? chain : void 0,
			type: formData.type,
			owners: owners.length > 0 ? owners : void 0,
			KycAmlStatus: formData.KycAmlStatus || void 0
		});
	}
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("style", { children: `
        input[name="account"]::placeholder {
          font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
        }
      ` }), /* @__PURE__ */ jsxs("form", {
		onSubmit: handleSubmit,
		className: "bg-white rounded-xl border border-gray-200 shadow-sm p-6",
		children: [/* @__PURE__ */ jsxs("div", {
			className: "space-y-6",
			children: [
				/* @__PURE__ */ jsxs("div", {
					className: "grid grid-cols-1 md:grid-cols-2 gap-6",
					children: [/* @__PURE__ */ jsxs("div", { children: [
						/* @__PURE__ */ jsxs("label", {
							htmlFor: "account-address",
							className: "block text-sm font-medium text-gray-700 mb-2",
							children: ["Account ", /* @__PURE__ */ jsx("span", {
								className: "text-red-500",
								children: "*"
							})]
						}),
						/* @__PURE__ */ jsx("input", {
							type: "text",
							id: "account-address",
							name: "account",
							value: formData.account,
							onChange: (e) => {
								const value = e.target.value;
								setFormData({
									...formData,
									account: value
								});
								if (accountError) setAccountError("");
							},
							onBlur: (e) => {
								validateAccount(e.target.value);
							},
							placeholder: "e.g., 0x1234...abcd",
							spellCheck: false,
							autoComplete: "off",
							className: `w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent ${accountError ? "border-red-300 focus:ring-red-500" : "border-gray-300"}`,
							required: true
						}),
						accountError && /* @__PURE__ */ jsx("p", {
							className: "mt-1 text-sm text-red-600",
							children: accountError
						}),
						!accountError && formData.account && /* @__PURE__ */ jsx("p", {
							className: "mt-1 text-xs text-gray-500",
							children: "Ethereum address format: 0x followed by 40 hexadecimal characters"
						})
					] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("label", {
						htmlFor: "account-name",
						className: "block text-sm font-medium text-gray-700 mb-2",
						children: ["Name ", /* @__PURE__ */ jsx("span", {
							className: "text-red-500",
							children: "*"
						})]
					}), /* @__PURE__ */ jsx("input", {
						type: "text",
						id: "account-name",
						name: "name",
						value: formData.name,
						onChange: (e) => setFormData({
							...formData,
							name: e.target.value
						}),
						placeholder: "e.g., Main Treasury",
						className: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",
						required: true
					})] })]
				}),
				/* @__PURE__ */ jsxs("div", {
					className: "grid grid-cols-1 md:grid-cols-2 gap-6",
					children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Provider, {
						delayDuration: 0,
						children: /* @__PURE__ */ jsxs("label", {
							htmlFor: "account-type",
							className: "flex items-center gap-1 text-sm font-medium text-gray-700 mb-2",
							children: [
								"Account Type ",
								/* @__PURE__ */ jsx("span", {
									className: "text-red-500",
									children: "*"
								}),
								/* @__PURE__ */ jsx(Tooltip, {
									content: /* @__PURE__ */ jsxs("div", {
										className: "text-xs",
										children: [
											/* @__PURE__ */ jsx("div", {
												className: "font-semibold mb-1",
												children: "Account Types:"
											}),
											/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", { children: "Source:" }), " Origin of funds (e.g., revenue streams)"] }),
											/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", { children: "Internal:" }), " Accounts within your organization"] }),
											/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", { children: "Destination:" }), " Where funds are sent (e.g., payments)"] }),
											/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", { children: "External:" }), " Third-party accounts outside your org"] })
										]
									}),
									side: "right",
									children: /* @__PURE__ */ jsx(Info, { className: "w-4 h-4 text-gray-400 cursor-help" })
								})
							]
						})
					}), /* @__PURE__ */ jsxs("select", {
						id: "account-type",
						name: "accountType",
						value: formData.type,
						onChange: (e) => {
							setFormData({
								...formData,
								type: e.target.value
							});
							e.target.setCustomValidity("");
						},
						className: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white",
						required: true,
						children: [
							/* @__PURE__ */ jsx("option", {
								value: "",
								children: "Select type..."
							}),
							/* @__PURE__ */ jsx("option", {
								value: "Source",
								children: "Source"
							}),
							/* @__PURE__ */ jsx("option", {
								value: "Internal",
								children: "Internal"
							}),
							/* @__PURE__ */ jsx("option", {
								value: "Destination",
								children: "Destination"
							}),
							/* @__PURE__ */ jsx("option", {
								value: "External",
								children: "External"
							})
						]
					})] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
						htmlFor: "kyc-status",
						className: "block text-sm font-medium text-gray-700 mb-2",
						children: "KYC/AML Status"
					}), /* @__PURE__ */ jsxs("select", {
						id: "kyc-status",
						name: "kycStatus",
						value: formData.KycAmlStatus,
						onChange: (e) => setFormData({
							...formData,
							KycAmlStatus: e.target.value
						}),
						className: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white",
						children: [
							/* @__PURE__ */ jsx("option", {
								value: "",
								children: "Select status..."
							}),
							/* @__PURE__ */ jsx("option", {
								value: "PASSED",
								children: "Passed"
							}),
							/* @__PURE__ */ jsx("option", {
								value: "PENDING",
								children: "Pending"
							}),
							/* @__PURE__ */ jsx("option", {
								value: "FAILED",
								children: "Failed"
							})
						]
					})] })]
				}),
				/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
					htmlFor: "budget-path",
					className: "block text-sm font-medium text-gray-700 mb-2",
					children: "Budget Path"
				}), /* @__PURE__ */ jsx("input", {
					type: "text",
					id: "budget-path",
					name: "budgetPath",
					value: formData.budgetPath,
					onChange: (e) => setFormData({
						...formData,
						budgetPath: e.target.value
					}),
					placeholder: "e.g., /treasury/operations",
					className: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
				})] }),
				account && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
					htmlFor: "account-transactions-id",
					className: "block text-sm font-medium text-gray-700 mb-2",
					children: "Account Transactions ID"
				}), /* @__PURE__ */ jsx("input", {
					type: "text",
					id: "account-transactions-id",
					name: "accountTransactionsId",
					value: formData.accountTransactionsId,
					onChange: (e) => setFormData({
						...formData,
						accountTransactionsId: e.target.value
					}),
					placeholder: "e.g., tx-12345",
					className: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
				})] }),
				/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("label", {
					htmlFor: "chains",
					className: "block text-sm font-medium text-gray-700 mb-2",
					children: ["Chains", /* @__PURE__ */ jsx("span", {
						className: "ml-2 text-xs text-gray-500 font-normal",
						children: "(comma-separated)"
					})]
				}), /* @__PURE__ */ jsx("input", {
					type: "text",
					id: "chains",
					name: "chain",
					value: formData.chain,
					onChange: (e) => setFormData({
						...formData,
						chain: e.target.value
					}),
					placeholder: "e.g., Ethereum, Polygon, Arbitrum",
					className: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
				})] }),
				/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("label", {
					htmlFor: "owners",
					className: "block text-sm font-medium text-gray-700 mb-2",
					children: ["Owners", /* @__PURE__ */ jsx("span", {
						className: "ml-2 text-xs text-gray-500 font-normal",
						children: "(comma-separated)"
					})]
				}), /* @__PURE__ */ jsx("input", {
					type: "text",
					id: "owners",
					name: "owners",
					value: formData.owners,
					onChange: (e) => setFormData({
						...formData,
						owners: e.target.value
					}),
					placeholder: "e.g., Alice, Bob, Charlie",
					className: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
				})] })
			]
		}), /* @__PURE__ */ jsxs("div", {
			className: "mt-8 flex items-center justify-end gap-3 pt-6 border-t border-gray-200",
			children: [/* @__PURE__ */ jsx(Button, {
				type: "button",
				onClick: onCancel,
				className: "px-6 py-2.5 border border-gray-300 rounded-lg font-medium text-gray-700 hover:bg-gray-50 transition-colors",
				children: "Cancel"
			}), /* @__PURE__ */ jsx(Button, {
				type: "submit",
				className: "px-6 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium shadow-sm transition-colors",
				children: account ? "Update Account" : "Add Account"
			})]
		})]
	})] });
}
//#endregion
//#region editors/accounts-editor/components/KYCStatusBadge.tsx
function KYCStatusBadge({ status }) {
	if (!status) return /* @__PURE__ */ jsx("span", {
		className: "inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700",
		children: "No Status"
	});
	const styles = {
		PASSED: "bg-green-100 text-green-800 border-green-200",
		PENDING: "bg-yellow-100 text-yellow-800 border-yellow-200",
		FAILED: "bg-red-100 text-red-800 border-red-200"
	};
	const icons = {
		PASSED: /* @__PURE__ */ jsx("svg", {
			className: "w-4 h-4",
			fill: "currentColor",
			viewBox: "0 0 20 20",
			children: /* @__PURE__ */ jsx("path", {
				fillRule: "evenodd",
				d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
				clipRule: "evenodd"
			})
		}),
		PENDING: /* @__PURE__ */ jsx("svg", {
			className: "w-4 h-4",
			fill: "currentColor",
			viewBox: "0 0 20 20",
			children: /* @__PURE__ */ jsx("path", {
				fillRule: "evenodd",
				d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z",
				clipRule: "evenodd"
			})
		}),
		FAILED: /* @__PURE__ */ jsx("svg", {
			className: "w-4 h-4",
			fill: "currentColor",
			viewBox: "0 0 20 20",
			children: /* @__PURE__ */ jsx("path", {
				fillRule: "evenodd",
				d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",
				clipRule: "evenodd"
			})
		})
	};
	return /* @__PURE__ */ jsxs("span", {
		className: `inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border ${styles[status]}`,
		children: [icons[status], /* @__PURE__ */ jsxs("span", { children: ["KYC/AML ", status] })]
	});
}
//#endregion
//#region editors/accounts-editor/components/AccountCard.tsx
function AccountCard({ account, onEdit, onDelete, onUpdateKycStatus, onCreateTransactions, isCreatingTransactions = false }) {
	const [showKycMenu, setShowKycMenu] = useState(false);
	const accountTypeColors = {
		Source: "bg-purple-100 text-purple-800",
		Internal: "bg-blue-100 text-blue-800",
		Destination: "bg-green-100 text-green-800",
		External: "bg-orange-100 text-orange-800"
	};
	function handleKycStatusChange(status) {
		onUpdateKycStatus(account.id, status);
		setShowKycMenu(false);
	}
	return /* @__PURE__ */ jsx("div", {
		className: "bg-white rounded-xl border border-gray-200 shadow-sm hover:shadow-md transition-shadow",
		children: /* @__PURE__ */ jsxs("div", {
			className: "p-6",
			children: [/* @__PURE__ */ jsxs("div", {
				className: "flex items-start justify-between mb-4",
				children: [/* @__PURE__ */ jsxs("div", {
					className: "flex-1",
					children: [/* @__PURE__ */ jsx("h3", {
						className: "text-lg font-semibold text-gray-900 mb-1",
						children: account.name
					}), /* @__PURE__ */ jsx("p", {
						className: "text-sm text-gray-600 font-mono",
						children: account.account
					})]
				}), /* @__PURE__ */ jsxs("div", {
					className: "flex items-center gap-2",
					children: [/* @__PURE__ */ jsx("button", {
						onClick: () => onEdit(account),
						className: "p-2 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-colors focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus:outline-none",
						title: "Edit account",
						"aria-label": `Edit account ${account.name}`,
						children: /* @__PURE__ */ jsx("svg", {
							className: "w-5 h-5",
							fill: "none",
							stroke: "currentColor",
							viewBox: "0 0 24 24",
							"aria-hidden": "true",
							children: /* @__PURE__ */ jsx("path", {
								strokeLinecap: "round",
								strokeLinejoin: "round",
								strokeWidth: 2,
								d: "M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"
							})
						})
					}), /* @__PURE__ */ jsx("button", {
						onClick: () => onDelete(account.id),
						className: "p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors focus-visible:ring-2 focus-visible:ring-red-500 focus-visible:ring-offset-2 focus:outline-none",
						title: "Delete account",
						"aria-label": `Delete account ${account.name}`,
						children: /* @__PURE__ */ jsx("svg", {
							className: "w-5 h-5",
							fill: "none",
							stroke: "currentColor",
							viewBox: "0 0 24 24",
							"aria-hidden": "true",
							children: /* @__PURE__ */ jsx("path", {
								strokeLinecap: "round",
								strokeLinejoin: "round",
								strokeWidth: 2,
								d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
							})
						})
					})]
				})]
			}), /* @__PURE__ */ jsxs("div", {
				className: "space-y-3",
				children: [
					account.type && /* @__PURE__ */ jsxs("div", {
						className: "flex items-center gap-2",
						children: [/* @__PURE__ */ jsx("span", {
							className: "text-sm font-medium text-gray-500",
							children: "Type:"
						}), /* @__PURE__ */ jsx("span", {
							className: `inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium ${accountTypeColors[account.type]}`,
							children: account.type
						})]
					}),
					account.budgetPath && /* @__PURE__ */ jsxs("div", {
						className: "flex items-center gap-2",
						children: [/* @__PURE__ */ jsx("span", {
							className: "text-sm font-medium text-gray-500",
							children: "Budget Path:"
						}), /* @__PURE__ */ jsx("span", {
							className: "text-sm text-gray-900",
							children: account.budgetPath
						})]
					}),
					account.accountTransactionsId && /* @__PURE__ */ jsxs("div", {
						className: "flex items-center gap-2",
						children: [/* @__PURE__ */ jsx("span", {
							className: "text-sm font-medium text-gray-500",
							children: "Transactions ID:"
						}), /* @__PURE__ */ jsx("span", {
							className: "text-sm text-gray-900 font-mono",
							children: account.accountTransactionsId
						})]
					}),
					account.chain && account.chain.length > 0 && /* @__PURE__ */ jsxs("div", {
						className: "flex items-start gap-2",
						children: [/* @__PURE__ */ jsx("span", {
							className: "text-sm font-medium text-gray-500",
							children: "Chains:"
						}), /* @__PURE__ */ jsx("div", {
							className: "flex flex-wrap gap-1.5",
							children: account.chain.map((chain, idx) => /* @__PURE__ */ jsx("span", {
								className: "inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-gray-100 text-gray-700",
								children: chain
							}, idx))
						})]
					}),
					account.owners && account.owners.length > 0 && /* @__PURE__ */ jsxs("div", {
						className: "flex items-start gap-2",
						children: [/* @__PURE__ */ jsx("span", {
							className: "text-sm font-medium text-gray-500",
							children: "Owners:"
						}), /* @__PURE__ */ jsx("div", {
							className: "flex flex-wrap gap-1.5",
							children: account.owners.map((owner, idx) => /* @__PURE__ */ jsx("span", {
								className: "inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-indigo-100 text-indigo-700",
								children: owner
							}, idx))
						})]
					}),
					/* @__PURE__ */ jsxs("div", {
						className: "pt-3 border-t border-gray-100",
						children: [/* @__PURE__ */ jsxs("div", {
							className: "flex items-center justify-between mb-4",
							children: [/* @__PURE__ */ jsx("span", {
								className: "text-sm font-medium text-gray-500",
								children: "KYC/AML Status:"
							}), /* @__PURE__ */ jsxs("div", {
								className: "relative",
								children: [/* @__PURE__ */ jsx("button", {
									id: `kyc-status-button-${account.id}`,
									onClick: () => setShowKycMenu(!showKycMenu),
									className: "hover:opacity-80 transition-opacity focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus:outline-none rounded",
									title: "Update KYC/AML status",
									"aria-label": `Update KYC/AML status for ${account.name}, currently ${account.KycAmlStatus || "Not Set"}`,
									"aria-expanded": showKycMenu,
									"aria-haspopup": "menu",
									children: /* @__PURE__ */ jsx(KYCStatusBadge, { status: account.KycAmlStatus })
								}), showKycMenu && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
									className: "fixed inset-0 z-10",
									onClick: () => setShowKycMenu(false),
									"aria-hidden": "true"
								}), /* @__PURE__ */ jsx("div", {
									className: "absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg border border-gray-200 z-20",
									role: "menu",
									"aria-orientation": "vertical",
									"aria-labelledby": `kyc-status-button-${account.id}`,
									children: /* @__PURE__ */ jsxs("div", {
										className: "py-1",
										children: [
											/* @__PURE__ */ jsxs("button", {
												role: "menuitem",
												onClick: () => handleKycStatusChange("PASSED"),
												className: "w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-green-50 hover:text-green-900 flex items-center gap-2 focus:bg-green-50 focus:text-green-900 focus:outline-none",
												children: [/* @__PURE__ */ jsx("span", {
													className: "w-2 h-2 rounded-full bg-green-500",
													"aria-hidden": "true"
												}), "Passed"]
											}),
											/* @__PURE__ */ jsxs("button", {
												role: "menuitem",
												onClick: () => handleKycStatusChange("PENDING"),
												className: "w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-yellow-50 hover:text-yellow-900 flex items-center gap-2 focus:bg-yellow-50 focus:text-yellow-900 focus:outline-none",
												children: [/* @__PURE__ */ jsx("span", {
													className: "w-2 h-2 rounded-full bg-yellow-500",
													"aria-hidden": "true"
												}), "Pending"]
											}),
											/* @__PURE__ */ jsxs("button", {
												role: "menuitem",
												onClick: () => handleKycStatusChange("FAILED"),
												className: "w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-red-50 hover:text-red-900 flex items-center gap-2 focus:bg-red-50 focus:text-red-900 focus:outline-none",
												children: [/* @__PURE__ */ jsx("span", {
													className: "w-2 h-2 rounded-full bg-red-500",
													"aria-hidden": "true"
												}), "Failed"]
											})
										]
									})
								})] })]
							})]
						}), onCreateTransactions && /* @__PURE__ */ jsx("div", {
							className: "flex flex-col gap-2",
							children: account.accountTransactionsId ? /* @__PURE__ */ jsx("button", {
								onClick: () => setSelectedNode(account.accountTransactionsId),
								className: "w-full bg-blue-50 hover:bg-blue-100 border border-blue-200 rounded-lg p-3 transition-colors text-left",
								"aria-label": `View transaction history for ${account.name}`,
								children: /* @__PURE__ */ jsxs("div", {
									className: "flex items-center justify-between gap-2",
									children: [/* @__PURE__ */ jsxs("div", {
										className: "flex items-center gap-2",
										children: [/* @__PURE__ */ jsx("svg", {
											className: "w-5 h-5 text-blue-600",
											fill: "none",
											stroke: "currentColor",
											viewBox: "0 0 24 24",
											"aria-hidden": "true",
											children: /* @__PURE__ */ jsx("path", {
												strokeLinecap: "round",
												strokeLinejoin: "round",
												strokeWidth: 2,
												d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
											})
										}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
											className: "text-sm font-medium text-blue-900",
											children: "View Transaction History"
										}), /* @__PURE__ */ jsx("p", {
											className: "text-xs text-blue-600 mt-0.5",
											children: "Transactions synced for reporting"
										})] })]
									}), /* @__PURE__ */ jsx("svg", {
										className: "w-5 h-5 text-blue-600 flex-shrink-0",
										fill: "none",
										stroke: "currentColor",
										viewBox: "0 0 24 24",
										"aria-hidden": "true",
										children: /* @__PURE__ */ jsx("path", {
											strokeLinecap: "round",
											strokeLinejoin: "round",
											strokeWidth: 2,
											d: "M9 5l7 7-7 7"
										})
									})]
								})
							}) : /* @__PURE__ */ jsxs("div", {
								className: "space-y-2",
								children: [/* @__PURE__ */ jsxs("div", {
									className: "flex items-start gap-2 p-3 bg-amber-50 border border-amber-200 rounded-lg",
									children: [/* @__PURE__ */ jsx("svg", {
										className: "w-5 h-5 text-amber-600 flex-shrink-0 mt-0.5",
										fill: "none",
										stroke: "currentColor",
										viewBox: "0 0 24 24",
										"aria-hidden": "true",
										children: /* @__PURE__ */ jsx("path", {
											strokeLinecap: "round",
											strokeLinejoin: "round",
											strokeWidth: 2,
											d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
										})
									}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
										className: "text-sm font-medium text-amber-900",
										children: "No transaction history"
									}), /* @__PURE__ */ jsx("p", {
										className: "text-xs text-amber-700 mt-0.5",
										children: "Fetch transactions to enable accurate expense reporting"
									})] })]
								}), /* @__PURE__ */ jsx(Button, {
									onClick: () => onCreateTransactions(account),
									disabled: isCreatingTransactions,
									className: "w-full bg-green-600 hover:bg-green-700 disabled:bg-gray-400 text-white px-4 py-2.5 rounded-lg font-medium shadow-sm transition-colors",
									children: isCreatingTransactions ? /* @__PURE__ */ jsxs("span", {
										className: "flex items-center justify-center gap-2",
										children: [/* @__PURE__ */ jsxs("svg", {
											className: "animate-spin h-4 w-4 text-white",
											fill: "none",
											viewBox: "0 0 24 24",
											"aria-hidden": "true",
											children: [/* @__PURE__ */ jsx("circle", {
												className: "opacity-25",
												cx: "12",
												cy: "12",
												r: "10",
												stroke: "currentColor",
												strokeWidth: "4"
											}), /* @__PURE__ */ jsx("path", {
												className: "opacity-75",
												fill: "currentColor",
												d: "m4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
											})]
										}), "Fetching transactions…"]
									}) : /* @__PURE__ */ jsxs("span", {
										className: "flex items-center justify-center gap-2",
										children: [/* @__PURE__ */ jsx("svg", {
											className: "w-4 h-4",
											fill: "none",
											stroke: "currentColor",
											viewBox: "0 0 24 24",
											"aria-hidden": "true",
											children: /* @__PURE__ */ jsx("path", {
												strokeLinecap: "round",
												strokeLinejoin: "round",
												strokeWidth: 2,
												d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"
											})
										}), "Fetch Transaction History"]
									})
								})]
							})
						})]
					})
				]
			})]
		})
	});
}
//#endregion
//#region editors/accounts-editor/components/AccountsList.tsx
function AccountsList({ accounts, onEdit, onDelete, onUpdateKycStatus, onCreateTransactions, creatingTransactionsFor }) {
	if (accounts.length === 0) return /* @__PURE__ */ jsxs("div", {
		className: "bg-white rounded-xl border border-gray-200 p-12 text-center",
		children: [
			/* @__PURE__ */ jsx("svg", {
				className: "mx-auto h-12 w-12 text-gray-400",
				fill: "none",
				stroke: "currentColor",
				viewBox: "0 0 24 24",
				children: /* @__PURE__ */ jsx("path", {
					strokeLinecap: "round",
					strokeLinejoin: "round",
					strokeWidth: 2,
					d: "M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"
				})
			}),
			/* @__PURE__ */ jsx("h3", {
				className: "mt-4 text-lg font-medium text-gray-900",
				children: "No accounts yet"
			}),
			/* @__PURE__ */ jsx("p", {
				className: "mt-2 text-sm text-gray-600",
				children: "Get started by adding your first account"
			})
		]
	});
	const accountsWithoutTransactions = accounts.filter((account) => !account.accountTransactionsId);
	return /* @__PURE__ */ jsxs("div", {
		className: "space-y-4",
		children: [/* @__PURE__ */ jsxs("div", {
			className: "flex items-center justify-between",
			children: [/* @__PURE__ */ jsxs("div", {
				className: "text-sm text-gray-600",
				children: [
					accounts.length,
					" account",
					accounts.length !== 1 ? "s" : ""
				]
			}), accountsWithoutTransactions.length > 0 && /* @__PURE__ */ jsxs("div", {
				className: "flex items-center gap-1.5 text-sm text-amber-700 bg-amber-50 px-3 py-1.5 rounded-full border border-amber-200",
				children: [/* @__PURE__ */ jsx("svg", {
					className: "w-4 h-4",
					fill: "none",
					stroke: "currentColor",
					viewBox: "0 0 24 24",
					"aria-hidden": "true",
					children: /* @__PURE__ */ jsx("path", {
						strokeLinecap: "round",
						strokeLinejoin: "round",
						strokeWidth: 2,
						d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
					})
				}), /* @__PURE__ */ jsxs("span", { children: [
					accountsWithoutTransactions.length,
					" account",
					accountsWithoutTransactions.length !== 1 ? "s" : "",
					" need",
					accountsWithoutTransactions.length === 1 ? "s" : "",
					" transaction history"
				] })]
			})]
		}), /* @__PURE__ */ jsx("div", {
			className: "space-y-4",
			children: accounts.map((account) => /* @__PURE__ */ jsx(AccountCard, {
				account,
				onEdit,
				onDelete,
				onUpdateKycStatus,
				onCreateTransactions,
				isCreatingTransactions: creatingTransactionsFor === account.id
			}, account.id))
		})]
	});
}
//#endregion
//#region editors/accounts-editor/editor.tsx
const HELP_DISMISSED_KEY = "accountsEditor.helpDismissed";
function InstructionSection({ onDismiss }) {
	const [isExpanded, setIsExpanded] = useState(true);
	return /* @__PURE__ */ jsxs("div", {
		className: "bg-blue-50 border border-blue-200 rounded-lg overflow-hidden",
		children: [/* @__PURE__ */ jsxs("div", {
			className: "w-full px-4 py-3 flex items-center justify-between text-left hover:bg-blue-100 transition-colors",
			children: [/* @__PURE__ */ jsxs("button", {
				type: "button",
				onClick: () => setIsExpanded(!isExpanded),
				className: "flex items-center gap-2 flex-1",
				children: [/* @__PURE__ */ jsx(CircleQuestionMark, { className: "w-5 h-5 text-blue-600" }), /* @__PURE__ */ jsx("span", {
					className: "font-medium text-blue-900",
					children: "Getting Started with Accounts"
				})]
			}), /* @__PURE__ */ jsxs("div", {
				className: "flex items-center gap-2",
				children: [/* @__PURE__ */ jsx("button", {
					type: "button",
					onClick: onDismiss,
					className: "p-1 hover:bg-blue-200 rounded text-blue-600",
					title: "Don't show again",
					"aria-label": "Dismiss help section",
					children: /* @__PURE__ */ jsx(X, {
						className: "w-4 h-4",
						"aria-hidden": "true"
					})
				}), /* @__PURE__ */ jsx("button", {
					type: "button",
					onClick: () => setIsExpanded(!isExpanded),
					className: "p-1 hover:bg-blue-100 rounded",
					children: isExpanded ? /* @__PURE__ */ jsx(ChevronUp, { className: "w-5 h-5 text-blue-600" }) : /* @__PURE__ */ jsx(ChevronDown, { className: "w-5 h-5 text-blue-600" })
				})]
			})]
		}), isExpanded && /* @__PURE__ */ jsxs("div", {
			className: "px-4 pb-4 text-sm text-blue-800 space-y-3",
			children: [
				/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", {
					className: "text-blue-900",
					children: "What is an Account?"
				}), /* @__PURE__ */ jsx("p", {
					className: "mt-1",
					children: "An account represents a wallet address or entity that participates in your financial flows. This could be a treasury wallet, a contributor's address, or an external service provider."
				})] }),
				/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", {
					className: "text-blue-900",
					children: "Why specify an Account Type?"
				}), /* @__PURE__ */ jsx("p", {
					className: "mt-1",
					children: "The account type helps categorize how funds flow in and out, making it easier to track transactions and generate accurate reports. It also enables automatic flow type detection."
				})] }),
				/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", {
					className: "text-blue-900",
					children: "Account Type Meanings:"
				}), /* @__PURE__ */ jsxs("ul", {
					className: "mt-1 ml-4 list-disc space-y-1",
					children: [
						/* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("strong", { children: "Source:" }), " Where funds originate (e.g., revenue streams, grants)"] }),
						/* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("strong", { children: "Internal:" }), " Wallets within your organization"] }),
						/* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("strong", { children: "Destination:" }), " Where you send payments (e.g., contributor wallets)"] }),
						/* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("strong", { children: "External:" }), " Third-party accounts outside your organization"] })
					]
				})] }),
				/* @__PURE__ */ jsxs("div", {
					className: "bg-amber-50 border border-amber-200 rounded-md p-3 mt-2",
					children: [/* @__PURE__ */ jsx("strong", {
						className: "text-amber-900",
						children: "📊 Why fetch transactions?"
					}), /* @__PURE__ */ jsx("p", {
						className: "mt-1 text-amber-800",
						children: "Transaction history is essential for generating accurate expense reports. Without complete transaction data, your reports may have gaps or inaccuracies. After adding an account, click \"Fetch Transaction History\" and sync regularly to ensure your reporting is complete."
					})]
				})
			]
		})]
	});
}
function Editor() {
	const [document, dispatch] = useSelectedAccountsDocument();
	const parentFolder = useParentFolderForSelectedNode();
	const [selectedDrive] = useSelectedDrive();
	const [viewMode, setViewMode] = useState("list");
	const [editingAccount, setEditingAccount] = useState(null);
	const [creatingTransactionsFor, setCreatingTransactionsFor] = useState(null);
	const [isSyncingAll, setIsSyncingAll] = useState(false);
	const [syncProgress, setSyncProgress] = useState(null);
	const [deleteConfirm, setDeleteConfirm] = useState({
		isOpen: false,
		accountId: null,
		accountName: ""
	});
	const [syncConfirm, setSyncConfirm] = useState(false);
	const [showHelp, setShowHelp] = useState(() => {
		if (typeof window !== "undefined") return localStorage.getItem(HELP_DISMISSED_KEY) !== "true";
		return true;
	});
	function handleDismissHelp() {
		setShowHelp(false);
		localStorage.setItem(HELP_DISMISSED_KEY, "true");
	}
	function handleClose() {
		setSelectedNode(parentFolder?.id);
	}
	function handleAddAccount(values) {
		dispatch(addAccount({
			id: generateId(),
			account: values.account,
			name: values.name,
			budgetPath: values.budgetPath,
			accountTransactionsId: values.accountTransactionsId,
			chain: values.chain,
			type: values.type || "External",
			owners: values.owners,
			KycAmlStatus: values.KycAmlStatus
		}));
		setViewMode("list");
	}
	function handleUpdateAccount(values) {
		if (!values.id) return;
		dispatch(updateAccount({
			id: values.id,
			account: values.account,
			name: values.name,
			budgetPath: values.budgetPath,
			accountTransactionsId: values.accountTransactionsId,
			chain: values.chain,
			type: values.type,
			owners: values.owners,
			KycAmlStatus: values.KycAmlStatus
		}));
		setViewMode("list");
		setEditingAccount(null);
	}
	function handleDeleteAccount(id) {
		setDeleteConfirm({
			isOpen: true,
			accountId: id,
			accountName: accounts.find((a) => a.id === id)?.name || "this account"
		});
	}
	function confirmDelete() {
		if (deleteConfirm.accountId) {
			dispatch(deleteAccount({ id: deleteConfirm.accountId }));
			toast$1("Account deleted successfully", { type: "success" });
		}
		setDeleteConfirm({
			isOpen: false,
			accountId: null,
			accountName: ""
		});
	}
	function handleUpdateKycStatus(id, KycAmlStatus) {
		dispatch(updateKycStatus({
			id,
			KycAmlStatus
		}));
	}
	function handleEditClick(account) {
		setEditingAccount(account);
		setViewMode("edit");
	}
	function handleCancelForm() {
		setViewMode("list");
		setEditingAccount(null);
	}
	async function handleCreateTransactions(account) {
		setCreatingTransactionsFor(account.id);
		try {
			const driveId = selectedDrive?.header?.id;
			const accountsDocumentId = document.header.id;
			const result = await accountTransactionsService.createAccountTransactionsDocument(account, accountsDocumentId, driveId);
			if (result.success) {
				if (result.documentId) dispatch(updateAccount({
					id: account.id,
					accountTransactionsId: result.documentId
				}));
				toast$1(`Created document and fetched ${result.transactionsAdded} transactions`, { type: "success" });
			} else toast$1(`Error: ${result.message}`, { type: "error" });
		} catch (error) {
			toast$1(`Error: ${error instanceof Error ? error.message : "Unknown error occurred"}`, { type: "error" });
		} finally {
			setCreatingTransactionsFor(null);
		}
	}
	function initiateSync() {
		if (accounts.length === 0) {
			toast$1("No accounts to sync transactions for", { type: "warning" });
			return;
		}
		setSyncConfirm(true);
	}
	async function handleSyncAllTransactions() {
		setSyncConfirm(false);
		setIsSyncingAll(true);
		const results = [];
		try {
			const driveId = selectedDrive?.header?.id;
			const accountsDocumentId = document.header.id;
			for (let i = 0; i < accounts.length; i++) {
				const account = accounts[i];
				setSyncProgress({
					current: i + 1,
					total: accounts.length,
					account: account.name
				});
				try {
					if (account.accountTransactionsId) {
						const result = await accountTransactionsService.syncTransactionsForDocument(account.accountTransactionsId, account.account);
						results.push({
							account: account.name,
							success: result.success,
							transactionsAdded: result.transactionsAdded || 0,
							message: result.message
						});
					} else {
						const result = await accountTransactionsService.createAccountTransactionsDocument(account, accountsDocumentId, driveId);
						if (result.success && result.documentId) dispatch(updateAccount({
							id: account.id,
							accountTransactionsId: result.documentId
						}));
						results.push({
							account: account.name,
							success: result.success,
							transactionsAdded: result.transactionsAdded || 0,
							message: result.message
						});
					}
				} catch (error) {
					results.push({
						account: account.name,
						success: false,
						transactionsAdded: 0,
						message: error instanceof Error ? error.message : "Unknown error occurred"
					});
				}
			}
			const totalAdded = results.reduce((sum, r) => sum + r.transactionsAdded, 0);
			const successCount = results.filter((r) => r.success).length;
			const failedCount = results.length - successCount;
			if (failedCount === 0) toast$1(`Synced ${successCount} account${successCount !== 1 ? "s" : ""}, ${totalAdded} new transactions`, { type: "success" });
			else toast$1(`Synced ${successCount}/${results.length} accounts. ${failedCount} failed.`, { type: "warning" });
		} catch (error) {
			toast$1(`Error during sync: ${error instanceof Error ? error.message : "Unknown error occurred"}`, { type: "error" });
		} finally {
			setIsSyncingAll(false);
			setSyncProgress(null);
		}
	}
	const accounts = document.state.global.accounts;
	return /* @__PURE__ */ jsxs("div", {
		className: "h-screen flex flex-col bg-gray-50",
		children: [
			/* @__PURE__ */ jsx(DocumentToolbar, {
				document,
				onClose: handleClose
			}),
			/* @__PURE__ */ jsx("div", {
				className: "bg-white border-b border-gray-200 px-4 py-3 flex items-center justify-between",
				children: /* @__PURE__ */ jsx("h1", {
					className: "text-lg font-semibold text-gray-900",
					children: "Accounts"
				})
			}),
			/* @__PURE__ */ jsx("div", {
				className: "flex-1 overflow-auto",
				children: /* @__PURE__ */ jsx("div", {
					className: "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",
					children: /* @__PURE__ */ jsxs("div", { children: [
						viewMode === "list" && /* @__PURE__ */ jsxs("div", {
							className: "space-y-6",
							children: [
								/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
									className: "text-2xl font-semibold text-gray-900",
									children: "Accounts"
								}), /* @__PURE__ */ jsx("p", {
									className: "mt-1 text-sm text-gray-600",
									children: "Manage your accounts and sync transactions"
								})] }),
								showHelp && /* @__PURE__ */ jsx(InstructionSection, { onDismiss: handleDismissHelp }),
								/* @__PURE__ */ jsxs("div", {
									className: "flex items-center justify-end gap-3",
									children: [/* @__PURE__ */ jsxs(Button, {
										onClick: () => setViewMode("add"),
										className: "bg-blue-600 hover:bg-blue-700 text-white px-6 py-2.5 rounded-lg font-medium shadow-sm transition-colors flex items-center gap-2",
										children: [/* @__PURE__ */ jsx(Plus, {
											className: "w-4 h-4",
											"aria-hidden": "true"
										}), "Add Account"]
									}), /* @__PURE__ */ jsx(Button, {
										onClick: initiateSync,
										disabled: isSyncingAll || accounts.length === 0,
										className: "border border-gray-300 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400 text-gray-700 px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2",
										children: isSyncingAll ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("svg", {
											className: "animate-spin h-4 w-4",
											xmlns: "http://www.w3.org/2000/svg",
											fill: "none",
											viewBox: "0 0 24 24",
											"aria-hidden": "true",
											children: [/* @__PURE__ */ jsx("circle", {
												className: "opacity-25",
												cx: "12",
												cy: "12",
												r: "10",
												stroke: "currentColor",
												strokeWidth: "4"
											}), /* @__PURE__ */ jsx("path", {
												className: "opacity-75",
												fill: "currentColor",
												d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
											})]
										}), syncProgress ? `Syncing ${syncProgress.current}/${syncProgress.total}…` : "Syncing…"] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RefreshCw, {
											className: "w-4 h-4",
											"aria-hidden": "true"
										}), "Sync Transactions"] })
									})]
								}),
								syncProgress && /* @__PURE__ */ jsx("div", {
									className: "bg-blue-50 border border-blue-200 rounded-lg p-4",
									children: /* @__PURE__ */ jsxs("div", {
										className: "flex items-center justify-between",
										children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("p", {
											className: "text-sm font-medium text-blue-900",
											children: ["Syncing transactions: ", syncProgress.account]
										}), /* @__PURE__ */ jsxs("p", {
											className: "text-xs text-blue-700 mt-1",
											children: [
												"Progress: ",
												syncProgress.current,
												" of",
												" ",
												syncProgress.total,
												" accounts"
											]
										})] }), /* @__PURE__ */ jsx("div", {
											className: "flex items-center gap-2",
											children: /* @__PURE__ */ jsxs("svg", {
												className: "animate-spin h-5 w-5 text-blue-600",
												xmlns: "http://www.w3.org/2000/svg",
												fill: "none",
												viewBox: "0 0 24 24",
												children: [/* @__PURE__ */ jsx("circle", {
													className: "opacity-25",
													cx: "12",
													cy: "12",
													r: "10",
													stroke: "currentColor",
													strokeWidth: "4"
												}), /* @__PURE__ */ jsx("path", {
													className: "opacity-75",
													fill: "currentColor",
													d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
												})]
											})
										})]
									})
								}),
								accounts.length === 0 ? /* @__PURE__ */ jsxs("div", {
									className: "bg-white rounded-xl border border-gray-200 p-12 text-center",
									children: [
										/* @__PURE__ */ jsx("svg", {
											className: "mx-auto h-12 w-12 text-gray-400",
											fill: "none",
											stroke: "currentColor",
											viewBox: "0 0 24 24",
											children: /* @__PURE__ */ jsx("path", {
												strokeLinecap: "round",
												strokeLinejoin: "round",
												strokeWidth: 2,
												d: "M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"
											})
										}),
										/* @__PURE__ */ jsx("h3", {
											className: "mt-4 text-lg font-medium text-gray-900",
											children: "No accounts yet"
										}),
										/* @__PURE__ */ jsx("p", {
											className: "mt-2 text-sm text-gray-600",
											children: "Get started by creating your first account"
										}),
										/* @__PURE__ */ jsx(Button, {
											onClick: () => setViewMode("add"),
											className: "mt-6 bg-blue-600 hover:bg-blue-700 text-white px-6 py-2.5 rounded-lg font-medium shadow-sm transition-colors",
											children: "Add Account"
										})
									]
								}) : /* @__PURE__ */ jsx(AccountsList, {
									accounts,
									onEdit: handleEditClick,
									onDelete: handleDeleteAccount,
									onUpdateKycStatus: handleUpdateKycStatus,
									onCreateTransactions: handleCreateTransactions,
									creatingTransactionsFor: creatingTransactionsFor || void 0
								})
							]
						}),
						viewMode === "add" && /* @__PURE__ */ jsxs("div", {
							className: "max-w-3xl",
							children: [/* @__PURE__ */ jsxs("div", {
								className: "mb-6",
								children: [/* @__PURE__ */ jsx("h2", {
									className: "text-2xl font-semibold text-gray-900",
									children: "Add New Account"
								}), /* @__PURE__ */ jsx("p", {
									className: "mt-1 text-sm text-gray-600",
									children: "Fill in the account details below"
								})]
							}), /* @__PURE__ */ jsx(AccountForm, {
								onSubmit: handleAddAccount,
								onCancel: handleCancelForm
							})]
						}),
						viewMode === "edit" && editingAccount && /* @__PURE__ */ jsxs("div", {
							className: "max-w-3xl",
							children: [/* @__PURE__ */ jsxs("div", {
								className: "mb-6",
								children: [/* @__PURE__ */ jsx("h2", {
									className: "text-2xl font-semibold text-gray-900",
									children: "Edit Account"
								}), /* @__PURE__ */ jsx("p", {
									className: "mt-1 text-sm text-gray-600",
									children: "Update the account details below"
								})]
							}), /* @__PURE__ */ jsx(AccountForm, {
								account: editingAccount,
								onSubmit: handleUpdateAccount,
								onCancel: handleCancelForm
							})]
						})
					] })
				})
			}),
			deleteConfirm.isOpen && /* @__PURE__ */ jsx("div", {
				className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50",
				onClick: () => setDeleteConfirm({
					isOpen: false,
					accountId: null,
					accountName: ""
				}),
				children: /* @__PURE__ */ jsxs("div", {
					className: "bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6",
					onClick: (e) => e.stopPropagation(),
					role: "dialog",
					"aria-modal": "true",
					"aria-labelledby": "delete-modal-title",
					children: [
						/* @__PURE__ */ jsx("h3", {
							id: "delete-modal-title",
							className: "text-lg font-semibold text-gray-900 mb-2",
							children: "Delete Account"
						}),
						/* @__PURE__ */ jsxs("p", {
							className: "text-gray-600 mb-6",
							children: [
								"Are you sure you want to delete \"",
								deleteConfirm.accountName,
								"\"? This action cannot be undone."
							]
						}),
						/* @__PURE__ */ jsxs("div", {
							className: "flex justify-end gap-3",
							children: [/* @__PURE__ */ jsx(Button, {
								onClick: () => setDeleteConfirm({
									isOpen: false,
									accountId: null,
									accountName: ""
								}),
								className: "px-4 py-2 border border-gray-300 rounded-lg font-medium text-gray-700 hover:bg-gray-50 transition-colors",
								children: "Cancel"
							}), /* @__PURE__ */ jsx(Button, {
								onClick: confirmDelete,
								className: "px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg font-medium transition-colors",
								children: "Delete Account"
							})]
						})
					]
				})
			}),
			syncConfirm && /* @__PURE__ */ jsx("div", {
				className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50",
				onClick: () => setSyncConfirm(false),
				children: /* @__PURE__ */ jsxs("div", {
					className: "bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6",
					onClick: (e) => e.stopPropagation(),
					role: "dialog",
					"aria-modal": "true",
					"aria-labelledby": "sync-modal-title",
					children: [
						/* @__PURE__ */ jsx("h3", {
							id: "sync-modal-title",
							className: "text-lg font-semibold text-gray-900 mb-2",
							children: "Sync Transactions"
						}),
						/* @__PURE__ */ jsxs("p", {
							className: "text-gray-600 mb-6",
							children: [
								"This will sync transactions for all ",
								accounts.length,
								" account",
								accounts.length !== 1 ? "s" : "",
								". Accounts without transaction documents will have them created automatically."
							]
						}),
						/* @__PURE__ */ jsxs("div", {
							className: "flex justify-end gap-3",
							children: [/* @__PURE__ */ jsx(Button, {
								onClick: () => setSyncConfirm(false),
								className: "px-4 py-2 border border-gray-300 rounded-lg font-medium text-gray-700 hover:bg-gray-50 transition-colors",
								children: "Cancel"
							}), /* @__PURE__ */ jsx(Button, {
								onClick: () => void handleSyncAllTransactions(),
								className: "px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors",
								children: "Sync All"
							})]
						})
					]
				})
			})
		]
	});
}
//#endregion
export { Editor as default };

//# sourceMappingURL=editor-BPjBGeXU.js.map