import { ChartDimensionController, DEFAULT_LAYOUT, } from '../controllers/chart-dimension-controller';
/** The LayoutInputProcessor class processes input chart options to calculate layout dimensions and margins. */
export class LayoutInputProcessor {
  /**
   * This function processes chart options and returns layout dimensions and margins.
   *
   * @param {ChartOptions<unknown>} input - A ChartOptions object containing the container and layout properties.
   * @returns {LayoutProcessResultType} An object with properties `width`, `height`, `innerWidth`, `innerHeight`, `top`, `right`,
   * `bottom`, and `left`.
   */
  process(input) {
    const { container, layout } = input;
    const { top, right, bottom, left } = ((layout === null || layout === void 0 ? void 0 : layout.margin) ||
      DEFAULT_LAYOUT.margin);
    const dimensionController = new ChartDimensionController(container);
    return {
      width: dimensionController.getContainerClientWidth(layout),
      height: dimensionController.getContainerClientHeight(layout),
      innerWidth: dimensionController.getContainerInnerWidth(layout),
      innerHeight: dimensionController.getContainerInnerHeight(layout),
      top,
      right,
      bottom,
      left,
    };
  }
}
