import { defineComponent as v, resolveComponent as y, openBlock as u, createElementBlock as w, createElementVNode as p, toDisplayString as _, unref as e, Fragment as S, renderList as T, createBlock as b, reactive as B } from "vue";
import { prettyBytes as g } from "./composables-5f691338.js";
const C = { class: "flex flex-col gap-2" }, D = { class: "p-2 text-sm flex flex-wrap gap-2" }, E = /* @__PURE__ */ p("div", { class: "p-1" }, "Torrent: ", -1), j = { class: "p-1" }, z = { class: "p-1" }, V = /* @__PURE__ */ v({
  __name: "TorrentDownload",
  props: {
    id: {
      type: String,
      default: ""
    }
  },
  setup(A) {
    const x = A;
    function h(m) {
      const t = B({
        files: [],
        task: null,
        status: {
          done: !1,
          progress: 0,
          downloadSpeed: 0,
          downloaded: 0
        }
      });
      return import("./webtorrent.min-a48e7c4c.js").then((i) => {
        const n = i.default, s = new n();
        t.task = s.add(m, (o) => {
          t.files = o.files;
        }), s.on("download", () => {
          const { progress: o, downloaded: a, done: d, downloadSpeed: c } = t.task;
          t.status = { done: d, progress: o, downloaded: a, downloadSpeed: c };
        });
      }), t;
    }
    const r = h(`magnet:?xt=urn:btih:${x.id}&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com`);
    return (m, t) => {
      var n, s, o, a, d, c, f, k, F;
      const i = y("file-card");
      return u(), w("div", C, [
        p("div", D, [
          E,
          p("div", j, _((s = (n = e(r)) == null ? void 0 : n.status) != null && s.done ? (a = (o = e(r)) == null ? void 0 : o.status) == null ? void 0 : a.progress : "done"), 1),
          p("div", z, "Total " + _(e(g)((c = (d = e(r)) == null ? void 0 : d.status) == null ? void 0 : c.downloaded)) + " at " + _(e(g)((k = (f = e(r)) == null ? void 0 : f.status) == null ? void 0 : k.downloadSpeed)) + "/s", 1)
        ]),
        (u(!0), w(S, null, T((F = e(r)) == null ? void 0 : F.files, (l) => (u(), b(i, {
          key: l == null ? void 0 : l.name,
          file: l
        }, null, 8, ["file"]))), 128))
      ]);
    };
  }
});
export {
  V as default
};
//# sourceMappingURL=TorrentDownload-5c76d7f3.js.map
