content: // Flutter imports:
  import 'package:flutter/material.dart';
  
  // Package imports:
  import 'package:flutter_riverpod/flutter_riverpod.dart';
  import 'package:i18n/i18n.dart';
  
  // Project imports:
  import '../../core/boorus/defaults/widgets.dart';
  import '../../core/boorus/engine/engine.dart';
  import '../../core/comments/widgets.dart';
  import '../../core/configs/config.dart';
  import '../../core/configs/config/providers.dart';
  import '../../core/configs/create/widgets.dart';
  import '../../core/configs/manage/widgets.dart';
  import '../../core/downloads/filename/types.dart';
  import '../../core/home/custom_home.dart';
  import '../../core/posts/details/widgets.dart';
  import '../../core/posts/details_parts/types.dart';
  import '../../core/posts/details_parts/widgets.dart';
  import '../../core/search/search/routes.dart';
  import '../../core/search/search/widgets.dart';
  import 'artists/widgets.dart';
  import 'configs/widgets.dart';
  import 'favorites/widgets.dart';
  import 'home/widgets.dart';
  import 'posts/providers.dart';
  import 'posts/types.dart';
  import 'posts/widgets.dart';
  
  class GelbooruBuilder extends BaseBooruBuilder {
    GelbooruBuilder();
  
    @override
    CreateConfigPageBuilder get createConfigPageBuilder =>
        (
          context,
          id, {
          backgroundColor,
        }) => CreateBooruConfigScope(
          id: id,
          config: BooruConfig.defaultConfig(
            booruType: id.booruType,
            url: id.url,
            customDownloadFileNameFormat: kDefaultCustomDownloadFileNameFormat,
          ),
          child: CreateGelbooruConfigPage(
            backgroundColor: backgroundColor,
          ),
        );
  
    @override
    HomePageBuilder get homePageBuilder =>
        (context) => const GelbooruHomePage();
  
    @override
    UpdateConfigPageBuilder get updateConfigPageBuilder =>
        (
          context,
          id, {
          backgroundColor,
          initialTab,
        }) => UpdateBooruConfigScope(
          id: id,
          child: CreateGelbooruConfigPage(
            backgroundColor: backgroundColor,
            initialTab: initialTab,
          ),
        );
  
    @override
    SearchPageBuilder get searchPageBuilder =>
        (context, params) => GelbooruSearchPage(
          params: params,
        );
  
    @override
    PostDetailsPageBuilder get postDetailsPageBuilder => (context, payload) {
      final posts = payload.posts.map((e) => e as GelbooruPost).toList();
  
      return PostDetailsScope(
        initialIndex: payload.initialIndex,
        initialThumbnailUrl: payload.initialThumbnailUrl,
        posts: posts,
        scrollController: payload.scrollController,
        dislclaimer: payload.dislclaimer,
        child: const DefaultPostDetailsPage<GelbooruPost>(),
      );
    };
  
    @override
    FavoritesPageBuilder? get favoritesPageBuilder =>
        (context) => const GelbooruFavoritesPage();
  
    @override
    ArtistPageBuilder? get artistPageBuilder =>
        (context, artistName) => GelbooruArtistPage(
          artistName: artistName,
        );
  
    @override
    CharacterPageBuilder? get characterPageBuilder =>
        (context, characterName) => GelbooruArtistPage(
          artistName: characterName,
        );
  
    @override
    CommentPageBuilder? get commentPageBuilder =>
        (context, useAppBar, postId) => CommentPageScaffold(
          postId: postId,
          useAppBar: useAppBar,
          singlePage: false,
        );
  
    @override
    Map<CustomHomeViewKey, CustomHomeDataBuilder> get customHomeViewBuilders =>
        kGelbooruAltHomeView;
  
    @override
    final postDetailsUIBuilder = PostDetailsUIBuilder(
      preview: {
        DetailsPart.toolbar: (context) =>
            const DefaultInheritedPostActionToolbar<GelbooruPost>(),
      },
      full: {
        DetailsPart.toolbar: (context) =>
            const DefaultInheritedPostActionToolbar<GelbooruPost>(),
        DetailsPart.source: (context) =>
            const DefaultInheritedSourceSection<GelbooruPost>(),
        DetailsPart.tags: (context) =>
            const DefaultInheritedTagsTile<GelbooruPost>(),
        DetailsPart.fileDetails: (context) => const GelbooruFileDetailsSection(),
        DetailsPart.artistPosts: (context) =>
            const DefaultInheritedArtistPostsSection<GelbooruPost>(),
        DetailsPart.characterList: (context) =>
            const DefaultInheritedCharacterPostsSection<GelbooruPost>(),
      },
    );
  }
  
  final kGelbooruAltHomeView = {
    ...kDefaultAltHomeView,
    const CustomHomeViewKey('favorites'): CustomHomeDataBuilder(
      displayName: (context) => context.t.profile.favorites,
      builder: (context, _) => const GelbooruFavoritesPage(),
    ),
  };
  
  class GelbooruSearchPage extends ConsumerWidget {
    const GelbooruSearchPage({
      required this.params,
      super.key,
    });
  
    final SearchParams params;
  
    @override
    Widget build(BuildContext context, WidgetRef ref) {
      final config = ref.watchConfigSearch;
      final postRepo = ref.watch(gelbooruPostRepoProvider(config));
  
      return SearchPageScaffold(
        params: params,
        fetcher: (page, controller) =>
            postRepo.getPostsFromController(controller.tagSet, page),
      );
    }
  }
  