import {
  TermTypeGroups,
  dtTerms,
  dtdnamethylation,
  dtgeneexpression,
  dtmetaboliteintensity,
  dtproteomeabundance,
  dtssgsea
} from "./chunk-4UWS5Y3N.js";

// ../shared/types/dist/index.js
var FlagStatus = {
  Normal: 0,
  Skipped: 1,
  Flagged: 2,
  Deleted: 3
};
var FeaturePrefixes = {
  Star: "annotation-star-",
  Square: "annotation-square-",
  Border: "annotation-border-",
  PredBorder: "prediction-border-"
};
var SelectionPrefixes = {
  TileSelection: "ts_",
  Prediction: "pred_",
  Annotation: "anno_"
};
var FlagStatusMessages = {
  [FlagStatus.Normal]: "",
  [FlagStatus.Skipped]: "(Skipped)",
  [FlagStatus.Flagged]: "(Flagged)"
  // Didn't add Deleted to FlagStatusMessages because deleted annotations dont exist
  // and deleted predictons are filtered out in proteinpaint/server/routes/aiProjectSelectedWSImages.ts around line 119
};
function createSelectionID(prefix, coordinates) {
  return prefix + JSON.stringify(coordinates);
}
function checkSelectionType(tileSelection, suspectedPrefix) {
  return tileSelection.id.startsWith(suspectedPrefix);
}
function createFeatureID(featurePrefix, coords) {
  return featurePrefix + JSON.stringify(coords);
}
var WSImage = class {
  constructor(filename) {
    this.filename = filename;
  }
};
function isErrorResponse(response) {
  return "error" in response && "status" in response;
}
var CATEGORICAL = "categorical";
var CONDITION = "condition";
var DATE = "date";
var DNA_METHYLATION = "dnaMethylation";
var FLOAT = "float";
var GENE_VARIANT = "geneVariant";
var GENE_EXPRESSION = "geneExpression";
var ISOFORM_EXPRESSION = "isoformExpression";
var INTEGER = "integer";
var METABOLITE_INTENSITY = "metaboliteIntensity";
var MULTIVALUE = "multivalue";
var SAMPLELST = "samplelst";
var SINGLECELL_CELLTYPE = "singleCellCellType";
var SINGLECELL_GENE_EXPRESSION = "singleCellGeneExpression";
var SNP = "snp";
var SNP_LIST = "snplst";
var SNP_LOCUS = "snplocus";
var SSGSEA = "ssGSEA";
var SURVIVAL = "survival";
var TERM_COLLECTION = "termCollection";
var PROTEOME_ABUNDANCE = "proteomeAbundance";
var PROTEOME_DAP = "proteomeDAP";
var TermTypes = {
  GENE_VARIANT,
  GENE_EXPRESSION,
  ISOFORM_EXPRESSION,
  SSGSEA,
  DNA_METHYLATION,
  CATEGORICAL,
  INTEGER,
  FLOAT,
  SNP,
  SNP_LIST,
  SNP_LOCUS,
  CONDITION,
  SURVIVAL,
  SAMPLELST,
  METABOLITE_INTENSITY,
  PROTEOME_ABUNDANCE,
  SINGLECELL_CELLTYPE,
  SINGLECELL_GENE_EXPRESSION,
  MULTIVALUE,
  DATE,
  TERM_COLLECTION
};

