import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useState, useCallback } from "react";
import { Button } from "../../../components/ui/button";
import { setupWizardService } from "../../../setup/services/setupWizardService";
import { SetupStepBackButton, SetupStepFooter, SetupStepLayout, } from "../SetupStepLayout";
import { Check, RefreshCw, ArrowRight, AlertCircle } from "lucide-react";
import { ParheliaIcon } from "../../ui/ParheliaIcon";
export function CompleteStep({ licenseConfigured, chatModelId, imageModelId, embeddingsModelId, onFinish, onBack, }) {
    const [finishing, setFinishing] = useState(false);
    const handleFinish = useCallback(async () => {
        try {
            setFinishing(true);
            // 1. Set default chat/image models on Settings item
            await setupWizardService.setDefaultModels({
                chatModelId,
                imageModelId,
            });
            // 2. If embeddings model selected, create/update Search Settings
            if (embeddingsModelId) {
                await setupWizardService.setEmbeddingsConfig({
                    modelId: embeddingsModelId,
                });
            }
            // 3. Mark setup as complete
            await setupWizardService.completeSetup();
            onFinish();
        }
        catch (e) {
            alert("Failed to save final settings: " + e.message);
        }
        finally {
            setFinishing(false);
        }
    }, [chatModelId, imageModelId, embeddingsModelId, onFinish]);
    return (_jsx(SetupStepLayout, { header: _jsxs("div", { className: "mb-8 flex flex-col items-center text-center", children: [_jsx("div", { className: "mb-8 flex items-center justify-center", children: _jsx(ParheliaIcon, { size: 96 }) }), _jsx("h2", { className: "text-neutral-grey-100 mb-4 text-3xl font-medium tracking-tight", children: "Parhelia is ready to go!" }), _jsx("p", { className: "text-neutral-grey-50 max-w-md leading-relaxed", children: "Parhelia is now configured and ready to transform your content workflow. Let's get to work." })] }), bodyClassName: "flex flex-col items-center text-center", footer: _jsxs(SetupStepFooter, { children: [_jsx(SetupStepBackButton, { onClick: onBack, disabled: finishing }), _jsx("div", { className: "flex-1" }), _jsx(Button, { size: "lg", onClick: handleFinish, disabled: finishing, children: finishing ? (_jsx(RefreshCw, { className: "h-4 w-4 animate-spin" })) : (_jsxs(_Fragment, { children: ["Launch Parhelia", _jsx(ArrowRight, { className: "ml-2 h-4 w-4", strokeWidth: 3 })] })) })] }), children: _jsxs("div", { className: "w-full max-w-sm space-y-4 text-left", children: [_jsx("h3", { className: "text-neutral-grey-100 block text-[14px] font-medium", children: "Final Configuration" }), _jsx("div", { className: "space-y-2", children: [
                        {
                            label: "License",
                            value: licenseConfigured ? "configured" : undefined,
                        },
                        { label: "Chat", value: chatModelId },
                        { label: "Image", value: imageModelId },
                        { label: "Embeddings", value: embeddingsModelId },
                    ].map((item) => (_jsxs("div", { className: "border-border-default flex items-center justify-between rounded-[8px] border px-3 py-2.5", children: [_jsx("span", { className: "text-neutral-grey-50 text-xs font-medium", children: item.label }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: `text-xs font-medium ${item.value ? "text-feedback-green" : "text-neutral-grey-50"}`, children: item.value ? "Configured" : "Not Set" }), item.value ? (_jsx("span", { className: "bg-feedback-green flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-white", children: _jsx(Check, { className: "h-3 w-3", strokeWidth: 3 }) })) : (_jsx(AlertCircle, { className: "text-neutral-grey-50 h-4 w-4" }))] })] }, item.label))) })] }) }));
}
//# sourceMappingURL=CompleteStep.js.map