import {
  NumericModes
} from "./chunk-NOEAT6CX.js";
import "./chunk-4UWS5Y3N.js";
import "./chunk-KSGA62R2.js";
import "./chunk-LOZEKOES.js";
import "./chunk-TOU7EVFQ.js";
import "./chunk-OAWQ6LOO.js";
import "./chunk-KYBIQBXE.js";
import "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-HFNDKYVF.js";

// plots/numericDictTermCluster.ts
function makeChartBtnMenu(holder, chartsInstance) {
  chartsInstance.dom.tip.clear();
  const menuDiv = holder.append("div");
  if (chartsInstance.state.termdbConfig.numericDictTermCluster?.plots) {
    for (const plot of chartsInstance.state.termdbConfig.numericDictTermCluster.plots) {
      menuDiv.append("button").style("margin", "10px").style("padding", "10px 15px").style("border-radius", "20px").style("border-color", "#ededed").style("display", "inline-block").text(plot.name).on("click", async () => {
        chartsInstance.dom.tip.hide();
        const config = await chartsInstance.app.vocabApi.getNumericDictTermClusterByName(plot.name);
        config.preBuiltPlotTitle = plot.name;
        chartsInstance.app.dispatch({
          type: "plot_create",
          config
        });
      });
    }
  }
  const chart = {
    //use the app name defined in dataset file
    label: chartsInstance.state.termdbConfig.numericDictTermCluster?.appName || "Numeric Dictionary Term cluster",
    chartType: "numericDictTermCluster",
    clickTo: chartsInstance.showTree_selectlst,
    usecase: {
      target: "numericDictTermCluster",
      detail: { exclude: chartsInstance.state.termdbConfig.numericDictTermCluster?.exclude }
    },
    updateActionBySelectedTerms: (action, termlst) => {
      const twlst = termlst.map((term) => ({
        term: structuredClone(term),
        q: { mode: NumericModes.continuous }
      }));
      if (twlst.length == 1) {
        action.config.chartType = "summary";
        action.config.term = twlst[0];
        return;
      }
      if (twlst.length == 2) {
        action.config.chartType = "summary";
        action.config.term = twlst[0];
        action.config.term2 = twlst[1];
        return;
      }
      action.config.chartType = "hierCluster";
      action.config.dataType = "numericDictTerm";
      action.config.termgroups = [
        {
          name: chartsInstance.state.termdbConfig.numericDictTermCluster?.settings?.termGroupName || "Numeric Dictionary Term Cluster",
          lst: twlst,
          type: "hierCluster"
        }
      ];
    }
  };
  chartsInstance.showTree_selectlst(chart);
}
export {
  makeChartBtnMenu
};
//# sourceMappingURL=numericDictTermCluster-TFXBBUVI.js.map
