import { jsx, Fragment } from "react/jsx-runtime";
import { SpinnerOverlay, Message } from "@contember/ui";
import { useEffect } from "react";
function FeedbackRenderer({ accessorTreeState, children }) {
  useEffect(() => {
    if (accessorTreeState.name === "error" && accessorTreeState.error.type === "unauthorized") {
      window.location.href = "/";
    }
  }, [accessorTreeState]);
  if (accessorTreeState.name === "initializing") {
    return /* @__PURE__ */ jsx(SpinnerOverlay, {});
  }
  if (accessorTreeState.name === "error") {
    switch (accessorTreeState.error.type) {
      case "unauthorized":
        return null;
      case "networkError":
        return /* @__PURE__ */ jsx(Message, { intent: "danger", children: "Network error" });
      case "gqlError":
        return /* @__PURE__ */ jsx(Message, { intent: "danger", children: "Unknown error" });
      case "unknownError":
      default:
        return /* @__PURE__ */ jsx(Message, { intent: "danger", children: "Unknown error" });
    }
  }
  return /* @__PURE__ */ jsx(Fragment, { children });
}
export {
  FeedbackRenderer
};
//# sourceMappingURL=FeedbackRenderer.js.map
