'use client'; import React, { useState } from 'react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; import { Button } from '@/components/ui/button'; import { Check, ChevronDown, LockIcon, ZapIcon } from 'lucide-react'; import { ModelOption, SubscriptionStatus } from './_use-model-selection'; import { PaywallDialog } from '@/components/payment/paywall-dialog'; interface ModelSelectorProps { selectedModel: string; onModelChange: (modelId: string) => void; modelOptions: ModelOption[]; canAccessModel: (modelId: string) => boolean; } export const ModelSelector: React.FC = ({ selectedModel, onModelChange, modelOptions, canAccessModel, }) => { const [paywallOpen, setPaywallOpen] = useState(false); const [lockedModel, setLockedModel] = useState(null); const selectedLabel = modelOptions.find((o) => o.id === selectedModel)?.label || 'Select model'; const handleSelect = (id: string) => { if (canAccessModel(id)) { onModelChange(id); } else { setLockedModel(id); setPaywallOpen(true); } }; const closeDialog = () => { setPaywallOpen(false); setLockedModel(null); }; return (
{modelOptions.map((opt) => { const accessible = canAccessModel(opt.id); return ( handleSelect(opt.id)} >
{opt.id === 'sonnet-3.7' && ( )} {opt.label} {!accessible && }
{selectedModel === opt.id && ( )}
{opt.description}
{!accessible && (

Requires subscription to access

)}
); })}
{paywallOpen && ( m.id === lockedModel )?.label}` : 'Subscribe to access premium models' } ctaText="Subscribe Now" cancelText="Maybe Later" /> )}
); };