var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
import { S as SvelteComponent, i as init, s as safe_not_equal, c as create_slot, e as element, a as space, b as attr, d as insert, f as append, u as update_slot_base, g as get_all_dirty_from_scope, h as get_slot_changes, t as transition_in, j as transition_out, k as detach, l as text, n as null_to_empty, m as set_data, o as group_outros, p as check_outros, q as createEventDispatcher, r as add_render_callback, v as create_bidirectional_transition, w as fade, x as src_url_equal, y as empty, z as listen, A as set_style, H as HtmlTag, B as noop, C as run_all, D as compute_rest_props, E as assign, F as exclude_internal_props, G as destroy_each, I as onMount, J as flush, K as binding_callbacks, L as bind, M as create_component, N as mount_component, O as add_flush_callback, P as destroy_component } from "./index-0ba2eb24.mjs";
import { p as parseContentPack, a as generateLcpSummary, b as generateMultiLcpSummary, L as LCPIndex, d as LANCER, e as getOfficialData, m as mergeOfficialDataAndLcpIndex, f as clearCompendiumData, i as importCP } from "./lancer-a96e7e01.mjs";
function create_fragment$4(ctx) {
  let div1, div0, t, current;
  const default_slot_template = (
    /*#slots*/
    ctx[1].default
  ), default_slot = create_slot(
    default_slot_template,
    ctx,
    /*$$scope*/
    ctx[0],
    null
  );
  return {
    c() {
      div1 = element("div"), div0 = element("div"), t = space(), default_slot && default_slot.c(), attr(div0, "class", "spinner__spinner svelte-cuey6r"), attr(div1, "class", "spinner__container svelte-cuey6r");
    },
    m(target, anchor) {
      insert(target, div1, anchor), append(div1, div0), append(div1, t), default_slot && default_slot.m(div1, null), current = !0;
    },
    p(ctx2, [dirty]) {
      default_slot && default_slot.p && (!current || dirty & /*$$scope*/
      1) && update_slot_base(
        default_slot,
        default_slot_template,
        ctx2,
        /*$$scope*/
        ctx2[0],
        current ? get_slot_changes(
          default_slot_template,
          /*$$scope*/
          ctx2[0],
          dirty,
          null
        ) : get_all_dirty_from_scope(
          /*$$scope*/
          ctx2[0]
        ),
        null
      );
    },
    i(local) {
      current || (transition_in(default_slot, local), current = !0);
    },
    o(local) {
      transition_out(default_slot, local), current = !1;
    },
    d(detaching) {
      detaching && detach(div1), default_slot && default_slot.d(detaching);
    }
  };
}
__name(create_fragment$4, "create_fragment$4");
function instance$4($$self, $$props, $$invalidate) {
  let { $$slots: slots = {}, $$scope } = $$props;
  return $$self.$$set = ($$props2) => {
    "$$scope" in $$props2 && $$invalidate(0, $$scope = $$props2.$$scope);
  }, [$$scope, slots];
}
__name(instance$4, "instance$4");
const _Spinner = class _Spinner extends SvelteComponent {
  constructor(options) {
    super(), init(this, options, instance$4, create_fragment$4, safe_not_equal, {});
  }
};
__name(_Spinner, "Spinner");
let Spinner = _Spinner;
const Spinner$1 = Spinner;
function create_if_block$2(ctx) {
  let div2, t0, div1, div0, t1, span, t3, ul, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, div0_class_value, t16, div2_transition, current;
  function select_block_type(ctx2, dirty) {
    return (
      /*oldContentSummary*/
      ctx2[2].website ? create_if_block_16 : create_else_block$2
    );
  }
  __name(select_block_type, "select_block_type");
  let current_block_type = select_block_type(ctx), if_block0 = current_block_type(ctx), if_block1 = (
    /*oldContentSummary*/
    ctx[2].image_url && create_if_block_15(ctx)
  ), if_block2 = (
    /*oldContentSummary*/
    ctx[2].skills && create_if_block_14(ctx)
  ), if_block3 = (
    /*oldContentSummary*/
    ctx[2].talents && create_if_block_13(ctx)
  ), if_block4 = (
    /*oldContentSummary*/
    ctx[2].bonds && create_if_block_12(ctx)
  ), if_block5 = (
    /*oldContentSummary*/
    ctx[2].reserves && create_if_block_11(ctx)
  ), if_block6 = (
    /*oldContentSummary*/
    ctx[2].gear && create_if_block_10(ctx)
  ), if_block7 = (
    /*oldContentSummary*/
    ctx[2].frames && create_if_block_9(ctx)
  ), if_block8 = (
    /*oldContentSummary*/
    ctx[2].systems && create_if_block_8(ctx)
  ), if_block9 = (
    /*oldContentSummary*/
    ctx[2].weapons && create_if_block_7(ctx)
  ), if_block10 = (
    /*oldContentSummary*/
    ctx[2].mods && create_if_block_6(ctx)
  ), if_block11 = (
    /*oldContentSummary*/
    ctx[2].npc_classes && create_if_block_5(ctx)
  ), if_block12 = (
    /*oldContentSummary*/
    ctx[2].npc_templates && create_if_block_4$1(ctx)
  ), if_block13 = (
    /*oldContentSummary*/
    ctx[2].npc_features && create_if_block_3$1(ctx)
  ), if_block14 = (
    /*oldContentSummary*/
    ctx[2].description && create_if_block_2$2(ctx)
  ), if_block15 = !/*showImportButton*/
  ctx[0] && !/*oldContentSummary*/
  ctx[2].aggregate && create_if_block_1$2(ctx);
  return {
    c() {
      div2 = element("div"), if_block0.c(), t0 = space(), div1 = element("div"), div0 = element("div"), if_block1 && if_block1.c(), t1 = space(), span = element("span"), span.textContent = "Contents:", t3 = space(), ul = element("ul"), if_block2 && if_block2.c(), t4 = space(), if_block3 && if_block3.c(), t5 = space(), if_block4 && if_block4.c(), t6 = space(), if_block5 && if_block5.c(), t7 = space(), if_block6 && if_block6.c(), t8 = space(), if_block7 && if_block7.c(), t9 = space(), if_block8 && if_block8.c(), t10 = space(), if_block9 && if_block9.c(), t11 = space(), if_block10 && if_block10.c(), t12 = space(), if_block11 && if_block11.c(), t13 = space(), if_block12 && if_block12.c(), t14 = space(), if_block13 && if_block13.c(), t15 = space(), if_block14 && if_block14.c(), t16 = space(), if_block15 && if_block15.c(), attr(ul, "class", "svelte-12o4e5i"), attr(div0, "class", div0_class_value = null_to_empty(`transition ${/*fadeDirection*/
      ctx[3]}`) + " svelte-12o4e5i"), attr(div1, "class", "lcp-description minor desc-text svelte-12o4e5i"), attr(div2, "class", "lcp-details__content svelte-12o4e5i");
    },
    m(target, anchor) {
      insert(target, div2, anchor), if_block0.m(div2, null), append(div2, t0), append(div2, div1), append(div1, div0), if_block1 && if_block1.m(div0, null), append(div0, t1), append(div0, span), append(div0, t3), append(div0, ul), if_block2 && if_block2.m(ul, null), append(ul, t4), if_block3 && if_block3.m(ul, null), append(ul, t5), if_block4 && if_block4.m(ul, null), append(ul, t6), if_block5 && if_block5.m(ul, null), append(ul, t7), if_block6 && if_block6.m(ul, null), append(ul, t8), if_block7 && if_block7.m(ul, null), append(ul, t9), if_block8 && if_block8.m(ul, null), append(ul, t10), if_block9 && if_block9.m(ul, null), append(ul, t11), if_block10 && if_block10.m(ul, null), append(ul, t12), if_block11 && if_block11.m(ul, null), append(ul, t13), if_block12 && if_block12.m(ul, null), append(ul, t14), if_block13 && if_block13.m(ul, null), append(div0, t15), if_block14 && if_block14.m(div0, null), append(div2, t16), if_block15 && if_block15.m(div2, null), current = !0;
    },
    p(ctx2, dirty) {
      current_block_type === (current_block_type = select_block_type(ctx2)) && if_block0 ? if_block0.p(ctx2, dirty) : (if_block0.d(1), if_block0 = current_block_type(ctx2), if_block0 && (if_block0.c(), if_block0.m(div2, t0))), /*oldContentSummary*/
      ctx2[2].image_url ? if_block1 ? if_block1.p(ctx2, dirty) : (if_block1 = create_if_block_15(ctx2), if_block1.c(), if_block1.m(div0, t1)) : if_block1 && (if_block1.d(1), if_block1 = null), /*oldContentSummary*/
      ctx2[2].skills ? if_block2 ? if_block2.p(ctx2, dirty) : (if_block2 = create_if_block_14(ctx2), if_block2.c(), if_block2.m(ul, t4)) : if_block2 && (if_block2.d(1), if_block2 = null), /*oldContentSummary*/
      ctx2[2].talents ? if_block3 ? if_block3.p(ctx2, dirty) : (if_block3 = create_if_block_13(ctx2), if_block3.c(), if_block3.m(ul, t5)) : if_block3 && (if_block3.d(1), if_block3 = null), /*oldContentSummary*/
      ctx2[2].bonds ? if_block4 ? if_block4.p(ctx2, dirty) : (if_block4 = create_if_block_12(ctx2), if_block4.c(), if_block4.m(ul, t6)) : if_block4 && (if_block4.d(1), if_block4 = null), /*oldContentSummary*/
      ctx2[2].reserves ? if_block5 ? if_block5.p(ctx2, dirty) : (if_block5 = create_if_block_11(ctx2), if_block5.c(), if_block5.m(ul, t7)) : if_block5 && (if_block5.d(1), if_block5 = null), /*oldContentSummary*/
      ctx2[2].gear ? if_block6 ? if_block6.p(ctx2, dirty) : (if_block6 = create_if_block_10(ctx2), if_block6.c(), if_block6.m(ul, t8)) : if_block6 && (if_block6.d(1), if_block6 = null), /*oldContentSummary*/
      ctx2[2].frames ? if_block7 ? if_block7.p(ctx2, dirty) : (if_block7 = create_if_block_9(ctx2), if_block7.c(), if_block7.m(ul, t9)) : if_block7 && (if_block7.d(1), if_block7 = null), /*oldContentSummary*/
      ctx2[2].systems ? if_block8 ? if_block8.p(ctx2, dirty) : (if_block8 = create_if_block_8(ctx2), if_block8.c(), if_block8.m(ul, t10)) : if_block8 && (if_block8.d(1), if_block8 = null), /*oldContentSummary*/
      ctx2[2].weapons ? if_block9 ? if_block9.p(ctx2, dirty) : (if_block9 = create_if_block_7(ctx2), if_block9.c(), if_block9.m(ul, t11)) : if_block9 && (if_block9.d(1), if_block9 = null), /*oldContentSummary*/
      ctx2[2].mods ? if_block10 ? if_block10.p(ctx2, dirty) : (if_block10 = create_if_block_6(ctx2), if_block10.c(), if_block10.m(ul, t12)) : if_block10 && (if_block10.d(1), if_block10 = null), /*oldContentSummary*/
      ctx2[2].npc_classes ? if_block11 ? if_block11.p(ctx2, dirty) : (if_block11 = create_if_block_5(ctx2), if_block11.c(), if_block11.m(ul, t13)) : if_block11 && (if_block11.d(1), if_block11 = null), /*oldContentSummary*/
      ctx2[2].npc_templates ? if_block12 ? if_block12.p(ctx2, dirty) : (if_block12 = create_if_block_4$1(ctx2), if_block12.c(), if_block12.m(ul, t14)) : if_block12 && (if_block12.d(1), if_block12 = null), /*oldContentSummary*/
      ctx2[2].npc_features ? if_block13 ? if_block13.p(ctx2, dirty) : (if_block13 = create_if_block_3$1(ctx2), if_block13.c(), if_block13.m(ul, null)) : if_block13 && (if_block13.d(1), if_block13 = null), /*oldContentSummary*/
      ctx2[2].description ? if_block14 ? if_block14.p(ctx2, dirty) : (if_block14 = create_if_block_2$2(ctx2), if_block14.c(), if_block14.m(div0, null)) : if_block14 && (if_block14.d(1), if_block14 = null), (!current || dirty & /*fadeDirection*/
      8 && div0_class_value !== (div0_class_value = null_to_empty(`transition ${/*fadeDirection*/
      ctx2[3]}`) + " svelte-12o4e5i")) && attr(div0, "class", div0_class_value), !/*showImportButton*/
      ctx2[0] && !/*oldContentSummary*/
      ctx2[2].aggregate ? if_block15 ? (if_block15.p(ctx2, dirty), dirty & /*showImportButton, oldContentSummary*/
      5 && transition_in(if_block15, 1)) : (if_block15 = create_if_block_1$2(ctx2), if_block15.c(), transition_in(if_block15, 1), if_block15.m(div2, null)) : if_block15 && (group_outros(), transition_out(if_block15, 1, 1, () => {
        if_block15 = null;
      }), check_outros());
    },
    i(local) {
      current || (transition_in(if_block15), add_render_callback(() => {
        current && (div2_transition || (div2_transition = create_bidirectional_transition(div2, fade, {}, !0)), div2_transition.run(1));
      }), current = !0);
    },
    o(local) {
      transition_out(if_block15), div2_transition || (div2_transition = create_bidirectional_transition(div2, fade, {}, !1)), div2_transition.run(0), current = !1;
    },
    d(detaching) {
      detaching && detach(div2), if_block0.d(), if_block1 && if_block1.d(), if_block2 && if_block2.d(), if_block3 && if_block3.d(), if_block4 && if_block4.d(), if_block5 && if_block5.d(), if_block6 && if_block6.d(), if_block7 && if_block7.d(), if_block8 && if_block8.d(), if_block9 && if_block9.d(), if_block10 && if_block10.d(), if_block11 && if_block11.d(), if_block12 && if_block12.d(), if_block13 && if_block13.d(), if_block14 && if_block14.d(), if_block15 && if_block15.d(), detaching && div2_transition && div2_transition.end();
    }
  };
}
__name(create_if_block$2, "create_if_block$2");
function create_else_block$2(ctx) {
  let div, t0, t1_value = (
    /*oldContentSummary*/
    ctx[2].author + ""
  ), t1, div_class_value;
  return {
    c() {
      div = element("div"), t0 = text("by "), t1 = text(t1_value), attr(div, "class", div_class_value = null_to_empty(`medium transition ${/*fadeDirection*/
      ctx[3]}`) + " svelte-12o4e5i"), set_style(div, "margin", "10px");
    },
    m(target, anchor) {
      insert(target, div, anchor), append(div, t0), append(div, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t1_value !== (t1_value = /*oldContentSummary*/
      ctx2[2].author + "") && set_data(t1, t1_value), dirty & /*fadeDirection*/
      8 && div_class_value !== (div_class_value = null_to_empty(`medium transition ${/*fadeDirection*/
      ctx2[3]}`) + " svelte-12o4e5i") && attr(div, "class", div_class_value);
    },
    d(detaching) {
      detaching && detach(div);
    }
  };
}
__name(create_else_block$2, "create_else_block$2");
function create_if_block_16(ctx) {
  let a, t0, t1_value = (
    /*oldContentSummary*/
    ctx[2].author + ""
  ), t1, a_href_value, a_class_value;
  return {
    c() {
      a = element("a"), t0 = text("by "), t1 = text(t1_value), attr(a, "href", a_href_value = /*oldContentSummary*/
      ctx[2].website), attr(a, "class", a_class_value = null_to_empty(`medium transition ${/*fadeDirection*/
      ctx[3]}`) + " svelte-12o4e5i"), set_style(a, "margin", "5px");
    },
    m(target, anchor) {
      insert(target, a, anchor), append(a, t0), append(a, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t1_value !== (t1_value = /*oldContentSummary*/
      ctx2[2].author + "") && set_data(t1, t1_value), dirty & /*oldContentSummary*/
      4 && a_href_value !== (a_href_value = /*oldContentSummary*/
      ctx2[2].website) && attr(a, "href", a_href_value), dirty & /*fadeDirection*/
      8 && a_class_value !== (a_class_value = null_to_empty(`medium transition ${/*fadeDirection*/
      ctx2[3]}`) + " svelte-12o4e5i") && attr(a, "class", a_class_value);
    },
    d(detaching) {
      detaching && detach(a);
    }
  };
}
__name(create_if_block_16, "create_if_block_16");
function create_if_block_15(ctx) {
  let img, img_class_value, img_src_value, img_title_value, img_alt_value;
  return {
    c() {
      img = element("img"), attr(img, "class", img_class_value = null_to_empty(`manifest-image transition ${/*fadeDirection*/
      ctx[3]}`) + " svelte-12o4e5i"), src_url_equal(img.src, img_src_value = /*oldContentSummary*/
      ctx[2].image_url) || attr(img, "src", img_src_value), attr(img, "title", img_title_value = /*oldContentSummary*/
      ctx[2].name), attr(img, "alt", img_alt_value = /*oldContentSummary*/
      ctx[2].name);
    },
    m(target, anchor) {
      insert(target, img, anchor);
    },
    p(ctx2, dirty) {
      dirty & /*fadeDirection*/
      8 && img_class_value !== (img_class_value = null_to_empty(`manifest-image transition ${/*fadeDirection*/
      ctx2[3]}`) + " svelte-12o4e5i") && attr(img, "class", img_class_value), dirty & /*oldContentSummary*/
      4 && !src_url_equal(img.src, img_src_value = /*oldContentSummary*/
      ctx2[2].image_url) && attr(img, "src", img_src_value), dirty & /*oldContentSummary*/
      4 && img_title_value !== (img_title_value = /*oldContentSummary*/
      ctx2[2].name) && attr(img, "title", img_title_value), dirty & /*oldContentSummary*/
      4 && img_alt_value !== (img_alt_value = /*oldContentSummary*/
      ctx2[2].name) && attr(img, "alt", img_alt_value);
    },
    d(detaching) {
      detaching && detach(img);
    }
  };
}
__name(create_if_block_15, "create_if_block_15");
function create_if_block_14(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].skills + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" pilot skills"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].skills + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_14, "create_if_block_14");
function create_if_block_13(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].talents + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" talents"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].talents + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_13, "create_if_block_13");
function create_if_block_12(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].bonds + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" bonds"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].bonds + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_12, "create_if_block_12");
function create_if_block_11(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].reserves + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" reserves"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].reserves + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_11, "create_if_block_11");
function create_if_block_10(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].gear + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" pilot gear"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].gear + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_10, "create_if_block_10");
function create_if_block_9(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].frames + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" frames"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].frames + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_9, "create_if_block_9");
function create_if_block_8(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].systems + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" mech systems"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].systems + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_8, "create_if_block_8");
function create_if_block_7(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].weapons + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" mech weapons"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].weapons + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_7, "create_if_block_7");
function create_if_block_6(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].mods + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" weapon mods"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].mods + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_6, "create_if_block_6");
function create_if_block_5(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].npc_classes + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" NPC classes"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].npc_classes + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_5, "create_if_block_5");
function create_if_block_4$1(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].npc_templates + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" NPC templates"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].npc_templates + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_4$1, "create_if_block_4$1");
function create_if_block_3$1(ctx) {
  let li, span, t0_value = (
    /*oldContentSummary*/
    ctx[2].npc_features + ""
  ), t0, t1;
  return {
    c() {
      li = element("li"), span = element("span"), t0 = text(t0_value), t1 = text(" NPC features"), attr(span, "class", "lcp-manifest-badge");
    },
    m(target, anchor) {
      insert(target, li, anchor), append(li, span), append(span, t0), append(li, t1);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && t0_value !== (t0_value = /*oldContentSummary*/
      ctx2[2].npc_features + "") && set_data(t0, t0_value);
    },
    d(detaching) {
      detaching && detach(li);
    }
  };
}
__name(create_if_block_3$1, "create_if_block_3$1");
function create_if_block_2$2(ctx) {
  let html_tag, raw_value = (
    /*oldContentSummary*/
    ctx[2].description + ""
  ), html_anchor;
  return {
    c() {
      html_tag = new HtmlTag(!1), html_anchor = empty(), html_tag.a = html_anchor;
    },
    m(target, anchor) {
      html_tag.m(raw_value, target, anchor), insert(target, html_anchor, anchor);
    },
    p(ctx2, dirty) {
      dirty & /*oldContentSummary*/
      4 && raw_value !== (raw_value = /*oldContentSummary*/
      ctx2[2].description + "") && html_tag.p(raw_value);
    },
    d(detaching) {
      detaching && detach(html_anchor), detaching && html_tag.d();
    }
  };
}
__name(create_if_block_2$2, "create_if_block_2$2");
function create_if_block_1$2(ctx) {
  let button, i, t, button_transition, current, mounted, dispose;
  return {
    c() {
      button = element("button"), i = element("i"), t = text(`
          Import LCP`), attr(i, "class", "cci cci-content-manager i--m"), attr(button, "type", "button"), attr(button, "class", "lcp-import"), attr(button, "title", "Import LCP"), attr(button, "tabindex", "-1"), button.disabled = /*disabled*/
      ctx[1];
    },
    m(target, anchor) {
      insert(target, button, anchor), append(button, i), append(button, t), current = !0, mounted || (dispose = listen(
        button,
        "click",
        /*click_handler*/
        ctx[7]
      ), mounted = !0);
    },
    p(ctx2, dirty) {
      (!current || dirty & /*disabled*/
      2) && (button.disabled = /*disabled*/
      ctx2[1]);
    },
    i(local) {
      current || (add_render_callback(() => {
        current && (button_transition || (button_transition = create_bidirectional_transition(button, fade, {}, !0)), button_transition.run(1));
      }), current = !0);
    },
    o(local) {
      button_transition || (button_transition = create_bidirectional_transition(button, fade, {}, !1)), button_transition.run(0), current = !1;
    },
    d(detaching) {
      detaching && detach(button), detaching && button_transition && button_transition.end(), mounted = !1, dispose();
    }
  };
}
__name(create_if_block_1$2, "create_if_block_1$2");
function create_fragment$3(ctx) {
  let div1, div0, span, t0, span_class_value, t1, current, if_block = (
    /*oldContentSummary*/
    ctx[2] && create_if_block$2(ctx)
  );
  return {
    c() {
      div1 = element("div"), div0 = element("div"), span = element("span"), t0 = text(
        /*title*/
        ctx[4]
      ), t1 = space(), if_block && if_block.c(), attr(span, "class", span_class_value = null_to_empty(`transition ${/*fadeDirection*/
      ctx[3]}`) + " svelte-12o4e5i"), attr(div0, "class", "lancer-header lancer-primary major"), attr(div1, "class", "lcp-details card clipped svelte-12o4e5i");
    },
    m(target, anchor) {
      insert(target, div1, anchor), append(div1, div0), append(div0, span), append(span, t0), append(div1, t1), if_block && if_block.m(div1, null), current = !0;
    },
    p(ctx2, [dirty]) {
      (!current || dirty & /*title*/
      16) && set_data(
        t0,
        /*title*/
        ctx2[4]
      ), (!current || dirty & /*fadeDirection*/
      8 && span_class_value !== (span_class_value = null_to_empty(`transition ${/*fadeDirection*/
      ctx2[3]}`) + " svelte-12o4e5i")) && attr(span, "class", span_class_value), /*oldContentSummary*/
      ctx2[2] ? if_block ? (if_block.p(ctx2, dirty), dirty & /*oldContentSummary*/
      4 && transition_in(if_block, 1)) : (if_block = create_if_block$2(ctx2), if_block.c(), transition_in(if_block, 1), if_block.m(div1, null)) : if_block && (group_outros(), transition_out(if_block, 1, 1, () => {
        if_block = null;
      }), check_outros());
    },
    i(local) {
      current || (transition_in(if_block), current = !0);
    },
    o(local) {
      transition_out(if_block), current = !1;
    },
    d(detaching) {
      detaching && detach(div1), if_block && if_block.d();
    }
  };
}
__name(create_fragment$3, "create_fragment$3");
function instance$3($$self, $$props, $$invalidate) {
  let title;
  const dispatch = createEventDispatcher();
  let { contentSummary = null } = $$props, { showImportButton } = $$props, { disabled = !1 } = $$props, oldContentSummary = null, fadeDirection = "fade-in";
  const click_handler2 = /* @__PURE__ */ __name(() => dispatch("importLcp"), "click_handler");
  return $$self.$$set = ($$props2) => {
    "contentSummary" in $$props2 && $$invalidate(6, contentSummary = $$props2.contentSummary), "showImportButton" in $$props2 && $$invalidate(0, showImportButton = $$props2.showImportButton), "disabled" in $$props2 && $$invalidate(1, disabled = $$props2.disabled);
  }, $$self.$$.update = () => {
    $$self.$$.dirty & /*contentSummary, oldContentSummary*/
    68 && contentSummary !== oldContentSummary && ($$invalidate(3, fadeDirection = "fade-out"), setTimeout(
      () => {
        $$invalidate(2, oldContentSummary = contentSummary), $$invalidate(3, fadeDirection = "fade-in");
      },
      100
    )), $$self.$$.dirty & /*oldContentSummary*/
    4 && $$invalidate(4, title = oldContentSummary ? `${oldContentSummary.name}${oldContentSummary.version ? ` v${oldContentSummary.version}` : ""}` : "No LCP Selected");
  }, [
    showImportButton,
    disabled,
    oldContentSummary,
    fadeDirection,
    title,
    dispatch,
    contentSummary,
    click_handler2
  ];
}
__name(instance$3, "instance$3");
const _LCPDetails = class _LCPDetails extends SvelteComponent {
  constructor(options) {
    super(), init(this, options, instance$3, create_fragment$3, safe_not_equal, {
      contentSummary: 6,
      showImportButton: 0,
      disabled: 1
    });
  }
};
__name(_LCPDetails, "LCPDetails");
let LCPDetails = _LCPDetails;
const LcpDetails = LCPDetails;
function create_fragment$2(ctx) {
  let div3, div0, t1, div2, label, input, t2, span1, div1, t4, span0, t5_value = (
    /*filenames*/
    (ctx[3] || "Choose file...") + ""
  ), t5, t6, button, i, t7, div3_style_value, mounted, dispose;
  return {
    c() {
      div3 = element("div"), div0 = element("div"), div0.textContent = "Import From File", t1 = space(), div2 = element("div"), label = element("label"), input = element("input"), t2 = space(), span1 = element("span"), div1 = element("div"), div1.textContent = "Browse", t4 = space(), span0 = element("span"), t5 = text(t5_value), t6 = space(), button = element("button"), i = element("i"), t7 = text(" Unselect File"), attr(div0, "class", "lancer-header lancer-primary major"), attr(input, "id", "lcp-file"), attr(input, "type", "file"), input.multiple = !0, attr(input, "aria-label", "Select LCP file"), attr(input, "name", "lcp-up"), attr(input, "class", "lcp-up svelte-136zbv5"), attr(input, "accept", ".lcp"), input.disabled = /*disabled*/
      ctx[0], attr(div1, "class", "file-custom__button svelte-136zbv5"), attr(span0, "class", "file-custom__filenames svelte-136zbv5"), attr(span1, "class", "file-custom svelte-136zbv5"), attr(label, "class", "file svelte-136zbv5"), attr(i, "class", "fas fa-broom"), attr(button, "class", "lancer-button deselect-file svelte-136zbv5"), button.disabled = /*disabled*/
      ctx[0], attr(div2, "class", "file-select-container svelte-136zbv5"), attr(div3, "style", div3_style_value = /*$$restProps*/
      ctx[5].style);
    },
    m(target, anchor) {
      insert(target, div3, anchor), append(div3, div0), append(div3, t1), append(div3, div2), append(div2, label), append(label, input), append(label, t2), append(label, span1), append(span1, div1), append(span1, t4), append(span1, span0), append(span0, t5), append(div2, t6), append(div2, button), append(button, i), append(button, t7), mounted || (dispose = [
        listen(
          input,
          "change",
          /*input_change_handler*/
          ctx[6]
        ),
        listen(
          input,
          "change",
          /*filesSelected*/
          ctx[4]
        ),
        listen(
          button,
          "click",
          /*deselect*/
          ctx[1]
        )
      ], mounted = !0);
    },
    p(ctx2, [dirty]) {
      dirty & /*disabled*/
      1 && (input.disabled = /*disabled*/
      ctx2[0]), dirty & /*filenames*/
      8 && t5_value !== (t5_value = /*filenames*/
      (ctx2[3] || "Choose file...") + "") && set_data(t5, t5_value), dirty & /*disabled*/
      1 && (button.disabled = /*disabled*/
      ctx2[0]), dirty & /*$$restProps*/
      32 && div3_style_value !== (div3_style_value = /*$$restProps*/
      ctx2[5].style) && attr(div3, "style", div3_style_value);
    },
    i: noop,
    o: noop,
    d(detaching) {
      detaching && detach(div3), mounted = !1, run_all(dispose);
    }
  };
}
__name(create_fragment$2, "create_fragment$2");
function instance$2($$self, $$props, $$invalidate) {
  const omit_props_names = ["disabled", "deselect"];
  let $$restProps = compute_rest_props($$props, omit_props_names);
  const dispatch = createEventDispatcher();
  let { disabled = !1 } = $$props;
  const deselect = /* @__PURE__ */ __name(() => {
    $$invalidate(2, selectedFiles = null), $$invalidate(3, filenames = null), console.log("Deselecting file"), dispatch("lcpLoaded", null);
  }, "deselect");
  let selectedFiles = null, filenames = null, filesData = [], contentSummary = null;
  function filesSelected(event) {
    var _a;
    const files = (_a = event.target) == null ? void 0 : _a.files;
    if (files) {
      $$invalidate(3, filenames = ""), filesData = [];
      for (let i = 0; i < files.length; i++) {
        const file = files[i];
        console.log(`Selected file: ${file.name}`), $$invalidate(3, filenames += file.name), i < files.length - 1 && $$invalidate(3, filenames += ", "), filesData.push({
          name: file.name,
          data: null,
          loaded: !1,
          cp: null
        });
        const reader = new FileReader();
        reader.addEventListener("loadend", (e) => {
          const data = reader.result, fd = filesData.find((fd2) => fd2.name === file.name);
          fd && (fd.loaded = !0, data && (fd.data = data));
        }), reader.readAsArrayBuffer(file);
      }
      waitAndDispatchLcpLoaded();
    }
  }
  __name(filesSelected, "filesSelected");
  async function waitAndDispatchLcpLoaded() {
    if (!filesData || !filesData.length)
      return;
    for (; filesData.some((fd) => !fd.loaded); )
      await new Promise((resolve) => setTimeout(resolve, 100));
    if (filesData.length === 1) {
      const fd = filesData[0];
      if (!fd.data) {
        ui.notifications.error(`Failed to load LCP ${fd.name}`);
        return;
      }
      fd.cp = await parseContentPack(fd.data), dispatch("lcpLoaded", {
        contentPacks: [fd.cp],
        contentSummary: generateLcpSummary(fd.cp)
      });
      return;
    }
    const aggregateManifest = {
      name: "Selected LCPs",
      author: "Various",
      item_prefix: "",
      version: "",
      description: ""
    };
    await Promise.all(filesData.map(async (fd) => {
      if (!fd.data) {
        ui.notifications.error(`Failed to load LCP ${fd.name}`);
        return;
      }
      fd.cp = await parseContentPack(fd.data);
      const author = fd.cp.manifest.website ? `<a href="${fd.cp.manifest.website}">${fd.cp.manifest.author}</a>` : `<em>${fd.cp.manifest.author}</em>`;
      aggregateManifest.description += `<b>${fd.cp.manifest.name}</b> v${fd.cp.manifest.version} by ${author}<br />`;
    }));
    const contentPacks = filesData.map((fd) => fd.cp).filter((cp) => !!cp);
    contentSummary = generateMultiLcpSummary(aggregateManifest, contentPacks), dispatch("lcpLoaded", { contentPacks, contentSummary });
  }
  __name(waitAndDispatchLcpLoaded, "waitAndDispatchLcpLoaded");
  function input_change_handler() {
    selectedFiles = this.files, $$invalidate(2, selectedFiles);
  }
  return __name(input_change_handler, "input_change_handler"), $$self.$$set = ($$new_props) => {
    $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)), $$invalidate(5, $$restProps = compute_rest_props($$props, omit_props_names)), "disabled" in $$new_props && $$invalidate(0, disabled = $$new_props.disabled);
  }, [
    disabled,
    deselect,
    selectedFiles,
    filenames,
    filesSelected,
    $$restProps,
    input_change_handler
  ];
}
__name(instance$2, "instance$2");
const _LCPSelector = class _LCPSelector extends SvelteComponent {
  constructor(options) {
    super(), init(this, options, instance$2, create_fragment$2, safe_not_equal, { disabled: 0, deselect: 1 });
  }
  get deselect() {
    return this.$$.ctx[1];
  }
};
__name(_LCPSelector, "LCPSelector");
let LCPSelector = _LCPSelector;
const LcpSelector = LCPSelector;
function get_each_context(ctx, list, i) {
  const child_ctx = ctx.slice();
  return child_ctx[27] = list[i], child_ctx[28] = list, child_ctx[29] = i, child_ctx;
}
__name(get_each_context, "get_each_context");
function create_else_block_1(ctx) {
  let span;
  return {
    c() {
      span = element("span"), attr(span, "class", "content-checkbox svelte-fa5x7f");
    },
    m(target, anchor) {
      insert(target, span, anchor);
    },
    p: noop,
    d(detaching) {
      detaching && detach(span);
    }
  };
}
__name(create_else_block_1, "create_else_block_1");
function create_if_block_4(ctx) {
  let input, input_name_value, mounted, dispose;
  function input_change_handler_1() {
    ctx[15].call(
      input,
      /*pack*/
      ctx[27]
    );
  }
  return __name(input_change_handler_1, "input_change_handler_1"), {
    c() {
      input = element("input"), attr(input, "class", "content-checkbox svelte-fa5x7f"), attr(input, "name", input_name_value = /*pack*/
      ctx[27].id), attr(input, "type", "checkbox"), input.disabled = /*disabled*/
      ctx[1];
    },
    m(target, anchor) {
      insert(target, input, anchor), input.checked = /*rowSelectionTracker*/
      ctx[2][
        /*pack*/
        ctx[27].id
      ].checked, mounted || (dispose = [
        listen(input, "change", input_change_handler_1),
        listen(
          input,
          "change",
          /*change_handler_1*/
          ctx[16]
        )
      ], mounted = !0);
    },
    p(new_ctx, dirty) {
      ctx = new_ctx, dirty & /*lcpData*/
      1 && input_name_value !== (input_name_value = /*pack*/
      ctx[27].id) && attr(input, "name", input_name_value), dirty & /*disabled*/
      2 && (input.disabled = /*disabled*/
      ctx[1]), dirty & /*rowSelectionTracker, lcpData*/
      5 && (input.checked = /*rowSelectionTracker*/
      ctx[2][
        /*pack*/
        ctx[27].id
      ].checked);
    },
    d(detaching) {
      detaching && detach(input), mounted = !1, run_all(dispose);
    }
  };
}
__name(create_if_block_4, "create_if_block_4");
function create_if_block_3(ctx) {
  let a, i, a_href_value, mounted, dispose;
  return {
    c() {
      a = element("a"), i = element("i"), attr(i, "class", "fas fa-external-link-alt svelte-fa5x7f"), attr(a, "href", a_href_value = /*pack*/
      ctx[27].url), attr(a, "target", "_blank"), attr(a, "rel", "noopener noreferrer"), attr(a, "class", "svelte-fa5x7f");
    },
    m(target, anchor) {
      insert(target, a, anchor), append(a, i), mounted || (dispose = listen(a, "click", click_handler), mounted = !0);
    },
    p(ctx2, dirty) {
      dirty & /*lcpData*/
      1 && a_href_value !== (a_href_value = /*pack*/
      ctx2[27].url) && attr(a, "href", a_href_value);
    },
    d(detaching) {
      detaching && detach(a), mounted = !1, dispose();
    }
  };
}
__name(create_if_block_3, "create_if_block_3");
function create_if_block$1(ctx) {
  let if_block_anchor;
  function select_block_type_1(ctx2, dirty) {
    return (
      /*pack*/
      ctx2[27].currentVersion === /*pack*/
      ctx2[27].availableVersion ? create_if_block_1$1 : (
        /*rowSelectionTracker*/
        ctx2[2][
          /*pack*/
          ctx2[27].id
        ] ? create_if_block_2$1 : create_else_block$1
      )
    );
  }
  __name(select_block_type_1, "select_block_type_1");
  let current_block_type = select_block_type_1(ctx), if_block = current_block_type(ctx);
  return {
    c() {
      if_block.c(), if_block_anchor = empty();
    },
    m(target, anchor) {
      if_block.m(target, anchor), insert(target, if_block_anchor, anchor);
    },
    p(ctx2, dirty) {
      current_block_type !== (current_block_type = select_block_type_1(ctx2)) && (if_block.d(1), if_block = current_block_type(ctx2), if_block && (if_block.c(), if_block.m(if_block_anchor.parentNode, if_block_anchor)));
    },
    d(detaching) {
      if_block.d(detaching), detaching && detach(if_block_anchor);
    }
  };
}
__name(create_if_block$1, "create_if_block$1");
function create_else_block$1(ctx) {
  let i;
  return {
    c() {
      i = element("i"), attr(i, "class", "fas fa-lock svelte-fa5x7f");
    },
    m(target, anchor) {
      insert(target, i, anchor);
    },
    d(detaching) {
      detaching && detach(i);
    }
  };
}
__name(create_else_block$1, "create_else_block$1");
function create_if_block_2$1(ctx) {
  let i;
  return {
    c() {
      i = element("i"), attr(i, "class", "fas fa-arrow-right svelte-fa5x7f");
    },
    m(target, anchor) {
      insert(target, i, anchor);
    },
    d(detaching) {
      detaching && detach(i);
    }
  };
}
__name(create_if_block_2$1, "create_if_block_2$1");
function create_if_block_1$1(ctx) {
  let i;
  return {
    c() {
      i = element("i"), attr(i, "class", "fas fa-check svelte-fa5x7f");
    },
    m(target, anchor) {
      insert(target, i, anchor);
    },
    d(detaching) {
      detaching && detach(i);
    }
  };
}
__name(create_if_block_1$1, "create_if_block_1$1");
function create_each_block(ctx) {
  let div, t0, span0, t1_value = (
    /*pack*/
    ctx[27].title + ""
  ), t1, t2, span1, t3_value = (
    /*pack*/
    ctx[27].author + ""
  ), t3, t4, span2, t5, span3, t6_value = (
    /*pack*/
    ctx[27].currentVersion + ""
  ), t6, t7, span4, t8, span5, t9_value = (
    /*pack*/
    ctx[27].availableVersion + ""
  ), t9, t10, div_class_value, mounted, dispose;
  function select_block_type(ctx2, dirty) {
    return (
      /*rowSelectionTracker*/
      ctx2[2][
        /*pack*/
        ctx2[27].id
      ].selectable ? create_if_block_4 : create_else_block_1
    );
  }
  __name(select_block_type, "select_block_type");
  let current_block_type = select_block_type(ctx), if_block0 = current_block_type(ctx), if_block1 = (
    /*pack*/
    ctx[27].url && create_if_block_3(ctx)
  ), if_block2 = (
    /*pack*/
    ctx[27].availableVersion && create_if_block$1(ctx)
  );
  function mouseenter_handler() {
    return (
      /*mouseenter_handler*/
      ctx[17](
        /*pack*/
        ctx[27]
      )
    );
  }
  __name(mouseenter_handler, "mouseenter_handler");
  function mouseleave_handler() {
    return (
      /*mouseleave_handler*/
      ctx[18](
        /*pack*/
        ctx[27]
      )
    );
  }
  __name(mouseleave_handler, "mouseleave_handler");
  function click_handler_1() {
    return (
      /*click_handler_1*/
      ctx[19](
        /*pack*/
        ctx[27]
      )
    );
  }
  __name(click_handler_1, "click_handler_1");
  function keypress_handler() {
    return (
      /*keypress_handler*/
      ctx[20](
        /*pack*/
        ctx[27]
      )
    );
  }
  return __name(keypress_handler, "keypress_handler"), {
    c() {
      div = element("div"), if_block0.c(), t0 = space(), span0 = element("span"), t1 = text(t1_value), t2 = space(), span1 = element("span"), t3 = text(t3_value), t4 = space(), span2 = element("span"), if_block1 && if_block1.c(), t5 = space(), span3 = element("span"), t6 = text(t6_value), t7 = space(), span4 = element("span"), if_block2 && if_block2.c(), t8 = space(), span5 = element("span"), t9 = text(t9_value), t10 = space(), attr(span0, "class", "content-label svelte-fa5x7f"), attr(span1, "class", "content-label svelte-fa5x7f"), attr(span2, "class", "content-label svelte-fa5x7f"), attr(span3, "class", "curr-version svelte-fa5x7f"), attr(span4, "class", "content-icon svelte-fa5x7f"), attr(span5, "class", "avail-version svelte-fa5x7f"), attr(div, "class", div_class_value = null_to_empty(`row${/*pack*/
      ctx[27].availableVersion ? " has-data" : ""}`) + " svelte-fa5x7f");
    },
    m(target, anchor) {
      insert(target, div, anchor), if_block0.m(div, null), append(div, t0), append(div, span0), append(span0, t1), append(div, t2), append(div, span1), append(span1, t3), append(div, t4), append(div, span2), if_block1 && if_block1.m(span2, null), append(div, t5), append(div, span3), append(span3, t6), append(div, t7), append(div, span4), if_block2 && if_block2.m(span4, null), append(div, t8), append(div, span5), append(span5, t9), append(div, t10), mounted || (dispose = [
        listen(div, "mouseenter", mouseenter_handler),
        listen(div, "mouseleave", mouseleave_handler),
        listen(div, "click", click_handler_1),
        listen(div, "keypress", keypress_handler)
      ], mounted = !0);
    },
    p(new_ctx, dirty) {
      ctx = new_ctx, current_block_type === (current_block_type = select_block_type(ctx)) && if_block0 ? if_block0.p(ctx, dirty) : (if_block0.d(1), if_block0 = current_block_type(ctx), if_block0 && (if_block0.c(), if_block0.m(div, t0))), dirty & /*lcpData*/
      1 && t1_value !== (t1_value = /*pack*/
      ctx[27].title + "") && set_data(t1, t1_value), dirty & /*lcpData*/
      1 && t3_value !== (t3_value = /*pack*/
      ctx[27].author + "") && set_data(t3, t3_value), /*pack*/
      ctx[27].url ? if_block1 ? if_block1.p(ctx, dirty) : (if_block1 = create_if_block_3(ctx), if_block1.c(), if_block1.m(span2, null)) : if_block1 && (if_block1.d(1), if_block1 = null), dirty & /*lcpData*/
      1 && t6_value !== (t6_value = /*pack*/
      ctx[27].currentVersion + "") && set_data(t6, t6_value), /*pack*/
      ctx[27].availableVersion ? if_block2 ? if_block2.p(ctx, dirty) : (if_block2 = create_if_block$1(ctx), if_block2.c(), if_block2.m(span4, null)) : if_block2 && (if_block2.d(1), if_block2 = null), dirty & /*lcpData*/
      1 && t9_value !== (t9_value = /*pack*/
      ctx[27].availableVersion + "") && set_data(t9, t9_value), dirty & /*lcpData*/
      1 && div_class_value !== (div_class_value = null_to_empty(`row${/*pack*/
      ctx[27].availableVersion ? " has-data" : ""}`) + " svelte-fa5x7f") && attr(div, "class", div_class_value);
    },
    d(detaching) {
      detaching && detach(div), if_block0.d(), if_block1 && if_block1.d(), if_block2 && if_block2.d(), mounted = !1, run_all(dispose);
    }
  };
}
__name(create_each_block, "create_each_block");
function create_fragment$1(ctx) {
  let div6, div0, t1, div4, div3, div2, div1, input, t2, span0, t4, span1, t6, span2, t7, span3, t9, span4, t10, span5, t12, t13, div5, button0, i0, t14, button0_disabled_value, t15, button1, i1, t16, button1_disabled_value, div6_style_value, mounted, dispose, each_value = (
    /*lcpData*/
    ctx[0]
  ), each_blocks = [];
  for (let i = 0; i < each_value.length; i += 1)
    each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
  return {
    c() {
      div6 = element("div"), div0 = element("div"), div0.textContent = "Available and Installed Content", t1 = space(), div4 = element("div"), div3 = element("div"), div2 = element("div"), div1 = element("div"), input = element("input"), t2 = space(), span0 = element("span"), span0.textContent = "TITLE", t4 = space(), span1 = element("span"), span1.textContent = "AUTHOR", t6 = space(), span2 = element("span"), t7 = space(), span3 = element("span"), span3.textContent = "CURRENT", t9 = space(), span4 = element("span"), t10 = space(), span5 = element("span"), span5.textContent = "AVAILABLE", t12 = space();
      for (let i = 0; i < each_blocks.length; i += 1)
        each_blocks[i].c();
      t13 = space(), div5 = element("div"), button0 = element("button"), i0 = element("i"), t14 = text(`
      Import/Update Selected`), t15 = space(), button1 = element("button"), i1 = element("i"), t16 = text(`
      Clear Compendium Data`), attr(div0, "class", "lancer-header clipped-top lancer-primary major svelte-fa5x7f"), attr(input, "class", "content-checkbox svelte-fa5x7f"), attr(input, "name", "select-all"), attr(input, "type", "checkbox"), input.disabled = /*disabled*/
      ctx[1], attr(div1, "class", "svelte-fa5x7f"), attr(span0, "class", "svelte-fa5x7f"), attr(span1, "class", "svelte-fa5x7f"), attr(span2, "class", "svelte-fa5x7f"), attr(span3, "class", "svelte-fa5x7f"), attr(span4, "class", "svelte-fa5x7f"), attr(span5, "class", "svelte-fa5x7f"), attr(div2, "class", "row header svelte-fa5x7f"), attr(div3, "class", "lcp-table__rows svelte-fa5x7f"), attr(div4, "id", "lcp-table"), attr(div4, "class", "svelte-fa5x7f"), attr(i0, "class", "cci cci-content-manager i--m svelte-fa5x7f"), attr(button0, "type", "button"), attr(button0, "class", "lancer-button lcp-bulk-import svelte-fa5x7f"), attr(button0, "title", "Import/Update Selected"), attr(button0, "tabindex", "-1"), button0.disabled = button0_disabled_value = /*disabled*/
      ctx[1] || !/*lcpData*/
      ctx[0].some(
        /*func*/
        ctx[21]
      ), attr(i1, "class", "fas fa-trash i--s svelte-fa5x7f"), attr(button1, "type", "button"), attr(button1, "class", "lancer-button lcp-clear-all svelte-fa5x7f"), attr(button1, "title", "Clear Compendium Data"), attr(button1, "tabindex", "-1"), button1.disabled = button1_disabled_value = /*disabled*/
      ctx[1] || !/*lcpData*/
      ctx[0].some(func_1), attr(div5, "class", "lcp-table__buttons svelte-fa5x7f"), attr(div6, "class", "lcp-table flexcol svelte-fa5x7f"), attr(div6, "style", div6_style_value = /*$$restProps*/
      ctx[11].style);
    },
    m(target, anchor) {
      insert(target, div6, anchor), append(div6, div0), append(div6, t1), append(div6, div4), append(div4, div3), append(div3, div2), append(div2, div1), append(div1, input), input.checked = /*selectAllRows*/
      ctx[3], append(div2, t2), append(div2, span0), append(div2, t4), append(div2, span1), append(div2, t6), append(div2, span2), append(div2, t7), append(div2, span3), append(div2, t9), append(div2, span4), append(div2, t10), append(div2, span5), append(div3, t12);
      for (let i = 0; i < each_blocks.length; i += 1)
        each_blocks[i] && each_blocks[i].m(div3, null);
      append(div6, t13), append(div6, div5), append(div5, button0), append(button0, i0), append(button0, t14), append(div5, t15), append(div5, button1), append(button1, i1), append(button1, t16), mounted || (dispose = [
        listen(
          input,
          "change",
          /*input_change_handler*/
          ctx[13]
        ),
        listen(
          input,
          "click",
          /*toggleSelectAllOfficial*/
          ctx[4]
        ),
        listen(
          input,
          "change",
          /*change_handler*/
          ctx[14]
        ),
        listen(
          button0,
          "click",
          /*dispatchLcpsToInstall*/
          ctx[9]
        ),
        listen(
          button1,
          "click",
          /*clearCompendiums*/
          ctx[10]
        )
      ], mounted = !0);
    },
    p(ctx2, [dirty]) {
      if (dirty & /*disabled*/
      2 && (input.disabled = /*disabled*/
      ctx2[1]), dirty & /*selectAllRows*/
      8 && (input.checked = /*selectAllRows*/
      ctx2[3]), dirty & /*lcpData, onMouseenterRow, onMouseleaveRow, toggleRow, rowSelectionTracker, disabled, debounceAggregateSummary*/
      487) {
        each_value = /*lcpData*/
        ctx2[0];
        let i;
        for (i = 0; i < each_value.length; i += 1) {
          const child_ctx = get_each_context(ctx2, each_value, i);
          each_blocks[i] ? each_blocks[i].p(child_ctx, dirty) : (each_blocks[i] = create_each_block(child_ctx), each_blocks[i].c(), each_blocks[i].m(div3, null));
        }
        for (; i < each_blocks.length; i += 1)
          each_blocks[i].d(1);
        each_blocks.length = each_value.length;
      }
      dirty & /*disabled, lcpData, rowSelectionTracker*/
      7 && button0_disabled_value !== (button0_disabled_value = /*disabled*/
      ctx2[1] || !/*lcpData*/
      ctx2[0].some(
        /*func*/
        ctx2[21]
      )) && (button0.disabled = button0_disabled_value), dirty & /*disabled, lcpData*/
      3 && button1_disabled_value !== (button1_disabled_value = /*disabled*/
      ctx2[1] || !/*lcpData*/
      ctx2[0].some(func_1)) && (button1.disabled = button1_disabled_value), dirty & /*$$restProps*/
      2048 && div6_style_value !== (div6_style_value = /*$$restProps*/
      ctx2[11].style) && attr(div6, "style", div6_style_value);
    },
    i: noop,
    o: noop,
    d(detaching) {
      detaching && detach(div6), destroy_each(each_blocks, detaching), mounted = !1, run_all(dispose);
    }
  };
}
__name(create_fragment$1, "create_fragment$1");
const click_handler = /* @__PURE__ */ __name((e) => e.stopPropagation(), "click_handler"), func_1 = /* @__PURE__ */ __name((p) => p.currentVersion !== "--", "func_1");
function instance$1($$self, $$props, $$invalidate) {
  let selectAllRows;
  const omit_props_names = ["lcpData", "disabled", "deselect"];
  let $$restProps = compute_rest_props($$props, omit_props_names);
  const dispatch = createEventDispatcher();
  let { lcpData } = $$props, { disabled = !1 } = $$props;
  const deselect = /* @__PURE__ */ __name(() => {
    for (const pack of lcpData)
      $$invalidate(2, rowSelectionTracker[pack.id].checked = !1, rowSelectionTracker);
  }, "deselect");
  onMount(() => debounceAggregateSummary());
  let rowSelectionTracker = {};
  function toggleSelectAllOfficial() {
    for (const pack of lcpData)
      rowSelectionTracker[pack.id].selectable && $$invalidate(2, rowSelectionTracker[pack.id].checked = !selectAllRows, rowSelectionTracker);
  }
  __name(toggleSelectAllOfficial, "toggleSelectAllOfficial");
  function toggleRow(packId) {
    $$invalidate(2, rowSelectionTracker[packId].checked = !rowSelectionTracker[packId].checked, rowSelectionTracker), debounceAggregateSummary();
  }
  __name(toggleRow, "toggleRow");
  const aggregateManifest = {
    author: "Massif Press",
    name: "Selected Official Sources",
    version: "1.0.0",
    item_prefix: "",
    description: "",
    website: "https://massif-press.itch.io/"
  };
  function generateAggregateSummary() {
    const selected = lcpData.filter((p) => rowSelectionTracker[p.id].checked);
    if (!selected.length)
      return null;
    if (selected.length === 1) {
      const summary = generateLcpSummary(selected[0].cp);
      return summary.aggregate = !0, summary;
    }
    return generateMultiLcpSummary(aggregateManifest, selected.filter((p) => !!p.cp).map((p) => p.cp));
  }
  __name(generateAggregateSummary, "generateAggregateSummary");
  let aggregateSummaryTimeout = null;
  function debounceAggregateSummary() {
    aggregateSummaryTimeout && clearTimeout(aggregateSummaryTimeout), aggregateSummaryTimeout = setTimeout(
      () => {
        dispatch("aggregateSummary", generateAggregateSummary());
      },
      100
    );
  }
  __name(debounceAggregateSummary, "debounceAggregateSummary");
  let hoveredRow = null;
  function onMouseenterRow(id) {
    hoveredRow = id;
    const rowLcp = lcpData.find((p) => p.id === id);
    if (!rowLcp || !rowLcp.cp || !rowLcp.cp.data) {
      dispatch("lcpHovered", null);
      return;
    }
    const lcpSummary = generateLcpSummary(rowLcp.cp);
    dispatch("lcpHovered", lcpSummary);
  }
  __name(onMouseenterRow, "onMouseenterRow");
  function onMouseleaveRow(id) {
    setTimeout(
      () => {
        hoveredRow === id && (hoveredRow = null, dispatch("lcpHovered", null));
      },
      50
    );
  }
  __name(onMouseleaveRow, "onMouseleaveRow");
  function dispatchLcpsToInstall() {
    const selected = lcpData.filter((p) => rowSelectionTracker[p.id].checked);
    dispatch("installManyLcps", selected.map((p) => p.cp));
  }
  __name(dispatchLcpsToInstall, "dispatchLcpsToInstall");
  function clearCompendiums() {
    dispatch("clearCompendiums");
  }
  __name(clearCompendiums, "clearCompendiums");
  function input_change_handler() {
    selectAllRows = this.checked, $$invalidate(3, selectAllRows), $$invalidate(2, rowSelectionTracker), $$invalidate(0, lcpData);
  }
  __name(input_change_handler, "input_change_handler");
  const change_handler = /* @__PURE__ */ __name(() => debounceAggregateSummary(), "change_handler");
  function input_change_handler_1(pack) {
    rowSelectionTracker[pack.id].checked = this.checked, $$invalidate(2, rowSelectionTracker), $$invalidate(0, lcpData);
  }
  __name(input_change_handler_1, "input_change_handler_1");
  const change_handler_1 = /* @__PURE__ */ __name(() => debounceAggregateSummary(), "change_handler_1"), mouseenter_handler = /* @__PURE__ */ __name((pack) => onMouseenterRow(pack.id), "mouseenter_handler"), mouseleave_handler = /* @__PURE__ */ __name((pack) => onMouseleaveRow(pack.id), "mouseleave_handler"), click_handler_1 = /* @__PURE__ */ __name((pack) => toggleRow(pack.id), "click_handler_1"), keypress_handler = /* @__PURE__ */ __name((pack) => toggleRow(pack.id), "keypress_handler"), func = /* @__PURE__ */ __name((p) => rowSelectionTracker[p.id].checked, "func");
  return $$self.$$set = ($$new_props) => {
    $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)), $$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names)), "lcpData" in $$new_props && $$invalidate(0, lcpData = $$new_props.lcpData), "disabled" in $$new_props && $$invalidate(1, disabled = $$new_props.disabled);
  }, $$self.$$.update = () => {
    if ($$self.$$.dirty & /*lcpData, rowSelectionTracker*/
    5 && typeof lcpData < "u")
      for (const pack of lcpData)
        rowSelectionTracker[pack.id] || $$invalidate(
          2,
          rowSelectionTracker[pack.id] = {
            checked: pack.availableVersion > pack.currentVersion,
            selectable: !!pack.availableVersion
          },
          rowSelectionTracker
        );
    $$self.$$.dirty & /*rowSelectionTracker*/
    4 && $$invalidate(3, selectAllRows = Object.values(rowSelectionTracker).every((v) => !v.selectable || v.checked));
  }, [
    lcpData,
    disabled,
    rowSelectionTracker,
    selectAllRows,
    toggleSelectAllOfficial,
    toggleRow,
    debounceAggregateSummary,
    onMouseenterRow,
    onMouseleaveRow,
    dispatchLcpsToInstall,
    clearCompendiums,
    $$restProps,
    deselect,
    input_change_handler,
    change_handler,
    input_change_handler_1,
    change_handler_1,
    mouseenter_handler,
    mouseleave_handler,
    click_handler_1,
    keypress_handler,
    func
  ];
}
__name(instance$1, "instance$1");
const _LCPTable = class _LCPTable extends SvelteComponent {
  constructor(options) {
    super(), init(this, options, instance$1, create_fragment$1, safe_not_equal, { lcpData: 0, disabled: 1, deselect: 12 });
  }
  get deselect() {
    return this.$$.ctx[12];
  }
};
__name(_LCPTable, "LCPTable");
let LCPTable = _LCPTable;
const LCPTable$1 = LCPTable;
function create_else_block(ctx) {
  let div1, lcptable, updating_disabled, updating_deselect, t0, div0, lcpselector, updating_disabled_1, updating_deselect_1, t1, lcpdetails, updating_disabled_2, t2, div3, div2, t3, current;
  function lcptable_disabled_binding(value) {
    ctx[22](value);
  }
  __name(lcptable_disabled_binding, "lcptable_disabled_binding");
  function lcptable_deselect_binding(value) {
    ctx[23](value);
  }
  __name(lcptable_deselect_binding, "lcptable_deselect_binding");
  let lcptable_props = { lcpData: (
    /*lcpData*/
    ctx[1]
  ) };
  /*busy*/
  ctx[11] !== void 0 && (lcptable_props.disabled = /*busy*/
  ctx[11]), /*deselectTable*/
  ctx[8] !== void 0 && (lcptable_props.deselect = /*deselectTable*/
  ctx[8]), lcptable = new LCPTable$1({ props: lcptable_props }), binding_callbacks.push(() => bind(lcptable, "disabled", lcptable_disabled_binding)), binding_callbacks.push(() => bind(lcptable, "deselect", lcptable_deselect_binding)), lcptable.$on(
    "lcpHovered",
    /*lcpHovered*/
    ctx[13]
  ), lcptable.$on(
    "aggregateSummary",
    /*updateAggregateSummary*/
    ctx[14]
  ), lcptable.$on(
    "installManyLcps",
    /*installManyLcps_handler*/
    ctx[24]
  ), lcptable.$on(
    "clearCompendiums",
    /*clearCompendiums*/
    ctx[16]
  );
  function lcpselector_disabled_binding(value) {
    ctx[25](value);
  }
  __name(lcpselector_disabled_binding, "lcpselector_disabled_binding");
  function lcpselector_deselect_binding(value) {
    ctx[26](value);
  }
  __name(lcpselector_deselect_binding, "lcpselector_deselect_binding");
  let lcpselector_props = {};
  /*busy*/
  ctx[11] !== void 0 && (lcpselector_props.disabled = /*busy*/
  ctx[11]), /*deselectFiles*/
  ctx[9] !== void 0 && (lcpselector_props.deselect = /*deselectFiles*/
  ctx[9]), lcpselector = new LcpSelector({ props: lcpselector_props }), binding_callbacks.push(() => bind(lcpselector, "disabled", lcpselector_disabled_binding)), binding_callbacks.push(() => bind(lcpselector, "deselect", lcpselector_deselect_binding)), lcpselector.$on(
    "lcpLoaded",
    /*lcpLoaded*/
    ctx[12]
  );
  function lcpdetails_disabled_binding(value) {
    ctx[27](value);
  }
  __name(lcpdetails_disabled_binding, "lcpdetails_disabled_binding");
  let lcpdetails_props = {
    contentSummary: (
      /*contentSummary*/
      ctx[4]
    ),
    showImportButton: (
      /*showImportButton*/
      ctx[10]
    )
  };
  /*busy*/
  ctx[11] !== void 0 && (lcpdetails_props.disabled = /*busy*/
  ctx[11]), lcpdetails = new LcpDetails({ props: lcpdetails_props }), binding_callbacks.push(() => bind(lcpdetails, "disabled", lcpdetails_disabled_binding)), lcpdetails.$on(
    "importLcp",
    /*importLcp_handler*/
    ctx[28]
  );
  let if_block0 = (
    /*importing*/
    (ctx[2] || /*importingMany*/
    ctx[3]) && create_if_block_2(ctx)
  ), if_block1 = (
    /*importingMany*/
    ctx[3] && create_if_block_1(ctx)
  );
  return {
    c() {
      div1 = element("div"), create_component(lcptable.$$.fragment), t0 = space(), div0 = element("div"), create_component(lcpselector.$$.fragment), t1 = space(), create_component(lcpdetails.$$.fragment), t2 = space(), div3 = element("div"), div2 = element("div"), if_block0 && if_block0.c(), t3 = space(), if_block1 && if_block1.c(), attr(div0, "class", "lcp-manager__detail-column svelte-ovtl20"), attr(div1, "class", "flexrow lcp-manager__main-content svelte-ovtl20"), set_style(div1, "flex", "1 1"), attr(div2, "class", "lcp-manager__progress svelte-ovtl20"), attr(div3, "class", "lcp-manager__progress-area svelte-ovtl20");
    },
    m(target, anchor) {
      insert(target, div1, anchor), mount_component(lcptable, div1, null), append(div1, t0), append(div1, div0), mount_component(lcpselector, div0, null), append(div0, t1), mount_component(lcpdetails, div0, null), insert(target, t2, anchor), insert(target, div3, anchor), append(div3, div2), if_block0 && if_block0.m(div2, null), append(div2, t3), if_block1 && if_block1.m(div2, null), current = !0;
    },
    p(ctx2, dirty) {
      const lcptable_changes = {};
      dirty[0] & /*lcpData*/
      2 && (lcptable_changes.lcpData = /*lcpData*/
      ctx2[1]), !updating_disabled && dirty[0] & /*busy*/
      2048 && (updating_disabled = !0, lcptable_changes.disabled = /*busy*/
      ctx2[11], add_flush_callback(() => updating_disabled = !1)), !updating_deselect && dirty[0] & /*deselectTable*/
      256 && (updating_deselect = !0, lcptable_changes.deselect = /*deselectTable*/
      ctx2[8], add_flush_callback(() => updating_deselect = !1)), lcptable.$set(lcptable_changes);
      const lcpselector_changes = {};
      !updating_disabled_1 && dirty[0] & /*busy*/
      2048 && (updating_disabled_1 = !0, lcpselector_changes.disabled = /*busy*/
      ctx2[11], add_flush_callback(() => updating_disabled_1 = !1)), !updating_deselect_1 && dirty[0] & /*deselectFiles*/
      512 && (updating_deselect_1 = !0, lcpselector_changes.deselect = /*deselectFiles*/
      ctx2[9], add_flush_callback(() => updating_deselect_1 = !1)), lcpselector.$set(lcpselector_changes);
      const lcpdetails_changes = {};
      dirty[0] & /*contentSummary*/
      16 && (lcpdetails_changes.contentSummary = /*contentSummary*/
      ctx2[4]), dirty[0] & /*showImportButton*/
      1024 && (lcpdetails_changes.showImportButton = /*showImportButton*/
      ctx2[10]), !updating_disabled_2 && dirty[0] & /*busy*/
      2048 && (updating_disabled_2 = !0, lcpdetails_changes.disabled = /*busy*/
      ctx2[11], add_flush_callback(() => updating_disabled_2 = !1)), lcpdetails.$set(lcpdetails_changes), /*importing*/
      ctx2[2] || /*importingMany*/
      ctx2[3] ? if_block0 ? (if_block0.p(ctx2, dirty), dirty[0] & /*importing, importingMany*/
      12 && transition_in(if_block0, 1)) : (if_block0 = create_if_block_2(ctx2), if_block0.c(), transition_in(if_block0, 1), if_block0.m(div2, t3)) : if_block0 && (group_outros(), transition_out(if_block0, 1, 1, () => {
        if_block0 = null;
      }), check_outros()), /*importingMany*/
      ctx2[3] ? if_block1 ? (if_block1.p(ctx2, dirty), dirty[0] & /*importingMany*/
      8 && transition_in(if_block1, 1)) : (if_block1 = create_if_block_1(ctx2), if_block1.c(), transition_in(if_block1, 1), if_block1.m(div2, null)) : if_block1 && (group_outros(), transition_out(if_block1, 1, 1, () => {
        if_block1 = null;
      }), check_outros());
    },
    i(local) {
      current || (transition_in(lcptable.$$.fragment, local), transition_in(lcpselector.$$.fragment, local), transition_in(lcpdetails.$$.fragment, local), transition_in(if_block0), transition_in(if_block1), current = !0);
    },
    o(local) {
      transition_out(lcptable.$$.fragment, local), transition_out(lcpselector.$$.fragment, local), transition_out(lcpdetails.$$.fragment, local), transition_out(if_block0), transition_out(if_block1), current = !1;
    },
    d(detaching) {
      detaching && detach(div1), destroy_component(lcptable), destroy_component(lcpselector), destroy_component(lcpdetails), detaching && detach(t2), detaching && detach(div3), if_block0 && if_block0.d(), if_block1 && if_block1.d();
    }
  };
}
__name(create_else_block, "create_else_block");
function create_if_block(ctx) {
  let div, spinner, current;
  return spinner = new Spinner$1({
    props: {
      $$slots: { default: [create_default_slot] },
      $$scope: { ctx }
    }
  }), {
    c() {
      div = element("div"), create_component(spinner.$$.fragment), attr(div, "class", "flexrow"), set_style(div, "margin", "5em");
    },
    m(target, anchor) {
      insert(target, div, anchor), mount_component(spinner, div, null), current = !0;
    },
    p(ctx2, dirty) {
      const spinner_changes = {};
      dirty[1] & /*$$scope*/
      64 && (spinner_changes.$$scope = { dirty, ctx: ctx2 }), spinner.$set(spinner_changes);
    },
    i(local) {
      current || (transition_in(spinner.$$.fragment, local), current = !0);
    },
    o(local) {
      transition_out(spinner.$$.fragment, local), current = !1;
    },
    d(detaching) {
      detaching && detach(div), destroy_component(spinner);
    }
  };
}
__name(create_if_block, "create_if_block");
function create_if_block_2(ctx) {
  var _a, _b;
  let span, t0_value = `${/*importingLcp*/
  (_a = ctx[5]) == null ? void 0 : _a.manifest.name} v${/*importingLcp*/
  (_b = ctx[5]) == null ? void 0 : _b.manifest.version}`, t0, t1, t2, t3, span_transition, t4, div, div_transition, current;
  return {
    c() {
      span = element("span"), t0 = text(t0_value), t1 = space(), t2 = text(
        /*barWidth*/
        ctx[6]
      ), t3 = text("%"), t4 = space(), div = element("div"), attr(span, "class", "monospace svelte-ovtl20"), attr(div, "class", "lcp-manager__progress-bar svelte-ovtl20"), set_style(
        div,
        "width",
        /*barWidth*/
        ctx[6] + "%"
      );
    },
    m(target, anchor) {
      insert(target, span, anchor), append(span, t0), append(span, t1), append(span, t2), append(span, t3), insert(target, t4, anchor), insert(target, div, anchor), current = !0;
    },
    p(ctx2, dirty) {
      var _a2, _b2;
      (!current || dirty[0] & /*importingLcp*/
      32) && t0_value !== (t0_value = `${/*importingLcp*/
      (_a2 = ctx2[5]) == null ? void 0 : _a2.manifest.name} v${/*importingLcp*/
      (_b2 = ctx2[5]) == null ? void 0 : _b2.manifest.version}`) && set_data(t0, t0_value), (!current || dirty[0] & /*barWidth*/
      64) && set_data(
        t2,
        /*barWidth*/
        ctx2[6]
      ), (!current || dirty[0] & /*barWidth*/
      64) && set_style(
        div,
        "width",
        /*barWidth*/
        ctx2[6] + "%"
      );
    },
    i(local) {
      current || (add_render_callback(() => {
        current && (span_transition || (span_transition = create_bidirectional_transition(span, fade, {}, !0)), span_transition.run(1));
      }), add_render_callback(() => {
        current && (div_transition || (div_transition = create_bidirectional_transition(div, fade, {}, !0)), div_transition.run(1));
      }), current = !0);
    },
    o(local) {
      span_transition || (span_transition = create_bidirectional_transition(span, fade, {}, !1)), span_transition.run(0), div_transition || (div_transition = create_bidirectional_transition(div, fade, {}, !1)), div_transition.run(0), current = !1;
    },
    d(detaching) {
      detaching && detach(span), detaching && span_transition && span_transition.end(), detaching && detach(t4), detaching && detach(div), detaching && div_transition && div_transition.end();
    }
  };
}
__name(create_if_block_2, "create_if_block_2");
function create_if_block_1(ctx) {
  let div, div_transition, current;
  return {
    c() {
      div = element("div"), attr(div, "class", "lcp-manager__progress-bar svelte-ovtl20"), set_style(
        div,
        "width",
        /*secondBarWidth*/
        ctx[7] + "%"
      );
    },
    m(target, anchor) {
      insert(target, div, anchor), current = !0;
    },
    p(ctx2, dirty) {
      (!current || dirty[0] & /*secondBarWidth*/
      128) && set_style(
        div,
        "width",
        /*secondBarWidth*/
        ctx2[7] + "%"
      );
    },
    i(local) {
      current || (add_render_callback(() => {
        current && (div_transition || (div_transition = create_bidirectional_transition(div, fade, {}, !0)), div_transition.run(1));
      }), current = !0);
    },
    o(local) {
      div_transition || (div_transition = create_bidirectional_transition(div, fade, {}, !1)), div_transition.run(0), current = !1;
    },
    d(detaching) {
      detaching && detach(div), detaching && div_transition && div_transition.end();
    }
  };
}
__name(create_if_block_1, "create_if_block_1");
function create_default_slot(ctx) {
  let span;
  return {
    c() {
      span = element("span"), span.textContent = "Loading data, please wait…", attr(span, "class", "monospace svelte-ovtl20");
    },
    m(target, anchor) {
      insert(target, span, anchor);
    },
    p: noop,
    d(detaching) {
      detaching && detach(span);
    }
  };
}
__name(create_default_slot, "create_default_slot");
function create_fragment(ctx) {
  let div, current_block_type_index, if_block, current;
  const if_block_creators = [create_if_block, create_else_block], if_blocks = [];
  function select_block_type(ctx2, dirty) {
    return (
      /*loading*/
      ctx2[0] ? 0 : 1
    );
  }
  return __name(select_block_type, "select_block_type"), current_block_type_index = select_block_type(ctx), if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx), {
    c() {
      div = element("div"), if_block.c(), attr(div, "class", "lcp-manager svelte-ovtl20");
    },
    m(target, anchor) {
      insert(target, div, anchor), if_blocks[current_block_type_index].m(div, null), current = !0;
    },
    p(ctx2, dirty) {
      let previous_block_index = current_block_type_index;
      current_block_type_index = select_block_type(ctx2), current_block_type_index === previous_block_index ? if_blocks[current_block_type_index].p(ctx2, dirty) : (group_outros(), transition_out(if_blocks[previous_block_index], 1, 1, () => {
        if_blocks[previous_block_index] = null;
      }), check_outros(), if_block = if_blocks[current_block_type_index], if_block ? if_block.p(ctx2, dirty) : (if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2), if_block.c()), transition_in(if_block, 1), if_block.m(div, null));
    },
    i(local) {
      current || (transition_in(if_block), current = !0);
    },
    o(local) {
      transition_out(if_block), current = !1;
    },
    d(detaching) {
      detaching && detach(div), if_blocks[current_block_type_index].d();
    }
  };
}
__name(create_fragment, "create_fragment");
function instance($$self, $$props, $$invalidate) {
  let busy, contentSummary, showImportButton, coreVersion;
  const lp = LANCER.log_prefix;
  let { injectedContentSummary = null } = $$props, { loading = !0 } = $$props, lcpData = [], contentPacks = [], fileContentSummary = null, hoveredContentSummary = null, aggregateContentSummary = null, importingLcp = null, importing = !1, importingMany = !1, clearing = !1, barWidth = 0, secondBarWidth = 0, deselectTable, deselectFiles;
  async function init2() {
    $$invalidate(0, loading = !0);
    const index = new LCPIndex(game.settings.get(game.system.id, LANCER.setting_lcps).index), officialData = await getOfficialData(index);
    $$invalidate(1, lcpData = mergeOfficialDataAndLcpIndex(officialData, index)), $$invalidate(0, loading = !1);
  }
  __name(init2, "init"), init2();
  function lcpLoaded(event) {
    if (!event.detail) {
      contentPacks = [], $$invalidate(18, fileContentSummary = null);
      return;
    }
    $$invalidate(18, fileContentSummary = event.detail.contentSummary), contentPacks = event.detail.contentPacks, deselectTable();
  }
  __name(lcpLoaded, "lcpLoaded");
  function lcpHovered(event) {
    $$invalidate(19, hoveredContentSummary = event.detail);
  }
  __name(lcpHovered, "lcpHovered");
  function updateAggregateSummary(event) {
    $$invalidate(20, aggregateContentSummary = event.detail), contentPacks = [], $$invalidate(18, fileContentSummary = null), deselectFiles();
  }
  __name(updateAggregateSummary, "updateAggregateSummary");
  async function updateLcpIndex(manifest) {
    const lcpIndex = new LCPIndex(game.settings.get(game.system.id, LANCER.setting_lcps).index);
    lcpIndex.updateManifest(manifest), await game.settings.set(game.system.id, LANCER.setting_lcps, lcpIndex);
    const updatedLcp = lcpData.find((lcp) => lcp.title === manifest.name && lcp.author === manifest.author);
    updatedLcp ? updatedLcp.currentVersion = manifest.version : lcpData.push({
      title: manifest.name,
      author: manifest.author,
      currentVersion: manifest.version,
      availableVersion: "",
      url: manifest.website,
      id: manifest.item_prefix || manifest.name.replace(/\s/g, "-").toLowerCase()
    }), $$invalidate(1, lcpData = [...lcpData]);
  }
  __name(updateLcpIndex, "updateLcpIndex");
  function _canImportLcp() {
    var _a;
    return (_a = game.user) != null && _a.isGM ? coreVersion ? !0 : (ui.notifications.warn("Please update the Core data before importing LCPs."), !1) : (ui.notifications.warn("Only GM can modify the Compendiums."), !1);
  }
  __name(_canImportLcp, "_canImportLcp");
  async function importLcp(cp = null) {
    if (!cp) {
      ui.notifications.error("You must select an LCP file before importing.");
      return;
    }
    if (!_canImportLcp())
      return;
    const manifest = cp.manifest;
    !cp || !manifest || (ui.notifications.info(`Starting import of ${cp.manifest.name} v${cp.manifest.version}. Please wait.`), $$invalidate(2, importing = !0), $$invalidate(6, barWidth = 0), $$invalidate(5, importingLcp = cp), updateProgressBar(0, 1), console.log(`${lp} Starting import of ${cp.manifest.name} v${cp.manifest.version}.`), console.log(`${lp} Parsed content pack:`, cp), await importCP(cp, (x, y) => updateProgressBar(x, y)), updateProgressBar(1, 1), console.log(`${lp} Import of ${cp.manifest.name} v${cp.manifest.version} complete.`), $$invalidate(2, importing = !1), setTimeout(
      () => {
        !importing && !importingMany && $$invalidate(5, importingLcp = null);
      },
      1e3
    ), cp.manifest.name === "Lancer Core Book Data" && cp.manifest.author === "Massif Press" && await game.settings.set(game.system.id, LANCER.setting_core_data, cp.manifest.version), updateLcpIndex(manifest));
  }
  __name(importLcp, "importLcp");
  async function importManyLcps(lcps = null) {
    if (lcps || (lcps = contentPacks), !!_canImportLcp()) {
      $$invalidate(3, importingMany = !0), $$invalidate(7, secondBarWidth = 0);
      for (const [index, cp] of lcps.entries())
        cp && ($$invalidate(7, secondBarWidth = Math.min(Math.ceil(index / lcps.length * 100), 100)), await importLcp(cp));
      $$invalidate(3, importingMany = !1);
    }
  }
  __name(importManyLcps, "importManyLcps");
  function updateProgressBar(done, outOf) {
    const percent = Math.min(Math.ceil(done / outOf * 100), 100);
    SceneNavigation.displayProgressBar({ label: "Importing...", pct: percent }), $$invalidate(6, barWidth = percent);
  }
  __name(updateProgressBar, "updateProgressBar");
  async function clearCompendiums() {
    if (!await foundry.applications.api.DialogV2.confirm({
      // @ts-expect-error This should expect a partial, not a complete window configuration.
      window: {
        title: "Clear Compendiums",
        icon: "fas fa-triangle-exclamation"
      },
      content: `<p>Are you sure you want to delete all actors and items from the Lancer compendiums?</p>
        <p><i class="fas fa-triangle-exclamation i--m"></i> This action cannot be undone!</p>`
    }))
      return;
    $$invalidate(21, clearing = !0), await clearCompendiumData();
    const officialData = await getOfficialData(), index = new LCPIndex(game.settings.get(game.system.id, LANCER.setting_lcps).index);
    $$invalidate(1, lcpData = mergeOfficialDataAndLcpIndex(officialData, index)), deselectFiles(), $$invalidate(21, clearing = !1);
  }
  __name(clearCompendiums, "clearCompendiums");
  function lcptable_disabled_binding(value) {
    busy = value, $$invalidate(11, busy), $$invalidate(2, importing), $$invalidate(3, importingMany), $$invalidate(21, clearing);
  }
  __name(lcptable_disabled_binding, "lcptable_disabled_binding");
  function lcptable_deselect_binding(value) {
    deselectTable = value, $$invalidate(8, deselectTable);
  }
  __name(lcptable_deselect_binding, "lcptable_deselect_binding");
  const installManyLcps_handler = /* @__PURE__ */ __name((event) => importManyLcps(event.detail), "installManyLcps_handler");
  function lcpselector_disabled_binding(value) {
    busy = value, $$invalidate(11, busy), $$invalidate(2, importing), $$invalidate(3, importingMany), $$invalidate(21, clearing);
  }
  __name(lcpselector_disabled_binding, "lcpselector_disabled_binding");
  function lcpselector_deselect_binding(value) {
    deselectFiles = value, $$invalidate(9, deselectFiles);
  }
  __name(lcpselector_deselect_binding, "lcpselector_deselect_binding");
  function lcpdetails_disabled_binding(value) {
    busy = value, $$invalidate(11, busy), $$invalidate(2, importing), $$invalidate(3, importingMany), $$invalidate(21, clearing);
  }
  __name(lcpdetails_disabled_binding, "lcpdetails_disabled_binding");
  const importLcp_handler = /* @__PURE__ */ __name(() => importManyLcps(), "importLcp_handler");
  return $$self.$$set = ($$props2) => {
    "injectedContentSummary" in $$props2 && $$invalidate(17, injectedContentSummary = $$props2.injectedContentSummary), "loading" in $$props2 && $$invalidate(0, loading = $$props2.loading);
  }, $$self.$$.update = () => {
    var _a;
    $$self.$$.dirty[0] & /*importing, importingMany, clearing*/
    2097164 && $$invalidate(11, busy = importing || importingMany || clearing), $$self.$$.dirty[0] & /*injectedContentSummary, hoveredContentSummary, fileContentSummary, aggregateContentSummary*/
    1966080 && $$invalidate(4, contentSummary = injectedContentSummary ?? hoveredContentSummary ?? fileContentSummary ?? aggregateContentSummary), $$self.$$.dirty[0] & /*hoveredContentSummary, contentSummary*/
    524304 && $$invalidate(10, showImportButton = hoveredContentSummary !== null && !(contentSummary != null && contentSummary.aggregate)), $$self.$$.dirty[0] & /*lcpData*/
    2 && (coreVersion = (_a = lcpData.find((lcp) => lcp.id === "core")) == null ? void 0 : _a.currentVersion);
  }, [
    loading,
    lcpData,
    importing,
    importingMany,
    contentSummary,
    importingLcp,
    barWidth,
    secondBarWidth,
    deselectTable,
    deselectFiles,
    showImportButton,
    busy,
    lcpLoaded,
    lcpHovered,
    updateAggregateSummary,
    importManyLcps,
    clearCompendiums,
    injectedContentSummary,
    fileContentSummary,
    hoveredContentSummary,
    aggregateContentSummary,
    clearing,
    lcptable_disabled_binding,
    lcptable_deselect_binding,
    installManyLcps_handler,
    lcpselector_disabled_binding,
    lcpselector_deselect_binding,
    lcpdetails_disabled_binding,
    importLcp_handler
  ];
}
__name(instance, "instance");
const _LCPManager = class _LCPManager extends SvelteComponent {
  constructor(options) {
    super(), init(this, options, instance, create_fragment, safe_not_equal, { injectedContentSummary: 17, loading: 0 }, null, [-1, -1]);
  }
  get injectedContentSummary() {
    return this.$$.ctx[17];
  }
  set injectedContentSummary(injectedContentSummary) {
    this.$$set({ injectedContentSummary }), flush();
  }
  get loading() {
    return this.$$.ctx[0];
  }
  set loading(loading) {
    this.$$set({ loading }), flush();
  }
};
__name(_LCPManager, "LCPManager");
let LCPManager = _LCPManager;
export {
  LCPManager as default
};
//# sourceMappingURL=LCPManager-3154a0fd.mjs.map
