import { jsxs as c, jsx as e } from "react/jsx-runtime";
import I, { forwardRef as O, useState as x, useRef as h, useImperativeHandle as _, useEffect as T } from "react";
import { debounce as k } from "es-toolkit/compat";
import a from "../../utils/classNames.js";
import F from "../smoothScrollbars/SmoothScrollbars.js";
const j = 200, G = 54, Z = O((g, y) => {
  const {
    className: b,
    innerClassName: i,
    forceScrollbar: N = !0,
    enableScrollToTop: B = !0,
    banner: p,
    navigation: m,
    bottomBar: s,
    bottomBarHeight: u = G,
    scrollResetTrigger: S,
    children: R,
    ...E
  } = g, [H, n] = x(0), o = h(null), r = h(null);
  _(y, () => r?.current, []), T(() => {
    o.current && (o.current.scrollTop(0), n(0));
  }, [S]), T(() => {
    r.current?.parentNode instanceof HTMLElement && r.current.parentNode.style.setProperty(
      "--ApplicationLayoutBodyBottomBarHeight",
      `${u}px`
    );
  }, [u]);
  const L = k(() => {
    o.current && n(o.current.getScrollTop());
  }, j), d = () => {
    if (!o.current)
      return;
    const l = o.current.container, f = l.firstElementChild, t = f?.scrollTop ?? 0;
    t > 10 ? (window.requestAnimationFrame(d), f?.scrollTo(0, t - t / 5), l.classList.add("is-scrolling-to-top"), n(t)) : l.classList.remove("is-scrolling-to-top");
  }, w = a("ApplicationLayoutBody", s ? "has-footer" : "", b), v = a(
    "module-content",
    i && i
  ), A = window.innerHeight * 0.1, C = a("scroll-to-top", H > A && "in");
  return /* @__PURE__ */ c(I.Fragment, { children: [
    /* @__PURE__ */ c("div", { ...E, ref: r, className: w, children: [
      /* @__PURE__ */ c("div", { className: "module-content-wrapper", children: [
        m && m,
        p && p,
        /* @__PURE__ */ e(
          F,
          {
            ref: o,
            slideIn: !N,
            largeTrack: !0,
            trackOffset: !0,
            className: v,
            onScroll: L,
            children: /* @__PURE__ */ e("div", { className: "scrollbar-content", children: R })
          }
        )
      ] }),
      B && /* @__PURE__ */ e("span", { className: C, children: /* @__PURE__ */ e("button", { type: "button", className: "btn btn-primary btn-icon-only", onClick: d, children: /* @__PURE__ */ e("span", { className: "rioglyph rioglyph-arrow-up" }) }) })
    ] }),
    s && s
  ] });
});
export {
  Z as default
};
//# sourceMappingURL=ApplicationLayoutBody.js.map
