import { jsxs as v, jsx as l } from "react/jsx-runtime";
import { classNames as r } from "./index-classNames.js";
import { Render as g } from "./index-Render.js";
import { useRef as L, useEffect as b } from "react";
import n from "./index-ListItem.module.scss2.js";
const w = (N) => {
  const {
    item: e,
    hideLeft: f = !1,
    hideRight: h = !1,
    onClick: u,
    scrollIntoView: c,
    isSticky: d,
    stickyItemStyles: i,
    stickyType: s,
    hoverable: p,
    onHover: o,
    idx: a
  } = N, t = L(null);
  return b(() => {
    var m;
    t.current && c && ((m = t == null ? void 0 : t.current) == null || m.scrollIntoView({
      behavior: "smooth",
      //center block does not work with sticky elements so we set it to nearest
      block: d ? "nearest" : "center",
      inline: "center"
    }));
  }, [c]), v("li", {
    ref: t,
    onClick: () => {
      u && (e != null && e.element) && u(e.element, a ?? -1);
    },
    className: r(n.listItemContainer, c && !d ? n.clicked : void 0, p ? n.hoverable : void 0, e.highlighted ? n.borderHighlighted : void 0, d ? "sticky" : void 0, d ? n.sticky : void 0, d && s === "none" ? i == null ? void 0 : i.normal : void 0, d && s === "top" ? i == null ? void 0 : i.stuckTop : void 0, d && s === "bottom" ? i == null ? void 0 : i.stuckBottom : void 0),
    onMouseEnter: () => o && e.element && o(e.element, a ?? -1, !0),
    onMouseLeave: () => o && e.element && o(e.element, a ?? -1, !1),
    children: [l(g, {
      if: !f && !!(e != null && e.left),
      children: l("div", {
        className: r(n.left),
        children: l("div", {
          className: n.left_content,
          children: e.left
        })
      })
    }), v("div", {
      className: r(n.middle, !e.left || f ? n.hiddenLeft : void 0, !e.right || h ? n.hiddenRight : void 0),
      children: [l("div", {
        className: r(n.titleLine),
        children: (e == null ? void 0 : e.title) ?? null
      }), l("div", {
        className: r(n.contentLine),
        children: (e == null ? void 0 : e.content) ?? null
      }), l("div", {
        className: r(n.lastLine),
        children: (e == null ? void 0 : e.last) ?? null
      })]
    }), l(g, {
      if: !h && !!(e != null && e.right),
      children: l("div", {
        className: r(n.right),
        children: l("div", {
          className: n.right_content,
          children: e.right
        })
      })
    })]
  });
};
export {
  w as ListItem
};
