"use client"; import Link from "next/link"; import { ArrowRight, BellRing, CheckCircle2, Coins, Crown, ExternalLink, Loader2, Lock, MessageSquare, Radar, Send, Sparkles, TrendingUp, Wallet, X, Zap, } from "lucide-react"; import s from "./UnlockProOverlay.module.css"; const DEFAULT_FAQ_HREF = "/subscription-help"; const DEFAULT_TELEGRAM_GROUP_URL = ""; 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; onManualPay?: () => void; onClose?: () => void; payBusy?: boolean; payLabel?: string; manualPayLabel?: string; locale?: "zh-CN" | "en-US"; errorText?: string; infoText?: string; faqHref?: string; telegramGroupUrl?: string; txHash?: string; chainId?: number; paymentTokenLabel?: string; }; const FEATURES = { "zh-CN": [ "市场扫描台 + V4-Pro 深度复核", "今日日内机场报文规则分析(含高温时段)", "未来日期分析 + 城市决策卡", "全平台智能气象推送", ], "en-US": [ "Market Scan Terminal + V4-Pro review", "Intraday METAR rule-based analysis with peak-time window", "Future-date analysis + city decision cards", "Cross-platform alerts", ], }; export function UnlockProOverlay({ points, planPriceUsd, usePoints, billing, onToggleUsePoints, onPay, onManualPay, onClose, payBusy = false, payLabel, manualPayLabel, locale = "zh-CN", errorText, infoText, faqHref = DEFAULT_FAQ_HREF, telegramGroupUrl = DEFAULT_TELEGRAM_GROUP_URL, txHash, chainId = 137, paymentTokenLabel, }: 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 maxDiscountUsdInt = Math.max(1, Math.floor(billing.maxDiscountUsd || 0)); const maxPointsForFullDiscount = Math.max( billing.pointsPerUsd, billing.pointsPerUsd * maxDiscountUsdInt, ); const redeemableUsdNow = billing.pointsEnabled ? Math.min(maxDiscountUsdInt, Math.floor(points / Math.max(1, billing.pointsPerUsd))) : 0; const progressPct = billing.pointsEnabled ? Math.min(100, Math.round((points / maxPointsForFullDiscount) * 100)) : 0; const resolvedTelegramGroupUrl = String(telegramGroupUrl || "").trim(); const txHref = txHash && txHash.startsWith("0x") ? `${chainId === 137 ? "https://polygonscan.com" : "https://etherscan.io"}/tx/${txHash}` : ""; 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)} {isEn ? "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 ? `Now redeemable: $${redeemableUsdNow.toFixed(0)} / $${maxDiscountUsdInt.toFixed(0)}` : `当前可抵:${redeemableUsdNow.toFixed(0)}U / ${maxDiscountUsdInt.toFixed(0)}U`}

{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 ? `Starts at ${billing.pointsPerUsd} pts, ${billing.pointsPerUsd} pts per $1, up to $${maxDiscountUsdInt}. You have: ${points}` : `满 ${billing.pointsPerUsd} 分起兑,每 ${billing.pointsPerUsd} 分抵 1U,最多抵 ${maxDiscountUsdInt}U。当前 ${points} 分`}

{billing.pointsEnabled && (
{points} / {maxPointsForFullDiscount} {isEn ? `$${redeemableUsdNow.toFixed(0)} / $${maxDiscountUsdInt.toFixed(0)}` : `${redeemableUsdNow.toFixed(0)}U / ${maxDiscountUsdInt.toFixed(0)}U`}
)}
{resolvedTelegramGroupUrl ? ( {isEn ? "Invite paid users to earn points" : "邀请付费用户即可获得积分"} ) : ( {isEn ? "Invite paid users to earn points" : "邀请付费用户即可获得积分"} )}
)}
{/* ── Payment summary ── */}

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

{paymentTokenLabel && (

{isEn ? "Token" : "支付币种"}: {paymentTokenLabel}

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

${planPriceUsd.toFixed(2)} USD

)}
${billing.finalPrice.toFixed(2)} USD
{onManualPay ? ( ) : null} {onManualPay ? (

{isEn ? "Choose one payment method only. Do not pay again after the order is completed." : "请只选择一种支付方式;订单完成后请勿重复付款。"}

) : null}
{/* ── Footer ── */}
{isEn ? "Secure Payment" : "安全付款"} · {isEn ? "Subscription FAQ" : "订阅说明"}
{/* ── Error / Info ── */} {errorText && (
{errorText}
)} {infoText && (
{infoText}
{txHref && ( {isEn ? "View on-chain transaction" : "查看链上交易"} )}
)}
); }