import { resolveComponent as k, openBlock as o, createElementBlock as r, createElementVNode as i, createVNode as _, Transition as $, withCtx as x, unref as e, createBlock as c, createCommentVNode as h, Fragment as u, renderList as f, normalizeClass as b, toDisplayString as D, withDirectives as V, vModelText as z, TransitionGroup as B, normalizeStyle as E } from "vue";
import { useUser as N, useDefs as T, dictRecord as m, langParts as L } from "./composables-5f691338.js";
const S = { class: "flex flex-col gap-2" }, U = { class: "flex w-full gap-2 flex-wrap" }, A = {
  key: 0,
  class: "flex flex-1 gap-2 m-2"
}, F = ["onClick"], G = { class: "flex gap-2 flex-1" }, M = { class: "flex flex-wrap gap-2" }, q = {
  __name: "DictDefList",
  emits: ["def", "root"],
  setup(P) {
    const { user: a } = N(), { def: l, addDef: v, found: y, linked: C } = T();
    return (d, s) => {
      const g = k("dict-word-card"), p = k("dict-def-card");
      return o(), r("div", S, [
        i("div", {
          class: "font-bold text-xl mb-2 cursor-pointer",
          onClick: s[0] || (s[0] = (t) => d.$emit("root", "defs"))
        }, "Definitions"),
        _($, {
          name: "fade",
          mode: "out-in"
        }, {
          default: x(() => {
            var t;
            return [
              (t = e(m)) != null && t.word ? (o(), c(g, {
                key: e(m).word,
                hash: e(m).word
              }, null, 8, ["hash"])) : h("", !0)
            ];
          }),
          _: 1
        }),
        i("div", U, [
          e(a).is ? (o(), r("div", A, [
            (o(!0), r(u, null, f(e(L), (t, n) => (o(), r("button", {
              class: b(["button capitalize text-xs", { active: e(l).part == n }]),
              key: t,
              onClick: (w) => e(l).part = n
            }, D(n), 11, F))), 128))
          ])) : h("", !0),
          i("div", G, [
            V(i("textarea", {
              class: "p-2 rounded-lg flex-auto dark-bg-dark-400",
              "onUpdate:modelValue": s[1] || (s[1] = (t) => e(l).text = t),
              placeholder: "Enter a definition"
            }, null, 512), [
              [z, e(l).text]
            ]),
            i("button", {
              class: "button",
              onClick: s[2] || (s[2] = (t) => e(a).is ? e(v)() : e(a).auth = !0)
            }, "Add")
          ])
        ]),
        i("div", M, [
          _(B, { name: "list" }, {
            default: x(() => [
              e(l).text ? (o(!0), r(u, { key: 1 }, f(e(y), (t) => (o(), c(p, {
                class: "cursor-pointer",
                key: t.item.hash,
                style: E({ opacity: 1 - t.score }),
                hash: t.item.hash,
                onClick: (n) => d.$emit("def", t.item.hash)
              }, null, 8, ["style", "hash", "onClick"]))), 128)) : (o(!0), r(u, { key: 0 }, f(e(C), (t, n) => (o(), c(p, {
                class: "cursor-pointer",
                key: n,
                hash: n,
                onClick: (w) => d.$emit("def", n)
              }, null, 8, ["hash", "onClick"]))), 128))
            ]),
            _: 1
          })
        ])
      ]);
    };
  }
};
export {
  q as default
};
//# sourceMappingURL=DictDefList-aad36fbe.js.map
