import Navigation from "./navigation";
import defaultLocaleJSON from "./variants/locales/default.json";
import defaultThemeJSON from "./variants/themes/default.json";
import {
    useFonts
} from "expo-font";
import moment from "moment";
import "moment/locale/tr";
import {
    Host,
    setupNCoreUIKit
} from "ncore-ui-kit";

const NCoreUIKitBase = setupNCoreUIKit({
    initialSelectedGapPropagation: "spacious",
    projectLocales: defaultLocaleJSON,
    projectThemes: defaultThemeJSON,
    initialSelectedTheme: "light"
});

moment.locale("tr");

const App = () => {
    return <Navigation/>;
};

const isExpo = typeof globalThis !== "undefined" && ("__expo" in globalThis || "Expo" in globalThis);

const ContextAPI = () => {
    if(isExpo) {
        /* eslint-disable @typescript-eslint/no-require-imports */
        const [loaded] = useFonts({
            "Geist-ExtraLight": require("./assets/fonts/Geist-ExtraLight.ttf"),
            "Geist-ExtraBold": require("./assets/fonts/Geist-ExtraBold.ttf"),
            "Geist-SemiBold": require("./assets/fonts/Geist-SemiBold.ttf"),
            "Geist-Regular": require("./assets/fonts/Geist-Regular.ttf"),
            "Geist-Medium": require("./assets/fonts/Geist-Medium.ttf"),
            "Geist-Black": require("./assets/fonts/Geist-Black.ttf"),
            "Geist-Light": require("./assets/fonts/Geist-Light.ttf"),
            "Geist-Bold": require("./assets/fonts/Geist-Bold.ttf"),
            "Geist-Thin": require("./assets/fonts/Geist-Thin.ttf")
        });

        if (!loaded) return null;
    }

    return <NCoreUIKitBase.Provider>
        <Host
            name="main-header"
        >
            <App/>
        </Host>
    </NCoreUIKitBase.Provider>;
};
export default ContextAPI;
