/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { M as o } from "./common.js";
import { v as i, w as n, x as c } from "./type-guards.js";
async function s(t) {
  const r = "config" in t ? i(t.config) : t.chartType;
  let a;
  if (!("layer" in t) && !("iLayer" in t) && "config" in t && t.config.iLayer === void 0)
    throw new Error(
      "The source is missing. You can provide it to createModel through either `iLayer`, `layer`, or by setting the `config.iLayer` property."
    );
  switch (r) {
    case o.LineChart: {
      const { LineChartModel: e } = await import("./line-chart-model.js");
      a = new e();
      break;
    }
    case o.ComboBarLineChart: {
      const { ComboBarLineChartModel: e } = await import("./combo-bar-line-chart-model.js");
      a = new e();
      break;
    }
    case o.PieChart: {
      const { PieChartModel: e } = await import("./pie-chart-model.js");
      a = new e();
      break;
    }
    case o.Histogram: {
      const { HistogramModel: e } = await import("./histogram-model.js");
      a = new e();
      break;
    }
    case o.Scatterplot: {
      const { ScatterplotModel: e } = await import("./scatterplot-model.js");
      a = new e();
      break;
    }
    case o.BoxPlot: {
      const { BoxPlotModel: e } = await import("./box-plot-model.js");
      a = new e();
      break;
    }
    case o.Gauge: {
      const { GaugeModel: e } = await import("./gauge-model.js");
      a = new e();
      break;
    }
    case o.RadarChart: {
      const { RadarChartModel: e } = await import("./radar-chart-model.js");
      a = new e();
      break;
    }
    case o.HeatChart: {
      const { HeatChartModel: e } = await import("./heat-chart-model.js");
      a = new e();
      break;
    }
    case o.BarChart:
    default: {
      const { BarChartModel: e } = await import("./bar-chart-model.js");
      a = new e();
      break;
    }
  }
  if (await a?.setup({
    layer: "layer" in t ? t.layer : void 0,
    iLayer: "iLayer" in t ? t.iLayer : void 0,
    config: "config" in t ? t.config : void 0
  }), r !== void 0 && n(a, r))
    return a;
  {
    const e = c(a.chartType);
    throw new Error(
      `Please check the arguments provided to \`createModel\`. The generated model's type (\`${e}\`) does not match the type specified by either the \`chartType\` or the \`config\` argument (\`${r}\`).`
    );
  }
}
export {
  s as c
};
