var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/preview/utils/index.ts
var utils_exports = {};
__export(utils_exports, {
  Ajax: () => Ajax,
  download: () => download
});
module.exports = __toCommonJS(utils_exports);
function download(file, fileName) {
  if (!fileName) {
    fileName = `PORTAL_FILE_${new Date().toLocaleString()}`;
  }
  if (typeof window.navigator.msSaveBlob !== "undefined") {
    window.navigator.msSaveBlob(file, fileName);
  } else {
    const URL = window.URL || window.webkitURL;
    const downloadUrl = file instanceof Blob ? URL.createObjectURL(file) : file;
    if (fileName) {
      const a = document.createElement("a");
      if (typeof a.download === "undefined") {
        window.location.href = downloadUrl;
      } else {
        a.href = downloadUrl;
        a.download = fileName;
        document.body.appendChild(a);
        a.click();
      }
    } else {
      window.location.href = downloadUrl;
    }
    setTimeout(() => {
      URL.revokeObjectURL(downloadUrl);
    }, 100);
  }
}
var Ajax = {
  get: function(url, fn, error) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url, true);
    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4) {
        if (xhr.status == 200 || xhr.status < 300) {
          fn.call(this, JSON.parse(xhr.responseText));
        } else {
          error.call(this, xhr.status);
        }
      }
    };
    xhr.send();
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Ajax,
  download
});
