export const DocsAppsHomeGrid = () => { const labelOverrides = new Map([ ["api-keys", "API Keys"], ["rbac", "RBAC"], ]); const toStartCase = (value) => { const override = labelOverrides.get(value); if (override != null) { return override; } return value .split("-") .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) .join(" "); }; const fallbackApps = [ { name: "Authentication", href: "/guides/apps/authentication/overview", iconSrc: "/images/app-icons/authentication.svg" }, { name: "Emails", href: "/guides/apps/emails/overview", iconSrc: "/images/app-icons/emails.svg" }, { name: "Payments", href: "/guides/apps/payments/overview", iconSrc: "/images/app-icons/payments.svg" }, { name: "Analytics", href: "/guides/apps/analytics/overview", iconSrc: "/images/app-icons/analytics.svg" }, { name: "Teams", href: "/guides/apps/teams/overview", iconSrc: "/images/app-icons/teams.svg" }, { name: "Fraud Protection", href: "/guides/apps/fraud-protection/overview", iconSrc: "/images/app-icons/fraud-protection.svg" }, { name: "RBAC", href: "/guides/apps/rbac/overview", iconSrc: "/images/app-icons/rbac.svg" }, { name: "API Keys", href: "/guides/apps/api-keys/overview", iconSrc: "/images/app-icons/api-keys.svg" }, { name: "Data Vault", href: "/guides/apps/data-vault/overview", iconSrc: "/images/app-icons/data-vault.svg" }, { name: "Webhooks", href: "/guides/apps/webhooks/overview", iconSrc: "/images/app-icons/webhooks.svg" }, { name: "Launch Checklist", href: "/guides/apps/launch-checklist/overview", iconSrc: "/images/app-icons/launch-checklist.svg" }, ]; const getAppsFromSidebar = () => { if (typeof document === "undefined") { return fallbackApps; } const sidebarRoot = document.querySelector("ul#sidebar-group"); if (sidebarRoot == null) { return fallbackApps; } const candidateLinks = sidebarRoot.querySelectorAll('a[href^="/guides/apps/"]'); const appItems = []; const seenHrefs = new Set(); for (const link of candidateLinks) { const href = link.getAttribute("href"); if (href == null || seenHrefs.has(href)) { continue; } const iconImage = link.querySelector("img"); if (iconImage == null) { continue; } const textContent = link.textContent?.replace(/\s+/g, " ").trim(); const slug = href.replace(/^\/guides\/apps\//, "").split("/")[0]; const iconSrc = iconImage.getAttribute("src") ?? `/images/app-icons/${slug}.svg`; const name = textContent != null && textContent.length > 0 ? textContent : toStartCase(slug); seenHrefs.add(href); appItems.push({ name, href, iconSrc }); } if (appItems.length === 0) { return fallbackApps; } return appItems; }; const appLinks = getAppsFromSidebar(); const onExploreSearchInput = (event) => { const input = event.currentTarget; const root = input.closest("[data-explore-apps-root='true']"); if (root == null) { return; } const query = input.value.trim().toLowerCase(); const cards = root.querySelectorAll("[data-explore-app-card='true']"); let visibleCount = 0; for (const card of cards) { const appName = (card.getAttribute("data-app-name") ?? "").toLowerCase(); const isVisible = query.length === 0 || appName.includes(query); card.style.display = isVisible ? "" : "none"; if (isVisible) { visibleCount += 1; } } const emptyState = root.querySelector("[data-explore-app-empty='true']"); if (emptyState != null) { emptyState.style.display = visibleCount === 0 ? "block" : "none"; } }; return (
); };