/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import "@arcgis/toolkit/type";
import { W as a, w as E } from "./series-types.js";
import "@arcgis/toolkit/intl";
import "lodash-es";
import "luxon";
import "d3-array";
import { dj as B, d5 as y, o as x, dp as u, a3 as f, _ as b } from "./index.js";
import "@arcgis/core/geometry/support/jsonUtils.js";
import "@arcgis/core/rest/support/AttributeBinsQuery.js";
import "@arcgis/core/rest/support/StatisticDefinition.js";
import "@arcgis/core/time/TimeExtent.js";
import "@arcgis/core/core/promiseUtils.js";
import "@arcgis/core/request.js";
import "./runtime.js";
import "@arcgis/toolkit/dom";
import { D as e, a as o, A as n } from "./index5.js";
import "@arcgis/core/intl.js";
import { i as g, r as F } from "./type-guards.js";
import { i as I } from "./rotated-state.js";
const D = [
  e.EditChart,
  e.Legend,
  e.RotateChart,
  e.FilterBySelection,
  e.FilterByExtent,
  e.Zoom,
  e.Selection,
  e.ClearSelection,
  e.FullExtent,
  e.SwitchSelection,
  e.ExportAsCSV,
  e.ExportAsImage
], L = [
  e.EditChart,
  e.Legend,
  e.RotateChart,
  e.FilterBySelection,
  e.FilterByExtent,
  e.Zoom,
  e.Selection,
  e.ClearSelection,
  e.FullExtent,
  e.SwitchSelection,
  e.ExportAsImage,
  e.ExportAsCSV
], T = [
  e.EditChart,
  e.Legend,
  e.RotateChart,
  e.FilterBySelection,
  e.FilterByExtent,
  e.Zoom,
  e.Selection,
  e.ClearSelection,
  e.FullExtent,
  e.SwitchSelection,
  e.ExportAsImage,
  e.ExportAsCSV
], v = [
  e.EditChart,
  e.Legend,
  e.FilterBySelection,
  e.FilterByExtent,
  e.Selection,
  e.ClearSelection,
  e.SwitchSelection,
  e.ExportAsImage,
  e.ExportAsCSV
], w = [
  e.EditChart,
  e.Legend,
  e.FilterBySelection,
  e.Selection,
  e.ClearSelection,
  e.SwitchSelection,
  e.ExportAsImage
], V = [
  e.EditChart,
  e.Legend,
  e.FilterBySelection,
  e.FilterByExtent,
  e.Zoom,
  e.Selection,
  e.ClearSelection,
  e.FullExtent,
  e.SwitchSelection,
  e.ExportAsImage,
  e.ExportAsCSV
], M = [
  e.EditChart,
  e.Legend,
  e.FilterBySelection,
  e.FilterByExtent,
  e.Zoom,
  e.Selection,
  e.ClearSelection,
  e.FullExtent,
  e.SwitchSelection,
  e.ExportAsImage,
  e.ExportAsCSV
], P = [
  e.EditChart,
  e.Legend,
  e.RotateChart,
  e.FilterBySelection,
  e.FilterByExtent,
  e.Zoom,
  e.Selection,
  e.ClearSelection,
  e.FullExtent,
  e.SwitchSelection,
  e.ExportAsImage,
  e.ExportAsCSV
], Z = [
  e.EditChart,
  e.FilterByExtent,
  e.ExportAsImage,
  e.ExportAsCSV
];
function ie(c) {
  switch (c) {
    case a.BarSeries:
      return D;
    case a.LineSeries:
      return L;
    case a.ComboLineAndBarSeries:
      return T;
    case a.PieSeries:
      return v;
    case a.HistogramSeries:
      return V;
    case a.ScatterSeries:
      return M;
    case a.BoxPlotSeries:
      return P;
    case a.GaugeSeries:
      return Z;
    case a.HeatSeries:
      return w;
    default:
      return [];
  }
}
const oe = (c, i, t) => {
  const l = c.target.assignedNodes().find((S) => "legendToggle" in S), s = E(t?.series);
  return l && (l.chartType = s, H({
    actionBar: l,
    chartComponent: i,
    config: t
  })), l;
};
function H(c) {
  const { actionBar: i, chartComponent: t, config: r, isWarningDisplayed: l } = c, s = B(t.selectionData), S = r?.legend ? r.legend.visible ?? !0 : !1;
  if (i.chartType = E(r?.series), t.enableConfiguration) {
    const h = i.hiddenActions ?? [];
    i.hiddenActions = h.filter((A) => A !== e.EditChart);
  }
  i.editChartState = t.enableConfiguration ? o.Enabled : o.Disabled;
  const d = r && y(r.series);
  i.legendState = d ? o.Enabled : o.Disabled;
  const m = g(t?.model) && F(t?.model) ? t.model.legendVisibility : S;
  i.legendToggle = d && m ? n.Active : n.Inactive;
  const p = g(t?.model) && I(t.model) ? t.model.rotatedState : r?.rotated;
  i.rotateChartToggle = p ? n.Active : n.Inactive;
  const C = x(r?.series ?? []) === u.PieFromFields;
  i.filterBySelectionState = !C && (t.filterBySelection === !0 || !s && t.filterByExtent !== !0) ? o.Enabled : o.Disabled, i.filterBySelectionToggle = t.filterBySelection === !0 ? n.Active : n.Inactive, i.filterByExtentState = t.filterByExtent === !0 || t.filterBySelection !== !0 ? o.Enabled : o.Disabled, i.filterByExtentToggle = t.filterByExtent === !0 ? n.Active : n.Inactive, i.zoomState = t.filterBySelection ? o.Disabled : o.Enabled, i.zoomToggle = t.actionMode === f.Zoom ? n.Active : n.Inactive, i.selectionState = t.filterBySelection ? o.Disabled : o.Enabled, i.selectionToggle = (t.actionMode ?? i.actionBarSelectionMode) === i.actionBarSelectionMode ? n.Active : n.Inactive, i.clearSelectionState = s ? o.Disabled : o.Enabled, i.fullExtentState = t.filterBySelection ? o.Disabled : o.Enabled, i.switchSelectionState = t.filterBySelection ? o.Disabled : o.Enabled, i.exportActionState = l || b(r) ? o.Disabled : o.Enabled;
}
export {
  ie as g,
  oe as o,
  H as u
};
