import { defineComponent, useCssVars, computed, openBlock, createElementBlock, createVNode, unref, createSlots, withCtx, renderSlot, Fragment, renderList, createBlock, withModifiers, createCommentVNode, createElementVNode, normalizeStyle } from "vue";
import { Swipe, SwipeItem, showImagePreview } from "vant";
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _hoisted_1 = { class: "swipe-wrap" };
const _hoisted_2 = ["src", "alt"];
const _hoisted_3 = {
  key: 0,
  class: "footer-line"
};
const __default__ = {
  name: "WlSwipe"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    list: { default: () => [] },
    height: { default: "" },
    type: null,
    indicatorsOutLine: { type: Boolean, default: false },
    imagePreview: { type: Boolean, default: true }
  },
  emits: ["onClick"],
  setup(__props, { emit }) {
    const props = __props;
    useCssVars((_ctx) => ({
      "692c37a0": __props.height,
      "6bd6965e": _ctx.swipeItemPointerEvent
    }));
    const outLineActiveStyle = computed(() => {
      return (active, total) => {
        const width = 100 / total;
        const left = width * active;
        return {
          width: width + "%",
          left: left + "%"
        };
      };
    });
    const onClick = (index) => {
      if (props.imagePreview && props.type === "img") {
        showImagePreview({
          images: props.list,
          startPosition: index,
          closeable: true,
          className: "img-preview"
        });
      }
      emit("onClick", index);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(Swipe), {
          height: __props.height,
          "lazy-render": ""
        }, createSlots({
          default: withCtx(() => [
            renderSlot(_ctx.$slots, "default", {}, () => [
              (openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (item, index) => {
                return openBlock(), createBlock(unref(SwipeItem), {
                  key: item,
                  onClick: withModifiers(($event) => onClick(index), ["stop"])
                }, {
                  default: withCtx(() => [
                    __props.type === "img" ? (openBlock(), createElementBlock("img", {
                      key: 0,
                      src: item,
                      class: "swipe-img-item",
                      alt: item
                    }, null, 8, _hoisted_2)) : createCommentVNode("", true)
                  ]),
                  _: 2
                }, 1032, ["onClick"]);
              }), 128))
            ], true)
          ]),
          _: 2
        }, [
          __props.indicatorsOutLine || _ctx.$slots.footer ? {
            name: "indicator",
            fn: withCtx(({ active, total }) => [
              __props.indicatorsOutLine ? (openBlock(), createElementBlock("div", _hoisted_3, [
                createElementVNode("div", {
                  class: "active-line",
                  style: normalizeStyle(unref(outLineActiveStyle)(active, total))
                }, null, 4)
              ])) : createCommentVNode("", true),
              _ctx.$slots.footer ? renderSlot(_ctx.$slots, "footer", {
                key: 1,
                active,
                total
              }, void 0, true) : createCommentVNode("", true)
            ])
          } : void 0
        ]), 1032, ["height"])
      ]);
    };
  }
});
var Comp = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-59751794"]]);
var __uno = "";
Comp.install = (app) => {
  app.component(Comp.name, Comp);
};
export { Comp as default };
