import { useUser as D, usePosts as N, ref as p, computed as U, countRating as v, openBlock as t, createElementBlock as a, createBaseVNode as s, toDisplayString as b, unref as l, createCommentVNode as n, createBlock as k, createVNode as x, withCtx as g, Transition as h, renderSlot as w, Fragment as V, renderList as A, withDirectives as F, normalizeStyle as L, vShow as T, TransitionGroup as j } from "./composables-Ci32s3jE.js";
import { QrShare as E, PostForm as G, PostCard as H } from "./components.js";
const Q = { class: "flex flex-col z-10 items-start justify-items-stretch" }, R = {
  key: 0,
  class: "flex flex-wrap items-center p-2 text-xl sticky z-100 top-0 shadow-lg bg-light-700 w-full"
}, q = /* @__PURE__ */ s("div", { class: "flex-1" }, null, -1), I = { class: "p-2 font-bold mx-2" }, J = { class: "flex flex-col bg-dark-50 bg-opacity-20 backdrop-filter backdrop-blur-md flex-1 p-2 w-full gap-8" }, K = {
  key: 0,
  class: "p-2 flex flex-wrap z-300 text-sm bg-light-300 bg-opacity-40 dark-bg-dark-500 rounded-2xl m-2 flex-1",
  style: { order: "-2147483647", flex: "1000 100%" }
}, M = {
  key: 1,
  class: "flex flex-wrap gap-2"
}, O = {
  key: 0,
  class: "i-la-plus"
}, W = {
  key: 1,
  class: "i-la-times"
}, X = /* @__PURE__ */ s("div", { class: "ml-2 mr-1" }, "Add", -1), Y = /* @__PURE__ */ s("label", {
  class: "button",
  title: "Upload feed",
  for: "import-feed"
}, [
  /* @__PURE__ */ s("div", { class: "i-la-file-upload" }),
  /* @__PURE__ */ s("div", { class: "ml-2 mr-1" }, "Upload")
], -1), Z = {
  key: 0,
  class: "i-la-eye"
}, ee = {
  key: 1,
  class: "i-la-eye-slash"
}, te = /* @__PURE__ */ s("div", { class: "ml-2" }, "Show hidden", -1), se = {
  key: 0,
  class: "i-la-file-download"
}, le = {
  key: 1,
  class: "i-la-redo-alt animate-spin"
}, oe = /* @__PURE__ */ s("div", { class: "ml-2 mr-1" }, "Download", -1), ae = {
  key: 1,
  class: "p-2 flex items-center gap-2",
  style: { order: "-2147483647", flex: "1000 100%" }
}, ie = { class: "flex flex-wrap gap-4 p-2" }, fe = {
  __name: "PostList",
  props: {
    tag: {
      type: String,
      default: ""
    },
    header: {
      type: Boolean,
      default: !0
    }
  },
  emits: ["close", "browse", "user"],
  setup(i, { emit: _ }) {
    const {
      user: u
    } = D(), C = i, $ = _, {
      posts: m,
      backlinks: ne,
      countPosts: y,
      countBacklinks: de,
      downloadPosts: P,
      downloading: S,
      uploadPosts: z
    } = N(C.tag), r = p();
    p(!1);
    const c = p(!1), B = U(() => {
      const d = {};
      for (let e in m) {
        const o = v(m[e]);
        (c.value || o > 0) && (d[e] = m[e]);
      }
      return d;
    });
    return (d, e) => (t(), a("div", Q, [
      i.header ? (t(), a("div", R, [
        s("div", {
          class: "text-xl ml-2 font-bold cursor-pointer",
          style: { flex: "1 100px" },
          onClick: e[0] || (e[0] = (o) => d.$emit("close"))
        }, "# " + b(i.tag), 1),
        q,
        s("div", I, b(l(y)), 1)
      ])) : n("", !0),
      s("div", J, [
        l(u).pub ? (t(), a("div", K, [
          i.header ? (t(), k(l(E), { key: 0 })) : n("", !0),
          l(u).pub ? (t(), a("div", M, [
            s("button", {
              class: "button",
              onClick: e[1] || (e[1] = (o) => r.value = !r.value)
            }, [
              x(h, {
                name: "fade",
                mode: "out-in"
              }, {
                default: g(() => [
                  r.value ? (t(), a("div", W)) : (t(), a("div", O))
                ]),
                _: 1
              }),
              X
            ]),
            Y,
            s("button", {
              class: "button",
              onClick: e[2] || (e[2] = (o) => c.value = !c.value)
            }, [
              c.value ? (t(), a("div", Z)) : (t(), a("div", ee)),
              te
            ]),
            0 < l(y) ? (t(), a("button", {
              key: 0,
              class: "button",
              title: "Download feed",
              onClick: e[3] || (e[3] = (o) => l(P)())
            }, [
              l(S) ? (t(), a("div", le)) : (t(), a("div", se)),
              oe
            ])) : n("", !0),
            w(d.$slots, "default")
          ])) : n("", !0),
          s("input", {
            class: "hidden",
            id: "import-feed",
            ref: "file",
            tabindex: "-1",
            type: "file",
            accept: ".zip",
            multiple: "",
            onChange: e[4] || (e[4] = (o) => l(z)(o.target.files))
          }, null, 544),
          x(h, { name: "fade" }, {
            default: g(() => [
              r.value ? (t(), k(l(G), {
                key: 0,
                tag: i.tag,
                onClose: e[5] || (e[5] = (o) => r.value = !1)
              }, null, 8, ["tag"])) : n("", !0)
            ]),
            _: 1
          })
        ])) : n("", !0),
        l(u).pub ? n("", !0) : (t(), a("div", ae, [
          s("button", {
            class: "button",
            onClick: e[6] || (e[6] = (o) => l(u).auth = !0)
          }, "Authorize to post here"),
          w(d.$slots, "default")
        ]))
      ]),
      s("div", ie, [
        x(j, { name: "list" }, {
          default: g(() => [
            (t(!0), a(V, null, A(B.value, (o, f) => F((t(), k(l(H), {
              class: "max-w-xl flex-1 shadow-xl",
              key: f,
              style: L({ order: -l(v)(o), opacity: l(v)(o) > 0 ? 1 : 0.3 }),
              hash: f,
              tag: i.tag,
              authors: o,
              onClick: (re) => $("browse", f)
            }, null, 8, ["style", "hash", "tag", "authors", "onClick"])), [
              [T, i.tag != f]
            ])), 128))
          ]),
          _: 1
        })
      ])
    ]));
  }
};
export {
  fe as default
};
//# sourceMappingURL=PostList-B4jCPZ2Q.js.map
