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