import 'yet-another-react-lightbox/styles.css'
import './index.css'

import PublishSuccessSubtleIndicator from '@/components/PublishSuccessSubtleIndicator'
import ReadAloudPlayerModal from '@/components/ReadAloudPlayerModal'
import { Toaster } from '@/components/ui/sonner'
import { BookmarksProvider } from '@/providers/BookmarksProvider'
import { NotificationThreadWatchProvider } from '@/providers/NotificationThreadWatchProvider'
import { ContentPolicyProvider } from '@/providers/ContentPolicyProvider'
import { DeletedEventProvider } from '@/providers/DeletedEventProvider'
import { FavoriteRelaysProvider } from '@/providers/FavoriteRelaysProvider'
import { FeedProvider } from '@/providers/FeedProvider'
import { FontSizeProvider } from '@/providers/FontSizeProvider'
import { FollowListProvider } from '@/providers/FollowListProvider'
import { InterestListProvider } from '@/providers/InterestListProvider'
import { KindFilterProvider } from '@/providers/KindFilterProvider'
import { MediaUploadServiceProvider } from '@/providers/MediaUploadServiceProvider'
import { MuteListProvider } from '@/providers/MuteListProvider'
import { NostrProvider } from '@/providers/NostrProvider'
import { ReplyProvider } from '@/providers/ReplyProvider'
import { ScreenSizeProvider } from '@/providers/ScreenSizeProvider'
import { ThemeProvider } from '@/providers/ThemeProvider'
import { LiveActivitiesProvider } from '@/providers/LiveActivitiesProvider'
import { UserPreferencesProvider } from '@/providers/UserPreferencesProvider'
import { ZapProvider } from '@/providers/ZapProvider'
import SlowConnectionHint from '@/components/SlowConnectionHint'
import StartupSessionBanner from '@/components/StartupSessionBanner'
import VersionUpdateBanner from '@/components/VersionUpdateBanner'
import { CacheBrowserProvider } from './contexts/cache-browser-context'
import { PageManager } from './PageManager'

export default function App(): JSX.Element {
  return (
    <ThemeProvider>
      <FontSizeProvider>
        <ContentPolicyProvider>
          <ScreenSizeProvider>
          <DeletedEventProvider>
            <NostrProvider>
              <CacheBrowserProvider>
              <div className="flex h-dvh max-h-dvh min-h-0 flex-col overflow-hidden max-md:h-[var(--vh)] max-md:max-h-[var(--vh)] max-md:min-h-0">
                <VersionUpdateBanner />
                <StartupSessionBanner />
                <SlowConnectionHint />
                <div className="flex min-h-0 min-w-0 flex-1 flex-col">
                  <ZapProvider>
                    <FavoriteRelaysProvider>
                      <FollowListProvider>
                        <MuteListProvider>
                          <InterestListProvider>
                                <BookmarksProvider>
                                  <NotificationThreadWatchProvider>
                                    <FeedProvider>
                                    <ReplyProvider>
                                      <MediaUploadServiceProvider>
                                        <KindFilterProvider>
                                          <UserPreferencesProvider>
                                            <LiveActivitiesProvider>
                                                <PageManager />
                                            </LiveActivitiesProvider>
                                            <ReadAloudPlayerModal />
                                            <PublishSuccessSubtleIndicator />
                                          </UserPreferencesProvider>
                                        </KindFilterProvider>
                                      </MediaUploadServiceProvider>
                                    </ReplyProvider>
                                  </FeedProvider>
                                  </NotificationThreadWatchProvider>
                                </BookmarksProvider>
                            </InterestListProvider>
                        </MuteListProvider>
                      </FollowListProvider>
                    </FavoriteRelaysProvider>
                  </ZapProvider>
                </div>
              </div>
              </CacheBrowserProvider>
            </NostrProvider>
            <Toaster />
          </DeletedEventProvider>
        </ScreenSizeProvider>
      </ContentPolicyProvider>
      </FontSizeProvider>
    </ThemeProvider>
  )
}
