import { jsx as t, jsxs as r, Fragment as x } from "react/jsx-runtime";
import { useState as b } from "react";
import { MenuProvider as g, MenuConsumer as w } from "@devgateway/wp-react-lib";
import { injectIntl as S } from "react-intl";
import { Container as M, Menu as a } from "semantic-ui-react";
import { decode as v } from "../utils/parseUtils.js";
const C = (e, i) => e ? e.substr(e.indexOf("/wp") + 3).startsWith("/" + i) ? e.substr(e.indexOf("/wp") + 3) : "/" + i + e.substr(e.indexOf("/wp") + 3) : "", N = S((e) => {
  const { menu: i, locale: d, match: h, selected: l, active: o, showIcons: s, onSetSelected: c } = e;
  return /* @__PURE__ */ t(x, { children: i && i.items.map((n, m) => /* @__PURE__ */ r(
    a.Item,
    {
      className: `divided ${n.child_items ? "has-child-items" : ""} 
                    ${l && l.ID == n.ID ? "selected" : ""}  
                    ${o == n.slug ? "active" : ""}`,
      children: [
        /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t("a", { href: C(n.url, d), children: n.title }) }),
        n.child_items && n.child_items.map((u, p) => /* @__PURE__ */ t(a.Item, { children: " " }))
      ]
    }
  )) });
}), q = (e) => {
  const {
    intl: i,
    parent: d,
    editing: h = !1,
    unique: l,
    onChange: o,
    "data-name": s = "main",
    "data-label": c,
    "data-icon": n,
    "data-icon-id": m,
    "data-show-icons": u,
    "data-show-labels": p,
    locale: f
  } = e, [j, I] = b(null);
  return /* @__PURE__ */ t(M, { fluid: !0, textAlign: "right", children: s && s != "" && /* @__PURE__ */ r(a, { className: "inline", size: "small", children: [
    /* @__PURE__ */ r(a.Item, { header: !0, children: [
      n && /* @__PURE__ */ t("img", { src: v(n), className: "icon" }),
      c && /* @__PURE__ */ t("span", { className: "label", children: c })
    ] }),
    /* @__PURE__ */ t(g, { slug: s, locale: f, children: /* @__PURE__ */ t(w, { children: /* @__PURE__ */ t(N, { onSetSelected: I }) }) })
  ] }) });
};
export {
  q as default
};
