'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Component } from 'react';
export class ErrorBoundary extends Component {
    constructor(props) {
        super(props);
        this.state = { hasError: false, error: null };
    }
    static getDerivedStateFromError(error) {
        return { hasError: true, error };
    }
    componentDidCatch(error, info) {
        console.error('[Actuate CMS] Unhandled error:', error, info.componentStack);
    }
    render() {
        if (this.state.hasError) {
            if (this.props.fallback)
                return this.props.fallback;
            return (_jsx("div", { className: "flex min-h-[200px] items-center justify-center p-6", children: _jsxs("div", { className: "text-center", children: [_jsx("h2", { className: "text-foreground mb-2 text-lg font-medium", children: "Something went wrong" }), _jsx("p", { className: "text-muted-foreground mb-4 text-sm", children: this.state.error?.message ?? 'An unexpected error occurred' }), _jsx("button", { onClick: () => this.setState({ hasError: false, error: null }), className: "text-primary-foreground bg-primary hover:bg-primary/90 rounded-md px-4 py-2 text-sm font-medium transition-colors", children: "Try Again" })] }) }));
        }
        return this.props.children;
    }
}
//# sourceMappingURL=ErrorBoundary.js.map