// ../shared/utils/dist/src/terms.js
var ROOT_SAMPLE_TYPE = 1;
var DEFAULT_SAMPLE_TYPE = 2;
var NumericModes = {
  continuous: "continuous",
  discrete: "discrete"
};
var dtTermTypes = new Set(dtTerms.map((t) => t.type));
for (const dtTermType of dtTermTypes) {
  TermTypes[dtTermType.toUpperCase()] = dtTermType;
}
var NUMERIC_DICTIONARY_TERM = "numericDictTerm";
var TermTypes2Dt = {
  [GENE_EXPRESSION]: dtgeneexpression,
  [SSGSEA]: dtssgsea,
  [DNA_METHYLATION]: dtdnamethylation,
  [METABOLITE_INTENSITY]: dtmetaboliteintensity,
  [PROTEOME_ABUNDANCE]: dtproteomeabundance
};
var typeGroup = {
  [CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,
  [CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,
  [FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,
  [INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,
  [SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,
  [SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,
  [DATE]: TermTypeGroups.DICTIONARY_VARIABLES,
  [MULTIVALUE]: TermTypeGroups.DICTIONARY_VARIABLES,
  [GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,
  [SNP]: TermTypeGroups.SNP,
  [SNP_LIST]: TermTypeGroups.SNP_LIST,
  [SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,
  [GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,
  [ISOFORM_EXPRESSION]: TermTypeGroups.ISOFORM_EXPRESSION,
  [SSGSEA]: TermTypeGroups.SSGSEA,
  [DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,
  [METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,
  [PROTEOME_ABUNDANCE]: TermTypeGroups.PROTEOME_ABUNDANCE,
  [TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,
  [SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,
  [SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION
};
var nonDictTypes = /* @__PURE__ */ new Set([
  SNP,
  SNP_LIST,
  SNP_LOCUS,
  GENE_EXPRESSION,
  ISOFORM_EXPRESSION,
  SSGSEA,
  DNA_METHYLATION,
  GENE_VARIANT,
  METABOLITE_INTENSITY,
  PROTEOME_ABUNDANCE,
  SINGLECELL_CELLTYPE,
  SINGLECELL_GENE_EXPRESSION
]);
for (const dtTermType of dtTermTypes) {
  nonDictTypes.add(TermTypes[dtTermType.toUpperCase()]);
}
var numericTypes = /* @__PURE__ */ new Set([
  INTEGER,
  FLOAT,
  GENE_EXPRESSION,
  ISOFORM_EXPRESSION,
  SSGSEA,
  DNA_METHYLATION,
  METABOLITE_INTENSITY,
  PROTEOME_ABUNDANCE,
  SINGLECELL_GENE_EXPRESSION,
  DATE
]);
var dictionaryNumericTypes = /* @__PURE__ */ new Set([INTEGER, FLOAT, DATE]);
var categoricalTypes = /* @__PURE__ */ new Set([CATEGORICAL, SNP]);
var singleCellTerms = /* @__PURE__ */ new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION]);
function isSingleCellTerm(term) {
  if (!term) return false;
  return singleCellTerms.has(term.type);
}
function isNumericTerm(term) {
  if (!term) return false;
  return numericTypes.has(term.type);
}
function isCategoricalTerm(term) {
  if (!term) return false;
  return categoricalTypes.has(term.type);
}
function isDictionaryType(type) {
  return !isNonDictionaryType(type);
}
function isNonDictionaryType(type) {
  if (!type) throw new Error("Type is not defined");
  return nonDictTypes.has(type);
}
function isNumTermCollection(term) {
  if (!term || !term.type) throw new Error("Term or term type is not defined");
  return term.type === TERM_COLLECTION;
}
function equals(t1, t2) {
  if (!t1) throw new Error("First term is not defined ");
  if (!t2) throw new Error("Second term is not defined ");
  if (t1.type !== t2.type) return false;
  if (isDictionaryType(t1.type) && isDictionaryType(t2.type) && t1.type != SAMPLELST) return t1.id === t2.id;
  switch (t1.type) {
    case GENE_EXPRESSION:
      return t1.gene == t2.gene;
    case ISOFORM_EXPRESSION:
      return t1.isoform == t2.isoform;
    case SSGSEA:
      return t1.id == t2.id;
    case DNA_METHYLATION:
      return t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
    case METABOLITE_INTENSITY:
    case PROTEOME_ABUNDANCE:
      return t1.name == t2.name;
    case GENE_VARIANT:
      return t1.gene == t2.gene || t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
    // TO DO: Add more cases
    // case SNP_LIST:
    // case SNP_LOCUS:
    // case SAMPLELST:
    default:
      return false;
  }
}
var typeMap = {
  categorical: "Categorical",
  condition: "Condition",
  float: "Numerical",
  integer: "Numerical",
  geneExpression: "Gene Expression",
  isoformExpression: "Isoform Expression",
  ssGSEA: "Geneset Expression",
  dnaMethylation: "DNA Methylation",
  geneVariant: "Gene Variant",
  metaboliteIntensity: "Metabolite Intensity",
  proteomeAbundance: "Proteome Abundance",
  proteomeDAP: "Proteome DAP",
  multivalue: "Multi Value",
  singleCellGeneExpression: "Single Cell, Gene Expression",
  singleCellCellType: "Single Cell, Cell Type",
  snplocus: "SNP Locus",
  snp: "SNP",
  snplst: "SNP List",
  numericDictTerm: "Numeric Dictionary Term",
  termCollection: "Term Collection"
};
function termType2label(type) {
  return typeMap[type] || "Unknown term type";
}
function getDateFromNumber(value) {
  const year = Math.floor(value);
  const january1st = new Date(year, 0, 1);
  const totalDays = getDaysInYear(year);
  const time = Math.round((value - year) * totalDays) * oneDayTime;
  const date = new Date(january1st.getTime() + time);
  return date;
}
var oneDayTime = 24 * 60 * 60 * 1e3;
function getDateStrFromNumber(value) {
  const date = getDateFromNumber(value);
  return date.toLocaleDateString("en-US", {
    year: "numeric",
    month: "long"
  });
}
function getDaysInYear(year) {
  const isLeap = new Date(year, 1, 29).getMonth() === 1;
  const days = isLeap ? 366 : 365;
  return days;
}

export {
  FlagStatus,
  FeaturePrefixes,
  SelectionPrefixes,
  FlagStatusMessages,
  createSelectionID,
  checkSelectionType,
  createFeatureID,
  WSImage,
  isErrorResponse,
  CATEGORICAL,
  DATE,
  DNA_METHYLATION,
  FLOAT,
  GENE_VARIANT,
  GENE_EXPRESSION,
  ISOFORM_EXPRESSION,
  INTEGER,
  METABOLITE_INTENSITY,
  SINGLECELL_CELLTYPE,
  SINGLECELL_GENE_EXPRESSION,
  SNP,
  SSGSEA,
  TERM_COLLECTION,
  PROTEOME_ABUNDANCE,
  PROTEOME_DAP,
  TermTypes,
  ROOT_SAMPLE_TYPE,
  DEFAULT_SAMPLE_TYPE,
  NumericModes,
  dtTermTypes,
  NUMERIC_DICTIONARY_TERM,
  TermTypes2Dt,
  typeGroup,
  numericTypes,
  dictionaryNumericTypes,
  isSingleCellTerm,
  isNumericTerm,
  isCategoricalTerm,
  isDictionaryType,
  isNonDictionaryType,
  isNumTermCollection,
  equals,
  termType2label,
  getDateFromNumber,
  getDateStrFromNumber
};
//# sourceMappingURL=chunk-NOEAT6CX.js.map
