class_docstr: Inspired by pygments/formatters/terminal256.py
class_docstr_tok: ["Inspired","by","pygments\/formatters\/terminal256.py"]
code: def _closest_color(self, r: int, g: int, b: int) -> tuple[int, int]:
      distance = (
          257 * 257 * 3
      )  # "infinity" (>distance from #000000 to #ffffff)
      fg_match = 0
      bg_match = 0
  
      for r_, g_, b_, fg_, bg_ in self._win32_colors:
          rd = r - r_
          gd = g - g_
          bd = b - b_
  
          d = rd * rd + gd * gd + bd * bd
  
          if d < distance:
              fg_match = fg_
              bg_match = bg_
              distance = d
      return fg_match, bg_match
  
imports: from __future__ import annotations
  import sys
  import os
  from ctypes import ArgumentError, byref, c_char, c_long, c_uint, c_ulong, pointer
  from ctypes.wintypes import DWORD, HANDLE
  from typing import Callable, TextIO, TypeVar
  from prompt_toolkit.cursor_shapes import CursorShape
  from prompt_toolkit.data_structures import Size
  from prompt_toolkit.styles import ANSI_COLOR_NAMES, Attrs
  from prompt_toolkit.utils import get_cwidth
  from prompt_toolkit.win32_types import CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE
  from ..utils import SPHINX_AUTODOC_RUNNING
  from .base import Output
  from .color_depth import ColorDepth
label_desc: Use image node_id 3 for calling the ColorLookupTable obj's underlying member method code with example usage: obj._closest_color(r, g, b) and returns: fg_match,  bg_match