"use client";

import type { ReactNode } from "react";

import { useNetworkStatus } from "@/hooks/use-network-status";
import { ServerError } from "@/components/server-error";

/**
 * 全局错误状态提供者
 * - 监听网络状态变化
 * - 渲染离线横幅和服务器错误覆盖层
 */
export function ErrorProvider({ children }: { children: ReactNode }): ReactNode {
  // 初始化网络状态监听
  useNetworkStatus();

  return (
    <>
      <ServerError />
      {children}
    </>
  );
}
