"use client";
import * as i from "react";
function l(n, o) {
  if (typeof n == "function")
    return n(o);
  n != null && (n.current = o);
}
function s(...n) {
  return (o) => {
    let u = !1;
    const c = n.map((e) => {
      const t = l(e, o);
      return !u && typeof t == "function" && (u = !0), t;
    });
    if (u)
      return () => {
        for (let e = 0; e < c.length; e++) {
          const t = c[e];
          typeof t == "function" ? t() : l(n[e], null);
        }
      };
  };
}
function f(...n) {
  return i.useCallback(s(...n), n);
}
export {
  s as composeRefs,
  f as useComposedRefs
};
