import { defineComponent, useAttrs, computed, resolveComponent, createElementBlock, openBlock, mergeProps, createCommentVNode, createBlock, unref, withCtx, createElementVNode, normalizeStyle, normalizeClass, createVNode, renderSlot, Fragment } from 'vue';
import '../../../utils/index.mjs';
import { FALL_BACK_IMG, imageProps } from './image.mjs';
import { omit } from 'lodash-es';
import { createNamespace } from '../../../utils/create-namespace.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "LlImage",
    inheritAttrs: false
  },
  __name: "image",
  props: imageProps,
  setup(__props) {
    const attrs = useAttrs();
    const props = __props;
    const bem = createNamespace("image");
    const containerAttrs = computed(() => ({
      class: attrs.class,
      style: attrs.style
    }));
    const componentAttrs = computed(() => {
      return omit(attrs, ["class", "style"]);
    });
    const computedFallback = computed(
      () => props.fallback ? props.fallback : FALL_BACK_IMG
    );
    const getImageClass = computed(() => {
      const borderClass = props.isShowBorder ? bem.m("border") : "";
      return `${borderClass}`;
    });
    const getImageStyle = computed(() => {
      return { borderRadius: props.borderRadius, overflow: "hidden" };
    });
    const getSrc = computed(() => {
      return props.src ? props.src : FALL_BACK_IMG;
    });
    return (_ctx, _cache) => {
      const _component_ll_icon = resolveComponent("ll-icon");
      const _component_a_image = resolveComponent("a-image");
      const _component_ll_watermark = resolveComponent("ll-watermark");
      return openBlock(), createElementBlock(
        "div",
        mergeProps({ style: { display: "inline-flex" } }, containerAttrs.value),
        [
          createCommentVNode(" \u652F\u6301\u6C34\u5370 "),
          (Array.isArray(_ctx.content) ? _ctx.content.length > 0 : _ctx.content) ? (openBlock(), createBlock(_component_ll_watermark, mergeProps({
            key: 0,
            class: `${unref(bem).b("watermark")}`
          }, componentAttrs.value, {
            style: getImageStyle.value,
            content: props.content,
            width: props.watermarkWidth,
            height: props.watermarkHeight,
            "z-index": 100
          }), {
            default: withCtx(() => [
              createElementVNode(
                "div",
                {
                  class: normalizeClass([
                    unref(bem).b("container"),
                    _ctx.$slots.previewMask ? "" : unref(bem).is("no-preview-mask"),
                    getImageClass.value
                  ]),
                  style: normalizeStyle(getImageStyle.value)
                },
                [
                  createVNode(_component_a_image, mergeProps({
                    class: `${unref(bem).b()}`,
                    style: { "object-fit": props.objectFit }
                  }, props, {
                    src: getSrc.value,
                    fallback: computedFallback.value
                  }), {
                    placeholder: withCtx(() => [
                      renderSlot(_ctx.$slots, "placeholder")
                    ]),
                    previewMask: withCtx(() => [
                      renderSlot(_ctx.$slots, "previewMask", {}, () => [
                        createElementVNode(
                          "div",
                          {
                            class: normalizeClass(unref(bem).e("preview-mask")),
                            style: normalizeStyle({ background: props.maskColor })
                          },
                          [
                            renderSlot(_ctx.$slots, "previewMaskContent", {}, () => [
                              createVNode(_component_ll_icon, {
                                class: normalizeClass(unref(bem).e("preview-icon")),
                                "icon-name": props.previewIcon,
                                size: props.iconSize
                              }, null, 8, ["class", "icon-name", "size"])
                            ])
                          ],
                          6
                          /* CLASS, STYLE */
                        )
                      ])
                    ]),
                    _: 3
                    /* FORWARDED */
                  }, 16, ["class", "style", "src", "fallback"])
                ],
                6
                /* CLASS, STYLE */
              )
            ]),
            _: 3
            /* FORWARDED */
          }, 16, ["class", "style", "content", "width", "height"])) : (openBlock(), createElementBlock(
            Fragment,
            { key: 1 },
            [
              createCommentVNode(" \u9ED8\u8BA4\u7684\u56FE\u7247\u5C55\u793A "),
              createElementVNode(
                "div",
                {
                  class: normalizeClass([
                    unref(bem).b("container"),
                    _ctx.$slots.previewMask ? "" : unref(bem).is("no-preview-mask"),
                    getImageClass.value
                  ]),
                  style: normalizeStyle(getImageStyle.value)
                },
                [
                  createVNode(_component_a_image, mergeProps({
                    class: `${unref(bem).b()}`,
                    style: { "object-fit": props.objectFit }
                  }, props, {
                    src: getSrc.value,
                    fallback: computedFallback.value
                  }), {
                    placeholder: withCtx(() => [
                      renderSlot(_ctx.$slots, "placeholder")
                    ]),
                    previewMask: withCtx(() => [
                      renderSlot(_ctx.$slots, "previewMask", {}, () => [
                        createElementVNode(
                          "div",
                          {
                            class: normalizeClass(unref(bem).e("preview-mask")),
                            style: normalizeStyle({ background: props.maskColor })
                          },
                          [
                            renderSlot(_ctx.$slots, "previewMaskContent", {}, () => [
                              createVNode(_component_ll_icon, {
                                class: normalizeClass(unref(bem).e("preview-icon")),
                                "icon-name": props.previewIcon,
                                size: props.iconSize
                              }, null, 8, ["class", "icon-name", "size"])
                            ])
                          ],
                          6
                          /* CLASS, STYLE */
                        )
                      ])
                    ]),
                    _: 3
                    /* FORWARDED */
                  }, 16, ["class", "style", "src", "fallback"])
                ],
                6
                /* CLASS, STYLE */
              )
            ],
            64
            /* STABLE_FRAGMENT */
          ))
        ],
        16
        /* FULL_PROPS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=image.vue2.mjs.map
