import { jsx } from "react/jsx-runtime";
import { NavigationContext } from "@contember/ui";
import { useEnvironment } from "@contember/react-binding";
import { useRoutingLinkFactory, isRoutingLinkTarget, PageNotFound, parseLinkTarget } from "@contember/react-routing";
const NavigationProvider = (props) => {
  const env = useEnvironment();
  const linkFactory = useRoutingLinkFactory();
  return /* @__PURE__ */ jsx(
    NavigationContext.Provider,
    {
      value: (val) => {
        if (!isRoutingLinkTarget(val)) {
          throw new PageNotFound("Invalid request");
        }
        return linkFactory(parseLinkTarget(val, env));
      },
      children: props.children
    }
  );
};
export {
  NavigationProvider
};
//# sourceMappingURL=NavigationProvider.js.map
