import { jsxDEV, Fragment } from "react/jsx-dev-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__ */ jsxDEV(SpinnerOverlay, {}, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/FeedbackRenderer.tsx",
      lineNumber: 18,
      columnNumber: 10
    }, this);
  }
  if (accessorTreeState.name === "error") {
    switch (accessorTreeState.error.type) {
      case "unauthorized":
        return null;
      case "networkError": {
        throw new Error(accessorTreeState.error.metadata.responseText);
      }
      case "gqlError": {
        throw new Error(JSON.stringify(accessorTreeState.error.errors, null, "  "));
      }
      case "unknownError":
      default:
        return /* @__PURE__ */ jsxDEV(Message, { intent: "danger", children: "Unknown error" }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/FeedbackRenderer.tsx",
          lineNumber: 42,
          columnNumber: 12
        }, this);
    }
  }
  return /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/FeedbackRenderer.tsx",
    lineNumber: 46,
    columnNumber: 9
  }, this);
}
export {
  FeedbackRenderer
};
//# sourceMappingURL=FeedbackRenderer.js.map
