import { defineComponent, watch, ref, computed, openBlock, createElementBlock, normalizeStyle, createElementVNode, renderSlot, createVNode, unref, createCommentVNode } from 'vue';
import { MeSvgIcon } from '../../svg-icon/index.mjs';

"use strict";
const _hoisted_1 = { class: "loading-body" };
const _hoisted_2 = { class: "loading-icon" };
const __default__ = defineComponent({
  name: "me-loading"
});
var script = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    show: { type: Boolean, required: false, default: true },
    icon: { type: String, required: false, default: "ri-shopping-bag-4-fill" },
    width: { type: String, required: false, default: "50px" },
    loadingWidth: { type: String, required: false, default: "3px" },
    loadingColor: { type: String, required: false, default: "red" }
  },
  setup(__props, { expose: __expose }) {
    const props = __props;
    watch(() => props.show, (val) => {
      if (val) {
        document.body.style.overflow = "hidden";
      } else {
        document.body.style.overflow = "auto";
      }
    }, { immediate: true });
    const icon = ref(props.icon);
    const loadingStyle = computed(() => {
      return {
        "--me-loading-width": props.width,
        "--me-loading-loader-width": props.loadingWidth,
        "--me-loading-loader-color": props.loadingColor
      };
    });
    const setIcon = (iconName) => {
      icon.value = iconName;
    };
    __expose({
      setIcon,
      icon
    });
    return (_ctx, _cache) => {
      return __props.show ? (openBlock(), createElementBlock(
        "div",
        {
          key: 0,
          class: "me-loading",
          style: normalizeStyle({ ...loadingStyle.value })
        },
        [
          createElementVNode("div", _hoisted_1, [
            createElementVNode("div", _hoisted_2, [
              renderSlot(_ctx.$slots, "default", {}, () => [
                createVNode(unref(MeSvgIcon), {
                  size: 20,
                  name: icon.value
                }, null, 8, ["name"])
              ])
            ]),
            _cache[0] || (_cache[0] = createElementVNode(
              "div",
              { class: "loader" },
              null,
              -1
              /* CACHED */
            ))
          ])
        ],
        4
        /* STYLE */
      )) : createCommentVNode("v-if", true);
    };
  }
});

export { script as default };
//# sourceMappingURL=loading.vue2.mjs.map
