"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const colorRegistry = require("./colorRegistry.js");
function computeStyles(theme, styleMap) {
  const styles = /* @__PURE__ */ Object.create(null);
  for (let key in styleMap) {
    const value = styleMap[key];
    if (value) {
      styles[key] = colorRegistry.resolveColorValue(value, theme);
    }
  }
  return styles;
}
function attachStyler(themeService, styleMap, widgetOrCallback) {
  function applyStyles() {
    const styles = computeStyles(themeService.getColorTheme(), styleMap);
    if (typeof widgetOrCallback === "function") {
      widgetOrCallback(styles);
    } else {
      widgetOrCallback.style(styles);
    }
  }
  applyStyles();
  return themeService.onDidColorThemeChange(applyStyles);
}
function attachBadgeStyler(widget, themeService, style) {
  return attachStyler(themeService, {
    badgeBackground: (style === null || style === void 0 ? void 0 : style.badgeBackground) || colorRegistry.badgeBackground,
    badgeForeground: (style === null || style === void 0 ? void 0 : style.badgeForeground) || colorRegistry.badgeForeground,
    badgeBorder: colorRegistry.contrastBorder
  }, widget);
}
function attachListStyler(widget, themeService, overrides) {
  return attachStyler(themeService, Object.assign(Object.assign({}, defaultListStyles), overrides || {}), widget);
}
const defaultListStyles = {
  listFocusBackground: colorRegistry.listFocusBackground,
  listFocusForeground: colorRegistry.listFocusForeground,
  listFocusOutline: colorRegistry.listFocusOutline,
  listActiveSelectionBackground: colorRegistry.listActiveSelectionBackground,
  listActiveSelectionForeground: colorRegistry.listActiveSelectionForeground,
  listActiveSelectionIconForeground: colorRegistry.listActiveSelectionIconForeground,
  listFocusAndSelectionBackground: colorRegistry.listActiveSelectionBackground,
  listFocusAndSelectionForeground: colorRegistry.listActiveSelectionForeground,
  listInactiveSelectionBackground: colorRegistry.listInactiveSelectionBackground,
  listInactiveSelectionIconForeground: colorRegistry.listInactiveSelectionIconForeground,
  listInactiveSelectionForeground: colorRegistry.listInactiveSelectionForeground,
  listInactiveFocusBackground: colorRegistry.listInactiveFocusBackground,
  listInactiveFocusOutline: colorRegistry.listInactiveFocusOutline,
  listHoverBackground: colorRegistry.listHoverBackground,
  listHoverForeground: colorRegistry.listHoverForeground,
  listDropBackground: colorRegistry.listDropBackground,
  listSelectionOutline: colorRegistry.activeContrastBorder,
  listHoverOutline: colorRegistry.activeContrastBorder,
  listFilterWidgetBackground: colorRegistry.listFilterWidgetBackground,
  listFilterWidgetOutline: colorRegistry.listFilterWidgetOutline,
  listFilterWidgetNoMatchesOutline: colorRegistry.listFilterWidgetNoMatchesOutline,
  listMatchesShadow: colorRegistry.widgetShadow,
  treeIndentGuidesStroke: colorRegistry.treeIndentGuidesStroke,
  tableColumnsBorder: colorRegistry.tableColumnsBorder,
  tableOddRowsBackgroundColor: colorRegistry.tableOddRowsBackgroundColor
};
const defaultMenuStyles = {
  shadowColor: colorRegistry.widgetShadow,
  borderColor: colorRegistry.menuBorder,
  foregroundColor: colorRegistry.menuForeground,
  backgroundColor: colorRegistry.menuBackground,
  selectionForegroundColor: colorRegistry.menuSelectionForeground,
  selectionBackgroundColor: colorRegistry.menuSelectionBackground,
  selectionBorderColor: colorRegistry.menuSelectionBorder,
  separatorColor: colorRegistry.menuSeparatorBackground,
  scrollbarShadow: colorRegistry.scrollbarShadow,
  scrollbarSliderBackground: colorRegistry.scrollbarSliderBackground,
  scrollbarSliderHoverBackground: colorRegistry.scrollbarSliderHoverBackground,
  scrollbarSliderActiveBackground: colorRegistry.scrollbarSliderActiveBackground
};
function attachMenuStyler(widget, themeService, style) {
  return attachStyler(themeService, Object.assign(Object.assign({}, defaultMenuStyles), style), widget);
}
exports.attachBadgeStyler = attachBadgeStyler;
exports.attachListStyler = attachListStyler;
exports.attachMenuStyler = attachMenuStyler;
exports.attachStyler = attachStyler;
exports.computeStyles = computeStyles;
exports.defaultListStyles = defaultListStyles;
exports.defaultMenuStyles = defaultMenuStyles;
