import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";

// =====================================================
// إعدادات Capacitor للأندرويد بوكس (تعمل فقط داخل APK)
// =====================================================
async function setupAndroidKiosk() {
  // نتجنب الكراش لو شغّلنا في المتصفح
  if (typeof window === "undefined" || !window.Capacitor?.isNativePlatform?.()) {
    return;
  }

  try {
    // ✅ منع الشاشة من النوم — مهم لشاشة عرض دائمة
    const { KeepAwake } = await import("@capacitor-community/keep-awake");
    await KeepAwake.keepAwake();
  } catch (e) {
    console.warn("KeepAwake failed:", e);
  }

  try {
    // ✅ إخفاء شريط الحالة
    const { StatusBar } = await import("@capacitor/status-bar");
    await StatusBar.hide();
  } catch (e) {
    console.warn("StatusBar.hide failed:", e);
  }

  try {
    // ✅ إخفاء شاشة الـ Splash بمجرد جاهزية التطبيق
    const { SplashScreen } = await import("@capacitor/splash-screen");
    await SplashScreen.hide();
  } catch (e) {
    console.warn("SplashScreen.hide failed:", e);
  }
}

setupAndroidKiosk();

ReactDOM.createRoot(document.getElementById("root")).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);
