import { useCallback as m, useEffect as p, useMemo as M } from "react";
import { u as g } from "./router-context-CDZd-F2n.js";
import { k as b, l as h, p as C, a as S } from "./use-debounce-search-DTQpLIZM.js";
import { u as i, U as w, a as I } from "./use-local-storage-m-P0qP0B.js";
function P() {
  const { useSearchParams: o } = g(), [s, n] = o(), u = s.get("query"), r = m(
    (e) => {
      n((a) => {
        var t;
        const c = (t = e == null ? void 0 : e.target) == null ? void 0 : t.value;
        return b(c) ? a.delete("query") : a.set("query", c), a;
      });
    },
    [n]
  );
  return {
    query: u || void 0,
    handleSearch: r
  };
}
const _ = 1024 * 1024, f = () => {
  try {
    return !!(window.performance && window.performance.memory);
  } catch {
    return !1;
  }
}, v = () => {
  try {
    if (!f()) return null;
    const o = window.performance.memory;
    return o ? Math.round(o.usedJSHeapSize / _) : null;
  } catch {
    return null;
  }
}, k = (o, s = 1200, n = 3e4) => {
  p(() => {
    if (!f()) {
      console.debug("Memory API not available - memory cleanup disabled");
      return;
    }
    const r = setInterval(() => {
      const e = v();
      e !== null && e > s && (console.debug(`Memory usage (${e}MB) exceeded threshold (${s}MB). Running cleanup...`), o());
    }, n);
    return () => clearInterval(r);
  }, [o, s, n]);
};
function q({
  storageKey: o,
  columns: s,
  defaultVisibleColumns: n
}) {
  const u = M(
    () => n ?? s.map((t) => t.value),
    [n, s]
  ), [r, e] = i(o, u), a = m(
    (t, y) => {
      if (y) {
        const l = r.includes(t) ? r : [...r, t];
        e(l);
      } else {
        const l = r.filter((d) => d !== t);
        e(l);
      }
    },
    [r, e]
  ), c = m(() => {
    e(u);
  }, [e, u]);
  return {
    visibleColumns: r,
    toggleColumn: a,
    resetColumns: c
  };
}
const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  UserPreference: w,
  useColumnFilter: q,
  useCommonFilter: P,
  useDebounceSearch: h,
  useDragAndDrop: C,
  useIsMounted: I,
  useLocalStorage: i,
  useMemoryCleanup: k,
  useResizeObserver: S
}, Symbol.toStringTag, { value: "Module" }));
export {
  k as a,
  q as b,
  A as i,
  P as u
};
//# sourceMappingURL=index-DL-GauCd.js.map
