import { SVGRenderer } from './svg-renderer';
import { CanvasRenderer } from './canvas-renderer';
/** The RendererFactory class provides a static method to create a renderer based on the type of context provided. */
export class RendererFactory {
  /**
   * This function returns a renderer based on the type of context provided (SVG or Canvas).
   *
   * @param {SVGElement | HTMLCanvasElement} context - The `context` parameter is either an
   * SVGElement or a HTMLCanvasElement. It is used to determine which renderer to instantiate and
   * return
   * @returns {BaseRenderer<SVGElement | HTMLCanvasElement> } based on the type of the `context` parameter. If
   * the `context` is an instance of `SVGElement`, an `SVGRenderer` object is returned
   */
  static get(context) {
    if (context instanceof SVGElement) {
      return new SVGRenderer(context);
    }
    else if (context instanceof HTMLCanvasElement) {
      return new CanvasRenderer(context);
    }
    else {
      throw new Error('Invalid context');
    }
  }
}
