"use client"; import Link from "next/link"; import { ArrowRight, BellRing, CheckCircle2, Coins, Crown, Loader2, Lock, MessageSquare, Radar, Send, Sparkles, TrendingUp, Wallet, X, Zap, } from "lucide-react"; import s from "./UnlockProOverlay.module.css"; export type UnlockProBilling = { pointsEnabled: boolean; isEligible: boolean; pointsUsed: number; discountAmount: number; finalPrice: number; maxDiscountUsd: number; pointsPerUsd: number; }; type UnlockProOverlayProps = { points: number; planPriceUsd: number; usePoints: boolean; billing: UnlockProBilling; onToggleUsePoints: () => void; onPay: () => void; onClose?: () => void; payBusy?: boolean; payLabel?: string; locale?: "zh-CN" | "en-US"; errorText?: string; infoText?: string; faqHref?: string; telegramGroupUrl?: string; }; const FEATURES = { "zh-CN": ["15天高精度趋势预报", "实时多源雷达图", "全平台智能气象推送"], "en-US": [ "15-day precision forecast", "Real-time radar panel", "Cross-platform alerts", ], }; export function UnlockProOverlay({ points, planPriceUsd, usePoints, billing, onToggleUsePoints, onPay, onClose, payBusy = false, payLabel, locale = "zh-CN", errorText, infoText, faqHref = "/account", telegramGroupUrl, }: UnlockProOverlayProps) { const isEn = locale === "en-US"; const canUsePoints = billing.pointsEnabled && billing.isEligible; const featureList = FEATURES[locale] ?? FEATURES["zh-CN"]; const finalPayLabel = payLabel || (isEn ? "Subscribe & Activate" : "立即订阅并激活服务"); const progressPct = billing.pointsEnabled ? Math.min(100, Math.round((points / billing.pointsPerUsd) * 100)) : 0; return (
{/* Ambient glows */}
{/* Close button */} {onClose && ( )} {/* ── Header ── */}
Pro

{isEn ? "Unlock PolyWeather Pro" : "解锁 PolyWeather Pro"}

{isEn ? "High-precision weather intelligence, delivered everywhere." : "全球最精准的高精度气象推送,全平台覆盖"}

{/* ── Cards ── */}
{/* Left: Plan card */}
Standard Pro
${planPriceUsd.toFixed(2)} / {isEn ? "mo" : "月"}
    {featureList.map((item, i) => (
  • {item}
  • ))}
{/* Right: Points card */} {canUsePoints ? (
{/* Header row */}
{isEn ? "Points Credit" : "积分抵扣"}
{/* Discount amount */}
-${billing.discountAmount.toFixed(2)} off

{usePoints ? isEn ? `Using ${billing.pointsUsed} pts · saves $${billing.discountAmount.toFixed(2)}` : `已消耗 ${billing.pointsUsed} 积分 · 省 $${billing.discountAmount.toFixed(2)}` : isEn ? `Toggle to save up to $${billing.maxDiscountUsd.toFixed(2)}` : `开启可最多抵扣 $${billing.maxDiscountUsd.toFixed(2)}`}

{isEn ? "Balance:" : "当前积分:"}{" "} {points}
) : ( /* Not eligible */
{!billing.pointsEnabled ? isEn ? "Points Disabled" : "积分未开启" : isEn ? "Insufficient Points" : "积分不足"}

{isEn ? "Earn Points & Save" : "赚取积分,抵扣订阅"}

{!billing.pointsEnabled ? isEn ? "Points redemption is unavailable for this plan." : "当前套餐暂不支持积分抵扣。" : isEn ? `Need ${billing.pointsPerUsd} pts minimum. You have: ${points}` : `至少需要 ${billing.pointsPerUsd} 积分,当前仅有 ${points}`}

{billing.pointsEnabled && (
{points} / {billing.pointsPerUsd} {progressPct}%
)}
{telegramGroupUrl ? ( {isEn ? "Join Telegram to earn" : "加入电报群赚取积分"} ) : ( {isEn ? "Join community to earn points" : "加入社群即可赚取积分"} )}
)}
{/* ── Payment summary ── */}

{isEn ? "Total Due Today" : "今日应付"}

{billing.discountAmount > 0 && usePoints && (

${planPriceUsd.toFixed(2)} USD

)}
${billing.finalPrice.toFixed(2)} USD
{/* ── Footer ── */}
{isEn ? "Secure Payment" : "安全付款"} · {isEn ? "Subscription FAQ" : "订阅说明"}
{/* ── Error / Info ── */} {errorText && (
{errorText}
)} {infoText && (
{infoText}
)}
); }