import { BaseChart } from './base-chart';
import { ArcPathDrawer } from './drawers/arc-path-drawer';
import { LegendDrawer } from './drawers/legend-drawer';
import { TextDrawer } from './drawers/text-drawer';
import { LayoutInputProcessor } from './input-processors/layout-input-processor';
import { ProcessorChain } from './input-processors/processor-chain';
import { PieChartArchPathInputProcessor } from './input-processors/pie-chart-arc-path-input-processor';
import { PieChartTextInputProcessor } from './input-processors/pie-chart-text-input-processor';
import { LegendInputProcessor } from './input-processors/legend-input-processor';
import { PieChartFilterInputProcessor } from './input-processors/pie-chart-filter-input-processor';
import { PieChartRadiusInputProcessor } from './input-processors/pie-chart-radius-input-processor';
/**
 * The PieChart class is a TypeScript implementation of a pie chart that extends the BaseChart class
 * and includes methods for creating a drawer chain
 */
export class PieChart extends BaseChart {
  constructor() {
    super(...arguments);
    this.layoutInputProcessor = new LayoutInputProcessor();
    this.filterInputProcessor = new PieChartFilterInputProcessor();
    this.radiusInputProcessor = new PieChartRadiusInputProcessor();
    this.arcPathInputProcessorChain = new ProcessorChain([
      this.filterInputProcessor,
      this.layoutInputProcessor,
      this.radiusInputProcessor,
      new PieChartArchPathInputProcessor(),
    ]);
    this.textInputProcessor = new PieChartTextInputProcessor();
    this.legendInputProcessChain = new ProcessorChain([
      this.layoutInputProcessor,
      new LegendInputProcessor(),
    ]);
  }
  /**
   * This function creates an array of BaseDrawer objects for rendering a chart with legends, and paths.
   *
   * @param {BaseRenderer<SVGElement | HTMLCanvasElement>} renderer - an instance of a BaseRenderer class that can render SVG or Canvas elements.
   * @param {BaseInteractor<SVGElement | HTMLCanvasElement>} interactor - an instance of a BaseInteractor class
   * @returns {BaseDrawer<unknown>[]} An array of BaseDrawer array.
   */
  createDrawerChain(renderer, interactor) {
    const arcPathProcessorChainOutput = this.arcPathInputProcessorChain.process(this.options);
    const legendInputProcessChainOutput = this.legendInputProcessChain.process(this.options);
    return [
      new ArcPathDrawer(renderer, interactor, {
        renderOptions: arcPathProcessorChainOutput,
      }),
      new TextDrawer(renderer, interactor, {
        renderOptions: this.textInputProcessor.process(arcPathProcessorChainOutput),
      }),
      new LegendDrawer(renderer, interactor, {
        renderOptions: legendInputProcessChainOutput,
      }),
    ];
  }
}
