import React from "react";
import ReactDOM from "react-dom/client";
import { RouterProvider } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import "./index.css";
import { router } from "./routes";
import { ToastProvider } from "./components/ToastProvider.jsx";

// RTL + Persian defaults
document.documentElement.setAttribute("dir", "rtl");
document.documentElement.setAttribute("lang", "fa");

const qc = new QueryClient({
  defaultOptions: { queries: { retry: 1, refetchOnWindowFocus: false } },
});

ReactDOM.createRoot(document.getElementById("root")).render(
  <React.StrictMode>
    <ToastProvider>
      <QueryClientProvider client={qc}>
        <RouterProvider router={router} />
      </QueryClientProvider>
    </ToastProvider>
  </React.StrictMode>
);
