import { RTENode } from '../../../dto/nodes/node.abstract';
import stateEntityRenderingRegistry from '../../../slimmers/controllers/state-entity-rendering-registry';
/**
 * Class representing a logic control node in the rich text editor.
 */
export class RTELogicControlNode extends RTENode {
  constructor(id, text, parent) {
    super(id);
    this.dtoName = RTELogicControlNode.dtoName;
    this.type = 'logic-control-node';
    this.text = '';
    this.text = text;
    this.parent = parent;
  }
  /**
   * Clone the current node instance.
   *
   * @returns {RTELogicControlNode} - A new instance of RTELogicControlNode.
   */
  clone() {
    return new RTELogicControlNode(this.id, this.text, this.parent);
  }
  /**
   * Convert the node to its HTML representation.
   *
   * @returns {string} - The HTML string of the logic control node.
   */
  toHtml() {
    return this.text;
  }
  /**
   * Convert the node to a JSON representation.
   *
   * @returns {unknown} - The JSON object of the statement syntax node.
   */
  toJSON() {
    return {
      id: this.id,
      type: this.type,
      text: this.text,
    };
  }
  /**
   * Get the end offset of the node's range.
   *
   * @returns {number} - The end offset of the node's range.
   */
  getRangeEndOffset() {
    return 1;
  }
  /**
   * Get the container element for the node's range.
   *
   * @returns {Nullable<Node>} - The container node for the range.
   */
  getRangeContainer() {
    const element = stateEntityRenderingRegistry.getDOMByEntity(this);
    if (element) {
      return element.parentElement;
    }
  }
  /**
   * Get the content editable state of the node.
   *
   * @returns {boolean} - The content editable state of the node.
   */
  isContentEditable() {
    return false;
  }
}
RTELogicControlNode.dtoName = 'RTELogicControlNode';
