import {
  showLDlegend
} from "./chunk-B6CSYKZJ.js";
import {
  legend_newrow
} from "./chunk-UJKW42DI.js";
import "./chunk-V2OJLJSK.js";
import "./chunk-VGYTAYFK.js";
import "./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 {
  dofetch3
} from "./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 {
  rgb_default
} from "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import "./chunk-HFNDKYVF.js";

// src/block.tk.ld.js
async function loadTk(tk, block) {
  if (tk.uninitiated) {
    makeTk(tk, block);
  }
  block.tkcloakon(tk);
  try {
    const arg = {
      genome: block.genome.name,
      file: tk.file,
      rglst: block.tkarg_rglst(tk),
      width: block.width,
      devicePixelRatio: window.devicePixelRatio > 1 ? window.devicePixelRatio : 1
    };
    const data = await dofetch3("tkld", { method: "POST", body: arg });
    if (data.error) throw data.error;
    tk.rglstG.selectAll("*").remove();
    let tkheight = 0;
    for (const r of data.rglst) {
      const g = tk.rglstG.append("g");
      if (r.rangetoobig) {
        r.text_rangetoobig = g.append("text").text(r.rangetoobig).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("x", r.width / 2);
        tkheight = Math.max(tkheight, 50);
        continue;
      }
      if (r.img) {
        g.append("image").attr("width", r.width).attr("height", r.img.height).attr("xlink:href", r.img.src);
        tkheight = Math.max(tkheight, r.img.height);
        continue;
      }
    }
    tk.height_main = tk.toppad + tkheight + tk.bottompad;
    block.tkcloakoff(tk, {});
  } catch (e) {
    tk.height_main = 50;
    block.tkcloakoff(tk, { error: e.message || e });
  }
  block.block_setheight(tk);
}
function makeTk(tk, block) {
  delete tk.uninitiated;
  tk.rglstG = tk.glider.append("g");
  const [tr, td] = legend_newrow(block, tk.name);
  tk.tr_legend = tr;
  tk.legend = {
    div: td.append("div")
  };
  tk.legend.div.html("LD r<sup>2</sup>");
  const scale = rgb_default("white", "red");
  showLDlegend(tk.legend.div, scale);
}
export {
  loadTk
};
//# sourceMappingURL=block.tk.ld-AJYQ4C6T.js.map
