import { getConfig as u } from "@das-fed/utils/config";
import { getUrlParams as d } from "@das-fed/utils/common-tools";
import { getAccessToken as I } from "@das-fed/utils/token-tools";
import { getTokenFromQuery as S, getProjectInfoFromQuery as y } from "@das-fed/utils/common-info/getInfoFromUrl";
const N = I, T = () => {
  var r;
  let e = JSON.parse(sessionStorage.getItem("tenantInfo") || "{}");
  return {
    id: e.id ?? "",
    name: e.userName ?? "",
    flag: e.flag ?? null,
    tenantId: ((r = e == null ? void 0 : e.tenant) == null ? void 0 : r.id) ?? ""
  };
}, J = () => {
  let e = JSON.parse(sessionStorage.getItem("userInfo") || "{}");
  const t = u();
  return JSON.stringify(e) === "{}" && t.personalInfo && (e = t.personalInfo), {
    id: e.id ?? "",
    name: e.name ?? "",
    userName: e.userName ?? "",
    phone: e.phone ?? "",
    email: e.email ?? "",
    headPicture: e.headPicture ?? ""
  };
}, O = () => {
  let e = JSON.parse(sessionStorage.getItem("tenantInfo") || "{}");
  return {
    userId: e.id ?? "",
    userName: e.userName ?? "",
    name: e.name ?? "",
    areaCode: e.areaCode ?? "",
    region: e.region ?? "",
    phone: e.phone ?? "",
    email: e.email ?? "",
    flag: e.flag ?? null,
    tenant: e.tenant ?? {},
    headPicture: e.headPicture ?? "",
    nickName: e.nickName ?? "",
    gender: e.gender ?? null,
    status: e.status ?? null,
    statusName: e.statusName ?? null,
    tags: e.tags ?? [],
    type: e.type ?? null,
    address: e.address ?? "",
    description: e.description ?? ""
  };
}, M = () => sessionStorage.getItem("languages"), C = () => {
  let e = JSON.parse(sessionStorage.getItem("projectInfo") || "{}");
  const t = u();
  return JSON.stringify(e) === "{}" && t.projectInfo && (e = t.projectInfo), {
    id: (e == null ? void 0 : e.id) ?? 0,
    code: (e == null ? void 0 : e.code) ?? 0,
    name: (e == null ? void 0 : e.name) ?? "",
    type: (e == null ? void 0 : e.type) ?? null,
    parentId: (e == null ? void 0 : e.parentId) ?? "",
    parentName: (e == null ? void 0 : e.parentName) ?? "",
    parentType: (e == null ? void 0 : e.parentType) ?? null,
    tenantId: (e == null ? void 0 : e.tenant) ?? "",
    isParent: (e == null ? void 0 : e.isParent) ?? !1,
    leaf: (e == null ? void 0 : e.leaf) ?? !1,
    optional: (e == null ? void 0 : e.leaf) ?? !0
  };
}, f = () => {
  let e = JSON.parse(sessionStorage.getItem("project-message") || "{}");
  return {
    id: (e == null ? void 0 : e.id) ?? 0,
    projectName: (e == null ? void 0 : e.projectName) ?? "",
    provinceCode: (e == null ? void 0 : e.provinceCode) ?? "",
    cityCode: (e == null ? void 0 : e.cityCode) ?? "",
    areaCode: (e == null ? void 0 : e.areaCode) ?? "",
    address: (e == null ? void 0 : e.address) ?? "",
    projectDesc: (e == null ? void 0 : e.projectDesc) ?? "",
    logoPath: (e == null ? void 0 : e.logoPath) ?? "",
    projectType: (e == null ? void 0 : e.projectType) ?? "",
    projectTypeCode: (e == null ? void 0 : e.projectTypeCode) ?? "",
    longitude: (e == null ? void 0 : e.longitude) ?? "",
    latitude: (e == null ? void 0 : e.latitude) ?? "",
    projectStartDate: (e == null ? void 0 : e.projectStartDate) ?? "",
    projectExpiryDate: (e == null ? void 0 : e.projectExpiryDate) ?? "",
    projectCode: (e == null ? void 0 : e.projectCode) ?? "",
    mapConfiguration: (e == null ? void 0 : e.mapConfiguration) ?? !1,
    cityName: (e == null ? void 0 : e.cityName) ?? "",
    cityNamePinyin: (e == null ? void 0 : e.cityNamePinyin) ?? "",
    timezone: (e == null ? void 0 : e.timezone) ?? "",
    autoTimezone: (e == null ? void 0 : e.autoTimezone) ?? !1,
    currency: (e == null ? void 0 : e.currency) ?? {}
  };
}, v = () => {
  const e = JSON.parse(sessionStorage.getItem("home-config") || "{}");
  return {
    applicationCode: (e == null ? void 0 : e.applicationCode) ?? "",
    applicationPath: (e == null ? void 0 : e.applicationPath) ?? "",
    enable: (e == null ? void 0 : e.enable) ?? !1,
    originalCode: (e == null ? void 0 : e.originalCode) ?? "",
    routeUrl: (e == null ? void 0 : e.routeUrl) ?? "",
    displayPosition: (e == null ? void 0 : e.displayPosition) ?? 1,
    type: (e == null ? void 0 : e.type) ?? null
  };
}, k = () => {
  const e = JSON.parse(sessionStorage.getItem("personal-config") || "{}");
  return {
    style: (e == null ? void 0 : e.style) ?? "",
    skinStyle: (e == null ? void 0 : e.skinStyle) ?? ""
  };
}, j = (e, t) => {
  var g;
  const r = "permission-btn", a = m(), o = d(location.href, "app") || "", s = t || o || a.currentSubAppCode;
  if (!s) return;
  const n = d(location.href, "menu") || "", l = e || n || a.currentSubApp.currentMenuCode, c = JSON.parse(sessionStorage.getItem(r) || "{}");
  if (!c || JSON.stringify(c) === "{}") return;
  const p = (g = c[s]) == null ? void 0 : g[l];
  if (p)
    return p.length ? p : c[s]["origin-auth"] ? c[s]["origin-auth"][l] ?? [] : [];
}, D = (e, t) => j(e, t) ?? [], m = () => {
  const e = JSON.parse(sessionStorage.getItem("subApps") || "{}");
  return {
    appcategorys: e.appcategorys ?? [],
    currentSubApp: e.currentSubApp ?? {},
    currentSubAppCode: e.currentSubAppCode ?? "",
    subAppList: e.subAppList ?? [],
    fixedApps: e.fixedApps ?? [],
    menuCollapses: e.menuCollapses ?? []
  };
}, U = (e, t = !1) => {
  var a, o;
  const r = m().subAppList;
  if (e)
    return t ? ((a = r == null ? void 0 : r.find((s) => s.code === e)) == null ? void 0 : a.originalMenus) ?? [] : ((o = r == null ? void 0 : r.find((s) => s.code === e)) == null ? void 0 : o.menus) ?? [];
  {
    let s = {};
    return t ? r == null || r.forEach((n) => {
      s[n.code] = n.originalMenus ?? [];
    }) : r == null || r.forEach((n) => {
      s[n.code] = n.menus ?? [];
    }), s;
  }
}, x = () => {
  const e = JSON.parse(sessionStorage.getItem("tabs") || "{}");
  return {
    currentCode: e.currentCode ?? "",
    currentTab: e.currentTab ?? {},
    tabMap: e.tabMap ?? {},
    preTab: e.preTab ?? {}
  };
}, E = () => {
  const e = u(), t = sessionStorage.getItem("minioAddress");
  return t || (e.baseURL ? e.baseURL : location.origin);
}, z = () => ({
  instanceInfo: JSON.parse(sessionStorage.getItem("instance") || "{}").instanceInfo ?? {}
}), F = () => localStorage.getItem("fav-icon") || "./logo.svg";
N() || S();
var i;
(i = C()) != null && i.id || y();
export {
  F as getFavIcon,
  v as getHomeInfo,
  z as getInstanceInfo,
  M as getLanguages,
  U as getMenus,
  E as getMinioAddress,
  j as getPageAuth,
  D as getPageAuthBtn,
  k as getPersonalConfig,
  J as getPersonalInfo,
  C as getProjectInfo,
  f as getProjectMessage,
  m as getSubApps,
  x as getTabInfo,
  O as getTenantInfo,
  N as getToken,
  T as getUserInfo
};
