import {
  make_one_checkbox
} from "./chunk-SA7APTJR.js";
import "./chunk-HJ6L54YS.js";
import {
  HandlerBase
} from "./chunk-LSEFWW72.js";
import "./chunk-SKREEF3H.js";
import "./chunk-HYOEWQ5P.js";
import "./chunk-HBW42TDT.js";
import "./chunk-G6O3URDN.js";
import "./chunk-FN5XPUPH.js";
import "./chunk-IIT367QZ.js";
import "./chunk-RZGEKL77.js";
import "./chunk-UI7OCM2A.js";
import "./chunk-YZK37YCC.js";
import "./chunk-7EMWHCVW.js";
import "./chunk-7IYJZZQI.js";
import "./chunk-M3J4MINX.js";
import "./chunk-PF4DSFDR.js";
import "./chunk-QH6W3NVF.js";
import "./chunk-NOEAT6CX.js";
import "./chunk-4UWS5Y3N.js";
import "./chunk-DD4R5P6W.js";
import "./chunk-JNITUVXP.js";
import "./chunk-KSGA62R2.js";
import "./chunk-LOZEKOES.js";
import "./chunk-TOU7EVFQ.js";
import "./chunk-OAWQ6LOO.js";
import "./chunk-TLT4YIG3.js";
import "./chunk-KYBIQBXE.js";
import "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import "./chunk-HFNDKYVF.js";

// termsetting/handlers/NumContEditor.ts
var NumContEditor = class extends HandlerBase {
  constructor(opts, handler) {
    super(opts);
    this.dom = {};
    this.termsetting = opts.termsetting;
    this.tw = opts.termsetting.tw;
    this.handler = handler;
    this.q = this.setDefaultQ();
  }
  setDefaultQ() {
    if (this.tw.q.mode == "continuous") return JSON.parse(JSON.stringify(this.tw.q));
    return { mode: "continuous" };
  }
  async showEditMenu(div) {
    this.tw = this.handler.tw;
    this.q = this.setDefaultQ();
    if (this.dom.inputsDiv) {
      if (div.node().contains(this.dom.inputsDiv.node())) return;
      else delete this.dom.inputsDiv;
    }
    this.dom.density_div = div.append("div");
    await this.handler.density.showViolin(this.dom.density_div);
    this.dom.inputsDiv = div.append("div");
    if (this.termsetting.opts.usecase?.target == "matrix") {
      this.dom.convert2ZCheckbox = await make_one_checkbox({
        holder: this.dom.inputsDiv.append("div"),
        labeltext: "Convert to Z-score",
        checked: this.q.convert2ZScore ? true : false,
        divstyle: { display: "inline-block", padding: "3px 10px" },
        callback: (checked) => {
          this.q.convert2ZScore = checked;
          if (checked) {
            this.dom.scaleSelect.property("value", 1);
            delete this.q.scale;
          }
        }
      });
    }
    const selectDiv = this.dom.inputsDiv.append("div").style("display", "inline-block");
    selectDiv.append("div").style("display", "inline-block").style("padding", "3px 10px").html("Scale values");
    this.dom.scaleSelect = selectDiv.append("select").on("change", (event) => {
      if (event.target.value == "1") delete this.q.scale;
      else {
        if (this.dom.convert2ZCheckbox) this.dom.convert2ZCheckbox.property("checked", false);
        this.q.scale = Number(event.target.value);
      }
    });
    this.dom.scaleSelect.selectAll("option").data([
      { html: "No Scaling", value: 1 },
      { html: "Per 10", value: 10 },
      { html: "Per 100", value: 100 },
      { html: "Per 1000", value: 1e3 }
    ]).enter().append("option").attr("value", (d) => d.value).html((d) => d.html).property("selected", (d) => "scale" in this.q && d.value == this.q.scale);
  }
  getEditedQ() {
    const scaleValue = this.dom.scaleSelect.property("value");
    if (scaleValue == "1") delete this.q.scale;
    else this.q.scale = Number(scaleValue);
    if (this.dom.convert2ZCheckbox) this.q.convert2ZScore = this.dom.convert2ZCheckbox.property("checked");
    return this.q;
  }
  destroy() {
    for (const name of Object.keys(this.dom)) {
      this.dom[name].remove();
      delete this.dom[name];
    }
  }
};
export {
  NumContEditor
};
//# sourceMappingURL=NumContEditor-4CSTHVRX.js.map
