import { M as z, g as D, s as G } from "./vendor.js";
import { a as Ve, m as Ue, b as Be, c as Ne, p as Fe, u as We } from "./vendor.js";
import j from "axios";
const Y = "lang", Se = (e, t) => {
  var i, a;
  const n = typeof window < "u", r = () => {
    var d;
    if (!n)
      return { innerWidth: 1920, innerHeight: 1080 };
    const s = window, l = typeof navigator < "u" ? s.navigator : {}, u = s.screen || {}, p = s.visualViewport, h = {
      innerWidth: s.innerWidth,
      innerHeight: s.innerHeight,
      outerWidth: s.outerWidth,
      outerHeight: s.outerHeight,
      screenWidth: u.width ?? s.innerWidth,
      screenHeight: u.height ?? s.innerHeight,
      availWidth: u.availWidth ?? s.innerWidth,
      availHeight: u.availHeight ?? s.innerHeight,
      devicePixelRatio: s.devicePixelRatio || 1,
      bodyHeight: s.innerHeight - ((d = t.pinia) != null && d.useTab ? 36 : 0) - 64 - 32,
      drawerHeight: parseInt(s.innerHeight * 0.9),
      pageHeight: s.innerHeight - 64 - 32,
      pageWidth: s.innerWidth
    };
    p && (h.visualViewportWidth = p.width, h.visualViewportHeight = p.height, h.visualViewportScale = p.scale);
    const c = l.userAgent || "";
    return h.env = {
      userAgent: c,
      language: l.language || "",
      languages: l.languages ? [...l.languages] : [],
      platform: l.platform || "",
      cookieEnabled: !!l.cookieEnabled,
      onLine: l.onLine !== !1,
      maxTouchPoints: l.maxTouchPoints || 0,
      isTouch: "ontouchstart" in s || (l.maxTouchPoints || 0) > 0,
      isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i.test(
        c
      )
    }, console.info(h), h;
  }, o = () => {
    var l;
    const s = r();
    globalThis.$config = globalThis.$config || {}, globalThis.$config.options = {
      ...globalThis.$config.options || {},
      ...s
    }, (l = e == null ? void 0 : e.config) != null && l.globalProperties && (e.config.globalProperties.$config = globalThis.$config);
  };
  o(), n && (window.addEventListener("resize", o, { passive: !0 }), (a = (i = window.visualViewport) == null ? void 0 : i.addEventListener) == null || a.call(i, "resize", o, {
    passive: !0
  }));
}, Ae = (e, t) => {
  var u, p, h;
  const n = t || {}, r = Array.isArray(n.use) && n.use.length > 0 ? n.use : z;
  globalThis.$config = globalThis.$config || {}, globalThis.$config.langUse = r.filter(
    (c) => c && c.use !== !1 && c.value
  ), (u = e == null ? void 0 : e.config) != null && u.globalProperties && (e.config.globalProperties.$config = globalThis.$config);
  const i = (typeof localStorage < "u" ? localStorage.getItem(Y) : null) || ((p = globalThis.$config) == null ? void 0 : p.lang) || "en_us", a = Object.assign(
    {},
    D(i),
    ((h = globalThis.$config) == null ? void 0 : h.langMaps) || {},
    n.langMaps || {}
  ), s = (c, d) => !d || globalThis.$getType(d) !== "Object" ? c : String(c).replace(
    /\{([A-Za-z0-9_.$-]+)\}/g,
    (m, C) => Object.prototype.hasOwnProperty.call(d, C) ? d[C] : m
  ), l = (c, d) => {
    if (c) {
      const m = a[c] || c;
      return s(m, d);
    } else
      return c ?? "";
  };
  globalThis.$patchLangMaps = (c) => {
    c && globalThis.$getType(c) === "Object" && Object.assign(a, c);
  }, globalThis.$l = l, e.config.globalProperties.$l = l, e.config.globalProperties.$patchLangMaps = globalThis.$patchLangMaps, String.prototype.$l = function() {
    return $l(this);
  };
}, Le = (e, t) => {
  if (!e || !t) return !1;
  const n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), o = r.right > n.left && r.left < n.right, i = r.bottom > n.top && r.top < n.bottom;
  return o && i;
}, K = (e, t) => {
  if (e === t) return !0;
  if (e == null || t == null || typeof e != "object" || typeof t != "object")
    return JSON.stringify(e) === JSON.stringify(t);
  const n = Object.keys(e), r = Object.keys(t);
  if (n.length !== r.length) return !1;
  for (const o of n)
    if (!r.includes(o) || !K(e[o], t[o])) return !1;
  return !0;
}, O = "download", X = 150, J = (e, t = O) => {
  const n = t || O, r = String(e ?? "").trim();
  if (!r) return n;
  const i = r.replace(/[/\\?%*:|"<>]/g, "_").replace(/\.\./g, "_").split(/[/\\]/).pop() || n, a = 200;
  return i.length > a ? i.slice(0, a) : i;
}, Z = (e) => {
  const t = ((e == null ? void 0 : e.type) || "").toLowerCase();
  return t ? t.includes("spreadsheet") || t.includes("ms-excel") || t.includes("excel") && t.includes("application") : !1;
}, S = (e, t) => {
  const n = URL.createObjectURL(e), r = J(t), o = document.createElement("a");
  o.href = n, o.download = r, o.style.display = "none", document.body.appendChild(o);
  try {
    o.click();
  } finally {
    document.body.removeChild(o), setTimeout(() => URL.revokeObjectURL(n), X);
  }
}, Q = (e) => {
  if (!e || e.source !== void 0 || e.type === void 0)
    return e;
  const { type: t, data: n, url: r, headers: o, name: i, filename: a, init: s, ...l } = e, u = a ?? i;
  return t === "csv" ? {
    ...l,
    source: "inline",
    content: n,
    filename: u,
    bom: e.bom
  } : t === "excel" ? {
    ...l,
    source: "fetch",
    url: r,
    init: { ...s || {}, headers: o ?? (s == null ? void 0 : s.headers) },
    response: "blob",
    expectExcel: !0,
    filename: u
  } : e;
}, $e = async (e = {}) => {
  const t = Q(e), {
    source: n = "inline",
    content: r,
    blob: o,
    bom: i = !0,
    mime: a,
    url: s,
    init: l,
    response: u = "blob",
    openIn: p = "self",
    expectExcel: h,
    filename: c,
    name: d,
    error: m = () => {
    },
    // 避免 legacy 字段渗入后续逻辑
    type: C,
    data: Te,
    headers: we,
    ...Me
  } = t, M = c ?? d;
  try {
    if (n === "inline") {
      if (o instanceof Blob) {
        S(o, M);
        return;
      }
      if (r == null) {
        m(new Error("content or blob is required for inline"));
        return;
      }
      const f = typeof r == "string" ? r : String(r), R = i ? "\uFEFF" + f : f, v = a || (i ? "text/csv;charset=utf-8" : "text/plain;charset=utf-8");
      S(new Blob([R], { type: v }), M);
      return;
    }
    if (n === "fetch") {
      if (!s) {
        m(new Error("url is required for fetch"));
        return;
      }
      const f = await fetch(s, l);
      if (!f.ok) {
        m(new Error(`fetch failed: ${f.status}`));
        return;
      }
      if (u === "text") {
        const v = await f.text(), W = i ? "\uFEFF" + v : v, q = a || (i ? "text/csv;charset=utf-8" : "text/plain;charset=utf-8");
        S(new Blob([W], { type: q }), M);
        return;
      }
      const R = await f.blob();
      if (h && !Z(R)) {
        m(new Error("excel does not exist"));
        return;
      }
      S(R, M);
      return;
    }
    if (n === "open") {
      if (!s) {
        m(new Error("url is required for open"));
        return;
      }
      p === "blank" ? window.open(s, "_blank", "noopener,noreferrer") : window.location.href = s;
      return;
    }
    m(new Error(`unknown source: ${n}`));
  } catch (f) {
    m(f instanceof Error ? f : new Error(String(f)));
  }
};
function ee(e, t, n) {
  if (t === "" || t === void 0 || t === null)
    return "";
  const r = globalThis.$fa, o = globalThis.$fu, i = (n == null ? void 0 : n.precision) ?? 2, a = n == null ? void 0 : n.unit;
  if ((a === "currency" || a === "%") && o) {
    const s = {
      [e]: {
        unit: a === "currency" ? "currency" : "%",
        precision: i
      }
    };
    try {
      return o({
        prop: e,
        currency: n == null ? void 0 : n.currency,
        value: t,
        obj: s
      });
    } catch {
    }
  }
  if (r)
    try {
      return r(t, i);
    } catch {
      return String(t);
    }
  return String(t);
}
function Pe(e, t, n = {}) {
  const { columns: r = [] } = e || {}, { resolveMetric: o } = n;
  return !r.length || !t || typeof t != "object" ? [] : r.map((i) => {
    const a = i.property ?? i.prop ?? "";
    if (!a)
      return "";
    let s = t[a];
    if (s === void 0 && (s = ""), s === "")
      return "";
    const l = typeof o == "function" ? o(a) : void 0;
    try {
      return ee(a, s, l);
    } catch {
      return String(s);
    }
  });
}
const I = "mvframe_primary", V = "mvframe_theme", x = "mvframe_theme_name", te = "dark", A = "main", L = "mv-theme-", T = { r: 255, g: 255, b: 255 }, ne = { r: 0, g: 0, b: 0 }, U = [1, 3, 5, 7, 9], re = [
  "--el-color-primary-light-3",
  "--el-color-primary-light-5",
  "--el-color-primary-light-7",
  "--el-color-primary-light-8",
  "--el-color-primary-light-9",
  "--el-color-primary-dark-2"
], oe = U.map(
  (e) => `--color-primary${e}`
);
function $(e) {
  let t = String(e).trim().replace(/^#/, "");
  if (t.length === 3 && (t = t.split("").map((r) => r + r).join("")), t.length >= 8 && (t = t.slice(0, 6)), t.length !== 6 || Number.isNaN(parseInt(t, 16)))
    return null;
  const n = parseInt(t, 16);
  return {
    r: n >> 16 & 255,
    g: n >> 8 & 255,
    b: n & 255
  };
}
function y(e, t, n) {
  const r = (o) => Math.max(0, Math.min(255, Math.round(o)));
  return `#${[r(e), r(t), r(n)].map((o) => o.toString(16).padStart(2, "0")).join("")}`;
}
function B(e, t, n, r) {
  const o = (a) => Math.max(0, Math.min(255, Math.round(a))), i = Math.max(0, Math.min(1, r));
  return `rgba(${o(e)}, ${o(t)}, ${o(n)}, ${i})`;
}
function se(e) {
  const t = [e.r, e.g, e.b].map((n) => (n /= 255, n <= 0.03928 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4));
  return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
}
function N(e) {
  return se(e) > 0.5 ? "#1a1a1a" : "#ffffff";
}
function b(e, t, n) {
  const r = n / 100, o = 1 - r;
  return {
    r: e.r * r + t.r * o,
    g: e.g * r + t.g * o,
    b: e.b * r + t.b * o
  };
}
function ie(e, t = "light") {
  const n = $(e);
  if (!n)
    return null;
  const r = b(T, n, 30), o = b(T, n, 50), i = b(T, n, 70), a = b(T, n, 80), s = b(T, n, 90), l = b(ne, n, 20);
  return {
    "--el-color-primary-light-3": y(r.r, r.g, r.b),
    "--el-color-primary-light-5": y(o.r, o.g, o.b),
    "--el-color-primary-light-7": t === "dark" ? B(n.r, n.g, n.b, 0.7) : y(i.r, i.g, i.b),
    "--el-color-primary-light-8": y(a.r, a.g, a.b),
    "--el-color-primary-light-9": y(s.r, s.g, s.b),
    "--el-color-primary-dark-2": y(l.r, l.g, l.b)
  };
}
function ae(e) {
  const t = $(e);
  return t ? Object.fromEntries(
    U.map((n) => [
      `--color-primary${n}`,
      B(t.r, t.g, t.b, n / 10)
    ])
  ) : null;
}
function le(e) {
  e.style.removeProperty("--el-color-primary"), e.style.removeProperty("--color-on-primary-text");
  for (const t of oe)
    e.style.removeProperty(t);
  for (const t of re)
    e.style.removeProperty(t);
}
function F(e) {
  const t = String(e ?? "").trim().toLowerCase();
  return t && t.replace(/[^a-z0-9_-]/g, "-").replace(/-+/g, "-") || A;
}
function ce(e) {
  const t = [...e.classList].find(
    (n) => n.startsWith(L)
  );
  return t ? t.slice(L.length) : A;
}
function ue(e) {
  [...e.classList].filter((t) => t.startsWith(L)).forEach((t) => e.classList.remove(t));
}
function he(e) {
  return e.classList.contains("light") ? "light" : e.classList.contains("dark") ? "dark" : te;
}
function de(e, t) {
  const n = F(t);
  return ue(e), e.classList.add(`${L}${n}`), n;
}
function me(e, t, n = "light") {
  const r = $(t.startsWith("#") ? t : `#${t}`);
  if (!r)
    return !1;
  const o = y(r.r, r.g, r.b);
  e.style.setProperty("--color-primary", o), e.style.setProperty("--el-color-primary", o), e.style.setProperty("--color-on-primary-text", N(r));
  const i = ae(o);
  i && Object.entries(i).forEach(([s, l]) => e.style.setProperty(s, l));
  const a = ie(o, n);
  return a && Object.entries(a).forEach(([s, l]) => e.style.setProperty(s, l)), !0;
}
function fe(e = {}) {
  const t = document.documentElement, n = (e.mode ?? he(t)) === "light" ? "light" : "dark", r = e.theme ?? ce(t);
  if (de(t, r), e.primary != null && e.primary !== "") {
    const o = String(e.primary).trim();
    if (!me(t, o, n)) {
      t.style.setProperty("--color-primary", o), t.style.setProperty("--el-color-primary", o);
      const i = $(o.startsWith("#") ? o : `#${o}`);
      i && t.style.setProperty("--color-on-primary-text", N(i));
    }
  } else (e.primary === null || e.primary === "") && (t.style.removeProperty("--color-primary"), le(t));
  t.classList.toggle("light", n === "light"), t.classList.toggle("dark", n === "dark");
}
function Ce(e) {
  e.primary !== void 0 && (e.primary == null || e.primary === "" ? localStorage.removeItem(I) : localStorage.setItem(I, String(e.primary))), e.mode !== void 0 && localStorage.setItem(V, e.mode), e.theme !== void 0 && (e.theme == null || e.theme === "" ? localStorage.removeItem(x) : localStorage.setItem(
    x,
    F(e.theme)
  ));
}
function Ie() {
  var o;
  const e = localStorage.getItem(I), t = localStorage.getItem(V), n = localStorage.getItem(x) || ((o = globalThis.$config) == null ? void 0 : o.theme) || A, r = t === "light" ? "light" : "dark";
  fe({
    primary: e != null && e !== "" ? e : null,
    mode: r,
    theme: n
  });
}
const pe = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
let w = null;
function H(e) {
  G("error", e);
}
function xe(e) {
  w = e && typeof e == "object" ? e : null;
}
function P(e) {
  if (w && w[e] != null && w[e] !== "")
    return String(w[e]);
  const t = typeof globalThis < "u" ? globalThis.__MVFRAME_ENV__ : null;
  if (t && t[e] != null && t[e] !== "")
    return String(t[e]);
  const n = typeof import.meta < "u" ? pe : null;
  return n && n[e] != null && n[e] !== "" ? String(n[e]) : "";
}
const _ = j.create({
  timeout: 0,
  withCredentials: !1
});
let g = [];
const ge = j.CancelToken, ye = (e) => {
  const t = e.url + "_" + e.headers["Content-HI"] + "_" + e.ex, n = [];
  if (g.length)
    for (let r in g)
      g[r].v === t && n.push(r);
  n.length > 0 && (g[n[0]].cb(), g.splice(n[0], 1));
}, E = (e) => {
  if (e != null && e.url) {
    const t = e.url + "_" + e.headers["Content-HI"] + "_" + e.ex;
    for (let n in g)
      if (g[n].v === t) {
        g.splice(n, 1);
        break;
      }
  }
};
_.interceptors.request.use(
  (e) => {
    e.headers = e.headers || {};
    const { login: t, accountInfo: n = {} } = window.$store.launch(), { access_token: r } = t.info, o = e.noaccount === !0 || e.noAccount === !0;
    return r && e.headers["Content-HI"] && (e.headers.Authorization = `Bearer ${r}`), n.partner_org_id && !o && (e.data ? e.method.toLowerCase() === "get" ? e.params.accountId = n.partner_org_id : e.data.accountId = n.partner_org_id : e.method.toLowerCase() === "get" ? e.params = { accountId: n.partner_org_id } : e.data = { accountId: n.partner_org_id }), ye(e), e.cancelToken = new ge((i) => {
      g.push({
        v: e.url + "_" + e.headers["Content-HI"] + "_" + e.ex,
        cb: i
      });
    }), e;
  },
  (e) => Promise.reject(e)
);
_.interceptors.response.use(
  ({ data: e, config: t }) => {
    var i;
    if (e == null || typeof e != "object" || Array.isArray(e))
      return E(t), e;
    let { code: n, message: r, msg: o } = e;
    if (o = o || r, n === 200)
      E(t);
    else if (n === 500) {
      if (t.showMsg !== !1) {
        const a = (i = t == null ? void 0 : t.headers) != null && i.CONTACT_CUSTOMER_SERVICE ? window.$l("CONTACT_CUSTOMER_SERVICE") : "";
        H({
          grouping: !0,
          showClose: !0,
          duration: 0,
          message: [o, a].filter(Boolean).join(" ")
        });
      }
      E(t);
    } else n === 403 && window.location.replace("/"), E(t);
    return e;
  },
  (e) => {
    var n, r, o, i, a;
    let t = !1;
    if (e && e.response)
      switch (e.response.status) {
        case 403:
          e.message = "403 Token Expired", window.location.replace("/");
          break;
        case 502:
          e.message = "502 Error";
          break;
        case 503:
          e.message = "503 Error";
          break;
        case 504:
          e.message = "504 Error", e.response = {};
          break;
        default:
          e.message = `Connection Error-${e.response.status}`;
      }
    else
      (n = e.stack) != null && n.includes("timeout") ? e.message = window.$l("Timeout, Please Refresh") : (e.message = window.$l("Connect Failed"), t = !0);
    return t || ((r = e == null ? void 0 : e.response) == null ? void 0 : r.status) !== 403 && H({
      grouping: !0,
      message: `${e.message} ${(i = (o = e.config) == null ? void 0 : o.headers) == null ? void 0 : i["Content-HI"]}`
    }), E(e.config), e.code === "ERR_CANCELED" ? Promise.resolve({ code: e.code, msg: e.message }) : Promise.resolve({
      code: (a = e.response) == null ? void 0 : a.status,
      msg: e.message
    });
  }
);
function be(e) {
  return e.baseURL = P("VITE_APP_BASEURL"), e.method = "get", e.headers = { "Content-Type": "application/x-www-form-urlencoded" }, e.data && (e.params = e.data), _(e);
}
function Ee(e) {
  return e.baseURL = P("VITE_APP_BASEURL"), e.method = "get", e.headers = {
    ...e.headers,
    "Content-HI": e.url
  }, e.url = e.ver ? `api/${e.ver}/ads` : "api/v3/ads", e.data && (e.params = e.data), _(e);
}
function _e(e) {
  if (e.baseURL = P("VITE_APP_BASEURL"), e.method = "post", e.headers = {
    ...e.headers,
    "Content-HI": e.url
  }, e.data && window.$getType(e.data) === "Object") {
    const n = {};
    Object.keys(e.data).forEach((r) => {
      const o = e.data[r];
      [null, "", void 0].includes(o) || (n[r] = o);
    }), e.data = n;
  }
  return e.url = e.ver ? `api/${e.ver}/ads` : "api/v3/ads", _(e);
}
function k({
  data: e,
  url: t,
  ex: n,
  method: r = "post",
  emptyString: o = !1
}) {
  const i = {}, a = [void 0, null];
  o === !1 && a.push("");
  for (let u in e)
    a.indexOf(e[u]) === -1 && (i[u] = e[u]);
  const { login: s } = window.$store.launch(), { access_token: l } = s.info || {};
  return _({
    headers: {
      "Content-Type": "application/json",
      token: l != null ? String(l) : ""
    },
    baseURL: P("VITE_APP_AIURL"),
    url: t,
    method: r,
    data: i,
    ex: n
  });
}
const ke = k;
function Oe(e) {
  globalThis.$login = be, globalThis.$get = Ee, globalThis.$post = _e, globalThis.$form = k, globalThis.$xform = k;
}
export {
  te as MVFRAME_DEFAULT_THEME_MODE,
  A as MVFRAME_DEFAULT_THEME_NAME,
  Y as MVFRAME_STORAGE_LANG,
  I as MVFRAME_STORAGE_PRIMARY,
  V as MVFRAME_STORAGE_THEME,
  x as MVFRAME_STORAGE_THEME_NAME,
  L as MVFRAME_THEME_CLASS_PREFIX,
  fe as applyMvframeTheme,
  K as deepEqual,
  $e as download,
  ee as formatSummaryCell,
  Ve as getMaps,
  Oe as installRq,
  Le as isInView,
  Ie as loadMvframeTheme,
  Ue as mapLang,
  Be as mapLangPath,
  Ne as mergeMaps,
  Fe as patchMaps,
  Ce as persistMvframeTheme,
  J as sanitizeDownloadFileName,
  xe as setMvframeRqEnv,
  k as useForm,
  Ee as useGet,
  Ae as useLang,
  be as useLogin,
  We as useMap,
  Se as useOptions,
  _e as usePost,
  Pe as useRemoteSummary,
  ke as useXform
};
