import { createElementBlock as r, openBlock as o, createElementVNode as i, createVNode as p, Transition as g, withCtx as k, createBlock as c, createCommentVNode as x, unref as e, Fragment as u, renderList as f, normalizeClass as D, toDisplayString as w, withDirectives as $, vModelText as b, TransitionGroup as V, normalizeStyle as z } from "vue";
import { useUser as B, useDefs as E, dictRecord as m, langParts as N } from "./composables-BAZQlC3e.js";
import { DictWordCard as T, 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" }, j = {
  __name: "DictDefList",
  emits: ["def", "root"],
  setup(M) {
    const { user: a } = B(), { def: l, addDef: v, found: C, linked: _ } = E();
    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(g, {
        name: "fade",
        mode: "out-in"
      }, {
        default: k(() => {
          var t;
          return [
            (t = e(m)) != null && t.word ? (o(), c(e(T), {
              key: e(m).word,
              hash: e(m).word
            }, null, 8, ["hash"])) : x("", !0)
          ];
        }),
        _: 1
      }),
      i("div", S, [
        e(a).is ? (o(), r("div", U, [
          (o(!0), r(u, null, f(e(N), (t, s) => (o(), r("button", {
            class: D(["button capitalize text-xs", { active: e(l).part == s }]),
            key: t,
            onClick: (y) => e(l).part = s
          }, w(s), 11, A))), 128))
        ])) : x("", !0),
        i("div", F, [
          $(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), [
            [b, 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(V, { name: "list" }, {
          default: k(() => [
            e(l).text ? (o(!0), r(u, { key: 1 }, f(e(C), (t) => (o(), c(e(h), {
              class: "cursor-pointer",
              key: t.item.hash,
              style: z({ 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(u, { key: 0 }, f(e(_), (t, s) => (o(), c(e(h), {
              class: "cursor-pointer",
              key: s,
              hash: s,
              onClick: (y) => d.$emit("def", s)
            }, null, 8, ["hash", "onClick"]))), 128))
          ]),
          _: 1
        })
      ])
    ]));
  }
};
export {
  j as default
};
//# sourceMappingURL=DictDefList-CsQRl0nd.js.map
