"use client"; import Link from "next/link"; import { AlertTriangle, CreditCard, LogIn, RefreshCw, } from "lucide-react"; const ACCESS_TERM = { signInToContinue: { en: "Sign in to continue", zh: "请先登录" }, proAccessRequired: { en: "Subscription expired", zh: "订阅已过期", }, month: { en: "/ 30 days", zh: "/ 30 天" }, subscribeNow: { en: "Renew and restore access", zh: "续费并恢复访问", }, backToProduct: { en: "Back to product overview", zh: "返回产品介绍页" }, } as const; function t(key: keyof typeof ACCESS_TERM, isEn: boolean) { return isEn ? ACCESS_TERM[key].en : ACCESS_TERM[key].zh; } function isExpiredSubscription(expiresAt?: string | null) { if (!expiresAt) return false; const timestamp = Date.parse(expiresAt); return Number.isFinite(timestamp) && timestamp <= Date.now(); } function formatSubscriptionDate(expiresAt: string | null | undefined, isEn: boolean) { if (!expiresAt) return ""; const timestamp = Date.parse(expiresAt); if (!Number.isFinite(timestamp)) return ""; try { return new Intl.DateTimeFormat(isEn ? "en-US" : "zh-CN", { day: "2-digit", month: "short", year: "numeric", }).format(new Date(timestamp)); } catch { return ""; } } // ─── Layer 2: Authenticated but no active subscription ─────────────────────── function SubscriptionGate({ isEn, subscriptionExpiresAt, }: { isEn: boolean; subscriptionExpiresAt?: string | null; }) { const expired = isExpiredSubscription(subscriptionExpiresAt); const expiryLabel = formatSubscriptionDate(subscriptionExpiresAt, isEn); const features = isEn ? [ "Real-time station, METAR, and runway signals", "DEB forecast curves and model comparison", "Full terminal grid with high-frequency refresh", "API and paid Telegram group access on paid Pro", ] : [ "实时气象站、METAR 与跑道信号", "DEB 预测曲线与模型对比", "完整终端网格与高频刷新", "付费 Pro 可进入 API 与付费 Telegram 群", ]; return (
{expired ? t("proAccessRequired", isEn) : isEn ? "No active subscription" : "无有效订阅"}

{isEn ? "Access paused" : "终端访问已暂停"}

{expired ? isEn ? "Your subscription has expired" : "订阅已过期,终端访问已暂停" : isEn ? "No active Pro subscription" : "未检测到有效订阅"}

{expiryLabel ? isEn ? `Expired ${expiryLabel}` : `到期日 ${expiryLabel}` : isEn ? "Action required" : "需要处理"}

{isEn ? "Renew to restore the Weather Terminal" : "续费后恢复天气决策台访问"}

{isEn ? "Your account is verified, but it does not currently have an active subscription. Renewing restores live temperature evidence, DEB paths, runway alerts, and paid Telegram/API access." : "你的账号已验证,但当前没有有效订阅。续费后会立即恢复实时温度、DEB 路径、跑道提醒和付费 Telegram/API 权益。"}

29.9 USDC {t("month", isEn)}
    {features.map((f) => (
  • {f}
  • ))}
{t("subscribeNow", isEn)}

{isEn ? "Already paid but still blocked?" : "已有付款但未恢复?"}

{isEn ? "Open account center" : "账户中心"}

{isEn ? "Access resumes automatically after payment confirmation" : "付款确认后会自动恢复访问"}

← {t("backToProduct", isEn)}
); } // ─── Layer 1 fallback: Should not normally appear (middleware handles it) ───── function UnauthenticatedGate({ isEn, userLocalTime, }: { isEn: boolean; userLocalTime: string; }) { return (
); } export function ProductAccessRequired({ isAuthenticated, isEn, subscriptionExpiresAt, userLocalTime, }: { isAuthenticated: boolean; isEn: boolean; subscriptionExpiresAt?: string | null; userLocalTime: string; }) { if (!isAuthenticated) { return ; } return (
); }