import { mergeProps as i, filterDOMProps as y } from "../../utils/dist/module.es.js";
import { useFocusable as D } from "../../focus/dist/module.es.js";
import { usePress as F } from "../../interactions/dist/module.es.js";
function w(s, t) {
  let {
    elementType: r = "button",
    isDisabled: e,
    onPress: l,
    onPressStart: u,
    onPressEnd: c,
    onPressChange: p,
    preventFocusOnPress: b,
    allowFocusWhenDisabled: f,
    onClick: d,
    href: P,
    target: $,
    rel: x,
    type: o = "button"
  } = s, a;
  r === "button" ? a = {
    type: o,
    disabled: e
  } : a = {
    role: "button",
    tabIndex: e ? void 0 : 0,
    href: r === "a" && e ? void 0 : P,
    target: r === "a" ? $ : void 0,
    type: r === "input" ? o : void 0,
    disabled: r === "input" ? e : void 0,
    "aria-disabled": !e || r === "input" ? void 0 : e,
    rel: r === "a" ? x : void 0
  };
  let { pressProps: h, isPressed: m } = F({
    onPressStart: u,
    onPressEnd: c,
    onPressChange: p,
    onPress: l,
    isDisabled: e,
    preventFocusOnPress: b,
    ref: t
  }), { focusableProps: n } = D(s, t);
  f && (n.tabIndex = e ? -1 : n.tabIndex);
  let g = i(n, h, y(s, {
    labelable: !0
  }));
  return {
    isPressed: m,
    buttonProps: i(a, g, {
      "aria-haspopup": s["aria-haspopup"],
      "aria-expanded": s["aria-expanded"],
      "aria-controls": s["aria-controls"],
      "aria-pressed": s["aria-pressed"],
      onClick: (C) => {
        d && (d(C), console.warn("onClick is deprecated, please use onPress"));
      }
    })
  };
}
export {
  w as useButton
};
//# sourceMappingURL=module.es.js.map
