import {
  getPillNameDefault,
  renderTable
} 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 "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import "./chunk-HFNDKYVF.js";

// termsetting/handlers/samplelst.ts
function getHandler(self) {
  return {
    showEditMenu(div) {
      div.selectAll("*").remove();
      const q = self.q;
      if (self.vocabApi.termdbConfig?.displaySampleIds && self.vocabApi.hasVerifiedToken()) {
        const groups = q.groups;
        for (const group of groups) {
          const groupDiv = div.append("div").style("display", "inline-block").style("vertical-align", "top");
          const noButtonCallback = (i, node) => {
            group.values[i].checked = node.checked;
          };
          const name = group.in ? group.name : `${group.name} will exclude these samples`;
          addTable(groupDiv, name, group, noButtonCallback);
        }
        div.append("div").append("div").style("display", "inline-block").style("float", "right").style("padding", "6px 20px").append("button").attr("class", "sjpp_apply_btn sja_filter_tag_btn").text("Apply").on("click", () => {
          for (const group of groups)
            group.values = group.values.filter((value) => !("checked" in value) || value.checked);
          self.api.runCallback();
        });
      } else {
        const e = self.vocabApi.tokenVerificationPayload;
        const missingAccess = e?.error == "Missing access" && self.vocabApi.termdbConfig.dataDownloadCatch?.missingAccess;
        const message = e && missingAccess?.message?.replace("MISSING-ACCESS-LINK", missingAccess?.links[e.linkKey || ""]);
        const helpLink = self.vocabApi.termdbConfig?.dataDownloadCatch?.helpLink;
        div.append("div").style("color", "#e44").style("padding", "10px").html(
          message || (self.vocabApi.tokenVerificationMessage || "Requires sign-in") + (helpLink ? ` <a href='${helpLink}' target=_blank>Tutorial</a>` : "")
        );
      }
    },
    getPillStatus() {
    },
    getPillName(d) {
      return getPillNameDefault(self, d);
    }
  };
}
function addTable(div, name, group, noButtonCallback) {
  div.style("padding", "6px").append("div").style("margin", "10px").style("font-size", "0.8rem").html(`<b> ${name}</b>.`);
  const rows = [];
  for (const value of group.values) rows.push([{ value: value.sample }]);
  const columns = [{ label: "Sample" }];
  renderTable({
    rows,
    columns,
    div,
    maxWidth: "30vw",
    maxHeight: "40vh",
    noButtonCallback,
    striped: false,
    showHeader: false,
    selectAll: true,
    columnButtons: void 0,
    //Leave until table.js is typed
    buttons: void 0
  });
}
function fillTW(tw) {
  if (!tw.q.groups) tw.q.groups = [];
  if (tw.q.groups.length == 0) {
    for (const k in tw.term.values) {
      const v = tw.term.values[k];
      tw.q.groups.push({
        name: k,
        inuse: v.inuse,
        values: v.list
      });
    }
  }
}
export {
  fillTW,
  getHandler
};
//# sourceMappingURL=samplelst-HXF5POJD.js.map
