import { defineComponent as _, inject as k, ref as h, watch as y, computed as b, openBlock as u, createBlock as v, unref as n, withCtx as a, createVNode as r, createElementBlock as g, Fragment as w, renderList as x, createTextVNode as C, toDisplayString as d, createElementVNode as f } from "vue";
import { ElDropdown as E, ElDropdownMenu as H, ElDropdownItem as S, ElIcon as B } from "element-plus";
import { CaretBottom as D } from "../../../node_modules/.pnpm/@element-plus_icons-vue@2.3.1_vue@3.4.21/node_modules/@element-plus/icons-vue/dist/index.mjs";
import { SymbolState as z } from "../symbol.mjs";
const N = { style: { width: "fit-content", display: "flex", "align-items": "center", color: "#06c" } }, V = { style: { width: "30px", "font-size": "14px" } }, A = /* @__PURE__ */ _({
  __name: "header-picker",
  setup(F) {
    const { quill: o } = k(z), c = h(0), i = (e) => {
      if (e) {
        let t = o.value.getFormat(e.index), l = t.header ? t.header : 0;
        c.value = l;
      }
    };
    y(o, (e) => {
      e && (o.value.on("selection-change", (t) => {
        i(t);
      }), o.value.on("text-change", () => {
        const t = o.value.getContents();
        console.log(t);
        const l = o.value.getSelection(!0);
        l && i(l);
      }));
    }, {
      immediate: !0
    });
    const m = b(() => {
      const e = s.find((t) => t.key === c.value);
      return e ? e.label : "正文";
    }), s = [
      {
        key: 1,
        label: "H1"
      },
      {
        key: 2,
        label: "H2"
      },
      {
        key: 3,
        label: "H3"
      },
      {
        key: 4,
        label: "H4"
      },
      {
        key: 5,
        label: "H5"
      },
      {
        key: 0,
        label: "正文"
      }
    ], p = (e) => {
      c.value = e, o.value.format("header", e);
    };
    return (e, t) => (u(), v(n(E), { trigger: "click" }, {
      dropdown: a(() => [
        r(n(H), null, {
          default: a(() => [
            (u(), g(w, null, x(s, (l) => r(n(S), {
              onClick: () => p(l.key),
              key: l.key
            }, {
              default: a(() => [
                C(d(l.label), 1)
              ]),
              _: 2
            }, 1032, ["onClick"])), 64))
          ]),
          _: 1
        })
      ]),
      default: a(() => [
        f("button", N, [
          f("span", V, d(m.value), 1),
          r(n(B), null, {
            default: a(() => [
              r(n(D))
            ]),
            _: 1
          })
        ])
      ]),
      _: 1
    }));
  }
});
export {
  A as default
};
