import { defineComponent as x, reactive as g, computed as B, onMounted as v, nextTick as w, watch as I, resolveComponent as N, openBlock as l, createElementBlock as a, normalizeClass as S, Fragment as $, renderList as D, createBlock as F, withCtx as L, createElementVNode as m, toDisplayString as p } from "vue";
import { C as s } from "../Shared/base-PQGakkrl.js";
const M = { key: 1 }, T = { class: "breadcrumb-item" }, A = /* @__PURE__ */ x({
  name: "ClBreadcrumb",
  __name: "Index",
  props: {
    className: String,
    list: {
      type: Array,
      default: () => []
    },
    title: String
  },
  emits: ["onClickUrl"],
  setup(d, { emit: f }) {
    const r = d, _ = f, i = g({
      keyIndex: `breadcrumb-${s.getRandom(8)}`,
      title: "",
      list: []
    }), k = (t) => !s.isEmpty(t), y = B(() => {
      const t = {
        breadcrumb: !0
      }, { className: e } = r;
      return e && !s.isEmpty(e) && e.split(" ").forEach((o) => {
        s.isEmpty(o) || (t[o] = !0);
      }), t;
    }), u = (t, e) => {
      const o = [];
      let n = "";
      if (!s.isEmpty(t)) {
        const c = t.length;
        t.forEach((b, E) => {
          E < c - 1 && o.push(b);
        }), n = t[c - 1].name, c > 1 && (n = s.isEmpty(e) ? n : e);
      }
      i.list = o, i.title = n;
    }, h = () => {
      u(r.list, r.title);
    };
    v(() => {
      w(() => {
        h();
      });
    }), I(
      [() => r.list, () => r.title],
      ([t, e]) => {
        u(t, e);
      }
    );
    const C = (t) => {
      _("onClickUrl", t);
    };
    return (t, e) => {
      const o = N("router-link");
      return l(), a("ol", {
        class: S(y.value)
      }, [
        (l(!0), a($, null, D(i.list, (n, c) => (l(), a("li", {
          class: "breadcrumb-item",
          key: `${i.keyIndex}-${c}`
        }, [
          k(n.href) ? (l(), F(o, {
            key: 0,
            to: n.href
          }, {
            default: L(() => [
              m("span", { onClick: C }, p(n.name), 1)
            ]),
            _: 2
          }, 1032, ["to"])) : (l(), a("span", M, p(n.name), 1))
        ]))), 128)),
        m("li", T, [
          m("span", null, p(i.title), 1)
        ])
      ], 2);
    };
  }
});
export {
  A as default
};
//# sourceMappingURL=ClBreadcrumb.js.map
