import { defineComponent as S, shallowRef as b, ref as $, watch as w, onMounted as E, provide as N, computed as B, openBlock as e, createElementBlock as s, normalizeClass as c, unref as a, withDirectives as O, createElementVNode as v, Fragment as _, renderList as h, createBlock as u, withCtx as T, createCommentVNode as m, vShow as V, normalizeStyle as z } from "vue";
/* empty css                                                                                         */
import H from "./toolbars/toolbar.mjs";
import { wetRichEditorProps as J } from "./types.mjs";
import { useNamespace as L, ElTooltip as M } from "element-plus";
import { useElementBounding as D } from "../../node_modules/.pnpm/@vueuse_core@10.9.0_vue@3.4.21/node_modules/@vueuse/core/index.mjs";
import { SymbolState as F } from "./symbol.mjs";
import I from "./toolbars/code-block.vue.mjs";
import P from "./toolbars/constom-code.mjs";
import Q from "./toolbars/header-picker.vue.mjs";
import j from "./toolbars/image-insert.vue.mjs";
import A from "./async-import.mjs";
const G = ["value"], K = {
  key: 4,
  class: "ql-picker__divbox"
}, U = ["value"], ie = /* @__PURE__ */ S({
  __name: "index",
  props: J,
  setup(C, { expose: g }) {
    const i = C, d = L("rich-editor"), y = b(), p = $(), { height: x } = D(p), n = b();
    w([n, () => i.initialValue], ([l, o]) => {
      var r;
      l && o && ((r = n.value) == null || r.setContents(JSON.parse(o)));
    }, {
      immediate: !0
    }), w([n, () => i.readOnly], ([l, o]) => {
      var r;
      l && ((r = n.value) == null || r.enable(!o));
    }, { immediate: !0 });
    const R = async () => {
      const l = await A(), o = await P();
      l.register("modules/constomCode", o), n.value = new l(y.value, {
        modules: {
          constomCode: !0,
          toolbar: {
            container: p.value,
            handlers: {
              table: function() {
                n.value.format("table-row", []);
              }
            }
          }
        },
        theme: "snow"
      });
    };
    return E(() => {
      R();
    }), N(F, {
      quill: n,
      httpRequest: B(() => i.imageHttpRequest)
    }), g({
      getContents: (l = !1) => {
        var o, r;
        if (l)
          return (o = n.value) == null ? void 0 : o.getSemanticHTML();
        {
          const f = (r = n.value) == null ? void 0 : r.getContents();
          return JSON.stringify(f);
        }
      }
    }), (l, o) => (e(), s("div", {
      class: c([a(d).b()])
    }, [
      O(v("div", {
        ref_key: "toolRef",
        ref: p
      }, [
        (e(!0), s(_, null, h(a(H), (r, f) => (e(), s("div", {
          class: "ql-formats",
          key: f
        }, [
          (e(!0), s(_, null, h(r, (t, q) => (e(), u(a(M), {
            key: q,
            content: t.title,
            placement: "top"
          }, {
            default: T(() => [
              t.render === "code-block" ? (e(), u(I, { key: 0 })) : m("", !0),
              t.render === "header" ? (e(), u(Q, { key: 1 })) : m("", !0),
              t.render === "image" ? (e(), u(j, { key: 2 })) : m("", !0),
              !t.options && !t.render ? (e(), s("button", {
                key: 3,
                class: c(`ql-${t.key}`),
                value: t.value
              }, null, 10, G)) : m("", !0),
              t.options ? (e(), s("div", K, [
                v("select", {
                  class: c(`ql-${t.key}`)
                }, [
                  (e(!0), s(_, null, h(t.options, (k) => (e(), s("option", {
                    value: k,
                    key: k
                  }, null, 8, U))), 128))
                ], 2)
              ])) : m("", !0)
            ]),
            _: 2
          }, 1032, ["content"]))), 128))
        ]))), 128))
      ], 512), [
        [V, i.showToolsbar]
      ]),
      v("div", {
        ref_key: "divRef",
        ref: y,
        class: c([a(d).e("inner-box"), a(d).is("no-toolsbar", !i.showToolsbar)]),
        style: z({
          "--wet-richeditor-inner-h": `${a(x)}px`
        })
      }, null, 6)
    ], 2));
  }
});
export {
  ie as default
};
