import { t } from '#cli/i18n'

export function getMcpSettingsDialogStrings() {
  return {
    title: t('mcpSettingsDialog.title'),
    hint: t('mcpSettingsDialog.hint'),
    configFileLabel: t('mcpSettingsDialog.configFileLabel'),
    noServersHint: t('mcpSettingsDialog.noServersHint'),
    serverCount: t('mcpSettingsDialog.serverCount'),
    guideText: t('mcpSettingsDialog.guideText'),
    openFile: t('mcpSettingsDialog.openFile'),
    reload: t('mcpSettingsDialog.reload'),
    close: t('mcpSettingsDialog.close'),
    status: t('mcpSettingsDialog.status'),
    tools: t('mcpSettingsDialog.toolCount'),
    disabled: t('mcpSettingsDialog.disabled'),
    test: t('mcpSettingsDialog.testConnection'),
    exampleFormat: t('mcpSettingsDialog.exampleFormat'),
  } as const
}

export type McpSettingsDialogLayout = Readonly<{
  dialogW: number
  dialogH: number
  innerW: number
  innerH: number
  contentH: number
  showHint: boolean
}>

export function computeMcpSettingsDialogLayout(
  input: Readonly<{ w: number; h: number }>,
): McpSettingsDialogLayout {
  const dialogW = Math.max(60, Math.floor(input.w))
  const dialogH = Math.max(20, Math.floor(input.h))
  const innerW = Math.max(0, dialogW - 4)
  const innerH = Math.max(0, dialogH - 4)
  const contentH = Math.max(0, innerH - 1)
  const showHint = dialogH >= 20

  return {
    dialogW,
    dialogH,
    innerW,
    innerH,
    contentH,
    showHint,
  }
}
