import { defineComponent, useAttrs, ref, computed, createBlock, openBlock, unref, mergeProps, createSlots, withCtx, createElementVNode, normalizeClass, renderSlot, toDisplayString, createCommentVNode, createVNode } from 'vue';
import '../../index.mjs';
import { Modal } from 'ant-design-vue';
import '../../../hooks/index.mjs';
import '../../../utils/index.mjs';
import { omit } from 'lodash-es';
import { newModalProps, newModalEmits } from './modal.mjs';
import { useScroll } from '../../../hooks/use-scroll/index.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';
import { LlButton } from '../../button/index.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlNewModal" },
  __name: "modal",
  props: newModalProps,
  emits: newModalEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const attrs = useAttrs();
    const { scrollPosition, isHasScrollBar, scrollRef } = useScroll();
    const modal = ref();
    const currentClass = ref("");
    const getBindValue = computed(() => {
      const result = {
        ...omit({ ...attrs }, [...Object.keys(newModalProps), "wrapClassName"])
      };
      if (!props.showFooter) result.footer = null;
      return result;
    });
    const isShowContentBottomBox = computed(() => {
      if (props.footerShadowPlacement === "inner") {
        return props.isShowFooterShadow && isHasScrollBar.value && scrollPosition.value !== "bottom";
      } else {
        return props.isShowFooterShadow;
      }
    });
    const bem = createNamespace("new-modal");
    const handleCancel = () => {
      emits("cancel");
      emits("update:open");
    };
    const handleOk = () => {
      emits("ok");
    };
    const scrollTop = () => {
      if (scrollRef && scrollRef.value) {
        scrollRef.value.scrollTop = 0;
        scrollPosition.value = "top";
      }
    };
    __expose({
      scrollTop
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Modal), mergeProps(getBindValue.value, {
        ref_key: "modal",
        ref: modal,
        keyboard: _ctx.keyboard,
        open: _ctx.open,
        "wrap-class-name": `${unref(bem).b()} ${_ctx.wrapClassName} ${currentClass.value}`,
        onCancel: handleCancel,
        onOk: handleOk
      }), createSlots({
        title: withCtx(() => [
          renderSlot(_ctx.$slots, "title", {}, () => [
            createElementVNode(
              "span",
              null,
              toDisplayString(_ctx.title),
              1
              /* TEXT */
            )
          ])
        ]),
        default: withCtx(() => [
          createElementVNode(
            "div",
            {
              ref_key: "scrollRef",
              ref: scrollRef,
              class: normalizeClass([unref(bem).e("container")])
            },
            [
              renderSlot(_ctx.$slots, "default")
            ],
            2
            /* CLASS */
          )
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        _ctx.$slots["closeIcon"] ? {
          name: "closeIcon",
          fn: withCtx(() => [
            renderSlot(_ctx.$slots, "closeIcon")
          ]),
          key: "0"
        } : void 0,
        _ctx.showFooter ? {
          name: "footer",
          fn: withCtx(() => [
            createElementVNode(
              "div",
              {
                class: normalizeClass(`${unref(bem).e("footer")} ${isShowContentBottomBox.value ? unref(bem).e("footer-shadow") : ""}`)
              },
              [
                renderSlot(_ctx.$slots, "footer", {}, () => [
                  _ctx.type !== "confirm" ? (openBlock(), createBlock(unref(LlButton), mergeProps({
                    key: 0,
                    label: _ctx.cancelText,
                    size: "middle"
                  }, _ctx.cancelButtonProps, { onClick: handleCancel }), null, 16, ["label"])) : createCommentVNode("v-if", true),
                  createVNode(unref(LlButton), mergeProps({
                    type: "primary",
                    loading: props.confirmLoading,
                    size: "middle",
                    label: props.confirmText ? props.confirmText : props.type === "confirm" ? "\u77E5\u9053\u4E86" : "\u786E\u8BA4"
                  }, _ctx.okButtonProps, { onClick: handleOk }), null, 16, ["loading", "label"])
                ])
              ],
              2
              /* CLASS */
            )
          ]),
          key: "1"
        } : void 0
      ]), 1040, ["keyboard", "open", "wrap-class-name"]);
    };
  }
});

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