'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../hooks/index.js');
require('../../../utils/index.js');
var lodashEs = require('lodash-es');
var drawer = require('./drawer.js');
var index = require('../../../hooks/use-scroll/index.js');
var createNamespace = require('../../../utils/create-namespace.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "LlNewDrawer" },
  __name: "drawer",
  props: drawer.newDrawerProps,
  emits: drawer.newDrawerEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const attrs = vue.useAttrs();
    const { scrollPosition, isHasScrollBar, scrollRef } = index.useScroll();
    const getBindValue = vue.computed(() => {
      const result = {
        ...lodashEs.omit({ ...attrs }, [...Object.keys(drawer.newDrawerProps), "rootClassName"])
      };
      if (!props.showFooter) result.footer = null;
      return result;
    });
    const isShowContentBottomBox = vue.computed(() => {
      if (props.footerShadowPlacement === "inner") {
        return props.isShowFooterShadow && isHasScrollBar.value && scrollPosition.value !== "bottom";
      } else {
        return props.isShowFooterShadow;
      }
    });
    const bem = createNamespace.createNamespace("new-drawer");
    const handleClose = () => {
      emits("close");
      emits("update:open");
    };
    const handleCancel = () => {
      emits("cancel");
      emits("update:open");
    };
    const handleConfirm = () => {
      emits("confirm");
    };
    const scrollTop = () => {
      if (scrollRef && scrollRef.value) {
        scrollRef.value.scrollTop = 0;
        scrollPosition.value = "top";
      }
    };
    __expose({
      scrollTop
    });
    return (_ctx, _cache) => {
      const _component_ll_button = vue.resolveComponent("ll-button");
      const _component_a_drawer = vue.resolveComponent("a-drawer");
      return vue.openBlock(), vue.createBlock(_component_a_drawer, vue.mergeProps(getBindValue.value, {
        open: _ctx.open,
        keyboard: _ctx.keyboard,
        "root-class-name": `${vue.unref(bem).b()} ${_ctx.rootClassName}`,
        onClose: handleClose
      }), vue.createSlots({
        title: vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "title", {}, () => [
            vue.createTextVNode(
              vue.toDisplayString(props.title),
              1
              /* TEXT */
            )
          ])
        ]),
        extra: vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "extra")
        ]),
        default: vue.withCtx(() => [
          vue.createElementVNode(
            "div",
            {
              class: vue.normalizeClass([vue.unref(bem).e("container")])
            },
            [
              vue.createCommentVNode(" \u5185\u5BB9\u533A\u57DF "),
              vue.createElementVNode(
                "div",
                {
                  ref_key: "scrollRef",
                  ref: scrollRef,
                  class: vue.normalizeClass([vue.unref(bem).e("content")])
                },
                [
                  vue.renderSlot(_ctx.$slots, "default")
                ],
                2
                /* CLASS */
              )
            ],
            2
            /* CLASS */
          )
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        _ctx.$slots["closeIcon"] ? {
          name: "closeIcon",
          fn: vue.withCtx(() => [
            vue.renderSlot(_ctx.$slots, "closeIcon")
          ]),
          key: "0"
        } : void 0,
        _ctx.showFooter ? {
          name: "footer",
          fn: vue.withCtx(() => [
            vue.createElementVNode(
              "div",
              {
                class: vue.normalizeClass(`${vue.unref(bem).e("footer")} ${isShowContentBottomBox.value ? vue.unref(bem).e("footer-shadow") : ""}`)
              },
              [
                vue.renderSlot(_ctx.$slots, "footer", {}, () => [
                  vue.createElementVNode(
                    "div",
                    {
                      class: vue.normalizeClass(vue.unref(bem).e("footer-left"))
                    },
                    [
                      vue.renderSlot(_ctx.$slots, "footer-left")
                    ],
                    2
                    /* CLASS */
                  ),
                  vue.createElementVNode(
                    "div",
                    {
                      class: vue.normalizeClass(vue.unref(bem).e("footer-right"))
                    },
                    [
                      vue.renderSlot(_ctx.$slots, "footer-right", {}, () => [
                        vue.createVNode(_component_ll_button, vue.mergeProps({
                          class: vue.unref(bem).m("cancel"),
                          label: _ctx.cancelText
                        }, _ctx.cancelButtonProps, { onClick: handleCancel }), null, 16, ["class", "label"]),
                        vue.createVNode(_component_ll_button, vue.mergeProps({
                          type: "primary",
                          loading: _ctx.confirmLoading,
                          label: _ctx.confirmText
                        }, _ctx.okButtonProps, { onClick: handleConfirm }), null, 16, ["loading", "label"])
                      ])
                    ],
                    2
                    /* CLASS */
                  )
                ])
              ],
              2
              /* CLASS */
            )
          ]),
          key: "1"
        } : void 0
      ]), 1040, ["open", "keyboard", "root-class-name"]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=drawer.vue2.js.map
