"use strict";

import React from 'react';
import { I18nextProvider } from 'react-i18next';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
import { DefaultTheme, NavigationContainer as ReactNavigationContainer, NavigationIndependentTree } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import StackScreen from "./StackScreen.js";
import DialogScreen from "./DialogScreen.js";
import ModalScreen from "./ModalScreen.js";
import { ApplicationContext } from "../Context/index.js";
import { HeaderBackground, HeaderTitle, NavigationBackButton } from "./Components/index.js";
import { Styles } from "../Consts/index.js";
import LoadingView from "./LoadingView.js";
import ToastView from "./ToastView.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const Stack = createStackNavigator();
const NavigationContainer = ({
  screen,
  theme,
  navigator,
  params,
  localization
}) => {
  return /*#__PURE__*/_jsx(SafeAreaProvider, {
    style: Styles.flex,
    children: /*#__PURE__*/_jsxs(GestureHandlerRootView, {
      style: Styles.flex,
      children: [/*#__PURE__*/_jsx(I18nextProvider, {
        i18n: localization.instance,
        defaultNS: 'translation',
        children: /*#__PURE__*/_jsx(ApplicationContext.Provider, {
          value: {
            theme,
            navigator,
            translate: localization.instance.t
          },
          children: /*#__PURE__*/_jsx(Navigation, {
            navigator: navigator,
            theme: theme,
            screen: screen,
            params: params
          })
        })
      }), /*#__PURE__*/_jsx(LoadingView, {
        ref: navigator.loadingRef
      }), /*#__PURE__*/_jsx(ToastView, {
        ref: navigator.toastRef
      })]
    })
  });
};
const Navigation = ({
  theme,
  navigator,
  params,
  screen
}) => {
  const insets = useSafeAreaInsets();
  return /*#__PURE__*/_jsx(NavigationIndependentTree, {
    children: /*#__PURE__*/_jsx(ReactNavigationContainer, {
      theme: {
        fonts: DefaultTheme.fonts,
        dark: theme.dark,
        colors: {
          primary: theme.colors.primary.default,
          background: theme.colors.background.default,
          card: theme.colors.background.surface,
          text: theme.colors.text.default,
          border: theme.colors.border.default,
          notification: theme.colors.error.default
        }
      },
      ref: navigator?.ref,
      children: /*#__PURE__*/_jsxs(Stack.Navigator, {
        initialRouteName: "Stack",
        screenOptions: {
          headerMode: 'screen',
          gestureEnabled: true,
          headerTitleAlign: 'center',
          headerTintColor: theme.colors.text.default,
          headerStyle: {
            height: 54 + insets.top
          }
        },
        children: [/*#__PURE__*/_jsx(Stack.Screen, {
          name: "Stack",
          component: StackScreen,
          initialParams: {
            ...params,
            screen
          },
          options: {
            headerTitle: props => {
              return /*#__PURE__*/_jsx(HeaderTitle, {
                ...props
              });
            },
            headerLeft: props => /*#__PURE__*/_jsx(NavigationBackButton, {
              ...props,
              icon: "arrow-left"
            }),
            headerBackground: () => /*#__PURE__*/_jsx(HeaderBackground, {})
          }
        }), /*#__PURE__*/_jsx(Stack.Screen, {
          name: "Dialog",
          component: DialogScreen,
          options: {
            presentation: 'transparentModal',
            gestureEnabled: false,
            cardStyle: {
              backgroundColor: theme.colors.background.default
            },
            headerTitle: props => {
              return /*#__PURE__*/_jsx(HeaderTitle, {
                ...props
              });
            },
            headerLeft: props => /*#__PURE__*/_jsx(NavigationBackButton, {
              ...props,
              icon: "close"
            }),
            headerBackground: () => /*#__PURE__*/_jsx(HeaderBackground, {})
          },
          initialParams: {
            screen
          }
        }), /*#__PURE__*/_jsx(Stack.Screen, {
          name: "Modal",
          component: ModalScreen,
          options: {
            headerShown: false,
            headerBackground: undefined,
            presentation: 'transparentModal',
            animation: 'none'
          },
          initialParams: {
            screen
          }
        })]
      })
    })
  });
};
export { ApplicationContext, NavigationContainer };
//# sourceMappingURL=NavigationContainer.js.map