"use client";
import { jsx } from "react/jsx-runtime";
import { forwardRef } from "react";
import { Link as LinkDef } from "../../../controls/link";
import { useResolvedValue } from "../../../runtimes/react/hooks/use-resolved-value";
import { useFrameworkContext } from "../../../runtimes/react/components/hooks/use-framework-context";
const Link = forwardRef(function Link2({ link, onClick = () => {
}, ...restOfProps }, ref) {
  const {
    href,
    target,
    onClick: resolvedOnClick
  } = useResolvedValue(
    link,
    (link2, resourceResolver) => LinkDef().resolveValue(link2, resourceResolver)
  ) ?? {};
  function handleClick(event) {
    onClick(event);
    if (event.defaultPrevented)
      return;
    if (event.currentTarget.isContentEditable)
      return event.preventDefault();
    return resolvedOnClick?.(event);
  }
  const { Link: LinkComponent } = useFrameworkContext();
  return /* @__PURE__ */ jsx(
    LinkComponent,
    {
      ...restOfProps,
      linkType: link?.type,
      ref,
      href,
      target,
      onClick: handleClick
    }
  );
});
export {
  Link
};
//# sourceMappingURL=index.js.map