import { Node } from '../node.js';

const LEVELS = new Map([
    ['note', { icon: 'information-line', color: 'blue-cumulus' }],
    ['tip', { icon: 'lightbulb-line', color: 'green-emeraude' }],
    ['important', { icon: 'feedback-line', color: 'purple-glycine' }],
    ['warning', { icon: 'alert-line', color: 'yellow-moutarde' }],
    ['caution', { icon: 'spam-2-line', color: 'pink-tuile' }]
  ]);

class BlockquoteNode extends Node {
  constructor (data) {
    super(data, 'div');
    if (this.children[0]?.type === 'heading') this.children[0].attributes.addClass('fr-callout__title');
    this.attributes.addClass('fr-callout fr-mb-6v');

    if (data?.level && LEVELS.has(data.level)) {
      this.children[0].attributes.addClass('fr-callout__title');
      const level = LEVELS.get(data.level);
      this.attributes.addClasses(`fr-icon-${level.icon}`, `fr-callout--${level.color}`);
    }
  }
}

BlockquoteNode.TYPE = 'blockquote';

export { BlockquoteNode };
