"use client"; import { Loader2, X } from "lucide-react"; import { useTranslations } from "next-intl"; import type { ParsedMailto } from "@/lib/protocol-handlers/mailto"; import type { ParsedWebcal } from "@/lib/protocol-handlers/webcal"; import type { AccountEntry } from "@/stores/account-store"; import { cn } from "@/lib/utils"; import { Avatar } from "@/components/ui/avatar"; type ProtocolAccountPickerProps = { accounts: AccountEntry[]; activeAccountId: string | null; isSwitching?: boolean; onSelect: (accountId: string) => void; onCancel: () => void; } & ( | { kind: "mailto"; operation?: ParsedMailto } | { kind: "webcal"; operation?: ParsedWebcal } ); function getHost(value: string): string { try { return new URL(value).hostname; } catch { return value; } } export function ProtocolAccountPicker({ kind, accounts, activeAccountId, isSwitching = false, onSelect, onCancel, operation, }: ProtocolAccountPickerProps) { const t = useTranslations("protocol_handlers"); const tCommon = useTranslations("common"); const details = operation ? kind === "mailto" ? [ { label: t("detail_to"), value: operation.to.join(", ") || "-" }, { label: t("detail_subject"), value: operation.subject || t("detail_no_subject") }, ] : [ { label: t("detail_calendar"), value: operation.suggestedName }, { label: t("detail_source"), value: getHost(operation.subscriptionUrl) }, ] : []; return (
); }