import { Component, Suspense, useState, type ReactNode } from "react"; import { captureBrowserException } from "../lib/sentry"; import { PaperclipLoading } from "./AnimatedPaperclipIcon"; import { Button } from "./ui/button"; import { Dialog, DialogContent, DialogTitle } from "./ui/dialog"; interface DeferredOverlayProps { requested: boolean; title: string; onClose: () => void; children: ReactNode; } function OverlayNotice({ title, onClose, failed = false }: Pick & { failed?: boolean }) { return { if (!open) onClose(); }}> {failed ? `Couldn't open ${title.toLowerCase()}` : `Loading ${title.toLowerCase()}…`} {failed ?

Close this window to keep working. Reload the page before trying again.

: }
; } class OverlayErrorBoundary extends Component { state = { failed: false }; static getDerivedStateFromError() { return { failed: true }; } componentDidCatch(error: Error) { captureBrowserException(error); } render() { if (!this.state.failed) return this.props.children; return this.props.requested ? : null; } } export function DeferredOverlay({ requested, title, onClose, children }: DeferredOverlayProps) { const [activated, setActivated] = useState(requested); if (requested && !activated) setActivated(true); if (!requested && !activated) return null; return : null}>{children} ; }