import { useState as d, useCallback as S } from "react";
const p = (e, r) => {
  try {
    const t = localStorage.getItem(e);
    return t === null ? r : JSON.parse(t) === !0;
  } catch {
    return r;
  }
}, a = "jtl-sidebar-collapsed", f = ({ collapsed: e, defaultCollapsed: r = !1, onCollapsedChange: t }) => {
  const [c, l] = d(() => p(a, r)), s = e !== void 0, n = s ? e : c, i = S(
    (o) => {
      s || l(o);
      try {
        localStorage.setItem(a, JSON.stringify(o));
      } catch {
        console.warn("Failed to persist sidebar collapsed state to localStorage");
      }
      t == null || t(o);
    },
    [s, t]
  );
  return { collapsed: n, onCollapsedChange: i };
};
export {
  f as useSidebarCollapse
};
//# sourceMappingURL=useSidebarCollapse.js.map
