var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
import "express";
import "axios";
import "knex";
import dompurify from "dompurify";
import * as vue from "vue";
import dayjs from "dayjs";
import chalk from "chalk";
import relativeTime from "dayjs/plugin/relativeTime.js";
import utc from "dayjs/plugin/utc.js";
import tz from "dayjs/plugin/timezone.js";
import updateLocale from "dayjs/plugin/updateLocale.js";
import weekOfYear from "dayjs/plugin/weekOfYear.js";
import path from "path-browserify";
import deepMergeUtility from "deepmerge";
import stableStringify from "fast-safe-stringify";
import md5 from "spark-md5";
import { customAlphabet } from "nanoid";
import { isPlainObject } from "is-plain-object";
import "js-cookie";
import events from "events";
import prettyoutput from "prettyoutput";
import consola from "consola";
import "http";
import "@medv/finder";
const tailwind = "";
const __uno = "";
dayjs.extend(relativeTime);
dayjs.extend(utc);
dayjs.extend(tz);
dayjs.extend(updateLocale);
dayjs.extend(weekOfYear);
dayjs.updateLocale("en", { weekStart: 1 });
if (typeof window !== "undefined" && typeof window.process == "undefined") {
  window.process = { env: {} };
}
const clean = (text) => dompurify.sanitize(text);
const stopwordsLib = [
  "a",
  "about",
  "above",
  "after",
  "again",
  "against",
  "all",
  "am",
  "an",
  "and",
  "any",
  "are",
  "aren't",
  "as",
  "at",
  "be",
  "because",
  "been",
  "before",
  "being",
  "below",
  "between",
  "both",
  "but",
  "by",
  "can't",
  "cannot",
  "could",
  "couldn't",
  "did",
  "didn't",
  "do",
  "does",
  "doesn't",
  "doing",
  "don't",
  "down",
  "during",
  "each",
  "few",
  "for",
  "from",
  "further",
  "had",
  "hadn't",
  "has",
  "hasn't",
  "have",
  "haven't",
  "having",
  "he",
  "he'd",
  "he'll",
  "he's",
  "her",
  "here",
  "here's",
  "hers",
  "herself",
  "him",
  "himself",
  "his",
  "how",
  "how's",
  "i",
  "i'd",
  "i'll",
  "i'm",
  "i've",
  "if",
  "in",
  "into",
  "is",
  "isn't",
  "it",
  "it's",
  "its",
  "itself",
  "let's",
  "me",
  "more",
  "most",
  "mustn't",
  "my",
  "myself",
  "no",
  "nor",
  "not",
  "of",
  "off",
  "on",
  "once",
  "only",
  "or",
  "other",
  "ought",
  "our",
  "out",
  "over",
  "own",
  "same",
  "shan't",
  "she",
  "she'd",
  "she'll",
  "she's",
  "should",
  "shouldn't",
  "so",
  "some",
  "such",
  "than",
  "that",
  "that's",
  "the",
  "their",
  "theirs",
  "them",
  "themselves",
  "then",
  "there",
  "there's",
  "these",
  "they",
  "they'd",
  "they'll",
  "they're",
  "they've",
  "this",
  "those",
  "through",
  "to",
  "too",
  "under",
  "until",
  "up",
  "very",
  "was",
  "wasn't",
  "we",
  "we'd",
  "we'll",
  "we're",
  "we've",
  "were",
  "weren't",
  "what",
  "what's",
  "when",
  "when's",
  "where",
  "where's",
  "which",
  "while",
  "who",
  "who's",
  "whom",
  "why",
  "why's",
  "with",
  "won't",
  "would",
  "wouldn't",
  "you",
  "you'd",
  "you'll",
  "you're",
  "you've",
  "your",
  "yours",
  "yourself",
  "yourselves"
];
const isNode = () => {
  return typeof process !== "undefined" && process.versions && process.versions.node ? true : false;
};
const isActualBrowser = () => !isNode();
const hasWindow = () => typeof window !== "undefined";
const isTest = () => {
  if (typeof process == "undefined")
    return false;
  return process.env.IS_TEST ? true : false;
};
const isApp = () => {
  if (typeof process == "undefined")
    return false;
  return process.env.IS_VITE ? true : false;
};
const isServer = () => !isApp();
const mode = () => {
  var _a;
  if (typeof process == "undefined")
    return "production";
  return (_a = process.env.NODE_ENV) != null ? _a : "production";
};
const isDev = () => {
  if (typeof process == "undefined")
    return false;
  return process.env.NODE_ENV == "development" ? true : false;
};
const isProd = () => !isDev();
const isDebug = () => {
  if (typeof process == "undefined")
    return false;
  return process.env.FACTOR_DEBUG ? true : false;
};
const isRestart = () => {
  if (typeof process == "undefined")
    return false;
  return process.env.IS_RESTART ? true : false;
};
const getVersion = () => {
  if (typeof process == "undefined")
    return "unknown";
  return process.env.RUNTIME_VERSION || "unknown";
};
const getCommit = () => {
  if (typeof process == "undefined")
    return "unknown";
  return process.env.RUNTIME_COMMIT || "unknown";
};
const getRequire = {};
const getMainFilePath = {};
const importIfExists = {};
const requireIfExists = {};
const resolveIfExists = {};
const getFaviconPath = {};
const streamToString = {};
const regExpEscape = (s) => {
  return s.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&");
};
const wildcardToRegExp = (s) => {
  return new RegExp(
    "^" + s.split(/\*+/).map((_) => regExpEscape(_)).join(".*") + "$"
  );
};
const safeDirname = (url, relativePath = "") => {
  if (!url)
    return "";
  return path.join(new URL(".", url).pathname, relativePath);
};
const safeUrl = (url) => {
  if (!url)
    return;
  try {
    const u = new URL(url);
    return u;
  } catch {
    console.warn(`url is invalid: ${url}`);
    return void 0;
  }
};
const safeResolve = (modulePath) => {
  if (!isNode())
    return "";
  return getRequire().resolve(modulePath);
};
const stringify = (data) => stableStringify(
  data,
  (_key, value) => {
    if (value === "[Circular]")
      return;
    else
      return value;
  },
  2
);
const fastHash = (data) => {
  return md5.hash(stableStringify(data)).toString();
};
const hashEqual = (a, b) => {
  return fastHash(a || {}) == fastHash(b || {});
};
const uuid = () => {
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
    const r = Math.trunc(Math.random() * 16), v = c == "x" ? r : r & 3 | 8;
    return v.toString(16);
  });
};
const shortId = () => {
  return customAlphabet("abcdefghijklmnopqrstuvwxyz123456789", 10)();
};
const getGlobalThis = () => {
  return typeof window != "undefined" ? window : global;
};
const isSearchBot = () => {
  if (typeof window == "undefined" || !window.navigator) {
    return false;
  }
  const result = /bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex/i.test(
    window.navigator.userAgent
  );
  return result;
};
const waitFor = (ms) => {
  return new Promise((resolve) => setTimeout(resolve, ms || 0));
};
const splitDisplayName = (fullName) => {
  const nameArray = fullName ? fullName.split(" ") : [];
  let firstName = "";
  let lastName = "";
  if (nameArray.length > 0) {
    firstName = nameArray[0];
  }
  if (nameArray.length > 1) {
    const lastItem = nameArray.pop();
    lastName = lastItem || "";
  }
  return { firstName, lastName };
};
const getWorkingDirectory = (cwd) => {
  return cwd || process.env.FACTOR_CWD || process.cwd();
};
const objectId = (idLength = 16) => {
  const nts = (s) => Math.floor(s).toString(idLength);
  return nts(Date.now() / 1e3) + " ".repeat(idLength).replace(/./g, () => nts(Math.random() * idLength));
};
const randomBetween = (min, max, decimalPlaces = 0) => {
  const rand = Math.random() * (max - min) + min;
  const power = Math.pow(10, decimalPlaces);
  return Math.floor(rand * power) / power;
};
const ensureTrailingSlash = (path2) => {
  path2 += path2.endsWith("/") ? "" : "/";
  return path2;
};
const sortPriority = (arr) => {
  if (!arr || arr.length === 0)
    return arr;
  return arr.sort((a, b) => {
    const ap = a.priority || 100;
    const bp = b.priority || 100;
    let result = 0;
    if (ap < bp) {
      result = -1;
    } else if (ap > bp) {
      result = 1;
    }
    return result;
  });
};
const dotSetting = ({
  key,
  settings
}) => {
  const currentKey = key.slice(0, key.indexOf("."));
  const subKeys = key.slice(key.indexOf(".") + 1);
  if (typeof settings[key] !== "undefined") {
    return settings[key];
  } else if (typeof settings[currentKey] == "object") {
    return dotSetting({ key: subKeys, settings: settings[currentKey] });
  } else {
    return void 0;
  }
};
const deepMerge = (items, options = {}) => {
  const mergeItems = items.filter(Boolean);
  const mergeOptions = {
    arrayMerge: (lowerPriority, higherPriority) => {
      if (options.mergeArrays) {
        return [...higherPriority, ...lowerPriority];
      }
      return higherPriority;
    }
  };
  if (options.plainOnly) {
    mergeOptions.isMergeableObject = isPlainObject;
  } else if (options.isMergeableObject) {
    mergeOptions.isMergeableObject = options.isMergeableObject;
  }
  const merged = deepMergeUtility.all(mergeItems, mergeOptions);
  return merged;
};
const deepMergeAll = (items) => {
  const i = items.filter(Boolean);
  return deepMerge(i, { mergeArrays: true });
};
const sortMerge = (arr) => {
  return deepMerge(sortPriority(arr));
};
const stopWordLowercase = (str, lib = []) => {
  if (lib.length === 0) {
    lib = stopwordsLib;
  }
  const words = str.split(" ");
  if (words.length <= 1)
    return str;
  const regex = new RegExp("\\b(" + lib.join("|") + ")\\b", "gi");
  return str.replace(regex, (match) => match.toLowerCase());
};
const camelToUpperSnake = (string) => {
  return string.replace(/\w([A-Z])/g, function(m) {
    return m[0] + "_" + m[1];
  }).toUpperCase();
};
const camelToKebab = (string) => {
  return !string ? string : string.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
};
const toLabel = (str) => {
  if (!str || typeof str !== "string")
    return "";
  const label = camelToKebab(str).replace(new RegExp("-|_", "g"), " ").replace(/\//g, " ").replace(/\b\w/g, (l) => l.toUpperCase()).trim();
  return stopWordLowercase(label, ["and", "an", "a", "the", "or", "am", "to"]);
};
const slugify = (text) => {
  if (!text)
    return "";
  return text.toString().toLowerCase().replace(/[^\dA-Za-z]/g, "").replace(/\s+/g, "-").replace(/^\d+/g, "").replace(/--+/g, "-").replace(/(\?|:)/g, "").replace(/^-+/, "").replace(/-+$/, "");
};
const snakeCase = (text) => {
  return text.replace(/([A-Z])/g, "_$1").toLowerCase();
};
const camelize = (str) => {
  if (!str)
    return "";
  return str.replace(/^\w|[A-Z]|\b\w/g, (word, index) => {
    return index === 0 ? word.toLowerCase() : word.toUpperCase();
  }).replace(/\s|-/g, "");
};
const snakeCaseKeys = (original) => {
  const newObject = {};
  for (const camel in original) {
    newObject[snakeCase(camel)] = original[camel];
  }
  return newObject;
};
const normalizeList = (list = [], options = {}) => {
  const { prefix = "" } = options;
  let { suffix = "" } = options;
  if (!Array.isArray(list))
    return [];
  suffix = suffix ? " " + suffix : "";
  const normalized = list.map((_) => {
    if (typeof _ == "string" || typeof _ == "number") {
      const label = `${prefix}${toLabel(_)}${suffix}`;
      return {
        value: _,
        name: label,
        desc: ""
      };
    } else {
      let { name, value } = _;
      if (!name && value) {
        name = `${prefix}${toLabel(value)}${suffix}`;
      } else if (typeof value == "undefined" && name) {
        value = slugify(name) || "";
      }
      if (!name)
        name = "";
      if (!value)
        value = "";
      return { ..._, name, value };
    }
  });
  return normalized;
};
const toPascalCase = (text) => {
  return `${text}`.replace(new RegExp(/[_-]+/, "g"), " ").replace(new RegExp(/[^\s\w]/, "g"), "").replace(
    new RegExp(/\s+(.)(\w+)/, "g"),
    ($1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`
  ).replace(new RegExp(/\s/, "g"), "").replace(new RegExp(/\w/), (s) => s.toUpperCase());
};
const validateEmail = (email) => {
  if (!email)
    return void 0;
  const re = /^(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\dA-Za-z-]+\.)+[A-Za-z]{2,}))$/;
  return re.test(String(email).toLowerCase()) ? email : void 0;
};
const displayDomain = (url) => {
  if (!url) {
    return "";
  }
  return url.replace(/^https?:\/\//, "").replace("www.", "").replace(/\/$/, "");
};
const getFavicon = (url) => {
  let hostname;
  if (!url)
    return "";
  if (Array.isArray(url)) {
    url = url[0];
  }
  if (!url.includes("http")) {
    url = `http://${url}`;
  }
  if (!url) {
    hostname = "";
  } else {
    const _url = new URL(url);
    hostname = _url.hostname;
  }
  return `https://icons.duckduckgo.com/ip3/${hostname}.ico`;
};
const capitalize = (s) => {
  if (typeof s !== "string")
    return "";
  return s.charAt(0).toUpperCase() + s.slice(1);
};
const urlPath = (...parts) => {
  const separator = "/";
  parts = parts.map((part, index) => {
    if (index) {
      part = part.replace(new RegExp("^" + separator), "");
    }
    if (index !== parts.length - 1) {
      part = part.replace(new RegExp(separator + "$"), "");
    }
    return part;
  });
  return parts.join(separator).replace(/\/+$/, "");
};
const isJson = (str) => {
  if (!str)
    return void 0;
  try {
    const r = JSON.parse(str);
    return r;
  } catch {
    return false;
  }
};
const inIFrame = () => {
  if (isNode())
    return false;
  try {
    return window.self !== window.top;
  } catch {
    return true;
  }
};
const groupBy = (items, key) => {
  return items.reduce(
    (result, item) => ({
      ...result,
      [item[key]]: [...result[item[key]] || [], item]
    }),
    {}
  );
};
const replaceAll = (str, match, replacement) => {
  return str.replace(new RegExp(regExpEscape(match), "g"), () => replacement);
};
const runHooks = async (params) => {
  const { list = [], hook, args = [] } = params;
  const hookArgs = args || [];
  const callbacks = list.filter((_) => _.hook == hook).map((_) => _.callback);
  let result = hookArgs[0];
  if (callbacks && callbacks.length > 0) {
    for (const cb of callbacks) {
      const returnResult = await cb(result, ...hookArgs.slice(1));
      if (returnResult !== void 0) {
        result = returnResult;
      }
    }
  }
  return result;
};
const runHooksSync = (params) => {
  const { list = [], hook, args = [] } = params;
  const hookArgs = args || [];
  const callbacks = list.filter((_) => _.hook == hook).map((_) => _.callback);
  let result = hookArgs[0];
  if (callbacks && callbacks.length > 0) {
    for (const cb of callbacks) {
      const returnResult = cb(result, ...hookArgs.slice(1));
      if (returnResult !== void 0) {
        result = returnResult;
      }
    }
  }
  return result;
};
class FactorLog {
  constructor(settings = {}) {
    __publicField(this, "hooks");
    __publicField(this, "isProd");
    __publicField(this, "isRestart");
    __publicField(this, "isDebug");
    __publicField(this, "setup", () => {
    });
    __publicField(this, "logLevel", {
      trace: { color: "#5233ff", priority: 5 },
      debug: { color: "#00BD0C", priority: 5 },
      info: { color: "#00ABFF", priority: 10 },
      warn: { color: "#ffa500", priority: 30 },
      error: { color: "#FF0000", priority: 40 }
    });
    __publicField(this, "contextLogger", (context) => {
      const out = {};
      const levels = Object.keys(this.logLevel);
      levels.forEach((level) => {
        out[level] = (description, config) => this.l({ level, description, context, ...config });
      });
      return out;
    });
    var _a, _b, _c, _d;
    this.hooks = (_a = settings.hooks) != null ? _a : [];
    this.isProd = (_b = settings.isProd) != null ? _b : isProd();
    this.isRestart = (_c = settings.isRestart) != null ? _c : isRestart();
    this.isDebug = (_d = settings.isDebug) != null ? _d : isDebug();
  }
  addHook(hook) {
    this.hooks.unshift(hook);
  }
  logBrowser(config) {
    const { level, description, context, color, data, error } = config;
    const shouldLog = !this.isProd || typeof localStorage !== "undefined" && localStorage.getItem("klog") ? true : false;
    if (shouldLog) {
      console.log(
        `%c${level}%c(${context != null ? context : "???"}):`,
        `color: ${color}99;`,
        `color: ${color};`,
        description,
        data != null ? data : ""
      );
      if (error) {
        console.error(error);
      }
    }
  }
  refineDataRecursive(obj, depth = 0) {
    depth++;
    return Object.fromEntries(
      Object.entries(obj).map(([k, v]) => {
        if (dayjs.isDayjs(v)) {
          v = `DAYJS: ${v.toISOString()}`;
        } else if (typeof v === "object" && v && Object.keys(v).length > 0) {
          const len = stringify(v);
          if (len.length > 1e4 && !process.env.DEBUG) {
            v = `LARGE OBJECT(${len.length}): ${len.slice(0, 100)}...`;
          } else if (depth < 4) {
            v = this.refineDataRecursive(v, depth);
          }
        }
        return [k, v];
      })
    );
  }
  logServer(config) {
    const {
      level,
      disableOnRestart,
      context,
      color = "#dddddd",
      data,
      description,
      error
    } = config;
    if (disableOnRestart && this.isRestart) {
      return;
    }
    const points = [chalk.hex(color).dim(level.padEnd(5))];
    points.push(chalk.hex(color)(`(${context != null ? context : "???"}): `.padEnd(10)));
    if (description)
      points.push(description);
    console.log(points.join(""));
    if (data instanceof Error) {
      consola.error(data);
    } else if (typeof data == "object" && data && Object.keys(data).length > 0) {
      console.log(
        prettyoutput(
          this.refineDataRecursive(data),
          { colors: { number: "yellow" } },
          2
        )
      );
    }
    if (error) {
      consola.error(error);
    }
    runHooks({
      list: this.hooks,
      hook: "logServer",
      args: [config]
    }).catch(console.error);
  }
  l(config) {
    const { level } = config;
    config.priority = this.logLevel[level].priority;
    config.color = this.logLevel[level].color;
    if (isNode()) {
      if (config.priority < 10 && !this.isProd && !this.isDebug) {
        config.data = void 0;
      }
      this.logServer(config);
    } else {
      this.logBrowser(config);
    }
  }
  warn(context, description, config) {
    this.l({ level: "warn", context, description, ...config });
  }
  error(context, description, config) {
    this.l({ level: "error", context, description, ...config });
  }
  info(context, description, config) {
    this.l({ level: "info", context, description, ...config });
  }
  debug(context, description, config) {
    this.l({ level: "debug", context, description, ...config });
  }
}
const log = new FactorLog();
let eventBus = void 0;
const getGlobalEventBus = () => {
  if (!eventBus) {
    eventBus = new events.EventEmitter();
    eventBus.setMaxListeners(50);
  }
  return eventBus;
};
const emitEvent = (event, ...data) => {
  getGlobalEventBus().emit(event, ...data);
  log.debug("emitEvent", `new event: ${event}`, { data });
};
const onEvent = (event, callback) => {
  return getGlobalEventBus().on(event, callback);
};
const removeEvent = (event, callback) => {
  getGlobalEventBus().off(event, callback);
};
class FactorNotify {
  constructor(settings = {}) {
    __publicField(this, "hooks");
    var _a;
    this.hooks = (_a = settings.hooks) != null ? _a : [];
  }
  emit(type, message, meta) {
    const notification = { type, message, ...meta };
    emitEvent("notify", notification);
    runHooks({
      list: this.hooks,
      hook: "notify",
      args: [notification]
    }).catch(console.error);
    if (type == "error" || type == "warn") {
      log.l({
        level: type,
        context: "notification",
        description: message,
        data: meta
      });
    }
  }
  info(message, meta) {
    this.emit("info", message, meta);
  }
  success(message, meta) {
    this.emit("success", message, meta);
  }
  error(message, meta) {
    this.emit("error", message, meta);
  }
  warning(message, meta) {
    this.emit("error", message, meta);
  }
}
const notify = new FactorNotify();
const runServicesSetup = async (serviceConfig) => {
  var _a, _b;
  const { service = {}, ...rest } = serviceConfig;
  const config = [rest];
  const pluginList = Object.values(service).filter(
    (_) => typeof _ == "object" && !Array.isArray(_) && !vue.isRef(_) && typeof _.setup != "undefined"
  );
  if (pluginList.length > 0) {
    for (const plugin of pluginList) {
      try {
        await plugin.setup();
      } catch (error) {
        const e = error;
        const name = (_a = plugin.constructor.name) != null ? _a : "unknown";
        e.message = `plugin setup error (${name}): ${e.message}`;
        throw e;
      }
    }
    for (const plugin of pluginList) {
      try {
        await plugin.afterSetup();
      } catch (error) {
        const e = error;
        const name = (_b = plugin.constructor.name) != null ? _b : "unknown";
        e.message = `plugin after setup error (${name}): ${e.message}`;
        throw e;
      }
    }
  }
  const r = deepMerge(config, {
    mergeArrays: true,
    plainOnly: true
  });
  r.service = service;
  delete r.server;
  return r;
};
const compileApplication = async (params) => {
  var _a;
  let { serviceConfig } = params;
  const { mainFilePath, isApp: isApp2 } = params;
  let mainFile = void 0;
  if (isApp2) {
    mainFile = await import("./assets/index.2544f8a4.js").then((n) => n.a);
  } else if (mainFilePath) {
    mainFile = await import(
      /* @vite-ignore */
      mainFilePath
    );
  }
  if (!mainFile)
    throw new Error("no mainFile");
  let entryConfig = {};
  if (mainFile) {
    entryConfig = (mainFile == null ? void 0 : mainFile.setup) ? await mainFile.setup(serviceConfig || {}) : {};
  }
  const merge = [serviceConfig, entryConfig];
  merge.push((_a = params.serviceConfig) != null ? _a : {});
  const merged = deepMerge(merge, {
    mergeArrays: true,
    plainOnly: true
  });
  delete merged.server;
  serviceConfig = merged;
  if (serviceConfig.service) {
    try {
      serviceConfig = await runServicesSetup(serviceConfig);
    } catch (error) {
      log.error("compileApplication", "plugin install error", { error });
    }
  }
  return { serviceConfig, mainFile, mainFilePath };
};
const getServerServiceConfig = async (params) => {
  var _a;
  const mainFilePath = (_a = params.mainFilePath) != null ? _a : getMainFilePath(params);
  const { serviceConfig } = await compileApplication({
    mainFilePath,
    isApp: false,
    serviceConfig: params.serviceConfig
  });
  return serviceConfig;
};
const renderedEnvVars = '{"NODE_ENV":"production","COMMAND":"render","COMMAND_OPTS":"{}","RUNTIME_VERSION":"5.5.46","SERVER_PORT":"3333","APP_PORT":"3000","IS_VITE":"yes"}';
const setupRenderedEnvVars = () => {
  var _a;
  let runtime = void 0;
  if (typeof window !== "undefined") {
    if (typeof window.process == "undefined") {
      window.process = { env: {} };
    }
    const run = (_a = document.querySelector("#factorRun")) == null ? void 0 : _a.textContent;
    if (run) {
      runtime = JSON.parse(run);
    }
    const rendered = JSON.parse(renderedEnvVars);
    const buildVars = { ...rendered, ...runtime };
    Object.entries(buildVars).forEach(([key, value]) => {
      process.env[key] = value;
    });
  }
};
setupRenderedEnvVars();
const runViteApp = async (params = {}) => {
  const { renderUrl } = params;
  const { serviceConfig, mainFile, mainFilePath } = await compileApplication({
    isApp: true
  });
  const { factorApp } = mainFile;
  if (!factorApp) {
    throw new Error(`no factorApp exported from mainFile: ${mainFilePath}`);
  }
  return await factorApp.mountApp({ renderUrl, serviceConfig });
};
if (typeof window !== "undefined") {
  runViteApp().catch(console.error);
}
export {
  isDev as $,
  stopWordLowercase as A,
  camelToUpperSnake as B,
  camelToKebab as C,
  toLabel as D,
  slugify as E,
  snakeCase as F,
  camelize as G,
  snakeCaseKeys as H,
  normalizeList as I,
  toPascalCase as J,
  validateEmail as K,
  displayDomain as L,
  getFavicon as M,
  capitalize as N,
  urlPath as O,
  isJson as P,
  inIFrame as Q,
  groupBy as R,
  replaceAll as S,
  runHooks as T,
  runHooksSync as U,
  isNode as V,
  isActualBrowser as W,
  hasWindow as X,
  isTest as Y,
  isServer as Z,
  mode as _,
  safeUrl as a,
  isProd as a0,
  isDebug as a1,
  isRestart as a2,
  getVersion as a3,
  getCommit as a4,
  clean as a5,
  regExpEscape as a6,
  wildcardToRegExp as a7,
  removeEvent as a8,
  getRequire as a9,
  getMainFilePath as aa,
  importIfExists as ab,
  requireIfExists as ac,
  resolveIfExists as ad,
  getFaviconPath as ae,
  streamToString as af,
  FactorNotify as ag,
  getServerServiceConfig as ah,
  safeResolve as b,
  stringify as c,
  deepMergeAll as d,
  emitEvent as e,
  fastHash as f,
  shortId as g,
  hashEqual as h,
  isApp as i,
  getGlobalThis as j,
  isSearchBot as k,
  log as l,
  splitDisplayName as m,
  notify as n,
  onEvent as o,
  getWorkingDirectory as p,
  objectId as q,
  randomBetween as r,
  runViteApp,
  safeDirname as s,
  ensureTrailingSlash as t,
  uuid as u,
  sortPriority as v,
  waitFor as w,
  dotSetting as x,
  deepMerge as y,
  sortMerge as z
};
