content: // Package imports:
  import 'package:booru_clients/zerochan.dart';
  import 'package:dio/dio.dart';
  import 'package:flutter_riverpod/flutter_riverpod.dart';
  
  // Project imports:
  import '../../core/boorus/defaults/types.dart';
  import '../../core/configs/config.dart';
  import '../../core/configs/create/create.dart';
  import '../../core/downloads/filename/types.dart';
  import '../../core/posts/post/post.dart';
  import '../../core/posts/post/providers.dart';
  import '../../core/tags/autocompletes/types.dart';
  import '../../core/tags/tag/colors.dart';
  import '../../core/tags/tag/tag.dart';
  import 'client_provider.dart';
  import 'posts/providers.dart';
  import 'tags/color.dart';
  import 'tags/providers.dart';
  
  const kZerochanCustomDownloadFileNameFormat =
      '{id}_{width}x{height}.{extension}';
  
  class ZerochanRepository extends BooruRepositoryDefault {
    const ZerochanRepository({required this.ref});
  
    @override
    final Ref ref;
  
    @override
    PostRepository<Post> post(BooruConfigSearch config) {
      return ref.read(zerochanPostRepoProvider(config));
    }
  
    @override
    AutocompleteRepository autocomplete(BooruConfigAuth config) {
      return ref.watch(zerochanAutoCompleteRepoProvider(config));
    }
  
    @override
    BooruSiteValidator? siteValidator(BooruConfigAuth config) {
      final dio = ref.watch(zerochanDioProvider(config));
  
      return () => ZerochanClient(
        dio: dio,
        baseUrl: config.url,
      ).getPosts(strict: true).then((value) => true);
    }
  
    @override
    PostLinkGenerator<Post> postLinkGenerator(BooruConfigAuth config) {
      return DirectIdPathPostLinkGenerator(baseUrl: config.url);
    }
  
    @override
    TagColorGenerator tagColorGenerator() {
      return const ZerochanTagColorGenerator();
    }
  
    @override
    DownloadFilenameGenerator<Post> downloadFilenameBuilder(
      BooruConfigAuth config,
    ) {
      return DownloadFileNameBuilder<Post>(
        defaultFileNameFormat: kZerochanCustomDownloadFileNameFormat,
        defaultBulkDownloadFileNameFormat: kZerochanCustomDownloadFileNameFormat,
        sampleData: kDanbooruPostSamples,
        hasMd5: false,
        hasRating: false,
        tokenHandlers: [
          WidthTokenHandler(),
          HeightTokenHandler(),
          AspectRatioTokenHandler(),
        ],
        asyncTokenHandlers: [
          AsyncTokenHandler(
            ClassicTagsTokenResolver(
              tagExtractor: tagExtractor(config),
            ),
          ),
        ],
      );
    }
  
    @override
    TagExtractor tagExtractor(BooruConfigAuth config) {
      return ref.watch(zerochanTagExtractorProvider(config));
    }
  
    @override
    Dio dio(BooruConfigAuth config) {
      return ref.watch(zerochanDioProvider(config));
    }
  }
  