import { ROUTES } from "./routes"; export type RouteAccess = | "public" | "guestEntry" | "session" | "realUser" | "authOnly"; const GLOBAL_ROUTE_ACCESS: Partial> = { [ROUTES.root]: "public", [ROUTES.splash]: "authOnly", [ROUTES.auth]: "authOnly", [ROUTES.chat]: "guestEntry", [ROUTES.privateZone]: "guestEntry", [ROUTES.tip]: "public", [ROUTES.externalEntry]: "public", [ROUTES.profile]: "realUser", [ROUTES.feedback]: "session", [ROUTES.subscription]: "realUser", [ROUTES.coinsRules]: "public", }; const CHARACTER_ROUTE_ACCESS: Readonly> = { splash: "authOnly", chat: "guestEntry", "private-zone": "guestEntry", tip: "public", }; export function getRouteAccess(pathname: string): RouteAccess { const globalAccess = GLOBAL_ROUTE_ACCESS[pathname]; if (globalAccess) return globalAccess; const match = pathname.match(/^\/characters\/[^/]+\/([^/]+)\/?$/); return (match?.[1] && CHARACTER_ROUTE_ACCESS[match[1]]) || "public"; } export function isInternalRoute(value: string | null | undefined): boolean { return Boolean(value && value.startsWith("/") && !value.startsWith("//")); }