import { jsx as C } from "react/jsx-runtime";
import { useRef as R } from "react";
import { createRecipeContext as h, mergeRefs as y } from "@chakra-ui/react";
import { $ as L } from "./useObjectRef-CaJ5pgjX.es.js";
import { $ } from "./mergeProps-Dsl8k3Ig.es.js";
import { $ as v } from "./filterDOMProps-BSVCO5jK.es.js";
import { a as D, b as E, c as S } from "./openLink-BNz58j4a.es.js";
import { $ as T } from "./usePress-BuLomD_X.es.js";
import { $ as w } from "./useFocusable-Cs6i58WP.es.js";
function _(e, o) {
  let { elementType: s = "a", onPress: n, onPressStart: i, onPressEnd: t, onClick: c, isDisabled: r, ...d } = e, a = {};
  s !== "a" && (a = {
    role: "link",
    tabIndex: r ? void 0 : 0
  });
  let { focusableProps: p } = w(e, o), { pressProps: l, isPressed: m } = T({
    onPress: n,
    onPressStart: i,
    onPressEnd: t,
    onClick: c,
    isDisabled: r,
    ref: o
  }), P = v(d, {
    labelable: !0
  }), k = $(p, l), u = D(), x = E(e);
  return {
    isPressed: m,
    linkProps: $(P, x, {
      ...k,
      ...a,
      "aria-disabled": r || void 0,
      "aria-current": e["aria-current"],
      onClick: (b) => {
        var f;
        (f = l.onClick) === null || f === void 0 || f.call(l, b), S(b, u, e.href, e.routerOptions);
      }
    })
  };
}
const { withContext: g } = /* @__PURE__ */ h({ key: "link" }), j = /* @__PURE__ */ g("a"), H = (e) => {
  const { as: o, asChild: s, children: n, ref: i, ...t } = e, c = R(null), r = L(y(c, i)), d = o || (s ? "span" : "a"), { linkProps: a } = _({ ...t, elementType: d }, r);
  return /* @__PURE__ */ C(j, { ...$(t, a, { as: o, asChild: s, ref: r }), children: n });
};
H.displayName = "Link";
export {
  H as L
};
//# sourceMappingURL=link-BMUyXcmC.es.js.map
