import { useState as b, useEffect as d } from "../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import p from "../core/Context/preact/useCoreContext.js";
const y = (c) => {
  const { componentRef: i } = p(), [s, o] = b(0), [f, n, a] = c;
  let r = !1;
  switch (f) {
    case "up":
      r = s >= n;
      break;
    case "down":
      r = s <= n;
      break;
    case "only":
      if (a) {
        const { min: e, max: t } = a;
        r = t ? s <= t : e ? s >= e : !1;
      } else
        r = s === n;
      break;
  }
  return d(() => {
    const e = i();
    if (!e) return;
    o(e.offsetWidth);
    const t = new ResizeObserver((u) => {
      for (const m of u)
        m.target === e && o(e.offsetWidth);
    });
    return t.observe(e), () => {
      t.unobserve(e), t.disconnect();
    };
  }, []), r;
};
export {
  y as useContainerQuery
};
