"use client"; import { useRouteLocale } from "@/components/layout/locale-context"; import Image from "next/image"; import Link from "next/link"; import { useEffect, useState, useSyncExternalStore } from "react"; import { applyLocale, getInitialLocale, withLocale, getLocaleMessages, type Locale } from "@/lib/i18n"; import { ThemeToggle } from "@/components/layout/theme-toggle"; const footerColumnHrefs = [ ["/policy/user-agreement", "/policy/privacy-policy", "/policy/disclaimer", "/policy/resource-pack"], ["/about", "/members", "/join-us"], ["mailto:connect@kivotos.cc", "mailto:infringement@kivotos.cc"], ] as const; const footerLegalHrefs = ["https://wiki.kivotosrailway.com", "https://url.kivotos.cc/status", "/links"] as const; const socialLinks = [ { label: "Bilibili", icon: "/icon/social/bilibili.svg", width: 28, height: 25, href: "https://space.bilibili.com/14823193" }, { label: "X", icon: "/icon/social/x.svg", width: 27, height: 28, href: "https://x.com/kivotosrailway" }, { label: "Xiaohongshu", icon: "/icon/social/xiaohongshu.svg", width: 28, height: 10, href: "https://www.xiaohongshu.com/user/profile/655396cf0000000008003eea" }, ] as const; function isIcpVisibleHost(hostname: string) { return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname.endsWith(".kivotos.cc"); } const subscribeToHost = () => () => {}; const getIcpVisibility = () => typeof window !== "undefined" && isIcpVisibleHost(window.location.hostname); const getServerIcpVisibility = () => false; export function SiteFooter() { const [locale, setLocale] = useState(useRouteLocale()); const showIcp = useSyncExternalStore(subscribeToHost, getIcpVisibility, getServerIcpVisibility); useEffect(() => { const syncLocale = (nextLocale: Locale) => setLocale(nextLocale); const handleLocaleChange = (event: Event) => { const nextLocale = (event as CustomEvent<{ locale?: Locale }>).detail?.locale ?? getInitialLocale(); syncLocale(nextLocale); }; const handleStorage = () => { syncLocale(getInitialLocale()); }; const currentLocale = getInitialLocale(); syncLocale(currentLocale); applyLocale(currentLocale); window.addEventListener("kr-locale-change", handleLocaleChange); window.addEventListener("storage", handleStorage); return () => { window.removeEventListener("kr-locale-change", handleLocaleChange); window.removeEventListener("storage", handleStorage); }; }, []); const messages = getLocaleMessages(locale); return ( ); }