import { BlockAnnotation, BlockAnnotationTypeEnum } from './block-annotation.abstract';
/**
 * Annotation to make block with horizontal alignment
 */
export class HorizontalAlignmentAnnotation extends BlockAnnotation {
  constructor(textAlign) {
    super();
    this.type = BlockAnnotationTypeEnum.ALIGNMENT;
    this.textAlign = textAlign;
  }
  /**
   * Generate the map item for the annotation
   *
   * @param {VegaRTEBlockAlignment} textAlign - Text alignment
   * @returns {[BlockAnnotationTypeEnum.ALIGNMENT, HorizontalAlignmentAnnotation]} Map item for the annotation
   */
  static from(textAlign) {
    return [BlockAnnotationTypeEnum.ALIGNMENT, new HorizontalAlignmentAnnotation(textAlign)];
  }
  /**
   * Get the default standalone styles for a given alignment value.
   *
   * @param {VegaRTEBlockAlignment} textAlign - The alignment value.
   * @returns {AnnotationStyle} The default standalone styles.
   */
  static getDefaultStyles(textAlign) {
    switch (textAlign) {
      case 'right':
      case 'center':
      case 'justify':
        return { textAlign };
      case 'left':
      default:
        return { textAlign: 'left' };
    }
  }
  /**
   * Generate the JSON item of the annotation
   *
   * @returns {Record<string, unknown>} JSON representation of the annotation
   */
  toJSON() {
    return {
      textAlign: this.textAlign,
    };
  }
  /**
   * @inheritDoc
   */
  renderClass(options) {
    if (options === null || options === void 0 ? void 0 : options.standalone)
      return null;
    switch (this.textAlign) {
      case 'right':
      case 'center':
      case 'justify':
        return `v-rte--horizontal-alignment-${this.textAlign}`;
      case 'left':
      default:
        return `v-rte--horizontal-alignment-left`;
    }
  }
  /**
   * @inheritDoc
   */
  clone() {
    return new HorizontalAlignmentAnnotation(this.textAlign);
  }
  /**
   * @inheritDoc
   */
  renderStyle(options) {
    if (!(options === null || options === void 0 ? void 0 : options.standalone))
      return null;
    return HorizontalAlignmentAnnotation.getDefaultStyles(this.textAlign);
  }
}
