"use client"; import { useTranslation } from "react-i18next"; type DocPageKey = | "overview" | "delivery" | "quickstart" | "fundamentals" | "setup" | "sso" | "iframe" | "wallet" | "transfer" | "errors" | "troubleshooting" | "golive"; const INTEGRATION_DOCS_NS = "integrationDocs"; function asStringArray(value: unknown): string[] { return Array.isArray(value) ? value.filter((item): item is string => typeof item === "string") : []; } function asStringMatrix(value: unknown): string[][] { return Array.isArray(value) ? value.filter((row): row is string[] => Array.isArray(row) && row.every((cell) => typeof cell === "string")) : []; } export function useIntegrationDoc(page: DocPageKey) { const { t } = useTranslation(INTEGRATION_DOCS_NS); return { t, p: (key: string) => t(`pages.${page}.${key}`, { ns: INTEGRATION_DOCS_NS }), rows: (key: string) => asStringMatrix(t(`pages.${page}.${key}`, { returnObjects: true, ns: INTEGRATION_DOCS_NS })), list: (key: string) => asStringArray(t(`pages.${page}.${key}`, { returnObjects: true, ns: INTEGRATION_DOCS_NS })), header: (key: string) => asStringArray(t(`headers.${key}`, { returnObjects: true, ns: INTEGRATION_DOCS_NS })), }; }