import { defineComponent, useAttrs, getCurrentInstance, computed, resolveComponent, createBlock, createCommentVNode, openBlock, mergeProps, unref, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps, createVNode } from 'vue';
import '../../../utils/index.mjs';
import { backTopProps } from './back-top.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlBackTop" },
  __name: "back-top",
  props: backTopProps,
  setup(__props) {
    const props = __props;
    const bem = createNamespace("back-top");
    const attrs = useAttrs();
    const instance = getCurrentInstance();
    const isHidden = computed(() => props.show === false);
    const getTarget = computed(() => {
      if (props.target && typeof props.target === "function") return props.target;
      return () => {
        if (!instance?.proxy?.$el) return window;
        let current = instance.proxy.$el.parentElement;
        while (current && current !== document.documentElement) {
          const style = window.getComputedStyle(current);
          const overflowY = style.overflowY;
          const overflow = style.overflow;
          const isScrollable = (overflowY === "scroll" || overflowY === "auto" || overflow === "scroll" || overflow === "auto") && current.scrollHeight > current.clientHeight;
          if (isScrollable) return current;
          current = current.parentElement;
        }
        return window;
      };
    });
    return (_ctx, _cache) => {
      const _component_ll_icon = resolveComponent("ll-icon");
      const _component_a_back_top = resolveComponent("a-back-top");
      return !isHidden.value ? (openBlock(), createBlock(_component_a_back_top, mergeProps({ key: 0 }, unref(attrs), {
        class: unref(bem).b(),
        "visibility-height": _ctx.show === true ? 0 : _ctx.visibilityHeight,
        shape: _ctx.shape,
        description: _ctx.shape === "circle" ? "" : _ctx.description,
        target: getTarget.value
      }), createSlots({
        _: 2
        /* DYNAMIC */
      }, [
        renderList(Object.keys(_ctx.$slots).filter((key) => key !== "icon"), (item) => {
          return {
            name: item,
            fn: withCtx((data) => [
              renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
            ])
          };
        }),
        _ctx.icon.iconName || _ctx.$slots.icon ? {
          name: "icon",
          fn: withCtx(() => [
            renderSlot(_ctx.$slots, "icon", {}, () => [
              createVNode(
                _component_ll_icon,
                normalizeProps(guardReactiveProps(_ctx.icon)),
                null,
                16
                /* FULL_PROPS */
              )
            ])
          ]),
          key: "0"
        } : void 0
      ]), 1040, ["class", "visibility-height", "shape", "description", "target"])) : createCommentVNode("v-if", true);
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=back-top.vue2.mjs.map
