import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { useCallback } from 'react';
import { Box, Newline, Text } from 'ink';
import { Colors } from '../colors.js';
import { useKeypress } from '../hooks/useKeypress.js';
const PROVIDER_INFO = {
    openai: {
        displayName: 'OpenAI',
        tosUrl: 'https://openai.com/policies/terms-of-use',
        privacyUrl: 'https://openai.com/policies/privacy-policy',
        keyPoints: [
            'API data is not used for training by default',
            '30-day data retention for abuse monitoring',
        ],
    },
    anthropic: {
        displayName: 'Anthropic',
        tosUrl: 'https://www.anthropic.com/legal/terms',
        privacyUrl: 'https://www.anthropic.com/legal/privacy',
        keyPoints: [
            'API data is not used for training',
            'Data retention for safety and legal compliance only',
        ],
    },
    fireworks: {
        displayName: 'Fireworks',
        tosUrl: 'https://fireworks.ai/terms-of-service',
        privacyUrl: 'https://fireworks.ai/privacy-policy',
        keyPoints: [
            'Data used only for service provision',
            'No model training on customer data',
        ],
    },
    openrouter: {
        displayName: 'OpenRouter',
        tosUrl: 'https://openrouter.ai/terms',
        privacyUrl: 'https://openrouter.ai/privacy',
        keyPoints: [
            'Acts as a proxy to multiple model providers',
            'Each underlying model may have additional terms',
        ],
    },
    local: {
        displayName: 'Local Model',
        tosUrl: '',
        privacyUrl: '',
        keyPoints: [
            'No data leaves your machine',
            'No external terms of service apply',
            'You control all data and privacy',
        ],
    },
};
// Aliases for provider name variations
const PROVIDER_ALIASES = {
    'lm-studio': 'local',
    lmstudio: 'local',
    ollama: 'local',
    llamacpp: 'local',
    'llama-cpp': 'local',
    'llama.cpp': 'local',
};
function getProviderInfo(providerName) {
    const normalizedName = providerName.toLowerCase();
    const aliasedName = PROVIDER_ALIASES[normalizedName] ?? normalizedName;
    return PROVIDER_INFO[aliasedName] ?? null;
}
function formatProviderName(providerName) {
    const info = getProviderInfo(providerName);
    if (info) {
        return info.displayName;
    }
    // Capitalize first letter for unknown providers
    return providerName.charAt(0).toUpperCase() + providerName.slice(1);
}
export const MultiProviderPrivacyNotice = ({ providerName, onExit, }) => {
    const handleKeypress = useCallback((key) => {
        if (key.name === 'escape') {
            onExit();
        }
    }, [onExit]);
    useKeypress(handleKeypress, { isActive: true });
    const providerInfo = getProviderInfo(providerName);
    const displayName = formatProviderName(providerName);
    const isLocal = providerInfo?.displayName === 'Local Model' ||
        PROVIDER_ALIASES[providerName.toLowerCase()] === 'local';
    return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { bold: true, color: Colors.AccentPurple, children: "LLxprt Code Privacy Notice" }), _jsx(Newline, {}), _jsxs(Text, { children: ["LLxprt Code does ", _jsx(Text, { bold: true, children: "NOT" }), " collect any telemetry or usage data."] }), _jsx(Text, { children: "All data handling is governed by your chosen AI provider's policies." }), _jsx(Newline, {}), _jsxs(Text, { bold: true, color: Colors.AccentCyan, children: ["Active Provider: ", displayName] }), _jsx(Newline, {}), isLocal ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: Colors.AccentGreen, children: "Local models keep all data on your machine." }), providerInfo?.keyPoints.map((point, index) => (_jsxs(Text, { children: ['  ', "- ", point] }, index)))] })) : providerInfo ? (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: Colors.AccentBlue, children: "[Terms]" }), " ", providerInfo.tosUrl] }), _jsxs(Text, { children: [_jsx(Text, { color: Colors.AccentGreen, children: "[Privacy]" }), ' ', providerInfo.privacyUrl] }), _jsx(Newline, {}), _jsx(Text, { bold: true, children: "Key points:" }), providerInfo.keyPoints.map((point, index) => (_jsxs(Text, { children: ['  ', "- ", point] }, index)))] })) : (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: ["Please refer to ", displayName, "'s terms of service and privacy policy"] }), _jsx(Text, { children: "for information about how your data is handled." })] })), _jsx(Newline, {}), _jsx(Text, { color: Colors.Gray, children: "For full provider information, see: docs/tos-privacy.md" }), _jsx(Newline, {}), _jsx(Text, { color: Colors.Gray, children: "Press Esc to exit." })] }));
};
//# sourceMappingURL=MultiProviderPrivacyNotice.js.map