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