import {
  Dark2_default,
  Paired_default,
  rainbow_default
} from "./chunk-KSGA62R2.js";
import {
  ordinal
} from "./chunk-OAWQ6LOO.js";
import {
  rgb
} from "./chunk-OMR2DT66.js";
import {
  __export
} from "./chunk-HFNDKYVF.js";

// ../shared/utils/dist/src/common.js
var common_exports = {};
__export(common_exports, {
  CNVClasses: () => CNVClasses,
  IN_frame: () => IN_frame,
  OUT_frame: () => OUT_frame,
  SOterm2class: () => SOterm2class,
  TermTypeGroups: () => TermTypeGroups,
  alleleInGenotypeStr: () => alleleInGenotypeStr,
  applyOverrides: () => applyOverrides,
  basecolor: () => basecolor,
  basecompliment: () => basecompliment,
  bplen: () => bplen,
  class2SOterm: () => class2SOterm,
  codon: () => codon,
  codon_stop: () => codon_stop,
  colorScaleMap: () => colorScaleMap,
  contigNameNoChr: () => contigNameNoChr,
  contigNameNoChr2: () => contigNameNoChr2,
  custommdstktype: () => custommdstktype,
  default_text_color: () => default_text_color,
  defaultcolor: () => defaultcolor,
  dt2color: () => dt2color,
  dt2label: () => dt2label,
  dt2lesion: () => dt2lesion,
  dtTerms: () => dtTerms,
  dtcloss: () => dtcloss,
  dtcnv: () => dtcnv,
  dtdel: () => dtdel,
  dtdnamethylation: () => dtdnamethylation,
  dtfusionrna: () => dtfusionrna,
  dtgeneexpression: () => dtgeneexpression,
  dtitd: () => dtitd,
  dtloh: () => dtloh,
  dtmetaboliteintensity: () => dtmetaboliteintensity,
  dtnloss: () => dtnloss,
  dtproteomeabundance: () => dtproteomeabundance,
  dtsnvindel: () => dtsnvindel,
  dtssgsea: () => dtssgsea,
  dtsv: () => dtsv,
  exoncolor: () => exoncolor,
  fasta2gmframecheck: () => fasta2gmframecheck,
  germlinelegend: () => germlinelegend,
  getColorScheme: () => getColorScheme,
  getColors: () => getColors,
  getMax_byiqr: () => getMax_byiqr,
  gmmode: () => gmmode,
  invalidcoord: () => invalidcoord,
  kernelDensityEstimator: () => kernelDensityEstimator,
  kernelEpanechnikov: () => kernelEpanechnikov,
  mclass: () => mclass,
  mclasscloss: () => mclasscloss,
  mclasscnvAmp: () => mclasscnvAmp,
  mclasscnvHomozygousDel: () => mclasscnvHomozygousDel,
  mclasscnvgain: () => mclasscnvgain,
  mclasscnvloh: () => mclasscnvloh,
  mclasscnvloss: () => mclasscnvloss,
  mclassdel: () => mclassdel,
  mclassdeletion: () => mclassdeletion,
  mclassfusionrna: () => mclassfusionrna,
  mclassinsertion: () => mclassinsertion,
  mclassitd: () => mclassitd,
  mclassmnv: () => mclassmnv,
  mclassnloss: () => mclassnloss,
  mclassnoncoding: () => mclassnoncoding,
  mclassnonstandard: () => mclassnonstandard,
  mclasssnv: () => mclasssnv,
  mclasssv: () => mclasssv,
  mclasstester: () => mclasstester,
  mclassutr3: () => mclassutr3,
  mclassutr5: () => mclassutr5,
  mds3tkMclass: () => mds3tkMclass,
  mdsvcftype: () => mdsvcftype,
  morigin: () => morigin,
  morigingermline: () => morigingermline,
  morigingermlinenonpathogenic: () => morigingermlinenonpathogenic,
  morigingermlinepathogenic: () => morigingermlinepathogenic,
  moriginrelapse: () => moriginrelapse,
  moriginsomatic: () => moriginsomatic,
  mutationClasses: () => mutationClasses,
  not_annotated: () => not_annotated,
  nt2aa: () => nt2aa,
  optionToDt: () => optionToDt,
  plotColor: () => plotColor,
  proteinChangingMutations: () => proteinChangingMutations,
  proteinDomainColorScale: () => proteinDomainColorScale,
  reversecompliment: () => reversecompliment,
  schemeCategory2: () => schemeCategory2,
  schemeCategory20: () => schemeCategory20,
  spliceeventchangegmexon: () => spliceeventchangegmexon,
  string2pos: () => string2pos,
  synonymousMutations: () => synonymousMutations,
  tkt: () => tkt,
  truncatingMutations: () => truncatingMutations,
  validate_vcfinfofilter: () => validate_vcfinfofilter,
  validtkt: () => validtkt,
  vcfcopymclass: () => vcfcopymclass,
  vepinfo: () => vepinfo
});
var TermTypeGroups = class {
  static {
    this.DICTIONARY_VARIABLES = "Dictionary Variables";
  }
  static {
    this.DNA_METHYLATION = "DNA Methylation";
  }
  static {
    this.GENE_DEPENDENCY = "Gene Dependency";
  }
  static {
    this.GENE_EXPRESSION = "Gene Expression";
  }
  static {
    this.ISOFORM_EXPRESSION = "Isoform Expression";
  }
  static {
    this.GSEA = "GSEA";
  }
  static {
    this.METABOLITE_INTENSITY = "Metabolite Intensity";
  }
  static {
    this.PROTEOME_ABUNDANCE = "Proteome Abundance";
  }
  static {
    this.MUTATION_CNV_FUSION = "Mutation/CNV/Fusion";
  }
  static {
    this.MUTATION_SIGNATURE = "Mutation Signature";
  }
  static {
    this.PROTEIN_EXPRESSION = "Protein Expression";
  }
  static {
    this.SINGLECELL_CELLTYPE = "Single-cell Cell Type";
  }
  static {
    this.SINGLECELL_GENE_EXPRESSION = "Single-cell Gene Expression";
  }
  static {
    this.SNP = "SNP Genotype";
  }
  static {
    this.SNP_LIST = "SNP List";
  }
  static {
    this.SNP_LOCUS = "SNP Locus";
  }
  static {
    this.SPLICE_JUNCTION = "Splice Junction";
  }
  static {
    this.SSGSEA = "Geneset Expression";
  }
  static {
    this.TERM_COLLECTION = "Term Collection";
  }
  static {
    this.VARIANT_GENOTYPE = "Variant Genotype";
  }
};
Object.freeze(TermTypeGroups);
var defaultcolor = rgb("#8AB1D4").darker();
var default_text_color = rgb("#aaa").darker().darker();
var exoncolor = "#4F8053";
var plotColor = "#ce768e";
var IN_frame = true;
var OUT_frame = false;
var dtsnvindel = 1;
var dtfusionrna = 2;
var dtgeneexpression = 3;
var dtcnv = 4;
var dtsv = 5;
var dtitd = 6;
var dtdel = 7;
var dtnloss = 8;
var dtcloss = 9;
var dtloh = 10;
var dtmetaboliteintensity = 11;
var dtssgsea = 12;
var dtdnamethylation = 13;
var dtproteomeabundance = 14;
var dt2label = {
  [dtsnvindel]: "SNV/indel",
  [dtfusionrna]: "Fusion RNA",
  [dtcnv]: "CNV",
  [dtsv]: "SV",
  [dtitd]: "ITD",
  [dtdel]: "Deletion",
  [dtnloss]: "N-loss",
  [dtcloss]: "C-loss",
  [dtloh]: "LOH",
  [dtgeneexpression]: "Gene Expression",
  [dtmetaboliteintensity]: "Metabolite Intensity",
  [dtproteomeabundance]: "Proteome Abundance"
};
var dt2lesion = {
  [dtsnvindel]: {
    uilabel: "SNV/INDEL (Mutation)",
    lesionTypes: [{ name: "Mutation", lesionType: "mutation", color: "#44AA44" }]
  },
  [dtcnv]: {
    uilabel: "CNV (Copy Number Variation)",
    lesionTypes: [
      { name: "Loss", lesionType: "loss", color: "#4444FF" },
      { name: "Gain", lesionType: "gain", color: "#FF4444" }
    ]
  },
  [dtsv]: {
    uilabel: "SV (Structural Variation)",
    lesionTypes: [{ name: "SV", lesionType: "sv", color: "#9932CC" }]
  },
  [dtfusionrna]: {
    uilabel: "Fusion (RNA Fusion)",
    lesionTypes: [{ name: "Fusion", lesionType: "fusion", color: "#FFA500" }]
  }
};
var optionToDt = {
  snvindelOptions: dtsnvindel,
  cnvOptions: dtcnv,
  fusionOptions: dtfusionrna,
  svOptions: dtsv
};
var mclass = {
  M: {
    label: "MISSENSE",
    color: "#3987CC",
    dt: dtsnvindel,
    desc: "A sequence variant, that changes one or more bases, resulting in a different amino acid sequence but where the length is preserved",
    key: "M"
  },
  E: { label: "EXON", color: "#bcbd22", dt: dtsnvindel, desc: "A variant in the exon of a non-coding RNA.", key: "E" },
  F: {
    label: "FRAMESHIFT",
    color: "rgb(200, 61, 61)",
    dt: dtsnvindel,
    desc: "A sequence variant which causes a disruption of the translational reading frame, because the number of nucleotides inserted or deleted is not a multiple of three",
    key: "F"
  },
  N: {
    label: "NONSENSE",
    color: "#ff7f0e",
    dt: dtsnvindel,
    desc: "A sequence variant whereby at least one base of a codon is changed, resulting in a premature stop codon, leading to a shortened transcript",
    key: "N"
  },
  S: {
    label: "SILENT",
    color: "#2ca02c",
    dt: dtsnvindel,
    desc: "A sequence variant where there is no resulting change to the encoded amino acid",
    key: "S"
  },
  D: {
    label: "PROTEINDEL",
    color: "rgb(100, 100, 100)",
    dt: dtsnvindel,
    desc: "An inframe non synonymous variant that deletes bases from the coding sequence",
    key: "D"
  },
  I: {
    label: "PROTEININS",
    color: "#8c564b",
    dt: dtsnvindel,
    desc: "An inframe non synonymous variant that inserts bases into in the coding sequence",
    key: "I"
  },
  ProteinAltering: {
    label: "PROTEINALTERING",
    color: "#5a0034",
    dt: dtsnvindel,
    desc: "An inframe complex change to the coding sequence",
    key: "ProteinAltering"
  },
  P: {
    label: "SPLICE_REGION",
    color: "#9467bd",
    dt: dtsnvindel,
    desc: "A sequence variant in which a change has occurred within the region of the splice site, either within 1-3 bases of the exon or 3-8 bases of the intron",
    key: "P"
  },
  L: {
    label: "SPLICE",
    color: "#6633FF",
    dt: dtsnvindel,
    desc: "A variant near an exon edge that may affect splicing functionality",
    key: "L"
  },
  Intron: { label: "INTRON", color: "#656565", dt: dtsnvindel, desc: "An intronic variant.", key: "Intron" },
  StopLost: {
    label: "Stop lost",
    color: "#ff7f0e",
    dt: dtsnvindel,
    desc: "A sequence variant where at least one base of the terminator codon (stop) is changed, resulting in an elongated transcript",
    key: "StopLost"
  },
  StartLost: {
    label: "Start lost",
    color: "#ff7f0e",
    dt: dtsnvindel,
    desc: "A codon variant that changes at least one base of the canonical start codon",
    key: "StartLost"
  },
  // quick fix!! for showing genes that are not tested in samples (e.g. gene panels) in the heatmap
  Blank: { label: "Not tested", color: "#fff", dt: dtsnvindel, desc: "This gene is not tested.", key: "Blank" },
  WT: { label: "Wildtype", color: "#D3D3D3", dt: dtsnvindel, desc: "Wildtype", key: "WT" }
};
var mclassitd = "ITD";
mclass[mclassitd] = {
  label: "ITD",
  color: "#ff70ff",
  dt: dtitd,
  desc: "In-frame internal tandem duplication",
  key: mclassitd
};
var mclassdel = "DEL";
mclass[mclassdel] = {
  label: "DELETION, intragenic",
  color: "#858585",
  dt: dtdel,
  desc: "Intragenic deletion",
  key: mclassdel
};
var mclassnloss = "NLOSS";
mclass[mclassnloss] = {
  label: "N-terminus loss",
  color: "#545454",
  dt: dtnloss,
  desc: "N-terminus loss due to translocation",
  key: mclassnloss
};
var mclasscloss = "CLOSS";
mclass[mclasscloss] = {
  label: "C-terminus loss",
  color: "#545454",
  dt: dtcloss,
  desc: "C-terminus loss due to translocation",
  key: mclasscloss
};
var mclassutr3 = "Utr3";
mclass[mclassutr3] = {
  label: "UTR_3",
  color: "#998199",
  dt: dtsnvindel,
  desc: "A variant in the 3' untranslated region",
  key: mclassutr3
};
var mclassutr5 = "Utr5";
mclass[mclassutr5] = {
  label: "UTR_5",
  color: "#819981",
  dt: dtsnvindel,
  desc: "A variant in the 5' untranslated region",
  key: mclassutr5
};
var mclassnonstandard = "X";
mclass[mclassnonstandard] = {
  label: "NONSTANDARD",
  color: "black",
  dt: dtsnvindel,
  desc: "A mutation class that either does not match our notation, or is unspecified",
  key: mclassnonstandard
};
var mclassnoncoding = "noncoding";
mclass[mclassnoncoding] = {
  label: "NONCODING",
  color: "black",
  dt: dtsnvindel,
  desc: "Noncoding mutation",
  key: mclassnoncoding
};
var SOterms = [
  //transcript_ablation // not supported: 1) do not expect this in maf/vcf 2) should be represented as cnv deletion but not the legacy unused value "dtdel"; if needed can reenable
  ["splice_acceptor_variant", "L"],
  ["splice_donor_variant", "L"],
  ["stop_gained", "N"],
  ["frameshift_variant", "F"],
  ["stop_lost", "StopLost"],
  ["start_lost", "StartLost"],
  //transcript_amplification // not supported, should be represented by cnv instead
  ["feature_elongation", mclassnoncoding],
  ["feature_truncation", mclassnoncoding],
  ["inframe_insertion", "I"],
  ["inframe_deletion", "D"],
  ["missense_variant", "M"],
  ["protein_altering_variant", "ProteinAltering"],
  ["splice_donor_5th_base_variant", "P"],
  ["splice_region_variant", "P"],
  ["splice_donor_region_variant", "P"],
  ["splice_polypyrimidine_tract_variant", "P"],
  ["incomplete_terminal_codon_variant", "N"],
  ["start_retained_variant", "S"],
  ["stop_retained_variant", "S"],
  ["synonymous_variant", "S"],
  ["coding_sequence_variant", "E"],
  ["mature_miRNA_variant", "E"],
  ["5_prime_UTR_variant", mclassutr5],
  ["3_prime_UTR_variant", mclassutr3],
  ["non_coding_transcript_exon_variant", "E"],
  ["intron_variant", "Intron"],
  ["NMD_transcript_variant", "F"],
  ["non_coding_transcript_variant", "E"],
  ["coding_transcript_variant", "E"],
  ["upstream_gene_variant", mclassnoncoding],
  ["downstream_gene_variant", mclassnoncoding],
  ["TFBS_ablation", mclassnoncoding],
  ["TFBS_amplification", mclassnoncoding],
  ["TF_binding_site_variant", mclassnoncoding],
  ["regulatory_region_ablation", mclassnoncoding],
  ["regulatory_region_amplification", mclassnoncoding],
  ["regulatory_region_variant", mclassnoncoding],
  ["intergenic_variant", mclassnoncoding],
  ["sequence_variant", mclassnonstandard]
];
var class2SOterm = /* @__PURE__ */ new Map();
for (const [csq, cls] of SOterms) {
  if (!class2SOterm.has(cls)) class2SOterm.set(cls, []);
  class2SOterm.get(cls).push(csq);
}
var SOterm2class = /* @__PURE__ */ new Map();
for (const [csq, cls] of SOterms) {
  SOterm2class.set(csq, cls);
}
function mclasstester(s) {
  switch (s.toLowerCase()) {
    case "missense_mutation":
      return "M";
    case "nonsense_mutation":
      return "N";
    case "splice_site":
      return "L";
    case "splice_region":
      return "P";
    case "rna":
      return mclassnoncoding;
    case "frame_shift_del":
      return "F";
    case "frame_shift_ins":
      return "F";
    case "in_frame_del":
      return "D";
    case "in_frame_ins":
      return "I";
    case "protein_altering_variant":
      return "ProteinAltering";
    case "translation_start_site":
      return mclassnonstandard;
    case "nonstop_mutation":
      return "N";
    case "3'utr":
      return mclassutr3;
    case "3'flank":
      return mclassnoncoding;
    case "5'utr":
      return mclassutr5;
    case "5'flank":
      return mclassnoncoding;
    case "silent":
      return "S";
    case "blank":
      return "Blank";
    default:
      return null;
  }
}
var mclassfusionrna = "Fuserna";
mclass[mclassfusionrna] = {
  label: "Fusion transcript",
  color: "#545454",
  dt: dtfusionrna,
  desc: `Marks the break points leading to fusion transcripts.<br><span style="font-size:150%">&#9680;</span> - 3' end of the break point is fused to the 5' end of another break point in a different gene.<br><span style="font-size:150%">&#9681;</span> - 5' end of the break point is fused to the 3' end of another break point in a different gene.`,
  key: mclassfusionrna
};
var mclasssv = "SV";
mclass[mclasssv] = {
  label: "Structural variation",
  color: "#858585",
  dt: dtsv,
  desc: `<span style="font-size:150%">&#9680;</span> - 3' end of the break point is fused to the 5' end of another break point in a different gene.<br><span style="font-size:150%">&#9681;</span> - 5' end of the break point is fused to the 3' end of another break point in a different gene.`,
  key: mclasssv
};
var mclasscnvgain = "CNV_amp";
mclass[mclasscnvgain] = {
  label: "Copy number gain",
  // TODO change to 'Gain'
  color: "#e9a3c9",
  dt: dtcnv,
  desc: "Copy number gain",
  key: mclasscnvgain
};
var mclasscnvloss = "CNV_loss";
mclass[mclasscnvloss] = {
  label: "Copy number loss",
  color: "#a1d76a",
  dt: dtcnv,
  desc: "Copy number loss",
  key: mclasscnvloss
};
var mclasscnvAmp = "CNV_amplification";
mclass[mclasscnvAmp] = {
  label: "Copy number amplification",
  color: "#ff0000",
  dt: dtcnv,
  desc: "Copy number amplification",
  key: mclasscnvAmp
};
var mclasscnvHomozygousDel = "CNV_homozygous_deletion";
mclass[mclasscnvHomozygousDel] = {
  label: "Copy number homozygous deletion",
  color: "#0000ff",
  dt: dtcnv,
  desc: "Copy number homozygous deletion",
  key: mclasscnvHomozygousDel
};
var mclasscnvloh = "CNV_loh";
mclass[mclasscnvloh] = { label: "LOH", color: "#12EDFC", dt: dtcnv, desc: "Loss of heterozygosity", key: mclasscnvloh };
var mclasssnv = "snv";
mclass[mclasssnv] = {
  label: "SNV",
  color: "#92a2d4",
  dt: dtsnvindel,
  desc: "Single nucleotide variation",
  key: mclasssnv
};
var mclassmnv = "mnv";
mclass[mclassmnv] = {
  label: "MNV",
  color: "#92a2d4",
  dt: dtsnvindel,
  desc: "Multiple nucleotide variation",
  key: mclassmnv
};
var mclassinsertion = "insertion";
mclass[mclassinsertion] = {
  label: "Sequence insertion",
  color: "#bd8e91",
  dt: dtsnvindel,
  desc: "Sequence insertion",
  key: mclassinsertion
};
var mclassdeletion = "deletion";
mclass[mclassdeletion] = {
  label: "Sequence deletion",
  color: "#b5a174",
  dt: dtsnvindel,
  desc: "Sequence deletion",
  key: mclassdeletion
};
function mds3tkMclass(k) {
  if (k == dtcnv) {
    return {
      color: "#858585",
      label: "CNV",
      desc: "Copy number variation"
    };
  }
  return mclass[k];
}
var dt2color = {
  [dtsnvindel]: mclass.M.color
  // general color for snvindel irrespective of class (when class is not available)
  // add new dt as needed
};
function applyOverrides(overrides = {}) {
  if (overrides.mclass) {
    for (const key in overrides.mclass) {
      if (!mclass[key]) mclass[key] = {};
      for (const subkey in overrides.mclass[key]) {
        mclass[key][subkey] = overrides.mclass[key][subkey];
      }
    }
  }
}
var vepinfo = function(s) {
  const l = s.toLowerCase().split(",");
  let rank = 1;
  if (l.indexOf("transcript_ablation") != -1) {
    return [dtdel, mclassdel, rank];
  }
  rank++;
  if (l.indexOf("splice_acceptor_variant") != -1) return [dtsnvindel, "L", rank];
  rank++;
  if (l.indexOf("splice_donor_variant") != -1) return [dtsnvindel, "L", rank];
  rank++;
  if (l.indexOf("stop_gained") != -1) return [dtsnvindel, "N", rank];
  rank++;
  if (l.indexOf("frameshift_variant") != -1) return [dtsnvindel, "F", rank];
  rank++;
  if (l.indexOf("stop_lost") != -1) return [dtsnvindel, "N", rank];
  rank++;
  if (l.indexOf("start_lost") != -1) return [dtsnvindel, "N", rank];
  rank++;
  if (l.indexOf("transcript_amplification") != -1) {
    return [dtsnvindel, mclassnonstandard, rank];
  }
  rank++;
  if (l.indexOf("inframe_insertion") != -1 || l.indexOf("conservative_inframe_insertion") != -1 || l.indexOf("disruptive_inframe_insertion") != -1)
    return [dtsnvindel, "I", rank];
  rank++;
  if (l.indexOf("inframe_deletion") != -1 || l.indexOf("conservative_inframe_deletion") != -1 || l.indexOf("disruptive_inframe_deletion") != -1)
    return [dtsnvindel, "D", rank];
  rank++;
  if (l.indexOf("missense_variant") != -1) return [dtsnvindel, "M", rank];
  rank++;
  if (l.indexOf("protein_altering_variant") != -1) return [dtsnvindel, "ProteinAltering", rank];
  rank++;
  if (l.indexOf("splice_region_variant") != -1) return [dtsnvindel, "P", rank];
  rank++;
  if (l.indexOf("incomplete_terminal_codon_variant") != -1) return [dtsnvindel, "N", rank];
  rank++;
  if (l.indexOf("stop_retained_variant") != -1) return [dtsnvindel, "S", rank];
  rank++;
  if (l.indexOf("synonymous_variant") != -1) return [dtsnvindel, "S", rank];
  rank++;
  if (l.indexOf("coding_sequence_variant") != -1) return [dtsnvindel, mclassnonstandard, rank];
  rank++;
  if (l.indexOf("mature_mirna_variant") != -1) return [dtsnvindel, "E", rank];
  rank++;
  if (l.indexOf("5_prime_utr_variant") != -1) return [dtsnvindel, mclassutr5, rank];
  rank++;
  if (l.indexOf("3_prime_utr_variant") != -1) return [dtsnvindel, mclassutr3, rank];
  rank++;
  if (l.indexOf("non_coding_transcript_exon_variant") != -1) return [dtsnvindel, "E", rank];
  rank++;
  if (l.indexOf("intron_variant") != -1) return [dtsnvindel, "Intron", rank];
  rank++;
  if (l.indexOf("nmd_transcript_variant") != -1) return [dtsnvindel, "S", rank];
  rank++;
  if (l.indexOf("non_coding_transcript_variant") != -1) return [dtsnvindel, "E", rank];
  rank++;
  if (l.indexOf("upstream_gene_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("downstream_gene_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("tfbs_ablation") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("tfbs_amplification") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("tf_binding_site_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("regulatory_region_ablation") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("regulatory_region_amplification") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("feature_elongation") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("regulatory_region_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("feature_truncation") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  if (l.indexOf("intergenic_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
  rank++;
  return [dtsnvindel, mclassnonstandard, rank];
};
var germlinelegend = '<circle cx="7" cy="12" r="7" fill="#b1b1b1"></circle><path d="M6.735557395310443e-16,-11A11,11 0 0,1 11,0L9,0A9,9 0 0,0 5.51091059616309e-16,-9Z" transform="translate(7,12)" fill="#858585" stroke="none"></path>';
var morigin = {};
var moriginsomatic = "S";
morigin[moriginsomatic] = {
  label: "Somatic",
  desc: "A variant found only in a tumor sample. The proportion is indicated by lack of any arc.",
  legend: '<circle cx="7" cy="12" r="7" fill="#b1b1b1"></circle>'
};
var morigingermline = "G";
morigin[morigingermline] = {
  label: "Germline",
  desc: "A constitutional variant found in a normal sample. The proportion is indicated by the span of the solid arc within the whole circle.",
  legend: germlinelegend
};
morigin.germline = morigin[morigingermline];
morigin.somatic = morigin[moriginsomatic];
var moriginrelapse = "R";
morigin[moriginrelapse] = {
  label: "Relapse",
  desc: "A somatic variant found only in a relapse sample. The proportion is indicated by the span of the hollow arc within the whole circle.",
  legend: '<circle cx="7" cy="12" r="7" fill="#b1b1b1"></circle><path d="M6.735557395310443e-16,-11A11,11 0 0,1 11,0L9,0A9,9 0 0,0 5.51091059616309e-16,-9Z" transform="translate(7,12)" fill="none" stroke="#858585"></path>'
};
var morigingermlinepathogenic = "GP";
morigin[morigingermlinepathogenic] = {
  label: "Germline pathogenic",
  desc: "A constitutional variant with pathogenic allele.",
  legend: germlinelegend
};
var morigingermlinenonpathogenic = "GNP";
morigin[morigingermlinenonpathogenic] = {
  label: "Germline non-pathogenic",
  desc: "A constitutional variant with non-pathogenic allele.",
  legend: germlinelegend,
  hidden: true
};
var tkt = {
  usegm: "usegm",
  ds: "dataset",
  bigwig: "bigwig",
  bigwigstranded: "bigwigstranded",
  junction: "junction",
  mdsjunction: "mdsjunction",
  mdssvcnv: "mdssvcnv",
  // replaced by mds3
  mdsexpressionrank: "mdsexpressionrank",
  mdsvcf: "mdsvcf",
  // for snv/indels, currently vcf, may include MAF
  //mdsgeneral:'mdsgeneral', // replaces mdssvcnv   ****** not ready yet
  bedj: "bedj",
  pgv: "profilegenevalue",
  bampile: "bampile",
  hicstraw: "hicstraw",
  expressionrank: "expressionrank",
  aicheck: "aicheck",
  ase: "ase",
  mds3: "mds3",
  //
  bedgraphdot: "bedgraphdot",
  bam: "bam",
  ld: "ld"
};
function validtkt(what) {
  for (const k in tkt) {
    if (what == tkt[k]) {
      return true;
    }
  }
  return false;
}
var mdsvcftype = {
  vcf: "vcf"
};
var custommdstktype = {
  vcf: "vcf",
  svcnvitd: "svcnvitd",
  geneexpression: "geneexpression"
};
var codon = {
  GCT: "A",
  GCC: "A",
  GCA: "A",
  GCG: "A",
  CGT: "R",
  CGC: "R",
  CGA: "R",
  CGG: "R",
  AGA: "R",
  AGG: "R",
  AAT: "N",
  AAC: "N",
  GAT: "D",
  GAC: "D",
  TGT: "C",
  TGC: "C",
  CAA: "Q",
  CAG: "Q",
  GAA: "E",
  GAG: "E",
  GGT: "G",
  GGC: "G",
  GGA: "G",
  GGG: "G",
  CAT: "H",
  CAC: "H",
  ATT: "I",
  ATC: "I",
  ATA: "I",
  TTA: "L",
  TTG: "L",
  CTT: "L",
  CTC: "L",
  CTA: "L",
  CTG: "L",
  AAA: "K",
  AAG: "K",
  ATG: "M",
  TTT: "F",
  TTC: "F",
  CCT: "P",
  CCC: "P",
  CCA: "P",
  CCG: "P",
  TCT: "S",
  TCC: "S",
  TCA: "S",
  TCG: "S",
  AGT: "S",
  AGC: "S",
  ACT: "T",
  ACC: "T",
  ACA: "T",
  ACG: "T",
  TGG: "W",
  TAT: "Y",
  TAC: "Y",
  GTT: "V",
  GTC: "V",
  GTA: "V",
  GTG: "V"
};
var codon_stop = "*";
function nt2aa(gm) {
  if (!gm.genomicseq) return void 0;
  const enlst = [];
  if (gm.coding) {
    for (const e of gm.coding.values()) {
      const s = gm.genomicseq.substr(e[0] - gm.start, e[1] - e[0]);
      if (gm.strand == "-") {
        enlst.push(reversecompliment(s));
      } else {
        enlst.push(s);
      }
    }
  }
  const nt = enlst.join("");
  const pep = [];
  const startntidx = gm.startCodonFrame ? 3 - gm.startCodonFrame : 0;
  for (let i = startntidx; i < nt.length; i += 3) {
    const a = codon[nt.substr(i, 3)];
    pep.push(a || codon_stop);
  }
  gm.cdseq = nt;
  return pep.join("");
}
function bplen(len, isfile) {
  if (len >= 1e9) return (len / 1e9).toFixed(1) + " Gb";
  if (len >= 1e7) return Math.ceil(len / 1e6) + " Mb";
  if (len >= 1e6) return (len / 1e6).toFixed(1) + " Mb";
  if (len >= 1e4) return Math.ceil(len / 1e3) + " Kb";
  if (len >= 1e3) return (len / 1e3).toFixed(1) + " Kb";
  return len + (isfile ? "bytes" : " bp");
}
var basecolor = {
  A: "#ca0020",
  T: "#f4a582",
  C: "#92c5de",
  G: "#0571b0"
};
function basecompliment(nt) {
  switch (nt) {
    case "A":
      return "T";
    case "T":
      return "A";
    case "C":
      return "G";
    case "G":
      return "C";
    case "a":
      return "t";
    case "t":
      return "a";
    case "c":
      return "g";
    case "g":
      return "c";
    default:
      return nt;
  }
}
function reversecompliment(s) {
  const tmp = [];
  for (let i = s.length - 1; i >= 0; i--) {
    tmp.push(basecompliment(s[i]));
  }
  return tmp.join("");
}
function spliceeventchangegmexon(gm, evt) {
  const gm2 = {
    chr: gm.chr,
    start: gm.start,
    stop: gm.stop,
    strand: gm.strand,
    coding: []
  };
  if (evt.isskipexon || evt.isaltexon) {
    for (let i = 0; i < gm.exon.length; i++) {
      const codingstart = Math.max(gm.codingstart, gm.exon[i][0]);
      const codingstop = Math.min(gm.codingstop, gm.exon[i][1]);
      if (codingstart > codingstop) {
        continue;
      }
      if (evt.skippedexon.indexOf(i) == -1) {
        gm2.coding.push([codingstart, codingstop]);
      } else {
      }
    }
  } else if (evt.a5ss || evt.a3ss) {
    const exons = gm.exon.map((e) => [e[0], e[1]]);
    const forward = gm.strand == "+";
    if (evt.a5ss) {
      if (forward) {
        exons[evt.exon5idx][1] = evt.junctionB.start;
      } else {
        exons[evt.exon5idx + 1][0] = evt.junctionB.stop;
      }
    } else {
      if (forward) {
        exons[evt.exon5idx + 1][0] = evt.junctionB.stop;
      } else {
        exons[evt.exon5idx][1] = evt.junctionB.start;
      }
    }
    for (const e of exons) {
      const codingstart = Math.max(gm.codingstart, e[0]);
      const codingstop = Math.min(gm.codingstop, e[1]);
      if (codingstart > codingstop) {
        continue;
      }
      gm2.coding.push([codingstart, codingstop]);
    }
  }
  return gm2;
}
function fasta2gmframecheck(gm, str) {
  const lines = str.split("\n");
  lines.shift();
  gm.genomicseq = lines.join("").toUpperCase();
  const aaseq = nt2aa(gm);
  if (!aaseq) return OUT_frame;
  let thisframe = OUT_frame;
  const stopcodonidx = aaseq.indexOf(codon_stop);
  if (stopcodonidx == aaseq.length - 1) {
    thisframe = IN_frame;
  }
  return thisframe;
}
function validate_vcfinfofilter(obj) {
  if (!obj.lst) return ".lst missing";
  if (!Array.isArray(obj.lst)) return "input is not an array";
  for (const set of obj.lst) {
    if (!set.name) return "name missing from a set of .vcfinfofilter.lst";
    if (set.autocategory || set.categories) {
      if (!set.autocategory) {
        for (const k in set.categories) {
          const v = set.categories[k];
          if (!set.autocolor && !v.color)
            return ".color missing for class " + k + " from .categories of set " + set.name;
          if (!v.label) {
            v.label = k;
          }
        }
      }
      if (set.categoryhidden) {
        for (const k in set.categoryhidden) {
          if (!set.categories[k]) return "unknown hidden-by-default category " + k + " from set " + set.name;
        }
      } else {
        set.categoryhidden = {};
      }
    } else if (set.numericfilter) {
      const lst = [];
      for (const v of set.numericfilter) {
        if (typeof v == "number") {
          lst.push({ side: "<", value: v });
        } else {
          lst.push({
            side: v.side || "<",
            value: v.value
          });
        }
      }
      set.numericfilter = lst;
    }
    if (set.altalleleinfo) {
      if (!set.altalleleinfo.key) {
        return ".key missing from .altalleleinfo from set " + set.name;
      }
    } else if (set.locusinfo) {
      if (!set.locusinfo.key) {
        return ".key missing from .locusinfo from set " + set.name;
      }
    } else {
      return "neither .altalleleinfo or .locusinfo is available from set " + set.name;
    }
  }
}
function contigNameNoChr(genome, chrlst) {
  for (const n in genome.majorchr) {
    if (chrlst.indexOf(n.replace("chr", "")) != -1) {
      return true;
    }
  }
  if (genome.minorchr) {
    for (const n in genome.minorchr) {
      if (chrlst.indexOf(n.replace("chr", "")) != -1) {
        return true;
      }
    }
  }
  return false;
}
function contigNameNoChr2(genome, chrlst) {
  let nochrcount = 0, haschrcount = 0;
  for (const n in genome.majorchr) {
    if (chrlst.includes(n)) {
      haschrcount++;
    } else if (chrlst.includes(n.replace("chr", ""))) {
      nochrcount++;
    }
  }
  if (genome.minorchr) {
    for (const n in genome.minorchr) {
      if (chrlst.includes(n)) {
        haschrcount++;
      } else if (chrlst.includes(n.replace("chr", ""))) {
        nochrcount++;
      }
    }
  }
  return [nochrcount, haschrcount];
}
function getMax_byiqr(lst, novaluemax) {
  if (lst.length == 0) return novaluemax;
  lst.sort((i, j) => i - j);
  const max = lst[lst.length - 1];
  if (lst.length <= 5) return max;
  const q1 = lst[Math.floor(lst.length / 4)];
  const q2 = lst[Math.floor(lst.length * 3 / 4)];
  return Math.min(q2 + (q2 - q1) * 1.5, max);
}
function alleleInGenotypeStr(genotype, allele) {
  if (!genotype) return false;
  if (genotype.indexOf("/") != -1) {
    return genotype.split("/").indexOf(allele) != -1;
  }
  return genotype.split("|").indexOf(allele) != -1;
}
var gmmode = {
  genomic: "genomic",
  splicingrna: "splicing RNA",
  // if just 1 exon, use "RNA" as label
  exononly: "exon only",
  protein: "protein",
  gmsum: "aggregated exons"
};
function vcfcopymclass(m, block) {
  if (m.csq) {
    let useone;
    if (block.usegm) {
      useone = m.csq.find((i) => i._isoform == block.usegm.isoform);
    }
    if (!useone) {
      useone = m.csq.find((i) => i.CANONICAL);
      if (!useone) {
        useone = m.csq[0];
        for (const q of m.csq) {
          if (q._csqrank < useone._csqrank) {
            useone = q;
          }
        }
      }
    }
    if (useone) {
      m.gene = useone._gene;
      m.isoform = useone._isoform;
      m.class = useone._class;
      m.dt = useone._dt;
      m.mname = useone._mname;
      if (m.class == mclassnoncoding) {
        delete m.class;
      }
    }
  } else if (m.ann) {
    let useone = null;
    if (block.usegm) {
      for (const q of m.ann) {
        if (q._isoform != block.usegm.isoform) continue;
        if (useone) {
          if (q._csqrank < useone._csqrank) {
            useone = q;
          }
        } else {
          useone = q;
        }
      }
      if (!useone && block.gmmode == gmmode.genomic) {
        useone = m.ann[0];
      }
    } else {
      useone = m.ann[0];
      for (const q of m.ann) {
        if (q._csqrank < useone._csqrank) {
          useone = q;
        }
      }
    }
    if (useone) {
      m.gene = useone._gene;
      m.isoform = useone._isoform;
      m.class = useone._class;
      m.dt = useone._dt;
      m.mname = useone._mname;
      if (m.class == mclassnoncoding) {
        delete m.class;
      }
    }
  }
  if (m.class == void 0) {
    if (mclass[m.type]) {
      m.class = m.type;
      m.dt = mclass[m.type].dt;
      m.mname = m.id && m.id != "." ? m.id : m.ref + ">" + m.alt;
      if (m.mname.length > 15) {
        m.mname = m.type;
      }
    } else {
      m.class = mclassnonstandard;
      m.dt = dtsnvindel;
      m.mname = m.type;
    }
  }
  delete m.type;
}
var not_annotated = "Unannotated";
function kernelDensityEstimator(kernel, X) {
  return function(V) {
    return X.map((x) => {
      return [x, V.map((v) => kernel(x - v)).reduce((i, j) => i + j, 0) / V.length];
    });
  };
}
function kernelEpanechnikov(k) {
  return function(v) {
    return Math.abs(v /= k) <= 1 ? 0.75 * (1 - v * v) / k : 0;
  };
}
var schemeCategory20 = [
  "#1f77b4",
  "#aec7e8",
  "#ff7f0e",
  "#ffbb78",
  "#2ca02c",
  "#98df8a",
  "#d62728",
  "#ff9896",
  "#9467bd",
  "#c5b0d5",
  "#8c564b",
  "#c49c94",
  "#e377c2",
  "#f7b6d2",
  "#7f7f7f",
  "#c7c7c7",
  "#bcbd22",
  "#dbdb8d",
  "#17becf",
  "#9edae5"
];
var schemeCategory2 = ["#e75480", "blue"];
function getColorScheme(number) {
  if (number > 20) {
    const scheme = [];
    for (let i = 0; i < number; i++) scheme.push(rainbow_default(i / number));
    return scheme;
  }
  if (number > 12) return schemeCategory20;
  else if (number > 8) return Paired_default;
  else if (number > 2) return Dark2_default;
  else return schemeCategory2;
}
function getColors(number) {
  const scheme = getColorScheme(number);
  return ordinal(scheme);
}
var proteinDomainColors = [
  "#8dd3c7",
  "#bebada",
  "#fb8072",
  "#80b1d3",
  "#E8E89E",
  "#a6d854",
  "#fdb462",
  "#ffd92f",
  "#e5c494",
  "#b3b3b3"
];
function proteinDomainColorScale() {
  return ordinal().range(proteinDomainColors);
}
var truncatingMutations = ["F", "N", "L", "P"];
var proteinChangingMutations = ["F", "N", "L", "P", "D", "I", "ProteinAltering", "M"];
var synonymousMutations = ["S", "Intron", "Utr3", "Utr5", "noncoding", "E"];
var mutationClasses = Object.values(mclass).filter((m) => m.dt == dtsnvindel).map((m) => m.key);
var CNVClasses = Object.values(mclass).filter((m) => m.dt == dtcnv).map((m) => m.key);
var dtTerms_temp = [
  {
    id: "snvindel",
    query: "snvindel",
    name: dt2label[dtsnvindel],
    parent_id: null,
    isleaf: true,
    type: "dtsnvindel",
    dt: dtsnvindel,
    values: {}
  },
  {
    id: "cnv",
    query: "cnv",
    name: dt2label[dtcnv],
    parent_id: null,
    isleaf: true,
    type: "dtcnv",
    dt: dtcnv,
    values: {}
  },
  {
    id: "fusion",
    query: "svfusion",
    name: dt2label[dtfusionrna],
    parent_id: null,
    isleaf: true,
    type: "dtfusion",
    dt: dtfusionrna,
    values: {}
  },
  {
    id: "sv",
    query: "svfusion",
    name: dt2label[dtsv],
    parent_id: null,
    isleaf: true,
    type: "dtsv",
    dt: dtsv,
    values: {}
  }
];
var dtTerms_temp2 = [];
for (const dtTerm of dtTerms_temp) {
  dtTerm.name_noOrigin = dtTerm.name;
  dtTerms_temp2.push(dtTerm);
  for (const origin of ["somatic", "germline"]) {
    const addOrigin = {
      id: `${dtTerm.id}_${origin}`,
      name: `${dtTerm.name} (${origin})`,
      origin
    };
    dtTerms_temp2.push(Object.assign({}, dtTerm, addOrigin));
  }
}
var dtTerms = dtTerms_temp2;
var colorScaleMap = {
  blueWhiteRed: { domain: [0, 0.5, 1], range: ["blue", "white", "red"] },
  greenWhiteRed: { domain: [0, 0.5, 1], range: ["green", "white", "red"] },
  blueYellowRed: {
    domain: [0, 0.17, 0.33, 0.5, 0.67, 0.83, 1],
    range: ["#313695", "#649AC7", "#BCE1ED", "#FFFFBF", "#FDBE70", "#EA5839", "#A50026"]
  },
  greenBlackRed: {
    domain: [0, 0.17, 0.33, 0.5, 0.67, 0.83, 1],
    range: ["#00FF00", "#14E10C", "#1AAF10", "#000000", "#B01205", "#E20E03", "#FF0000"]
  },
  blueBlackYellow: {
    domain: [0, 0.17, 0.33, 0.5, 0.67, 0.83, 1],
    range: ["#0000FF", "#0000CC", "#000099", "#202020", "#999900", "#CCCC00", "#FFFF00"]
  },
  // when hierCluster z-score transformation is not performed, should use two-color scale
  whiteRed: { domain: [0, 1], range: ["white", "red"] }
};
function invalidcoord(thisgenome, chrom, start, stop) {
  if (!thisgenome) return "no genome";
  if (!chrom) return "no chr name";
  const chr = thisgenome.chrlookup[chrom.toUpperCase()];
  if (!chr) return "Invalid chromosome name: " + chr;
  if (!Number.isInteger(start)) return "Non-numerical position: " + start;
  if (start < 0 || start >= chr.len) return "Position out of range: " + start;
  if (!Number.isInteger(stop)) return "Non-numerical position: " + stop;
  if (stop < 0 || stop > chr.len) return "Position out of range: " + stop;
  if (start > stop) return "Start position is greater than stop";
  return false;
}
function string2pos(s, genome, donotextend) {
  s = s.replace(/,/g, "");
  const chr = genome.chrlookup[s.toUpperCase()];
  if (chr) {
    return {
      chr: chr.name,
      chrlen: chr.len,
      start: Math.max(0, Math.ceil(chr.len / 2) - 1e4),
      stop: Math.min(chr.len, Math.ceil(chr.len / 2) + 1e4)
    };
  }
  {
    const tmp2 = s.split(".");
    if (tmp2.length >= 2) {
      const chr2 = genome.chrlookup[tmp2[0].toUpperCase()];
      const pos = Number.parseInt(tmp2[1]);
      const e = invalidcoord(genome, tmp2[0], pos, pos + 1);
      if (!e) {
        const bpspan = 400;
        return {
          chr: chr2.name,
          chrlen: chr2.len,
          start: Math.max(0, pos - Math.ceil(bpspan / 2)),
          stop: Math.min(chr2.len, pos + Math.ceil(bpspan / 2)),
          actualposition: { position: pos, len: 1 }
        };
      }
    }
  }
  const tmp = s.split(/[-:\s]+/);
  if (tmp.length == 2) {
    const pos = Number.parseInt(tmp[1]);
    const e = invalidcoord(genome, tmp[0], pos, pos + 1);
    if (e) {
      return null;
    }
    const chr2 = genome.chrlookup[tmp[0].toUpperCase()];
    const bpspan = 400;
    return {
      chr: chr2.name,
      chrlen: chr2.len,
      start: Math.max(0, pos - Math.ceil(bpspan / 2)),
      stop: Math.min(chr2.len, pos + Math.ceil(bpspan / 2)),
      actualposition: { position: pos, len: 1 }
    };
  }
  if (tmp.length == 3) {
    let start = Number.parseInt(tmp[1]), stop = Number.parseInt(tmp[2]);
    const e = invalidcoord(genome, tmp[0], start, stop);
    if (e) {
      return null;
    }
    const actualposition = { position: start, len: stop - start };
    const chr2 = genome.chrlookup[tmp[0].toUpperCase()];
    if (!donotextend) {
      const minspan = 400;
      if (stop - start < minspan) {
        let center = Math.ceil((start + stop) / 2);
        if (center + minspan / 2 >= chr2.len) {
          center = chr2.len - Math.ceil(minspan / 2);
        }
        start = Math.max(0, center - Math.ceil(minspan / 2));
        stop = start + minspan;
      }
    }
    return {
      chr: chr2.name,
      chrlen: chr2.len,
      start,
      stop,
      actualposition
    };
  }
  return null;
}

export {
  TermTypeGroups,
  defaultcolor,
  default_text_color,
  exoncolor,
  plotColor,
  IN_frame,
  OUT_frame,
  dtsnvindel,
  dtfusionrna,
  dtgeneexpression,
  dtcnv,
  dtsv,
  dtitd,
  dtdel,
  dtnloss,
  dtcloss,
  dtloh,
  dtmetaboliteintensity,
  dtssgsea,
  dtdnamethylation,
  dtproteomeabundance,
  dt2label,
  dt2lesion,
  mclass,
  mclassitd,
  mclassdel,
  mclassnloss,
  mclasscloss,
  mclassutr3,
  mclassutr5,
  mclassnonstandard,
  class2SOterm,
  mclasstester,
  mclassfusionrna,
  mclasssv,
  mclasscnvgain,
  mclasscnvloss,
  mclasscnvAmp,
  mclasscnvHomozygousDel,
  mclasscnvloh,
  mclasssnv,
  mclassmnv,
  mclassinsertion,
  mclassdeletion,
  mds3tkMclass,
  dt2color,
  applyOverrides,
  vepinfo,
  morigin,
  moriginsomatic,
  morigingermline,
  moriginrelapse,
  morigingermlinepathogenic,
  morigingermlinenonpathogenic,
  tkt,
  validtkt,
  codon_stop,
  nt2aa,
  bplen,
  basecolor,
  basecompliment,
  spliceeventchangegmexon,
  validate_vcfinfofilter,
  contigNameNoChr,
  contigNameNoChr2,
  getMax_byiqr,
  alleleInGenotypeStr,
  gmmode,
  vcfcopymclass,
  getColors,
  proteinDomainColorScale,
  truncatingMutations,
  proteinChangingMutations,
  synonymousMutations,
  mutationClasses,
  CNVClasses,
  dtTerms,
  colorScaleMap,
  common_exports
};
//# sourceMappingURL=chunk-4UWS5Y3N.js.map
