import { BlockAnnotation } from '../../../dto/annotations/block-annotation.abstract';
import { RTETableExtensionAnnotationTypeEnum } from './table-annotation';
import { VegaInternalThemeManager } from '../../../../../helpers/theme/internal-theme-manager';
import { RTE_TABLE_HEAD_DEFAULT_BACKGROUND_COLOR } from '../constants/styles.constants';
/**
 * Class representing a table caption annotation in the rich text editor.
 */
export class RTETableCaptionAnnotation extends BlockAnnotation {
  constructor() {
    super(...arguments);
    this.type = RTETableExtensionAnnotationTypeEnum.CAPTION;
  }
  /**
   * Get the default styles for the table caption annotation.
   *
   * @returns {AnnotationStyle} The default styles for the table caption annotation.
   */
  static getDefaultStyles() {
    return {
      padding: '8px',
      border: '1px solid #ddd',
      borderBottom: 'none',
      position: 'relative',
      textAlign: 'center',
      minHeight: '22px',
    };
  }
  /**
   * @inheritDoc
   */
  clone() {
    return new RTETableCaptionAnnotation();
  }
  /**
   * @inheritDoc
   */
  renderClass(options) {
    if (options === null || options === void 0 ? void 0 : options.standalone)
      return null;
    return 'v-rte--extension-table-caption';
  }
  /**
   * @inheritDoc
   */
  renderStyle(options) {
    if (!(options === null || options === void 0 ? void 0 : options.standalone))
      return null;
    return Object.assign(Object.assign({}, RTETableCaptionAnnotation.getDefaultStyles()), { backgroundColor: this.getCaptionBackgroundColor() });
  }
  /**
   * @inheritDoc
   */
  toJSON() {
    return {
      caption: true,
    };
  }
  /**
   * Get the background color for the caption based on the current theme mode.
   *
   * @returns {string} The background color for the caption.
   */
  getCaptionBackgroundColor() {
    return VegaInternalThemeManager.isDarkMode()
      ? RTE_TABLE_HEAD_DEFAULT_BACKGROUND_COLOR.dark
      : RTE_TABLE_HEAD_DEFAULT_BACKGROUND_COLOR.light;
  }
}
