"use client";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useLicense } from "./LicenseContext";
import { EmailEntry } from "./EmailEntry";
import { LicenseActivationForm } from "./LicenseActivationForm";
import { LicenseCodeEntry } from "./LicenseCodeEntry";
import { Button } from "../components/ui/button";
import { AlertCircle, CheckCircle, KeyRound, RefreshCw } from "lucide-react";
export function LicenseOverlay() {
    const { activationState, error, isLoading, licenseType, daysRemaining, activationEmail, activationRetryAfterSeconds, checkEmail, submitLicenseRequest, submitActivationCode, startActivation, } = useLicense();
    // Don't render if idle or just checking
    if (activationState === "idle") {
        return null;
    }
    return (_jsx("div", { className: "bg-neutral-grey-100/40 fixed inset-0 z-[9999] flex items-center justify-center p-4 backdrop-blur-sm", children: _jsxs("div", { className: "w-full max-w-2xl", children: [_jsxs("div", { className: "overflow-hidden rounded-2xl border-none bg-white shadow-2xl", children: [_jsx("div", { className: "bg-neutral-grey-5 h-1 w-full", children: _jsx("div", { className: "bg-feedback-blue h-full w-full" }) }), _jsxs("div", { className: "flex min-h-[520px] flex-col items-center justify-center p-12", children: [_jsx("div", { className: "bg-feedback-blue-light ring-feedback-blue mb-8 rounded-2xl p-6 ring-1", children: _jsx(KeyRound, { className: "text-feedback-blue h-16 w-12", strokeWidth: 1.5 }) }), activationState === "loading" && (_jsxs("div", { className: "text-neutral-grey-50 flex flex-col items-center gap-3", children: [_jsx(RefreshCw, { className: "text-feedback-blue h-10 w-10 animate-spin" }), _jsx("p", { className: "text-sm font-medium", children: "Processing..." })] })), activationState === "email_entry" && (_jsx(EmailEntry, { onSubmit: checkEmail, error: error })), activationState === "trial_form" && activationEmail && (_jsx(LicenseActivationForm, { email: activationEmail, onSubmit: submitLicenseRequest, onBack: () => startActivation(), error: error })), activationState === "code_entry" && (_jsx(LicenseCodeEntry, { email: activationEmail || "", onSubmit: submitActivationCode, onBack: () => startActivation(), error: error, retryAfterSeconds: activationRetryAfterSeconds })), activationState === "trial_expired" && (_jsxs("div", { className: "max-w-md text-center", children: [_jsx("div", { className: "bg-feedback-orange-light mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(AlertCircle, { className: "text-feedback-orange h-8 w-8" }) }), _jsx("h2", { className: "text-neutral-grey-100 mb-4 text-3xl font-bold tracking-tight", children: "Trial Expired" }), _jsx("p", { className: "text-neutral-grey-50 leading-relaxed", children: "Your trial period has ended. Please contact us to purchase a license." }), _jsx(Button, { asChild: true, size: "lg", className: "mt-8", children: _jsx("a", { href: "mailto:sales@parhelia.ai?subject=License%20Inquiry", children: "Contact Sales" }) })] })), activationState === "welcome_back" && (_jsxs("div", { className: "animate-in fade-in zoom-in text-feedback-green flex flex-col items-center gap-3 duration-500", children: [_jsx("div", { className: "bg-feedback-green-light rounded-full p-3", children: _jsx(CheckCircle, { className: "h-10 w-10", strokeWidth: 2 }) }), _jsx("h2", { className: "text-neutral-grey-100 text-xl font-semibold", children: "Welcome back" }), _jsx("p", { className: "text-neutral-grey-50 text-center", children: licenseType === "trial" ? (_jsxs(_Fragment, { children: ["Your trial is active again on this environment.", " ", daysRemaining != null &&
                                                        `${daysRemaining} days remaining.`] })) : ("Your license has been restored.") })] })), activationState === "success" && (_jsxs("div", { className: "animate-in fade-in zoom-in text-feedback-green flex flex-col items-center gap-3 duration-500", children: [_jsx("div", { className: "bg-feedback-green-light rounded-full p-3", children: _jsx(CheckCircle, { className: "h-10 w-10", strokeWidth: 2 }) }), _jsx("h2", { className: "text-neutral-grey-100 text-xl font-semibold", children: "License Activated!" }), _jsx("p", { className: "text-neutral-grey-50 text-center", children: licenseType === "trial" ? (_jsxs(_Fragment, { children: ["Your trial is now active.", " ", daysRemaining && `${daysRemaining} days remaining.`] })) : ("Your license has been activated successfully.") })] })), activationState === "error" && (_jsxs("div", { className: "max-w-md text-center", children: [_jsx("div", { className: "bg-feedback-red-light mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(AlertCircle, { className: "text-feedback-red h-8 w-8" }) }), _jsx("h2", { className: "text-neutral-grey-100 mb-2 text-2xl font-bold", children: "Error" }), _jsx("p", { className: "text-neutral-grey-50", children: error || "An error occurred" }), _jsx(Button, { size: "lg", onClick: () => startActivation(), className: "mt-8", children: "Try Again" })] }))] })] }), _jsxs("p", { className: "text-neutral-grey-50 mt-8 text-center text-xs", children: ["\u00A9 ", new Date().getFullYear(), " Parhelia. All rights reserved."] })] }) }));
}
//# sourceMappingURL=LicenseOverlay.js.map