import type { CustomApiKey } from '@/lib/custom-api-store';
import type { ManagedSystemApi } from '@/lib/model-config-types';

function compactLabel(parts: Array<string | null | undefined>): string {
  return parts.map(part => part?.trim()).filter(Boolean).join(' / ');
}

export function getCustomApiModelLabel(key: CustomApiKey | undefined): string {
  if (!key) return '自定义模型';
  return key.note?.trim() || compactLabel([key.supplierName || key.provider, key.modelName]) || key.modelName || '自定义模型';
}

export function getSystemApiModelLabel(api: ManagedSystemApi | undefined): string {
  if (!api) return '系统模型';
  return api.note?.trim() || compactLabel([api.name || api.provider, api.modelName]) || api.modelName || '系统模型';
}
