import type { ServerSettings } from './api'

export function applySettings(settings: ServerSettings) {
  const root = document.documentElement
  root.removeAttribute('data-theme')
  if (settings.theme === 'light') root.setAttribute('data-theme', 'light')
  if (settings.theme === 'dark') root.setAttribute('data-theme', 'dark')
  root.removeAttribute('data-colorblind')
  if (settings.colorblind !== 'none') root.setAttribute('data-colorblind', String(settings.colorblind))
  root.style.fontSize = `${String(settings.textScale)}%`
  if (settings.torFriendly) root.classList.add('tor-friendly')
  else root.classList.remove('tor-friendly')
}