const MathQueue = function (elementId) {
  // check MathJax is ready
  if (!window.MathJax.version) return
  // re-render
  // window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, docEle]);
  MathJax.startup.promise.then(_ => {
    if (!elementId) return MathJax.typesetPromise()
    const docEle = document.getElementById(elementId)
    if (!docEle) return
    MathJax.typesetPromise([docEle])
  })
};

const EvalOpenStates = ["已开启", "未开启"];
const EvalInspectionStates = ["已阅卷", "未阅卷"];

const MergeEvalOpenStates = function (item) {
  if (!item || EvalOpenStates.includes(item))
    return EvalOpenStates
  return [...EvalOpenStates, item]
}

const MergeEvalInspectionStates = function (item) {
  if (!item || EvalInspectionStates.includes(item))
    return EvalInspectionStates;
  return [...EvalInspectionStates, item]
}

const TailingClassName = function (className) {
  if (!className) return "";
  if (className.endsWith("班")) return className;
  return className + "班";
}

const EvalTitleSeperator = "--------";

const uploadFileTypes = ['application/msword', 'application/pdf', 'application/vnd.ms-powerpoint',
  'application/vnd.ms-excel', 'image/jpeg', 'image/jpg', 'image/png',
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  'application/vnd.openxmlformats-officedocument.presentationml.presentation'
]

export default {
  MathQueue,
  EvalOpenStates,
  EvalInspectionStates,
  MergeEvalOpenStates,
  MergeEvalInspectionStates,
  TailingClassName,
  EvalTitleSeperator,
  uploadFileTypes
}
