import { BlockAnnotation, BlockAnnotationTypeEnum } from './block-annotation.abstract';
/**
 * Text style annotation
 */
export class TextStyleAnnotation extends BlockAnnotation {
  constructor(textStyle) {
    super();
    this.type = BlockAnnotationTypeEnum.TEXT_STYLE;
    this.textStyle = textStyle;
  }
  /**
   * Generate the map item for the annotations
   *
   * @param {VegaRTETextStyleType} textStyle - the text style type
   * @returns {[BlockAnnotationTypeEnum.TEXT_STYLE, TextStyleAnnotation]} Map item for the annotation
   */
  static from(textStyle) {
    return [BlockAnnotationTypeEnum.TEXT_STYLE, new TextStyleAnnotation(textStyle)];
  }
  /**
   * Get the default styles for a given text style type.
   *
   * @param {VegaRTETextStyleType} textStyle - The text style type.
   * @returns {Nullable<AnnotationStyle>} The default styles for the given text style type.
   */
  static getDefaultStyles(textStyle) {
    const textStyleBase = {
      fontFamily: 'Inter',
      fontSize: '16px',
      lineHeight: '22px',
      minHeight: '22px',
      fontWeight: '500',
    };
    const paragraphStyle = Object.assign(Object.assign({}, textStyleBase), { marginTop: '0px', marginBottom: '0px' });
    switch (textStyle) {
      case 'paragraph': {
        return paragraphStyle;
      }
      case 'title': {
        return Object.assign(Object.assign({}, textStyleBase), { fontSize: '36px', lineHeight: '40px', minHeight: '40px' });
      }
      case 'subtitle': {
        return Object.assign(Object.assign({}, textStyleBase), { fontSize: '28px', lineHeight: '32px', minHeight: '32px' });
      }
      case 'heading-1': {
        return Object.assign(Object.assign({}, paragraphStyle), { fontSize: '22px', lineHeight: '24px', minHeight: '24px' });
      }
      case 'heading-2': {
        return Object.assign(Object.assign({}, paragraphStyle), { fontSize: '20px', lineHeight: '24px', minHeight: '24px' });
      }
      case 'heading-3': {
        return Object.assign(Object.assign({}, paragraphStyle), { fontSize: '18px' });
      }
      case 'heading-4': {
        return Object.assign({}, paragraphStyle);
      }
      case 'heading-5': {
        return Object.assign(Object.assign({}, paragraphStyle), { fontSize: '14px' });
      }
      case 'heading-6': {
        return Object.assign(Object.assign({}, paragraphStyle), { fontSize: '12px' });
      }
      default:
        return null;
    }
  }
  /**
   * Generate the JSON representation of the annotation
   *
   * @returns {Nullable<Record<string, unknown>>} JSON representation of the annotation
   */
  toJSON() {
    return { textStyle: this.textStyle };
  }
  /**
   * @inheritDoc
   */
  clone() {
    return new TextStyleAnnotation(this.textStyle);
  }
  /**
   * @inheritDoc
   */
  renderClass(options) {
    if (options === null || options === void 0 ? void 0 : options.standalone)
      return null;
    return this.textStyle ? `v-rte--text-style-${this.textStyle}` : null;
  }
  /**
   * @inheritDoc
   */
  renderStyle(options) {
    if (!(options === null || options === void 0 ? void 0 : options.standalone))
      return null;
    return this.textStyle ? TextStyleAnnotation.getDefaultStyles(this.textStyle) : null;
  }
}
