/* Copyright (C) 2023-2026 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { Wrench01Icon } from '@hugeicons/core-free-icons' import { HugeiconsIcon } from '@hugeicons/react' import { useTranslation } from 'react-i18next' import { StatusBadge } from '@/components/status-badge' import { Badge } from '@/components/ui/badge' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip' import { formatLogQuota } from '@/lib/format' import { hasToolSurcharge } from '../lib/format' import type { LogOtherData } from '../types' interface LogCostDisplayProps { quota: number other: LogOtherData | null } function splitQuotaDisplay(value: string): { prefix: string; amount: string } { const match = value.match(/^([^0-9+\-.,\s]+)(.+)$/) if (!match) return { prefix: '', amount: value } return { prefix: match[1], amount: match[2] } } function ToolSurchargeMarker() { const { t } = useTranslation() const label = t('Includes tool-call surcharge') return ( ) } function QuotaBadge(props: { quota: number }) { const quotaDisplay = splitQuotaDisplay(formatLogQuota(props.quota)) return ( {quotaDisplay.prefix ? ( {quotaDisplay.prefix} ) : null} {quotaDisplay.amount} ) } function SubscriptionBadge(props: { quota: number }) { const { t } = useTranslation() return ( } /> {t('Deducted by subscription')}: {formatLogQuota(props.quota)} ) } export function LogCostDisplay(props: LogCostDisplayProps) { const isSubscription = props.other?.billing_source === 'subscription' const showToolSurcharge = hasToolSurcharge(props.other) if (!isSubscription && !showToolSurcharge) { return (
) } return (
{isSubscription ? ( ) : ( )} {showToolSurcharge ? : null}
) }