import { ref as d, computed as w, watchEffect as Ie, watch as k } from "vue";
import { defineStore as x } from "pinia";
import { o as pe, B as ve, p as Ee, q as ge, r as Me, s as fe, t as m, v as M, N as I, w as z, x as D, P as be, y as Ne, S as B } from "./start-BYfL32Oe.mjs";
const Oe = `${ve}Navigation.`, Te = {
  /** Clear tenant cache */
  async setPluginOrder(e) {
    return pe.post(`${Oe}setPluginOrder`, e);
  }
};
var _e = {};
const Pe = d(
  Ee() ? JSON.parse(_e.CORE1_LOCAL_PLUGINS || "{}") : {}
), H = "ActindoWorkFlow", We = "start", we = `Actindo.Modules.Actindo.${H}.${We}`, G = "Channels", Ve = "start", Se = `Actindo.Modules.Actindo.${G}.${Ve}`;
var l = /* @__PURE__ */ ((e) => (e[e.TODO = 1] = "TODO", e[e.ERROR = 2] = "ERROR", e[e.DONE = 3] = "DONE", e[e.FROZEN = 4] = "FROZEN", e[e.AWAITING_CONFIRMATION = 5] = "AWAITING_CONFIRMATION", e[e.SYNCHRONOUS = 6] = "SYNCHRONOUS", e[e.AWAITING_DIFFERENT_CONFIRMATION = 7] = "AWAITING_DIFFERENT_CONFIRMATION", e[e.SEMI_AUTOMATIC_ACCEPTED = 8] = "SEMI_AUTOMATIC_ACCEPTED", e))(l || {}), R = /* @__PURE__ */ ((e) => (e[e.COPY_ONCE = 0] = "COPY_ONCE", e[e.INHERIT = 1] = "INHERIT", e))(R || {}), f = /* @__PURE__ */ ((e) => (e[e.DEFAULT = -1] = "DEFAULT", e[e.MANUAL = 0] = "MANUAL", e[e.SEMIAUTOMATIC = 1] = "SEMIAUTOMATIC", e[e.AUTOMATIC = 2] = "AUTOMATIC", e[e.SEMIAUTOMATIC_DIFFERENT_USER = 3] = "SEMIAUTOMATIC_DIFFERENT_USER", e))(f || {}), Fe = /* @__PURE__ */ ((e) => (e[e.DataHub = 0] = "DataHub", e[e.NATIVE = 1] = "NATIVE", e[e.EMPTY = 2] = "EMPTY", e[e.SUB_ENTITY = 3] = "SUB_ENTITY", e))(Fe || {});
const j = "DataHub", Re = "start", $e = `Actindo.Modules.Actindo.${j}.${Re}`, Qe = {
  false: {
    icon: "cancel",
    label: "datahub-ui.dh-statuses.isActive.inactive",
    color: "on_light"
  },
  true: {
    icon: "check_circle",
    label: "datahub-ui.dh-statuses.isActive.active",
    color: "positive_gradient_1"
  }
}, et = {
  [l.TODO]: {
    icon: "play_circle",
    label: "datahub-ui.etlProcesses.etlProcessStatus.Todo",
    color: "on_dark"
  },
  [l.ERROR]: {
    icon: "error",
    label: "datahub-ui.etlProcesses.etlProcessStatus.Error",
    color: "alert"
  },
  [l.DONE]: {
    icon: "check_circle",
    label: "datahub-ui.etlProcesses.etlProcessStatus.Done",
    color: "positive_gradient_1"
  },
  [l.FROZEN]: {
    icon: "pause",
    label: "datahub-ui.etlProcesses.etlProcessStatus.Frozen",
    color: "on_light_64"
  },
  [l.AWAITING_CONFIRMATION]: {
    icon: "pause",
    label: "datahub-ui.etlProcesses.etlProcessStatus.AwaitingConfirmation",
    color: "on_light_64"
  },
  [l.SYNCHRONOUS]: {
    icon: "timelapse",
    label: "datahub-ui.etlProcesses.etlProcessStatus.Synchronous",
    color: "gradient_2"
  },
  [l.AWAITING_DIFFERENT_CONFIRMATION]: {
    icon: "pause",
    label: "datahub-ui.etlProcesses.etlProcessStatus.AwaitingConfirmationByDifferentUser",
    color: "on_light_64"
  },
  [l.SEMI_AUTOMATIC_ACCEPTED]: {
    icon: "play_circle",
    label: "datahub-ui.etlProcesses.etlProcessStatus.SemiChangeAccepted",
    color: "on_dark"
  }
}, tt = {
  [R.COPY_ONCE]: "datahub-ui.dh-shared.inheritance.copyOnce",
  [R.INHERIT]: "datahub-ui..inheritance.inherit"
}, at = {
  [f.DEFAULT]: "datahub-ui.etlProcesses.changeTrackingMode.changeTrackingManual",
  [f.MANUAL]: "datahub-ui.etlProcesses.changeTrackingMode.changeTrackingManual",
  [f.SEMIAUTOMATIC]: "datahub-ui.etlProcesses.changeTrackingMode.changeTrackingSemiAutomatic",
  [f.SEMIAUTOMATIC_DIFFERENT_USER]: "datahub-ui.etlProcesses.changeTrackingMode.changeTrackingSemiAutomaticDifferentUser",
  [f.AUTOMATIC]: "datahub-ui.etlProcesses.changeTrackingMode.changeTrackingAutomatic"
}, st = /^[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]$/, ot = /^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUseA>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUseB>x(-[A-Za-z0-9]{1,8})+))$/, nt = 1e6;
var Ue = /* @__PURE__ */ ((e) => (e.ATTRIBUTES = "datahub-Attributes", e.ATTRIBUTE_SETS = "datahub-AttributeSets", e.ATTRIBUTE_GROUPS = "datahub-AttributeGroups", e.SCOPES = "datahub-Scopes", e.LANGUAGES = "datahub-Languages", e))(Ue || {});
const it = "datahub_translatable_name", ct = [
  l.FROZEN,
  l.ERROR
], q = "ECM", ye = "start", Le = `Actindo.Modules.Actindo.${q}.${ye}`, K = "OMS", ke = "start", me = `Actindo.Modules.Actindo.${K}.${ke}`, Y = "PIM", ze = "start", De = `Actindo.Modules.Actindo.${Y}.${ze}`, X = "Tasks", Be = "start", Ce = `Actindo.Modules.Actindo.${X}.${Be}`, J = "Taxes", Ze = "start", xe = `Actindo.Modules.Actindo.${J}.${Ze}`;
var V = /* @__PURE__ */ ((e) => (e.PERSIST = "postPersist", e.UPDATE = "postUpdate", e.REMOVE = "postRemove", e))(V || {}), E = /* @__PURE__ */ ((e) => (e.EQ = "eq", e.NEQ = "neq", e.IS_SET = "isset", e))(E || {}), T = /* @__PURE__ */ ((e) => (e[e.READY_TO_SENT = 0] = "READY_TO_SENT", e[e.SUCCESS = 1] = "SUCCESS", e[e.FINALLY_FAILED = 2] = "FINALLY_FAILED", e[e.PRE_REMOVE = 3] = "PRE_REMOVE", e))(T || {});
const Q = "Webhooks", He = "start", Ge = `Actindo.Modules.Actindo.${Q}.${He}`;
V.PERSIST + "", V.UPDATE + "", V.REMOVE + "";
E.EQ + "", E.NEQ + "", E.IS_SET + "";
E.EQ + "", E.NEQ + "", E.IS_SET + "";
T.READY_TO_SENT + "", T.SUCCESS + "", T.FINALLY_FAILED + "", T.PRE_REMOVE + "";
const je = {
  [H]: [we],
  [G]: [Se],
  [j]: [$e],
  // GDM doesn't have UI
  [q]: [Le],
  // PIM channels connection doesn't have UI
  [K]: [me],
  // EcmDataHubIntegration doesn't have UI
  // Setting doesn't have UI
  [Y]: [De],
  [X]: [Ce],
  [J]: [xe],
  [Q]: [Ge]
};
function C(e) {
  return "Core1Authentication" + e.charAt(0).toUpperCase() + e.substring(1);
}
function ee(e, p) {
  return new Set(
    p.filter(({ namespace: u }) => u === e.namespace).map(({ viewType: u }) => u)
  );
}
function Z(e, p, u) {
  return ee(e, u).size === 1 || [I.LocalVue, I.Vue3].includes(
    e.viewType
  );
}
function qe(e, p, u) {
  return ee(e, u).size > 1 && ![I.LocalVue, I.Vue3].includes(
    e.viewType
  );
}
x("Core-plugins", () => {
  const e = ge(), p = Me(), u = fe(), A = w({
    get: () => e.fullPath,
    set: (t) => {
      t !== e.fullPath && p.replace(t);
    }
  }), $ = d(""), S = d([]), _ = d([]), b = d(), U = d(), P = d({}), y = d(), r = d(
    m(C("navigationItems"), [], {
      serializer: B.object
    })
  ), F = d(
    m(C("topBarItem"), [], {
      serializer: B.object
    })
  ), W = w(
    () => r.value.map((t) => {
      var c, N, O, h;
      const o = M(t), a = (c = t.icon) != null && c.startsWith("mdi-") ? `mdi:${t.icon}` : t.icon, s = (N = t.children) == null ? void 0 : N.map((v) => ({
        ...v,
        lastPath: P.value[`${M(t)}/${v.route}`] ?? v.route,
        path: `${o}/${v.route}`
      })), n = P.value[M(t)] ?? ((O = s == null ? void 0 : s[0]) == null ? void 0 : O.path) ?? o;
      let i = t.viewType;
      return t.viewType === I.Vue3 && (i = (h = je[t.name]) != null && h.includes(t.view) ? I.LocalVue : I.Vue3), {
        ...t,
        icon: a,
        path: o,
        lastPath: n,
        children: s,
        viewType: i
      };
    })
  ), te = w({
    get() {
      const t = String($.value).toLowerCase();
      return t ? W.value.filter(
        ({ title: o, name: a }) => o.toLowerCase().includes(t) || a.toLowerCase().includes(t)
      ) : W.value;
    },
    set(t) {
      r.value = t;
      const o = t.map(
        (a, s) => ({
          namespace: a.namespace,
          view: a.view,
          sorting: s
        })
      );
      Te.setPluginOrder({ sortings: o });
    }
  }), ae = w(() => {
    var t;
    return !((t = r.value) != null && t.length);
  });
  Ie(() => {
    var c, N, O;
    const [, , , t, o] = `${A.value}`.split("/") ?? [], a = r.value.findIndex(
      (h) => h.name === t && h.view.slice(h.namespace.length + 1) === o
    );
    b.value = (c = r.value) == null ? void 0 : c[a];
    const s = (N = W.value) == null ? void 0 : N[a];
    if (U.value = s, !s)
      return;
    const n = M(b.value ?? {});
    s.lastPath !== A.value && (P.value[n] = e.path);
    const i = (O = s.children) == null ? void 0 : O.find(({ route: h }) => {
      const v = `${s.path}/${h}`;
      return A.value === v || A.value.startsWith(`${v}/`);
    });
    i && (P.value[`${n}/${i.route}`] = e.path.slice(
      s.path.length + 1
    ));
  });
  const g = (t, o) => {
    var a;
    return (a = r.value) == null ? void 0 : a.find(
      (s) => s.view === t && s.name === o
    );
  };
  function se({ view: t, name: o }, a = []) {
    const s = g(t, o);
    s && (s.children = a);
  }
  function oe({ view: t, name: o }, a) {
    const s = g(t, o);
    s && Object.assign(s, a);
  }
  function L({ view: t, name: o }, a) {
    const s = g(t, o);
    s && (s.children ? s.children.push(a) : s.children = [a]);
  }
  function ne({ view: t, name: o }, a) {
    var i;
    const s = g(t, o);
    if (!s)
      return;
    const n = (i = s.children) == null ? void 0 : i.find(({ route: c }) => c === a.route);
    n ? (n.label = a.label ?? n.label, n.disabled = a.disabled ?? n.disabled) : a.label && a.route && L({ view: t, name: o }, a);
  }
  function ie({ view: t, name: o }, a) {
    var n;
    const s = g(t, o);
    s && (s.children = (n = s.children) == null ? void 0 : n.filter(
      ({ route: i }) => i !== (a == null ? void 0 : a.route)
    ));
  }
  const ce = ({
    namespace: t,
    view: o
  }) => {
    var a, s;
    return t === ((a = b.value) == null ? void 0 : a.namespace) && ((s = b.value) == null ? void 0 : s.view) === o;
  }, re = (t) => A.value.startsWith(t.path);
  function le(t, o) {
    if (!e || o.disabled)
      return;
    const a = o.lastPath || o.route;
    t.viewType === I.LocalVue && a && (A.value = `${M(t)}/${a}`), y.value = {
      module: t,
      route: a
    };
  }
  async function ue() {
    if (!u.hasPrivilege(be.START_NAVIGATION_MODULES_LIST)) {
      r.value = [], F.value = [];
      return;
    }
    try {
      const t = await Ne.getModuleNavigation();
      S.value = t.map((o) => {
        const a = {
          ...o,
          ...Pe.value[o.view]
        };
        a.view = a.view ?? `${a.namespace}.start`;
        const s = r.value.find(
          ({ namespace: n, view: i }) => n === a.namespace && i === a.view
        );
        return a.children = a.children ?? (s == null ? void 0 : s.children), a;
      }).sort((o, a) => {
        var s;
        return (s = o.title) == null ? void 0 : s.localeCompare(a.title || "");
      });
    } catch (t) {
      S.value = [], console.error(t);
    }
  }
  function de({ url: t, view: o, name: a, namespace: s }) {
    if (!o || !a || !s)
      return p.push(t);
    const n = M({ view: o, name: a, namespace: s }), i = t.startsWith("/") ? "" : "/", c = n + i + t;
    p.push(c);
  }
  function Ae(t) {
    t.moduleUrl = D(t.moduleUrl), _.value.push(t);
  }
  function he(t) {
    _.value = _.value.filter((o) => o !== t);
  }
  return k(S, (t) => {
    const o = t.filter(
      ({ position: n }) => n === z.Menu
    ), a = o.filter(Z), s = o.filter(qe).map((n) => ({ ...n, legacy: !0 }));
    r.value = [...a, ...s], F.value = t.filter(
      ({ position: n, view: i, moduleUrl: c }) => n === z.Top && (i || c)
    ).filter(Z).map(({ moduleUrl: n, view: i, ...c }) => ({
      ...c,
      view: i,
      moduleUrl: n ? i : D(n)
    }));
  }), k(
    () => u.user,
    (t) => {
      t || (r.value = []);
    }
  ), {
    plugins: r,
    topBarItem: F,
    embeddedApps: _,
    filter: $,
    modules: W,
    filteredModules: te,
    isEmpty: ae,
    activePlugin: b,
    activeModule: U,
    activeRoutePath: A,
    isActivePlugin: ce,
    isActiveSubRoute: re,
    setChildren: se,
    addChild: L,
    updateChild: ne,
    removeChild: ie,
    updateNavigation: oe,
    navigateTo: le,
    setUrl: de,
    requestedNavigation: y,
    fetchModuleNavigation: ue,
    openEmbeddedApps: Ae,
    closeEmbeddedApps: he,
    findByViewAndName: g
  };
});
const Ke = () => ({
  titles: []
});
x("Core-header", {
  state: Ke
});
export {
  f as C,
  j as D,
  et as E,
  Qe as I,
  st as K,
  Ue as L,
  nt as M,
  it as N,
  ct as R,
  Fe as S,
  tt as a,
  at as b,
  ot as c
};
