import {
  agedx
} from "./chunk-32AI7I4C.js";
import {
  NumericHandler
} from "./chunk-ZXTHADSC.js";
import "./chunk-WHI6466S.js";
import {
  termjson
} from "./chunk-DHPLHIVP.js";
import {
  require_tape
} from "./chunk-QWOE5YTB.js";
import {
  TwRouter
} from "./chunk-SA7APTJR.js";
import "./chunk-HJ6L54YS.js";
import "./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 {
  select_default
} from "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import {
  __toESM
} from "./chunk-HFNDKYVF.js";

// termsetting/handlers/test/NumContEditor.unit.spec.ts
var import_tape = __toESM(require_tape(), 1);
async function getNumericHandler(opts = {}) {
  const term = JSON.parse(JSON.stringify(termjson.agedx));
  const rawTw = {
    term,
    q: {
      mode: "continuous"
    }
  };
  const tw = await TwRouter.initRaw(rawTw);
  const handler = new NumericHandler({
    termsetting: {
      tw,
      term: rawTw.term,
      q: rawTw.q,
      opts: {
        numericEditMenuVersion: ["continuous", "discrete", "binary", "spline"],
        usecase: opts.usecase
      },
      api: {
        runCallback() {
        }
      },
      dom: {
        tip: {
          hide() {
          }
        }
      },
      vocabApi: {
        getViolinBox() {
          return agedx;
        }
      }
    }
  });
  const holder = select_default("body").append("div").style("position", "relative").style("width", "fit-content").style("margin", "20px").style("padding", "5px").style("border", "1px solid #000");
  await handler.setEditHandler(handler.tabs[0]);
  return {
    rawTw,
    tw,
    handler,
    editHandler: handler.editHandler,
    holder,
    destroy: () => {
      if ("destroy" in handler.editHandler) handler.editHandler.destroy();
      if (typeof handler.destroy == "function") handler.destroy();
      holder.remove();
    }
  };
}
(0, import_tape.default)("\n", (test) => {
  test.comment("-***- NumContEditor.unit.spec -***-");
  test.end();
});
(0, import_tape.default)("no opts.usecase", async (test) => {
  const { editHandler, holder, destroy } = await getNumericHandler();
  await editHandler.showEditMenu(holder);
  test.equal(editHandler.dom?.density_div.selectAll("svg").size(), 1, `should render a density plot svg`);
  test.equal(
    editHandler.dom.inputsDiv.selectAll("option").size(),
    4,
    `should render scale dropdown with the expected number of options`
  );
  test.equal(
    editHandler.dom.inputsDiv.selectAll(`input[type='checkbox']`).size(),
    0,
    `should not render a checkbox for z-score conversion`
  );
  const scaleValue = 100;
  editHandler.dom?.scaleSelect.property("value", scaleValue);
  editHandler.dom?.scaleSelect.node().dispatchEvent(new Event("change", { bubbles: true }));
  test.equal(editHandler.q.scale, scaleValue, `should set q.scale to ${scaleValue}`);
  test.deepEqual(
    editHandler.getEditedQ(),
    { mode: "continuous", isAtomic: true, hiddenValues: {}, scale: 100 },
    `should give the expected edited q object`
  );
  if (test._ok) destroy();
  test.end();
});
(0, import_tape.default)(`opts.usecase={target: 'matrix'}`, async (test) => {
  const { editHandler, holder, destroy } = await getNumericHandler({ usecase: { target: "matrix" } });
  await editHandler.showEditMenu(holder);
  test.equal(editHandler.dom?.density_div.selectAll("svg").size(), 1, `should render a density plot svg`);
  test.equal(
    editHandler.dom?.inputsDiv.selectAll("option").size(),
    4,
    `should render scale dropdown with the expected number of options`
  );
  test.equal(
    editHandler.dom?.inputsDiv.selectAll(`input[type='checkbox']`).size(),
    1,
    `should render a checkbox for z-score conversion`
  );
  const scaleValue = 1e3;
  editHandler.dom.scaleSelect.property("value", scaleValue);
  editHandler.dom.scaleSelect.node().dispatchEvent(new Event("change", { bubbles: true }));
  editHandler.dom.convert2ZCheckbox.property("checked", true);
  editHandler.dom.convert2ZCheckbox.node().dispatchEvent(new Event("input", { bubbles: true }));
  test.equal(editHandler.q.scale, void 0, `should delete q.scale when convert2ZCheckbox is checked`);
  editHandler.dom.scaleSelect.property("value", scaleValue);
  editHandler.dom.scaleSelect.node().dispatchEvent(new Event("change", { bubbles: true }));
  test.equal(
    editHandler.dom.convert2ZCheckbox.property("checked"),
    false,
    `should set convert2ZCheckbox to false when scale is set to >1`
  );
  test.deepEqual(
    editHandler.getEditedQ(),
    { mode: "continuous", isAtomic: true, hiddenValues: {}, convert2ZScore: false, scale: 1e3 },
    `should give the expected edited q object`
  );
  if (test._ok) destroy();
  test.end();
});
//# sourceMappingURL=NumContEditor.unit.spec-2YF3OS3A.js.map
