# Data and settings field checklist

Extracted field/declaration lines from domain/database models. Use the linked original for multiline defaults, enum members and method bodies. Serialized spelling, nullability and defaults are compatibility contracts. This is a reading aid, not compilable code.

## [DatabaseEntities.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DatabaseEntities.kt)

```kotlin
7: enum class DbActionType {
18: enum class DbStatus {
31: enum class DbItemType {
38: enum class DbSourceCodeLanguage {
46: enum class DbTrackStatus {
59: enum class DbDisplayType {
67: enum class DbScaleType {
77: enum class DbBackgroundColor {
85: enum class DbReaderMode {
96: enum class DbNovelTextAlign {
104: enum class DbPageMode {
110: enum class DbSectionType {
117: enum class DbDebandingType {
124: enum class DbAudioChannel(val mpvName: String) {
133: enum class DbColorFilterBlendMode {
150: data class DbChangedPart(
151:     val id: Long = 0,
152:     val actionType: DbActionType,
153:     val isarId: Long? = null,
154:     val data: String,
155:     val clientDate: Long,
164: data class DbOutboxOp(
165:     val kind: Int,
166:     val id: Long,
167:     val path: String,
168:     val value: String? = null,
169:     val hlc: Long,
170:     val seq: Long,
172:     val epoch: Int = 0,
176: data class DbCategory(
177:     val id: Long = 0,
178:     val name: String,
179:     val forItemType: DbItemType,
180:     val position: Int? = null,
181:     val hidden: Boolean? = null,
182:     val shouldUpdate: Boolean? = null,
183:     val updatedAt: Long = 0,
187: data class DbChapter(
188:     val id: Long = 0,
189:     val mangaId: Long? = null,
190:     val name: String? = null,
191:     val url: String = "",
192:     val dateUpload: String = "",
193:     val scanlator: String = "",
194:     val isBookmarked: Boolean = false,
195:     val isRead: Boolean = false,
196:     val lastPageRead: String = "",
197:     val archivePath: String = "",
198:     val isFiller: Boolean = false,
199:     val thumbnailUrl: String? = null,
200:     val description: String? = null,
201:     val downloadSize: String? = null,
202:     val duration: String? = null,
203:     val updatedAt: Long = 0,
205:     val fetchedAt: Long = 0,
207:     val number: Double? = null,
208:     val season: Int? = null,
210:     val numberingName: String? = null,
212:     val fillerOverride: Boolean? = null,
216: val DbChapter.effectiveFiller: Boolean get() = fillerOverride ?: isFiller
234:     val firstNumber = first.toLongOrNull()
235:     val secondNumber = second.toLongOrNull()
241: enum class DbFetchType { Seasons, Episodes }
244: data class DbCustomButton(
245:     val id: Long = 0,
246:     val title: String? = null,
247:     val codePress: String? = null,
248:     val codeLongPress: String = "",
249:     val codeStartup: String = "",
250:     val isFavourite: Boolean = false,
251:     val position: Int,
252:     val updatedAt: Long = 0,
263: data class DbDownload(
264:     val id: Long = 0,
265:     val chapterId: Long? = null,
266:     val succeeded: Int? = null,
267:     val failed: Int? = null,
268:     val total: Int? = null,
269:     val isDownload: Boolean? = null,
270:     val isStartDownload: Boolean? = null,
271:     val isPaused: Boolean = false,
272:     val storageLocation: String? = null,
274:     val requestJson: String? = null,
278: data class DbHistory(
279:     val id: Long = 0,
280:     val mangaId: Long? = null,
281:     val chapterId: Long? = null,
282:     val itemType: DbItemType,
283:     val date: String? = null,
284:     val updatedAt: Long = 0,
285:     val readingTimeSeconds: Int? = null,
289: data class DbManga(
290:     val id: Long = 0,
291:     val name: String? = null,
292:     val link: String? = null,
293:     val imageUrl: String? = null,
294:     val description: String? = null,
295:     val author: String? = null,
296:     val artist: String? = null,
297:     val status: DbStatus = DbStatus.Unknown,
298:     val itemType: DbItemType = DbItemType.Manga,
299:     val genre: List<String>? = null,
300:     val favorite: Boolean = false,
301:     val source: String? = null,
302:     val lang: String? = null,
303:     val dateAdded: Long? = null,
304:     val lastUpdate: Long? = null,
305:     val lastRead: Long = 0,
306:     val categories: List<Long>? = null,
307:     val isLocalArchive: Boolean = false,
308:     val customCoverImage: ByteArray? = null,
309:     val customCoverFromTracker: String? = null,
310:     val smartUpdateDays: Int? = null,
311:     val updatedAt: Long = 0,
312:     val sourceId: Long? = null,
314:     val privateNote: String = "",
316:     val nextEpisodeAiringAt: Long = 0,
317:     val nextEpisodeNumber: Int? = null,
318:     val airingScheduleUpdatedAt: Long = 0,
319:     val cast: List<eu.friedcutlet.yokan.domain.TitleCredit> = emptyList(),
321:     val parentId: Long? = null,
322:     val fetchType: DbFetchType = DbFetchType.Episodes,
324:     val seasonNumber: Double? = null,
352:     val byId = associateBy { it.id }
359: data class DbPageUrl(
360:     val url: String,
361:     val fileName: String? = null,
362:     val headers: Map<String, String>? = null,
366: data class DbRepo(
367:     val name: String? = null,
368:     val website: String? = null,
369:     val jsonUrl: String? = null,
370:     val hidden: Boolean? = null,
374: data class DbLocalFolder(
375:     val name: String,
376:     val path: String,
380: data class DbSource(
381:     val id: Long = 0,
382:     val name: String = "",
383:     val baseUrl: String = "",
384:     val lang: String = "",
385:     val isActive: Boolean = true,
386:     val isAdded: Boolean = false,
387:     val isPinned: Boolean = false,
388:     val isNsfw: Boolean = false,
389:     val sourceCode: String = "",
390:     val sourceCodeUrl: String = "",
391:     val typeSource: String = "",
392:     val iconUrl: String = "",
393:     val isFullData: Boolean = false,
394:     val hasCloudflare: Boolean = false,
395:     val lastUsed: Boolean = false,
396:     val dateFormat: String = "",
397:     val dateFormatLocale: String = "",
398:     val apiUrl: String = "",
399:     val version: String = "0.0.1",
400:     val versionLast: String = "0.0.1",
401:     val headers: String = "",
402:     val supportLatest: Boolean? = null,
403:     val filterList: String? = null,
404:     val preferenceList: String? = null,
405:     val itemType: DbItemType = DbItemType.Manga,
406:     val appMinVerReq: String = "",
407:     val additionalParams: String = "",
408:     val isLocal: Boolean = false,
409:     val isObsolete: Boolean = false,
410:     val sourceCodeLanguage: DbSourceCodeLanguage = DbSourceCodeLanguage.JavaScript,
411:     val notes: String = "",
412:     val repo: DbRepo? = null,
413:     val updatedAt: Long = 0,
415:     val isTorrent: Boolean get() = typeSource.lowercase() == "torrent"
419: data class DbSyncPreference(
420:     val syncId: Long? = null,
421:     val email: String? = null,
422:     val authToken: String? = null,
423:     val lastSyncManga: Long? = null,
424:     val lastSyncHistory: Long? = null,
425:     val lastSyncUpdate: Long? = null,
426:     val server: String? = null,
427:     val syncOn: Boolean = false,
428:     val autoSyncFrequency: Int = 0,
429:     val syncHistories: Boolean = false,
430:     val syncUpdates: Boolean = false,
431:     val syncSettings: Boolean = false,
433:     val hubHead: Long = 0,
435:     val hubEpoch: Int = 0,
437:     val hubRecoveryPending: Boolean = false,
439:     val hubBootstrapComplete: Boolean = false,
441:     val hubHlc: Long = 0,
443:     val deviceId: String? = null,
444:     val serverProvider: SyncServerProvider = SyncServerProvider.YokanHub,
445:     val mangayomiIdMappings: String? = null,
449: enum class SyncServerProvider {
459: data class DbTrack(
460:     val id: Long = 0,
461:     val libraryId: Long? = null,
462:     val mediaId: Long? = null,
463:     val mangaId: Long? = null,
464:     val syncId: Int? = null,
465:     val title: String? = null,
466:     val lastChapterRead: Int? = null,
467:     val totalChapter: Int? = null,
468:     val score: Int? = null,
469:     val status: DbTrackStatus,
470:     val startedReadingDate: Long? = null,
471:     val finishedReadingDate: Long? = null,
472:     val trackingUrl: String? = null,
473:     val itemType: DbItemType = DbItemType.Manga,
474:     val updatedAt: Long = 0,
478: data class DbTrackPreference(
479:     val syncId: Long? = null,
480:     val username: String? = null,
481:     val accountName: String? = null,
482:     val accountAvatarUrl: String? = null,
483:     val oauth: String? = null,
484:     val prefs: String? = null,
485:     val refreshing: Boolean? = null,
489: data class DbTrackSearch(
490:     val id: Long? = null,
491:     val libraryId: Long? = null,
492:     val mediaId: Long? = null,
493:     val syncId: Int? = null,
494:     val title: String? = null,
495:     val lastChapterRead: Int? = null,
496:     val totalChapter: Int? = null,
497:     val score: Double? = null,
498:     val status: String = "",
499:     val startedReadingDate: Long? = null,
500:     val finishedReadingDate: Long? = null,
501:     val trackingUrl: String? = null,
502:     val coverUrl: String = "",
503:     val summary: String = "",
504:     val publishingStatus: String = "",
505:     val publishingType: String = "",
506:     val startDate: String = "",
510: data class DbUpdate(
511:     val id: Long = 0,
512:     val mangaId: Long? = null,
513:     val chapterId: Long? = null,
514:     val chapterName: String? = null,
515:     val date: String? = null,
516:     val updatedAt: Long = 0,
520: data class DbVideoTrack(
521:     val file: String? = null,
522:     val label: String? = null,
526: data class DbVideo(
527:     val url: String,
528:     val quality: String,
529:     val originalUrl: String,
530:     val headers: Map<String, String>? = null,
531:     val subtitles: List<DbVideoTrack> = emptyList(),
532:     val audios: List<DbVideoTrack> = emptyList(),
534:     val thumbnailTrack: String? = null,
538: data class DbCookie(
539:     val host: String? = null,
540:     val cookie: String? = null,
544: data class DbSortLibraryManga(
545:     val reverse: Boolean = false,
546:     val index: Int = 0,
550: data class DbSortChapter(
551:     val mangaId: Long? = null,
552:     val reverse: Boolean = false,
553:     val index: Int = 1,
557: data class DbChapterFilter(
558:     val mangaId: Long? = null,
559:     val type: Int = 0,
564: data class DbChapterPageUrls(
565:     val chapterId: Long? = null,
566:     val chapterUrl: String? = null,
567:     val urls: List<String>? = null,
568:     val headers: List<String>? = null,
570:     val fetchedAt: Long? = null,
571:     val sourceId: Long? = null,
573:     val sourceVersion: String? = null,
577: data class DbChapterPageIndex(
578:     val chapterId: Long? = null,
579:     val index: Int? = null,
583: data class DbPersonalReaderMode(
584:     val mangaId: Long? = null,
585:     val readerMode: DbReaderMode = DbReaderMode.Vertical,
589: data class DbAutoScrollPages(
590:     val mangaId: Long? = null,
591:     val pageOffset: Double = 10.0,
592:     val autoScroll: Boolean = false,
596: data class DbPersonalPageMode(
597:     val mangaId: Long? = null,
598:     val pageMode: DbPageMode = DbPageMode.OnePage,
602: data class DbFilterScanlator(
603:     val mangaId: Long? = null,
604:     val scanlators: List<String>? = null,
608: data class DbL10nLocale(
609:     val languageCode: String? = null,
610:     val countryCode: String? = null,
614: data class DbCustomColorFilter(
615:     val a: Int? = null,
616:     val r: Int? = null,
617:     val g: Int? = null,
618:     val b: Int? = null,
622: data class DbPlayerSubtitleSettings(
623:     val fontSize: Int = 45,
624:     val useBold: Boolean = true,
625:     val useItalic: Boolean = false,
626:     val textColorA: Int = 255,
627:     val textColorR: Int = 255,
628:     val textColorG: Int = 255,
629:     val textColorB: Int = 255,
630:     val borderColorA: Int = 255,
631:     val borderColorR: Int = 0,
632:     val borderColorG: Int = 0,
633:     val borderColorB: Int = 0,
634:     val backgroundColorA: Int = 0,
635:     val backgroundColorR: Int = 0,
636:     val backgroundColorG: Int = 0,
637:     val backgroundColorB: Int = 0,
641: data class DbAlgorithmWeights(
642:     val genre: Int = 30,
643:     val setting: Int = 15,
644:     val synopsis: Int = 40,
645:     val theme: Int = 20,
649: data class DbSourcePreference(
650:     val sourceId: Long,
651:     val key: String,
652:     val value: String,
656: data class DbSavedSearch(
657:     val sourceId: Long,
658:     val name: String,
659:     val query: String,
661:     val id: String = "legacy:$sourceId:$name",
662:     val sourceIdentity: DbPresetSource? = null,
663:     val filters: List<DbPresetFilter> = emptyList(),
664:     val presetVersion: Int = 1,
665:     val filterSchemaRecorded: Boolean = false,
667:     val missingSourceIdentity: Boolean = false,
671: data class DbUpdateError(
672:     val mangaId: Long,
673:     val name: String,
674:     val error: String,
```

## [DbActivityFilters.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbActivityFilters.kt)

```kotlin
7: data class DbActivityPreferences(
8:     val updates: Map<DbItemType, DbUpdatesFilter> = emptyMap(),
9:     val upcoming: Map<DbItemType, DbActivityCategoryFilter> = emptyMap(),
21: enum class UpdatesFilterKind { Downloaded, Unread, Started, Bookmarked }
24: data class DbUpdatesFilter(
25:     val downloaded: Int = 0,
26:     val unread: Int = 0,
27:     val started: Int = 0,
28:     val bookmarked: Int = 0,
29:     val hideExcludedScanlators: Boolean = false,
30:     val categories: DbActivityCategoryFilter = DbActivityCategoryFilter(),
40:         val next = (value(kind) + 1) % 3
49:     val active: Boolean get() = UpdatesFilterKind.entries.any { value(it) != 0 } || hideExcludedScanlators || categories.active
54: data class DbActivityCategoryFilter(val states: Map<Long, Int> = emptyMap()) {
58:         val next = (value(id) + 1) % 3
61:     val active: Boolean get() = states.any { (id, value) -> (id > 0 || id == UncategorizedActivityCategoryId) && value in 1..2 }
64: const val UncategorizedActivityCategoryId = -1L
```

## [DbAutomaticUpdateConstraints.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbAutomaticUpdateConstraints.kt)

```kotlin
6: data class DbAutomaticUpdateConstraints(
8:     val network: DbUpdateNetwork = DbUpdateNetwork.Legacy,
9:     val requireExternalPower: Boolean = false,
11:     val unknownNetworkCost: DbUnknownNetworkCost = DbUnknownNetworkCost.Wait,
15: enum class DbUpdateNetwork { Legacy, Connected, Unmetered, Wifi }
18: enum class DbUnknownNetworkCost { Wait, Metered, Unmetered }
```

## [DbBrowsePreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbBrowsePreferences.kt)

```kotlin
8: data class DbBrowsePreferences(
9:     val hideLibraryManga: Boolean = false,
10:     val hideLibraryAnime: Boolean = false,
11:     val hideLibraryNovel: Boolean = false,
```

## [DbChapterReleasePreference.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbChapterReleasePreference.kt)

```kotlin
8: data class DbChapterReleasePreference(
9:     val mangaId: Long? = null,
10:     val scanlatorPriority: List<String> = emptyList(),
11:     val skipDuplicateReleases: Boolean = false,
34:     val ordered = orderedScanlators(priority, available).toMutableList()
35:     val index = ordered.indexOf(normalizeScanlator(scanlator))
36:     val target = index + direction
38:     val value = ordered.removeAt(index)
```

## [DbDiscordPreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbDiscordPreferences.kt)

```kotlin
6: enum class DbDiscordStatus(val gatewayValue: String) { Online("online"), Idle("idle"), DoNotDisturb("dnd") }
10: data class DbDiscordAccount(
11:     val id: String,
12:     val username: String,
13:     val displayName: String = username,
14:     val avatarUrl: String? = null,
15:     val token: String,
21: data class DbDiscordButton(val label: String, val url: String)
23: val DefaultDiscordButtons = listOf(
30: data class DbDiscordPreferences(
31:     val accounts: List<DbDiscordAccount> = emptyList(),
32:     val activeAccountId: String? = null,
33:     val status: DbDiscordStatus = DbDiscordStatus.Online,
34:     val customMessage: String = "",
35:     val showTimestamp: Boolean = true,
36:     val showButtons: Boolean = true,
37:     val buttons: List<DbDiscordButton> = DefaultDiscordButtons,
39:     val alwaysPrivate: Boolean = false,
41:     val privateCategoryIds: Set<Long> = emptySet(),
43:     val activeAccount: DbDiscordAccount? get() = accounts.firstOrNull { it.id == activeAccountId }
51:         val remaining = accounts.filterNot { it.id == id }
52:         val active = activeAccountId.takeIf { it != id && remaining.any { account -> account.id == it } } ?: remaining.firstOrNull()?.id
```

## [DbEinkPreset.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbEinkPreset.kt)

```kotlin
10: enum class DbEinkPreset(val label: String, val width: Int, val height: Int) {
24: val EinkRefreshIntervals = listOf(0, 1, 3, 6, 10, 20)
28:     val shortSide = minOf(width, height)
30:     val scale = maxShortSide.toDouble() / shortSide
```

## [DbExternalDownloads.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbExternalDownloads.kt)

```kotlin
11: data class DbExternalDownloads(
12:     val preferred: PreferredDownloader = PreferredDownloader.BuiltIn,
13:     val endpoint: String = "",
14:     val secret: String = "",
15:     val directory: String = "",
16:     val jobs: List<DbRemoteDownloadJob> = emptyList(),
20: data class DbRemoteDownloadJob(
21:     val id: String,
22:     val chapterId: Long,
23:     val itemType: DbItemType,
24:     val mangaName: String,
25:     val chapterName: String,
26:     val endpoint: String,
28:     val accountBinding: String,
29:     val directory: String,
30:     val files: List<DbRemoteDownloadFile>,
31:     val intent: RemoteDownloadIntent = RemoteDownloadIntent.Run,
32:     val problem: RemoteDownloadProblem = RemoteDownloadProblem.None,
33:     val createdAt: Long = 0,
34:     val mangaId: Long? = null,
35:     val sourceId: Long? = null,
36:     val mangaLink: String? = null,
37:     val chapterUrl: String = "",
38:     val sourceTitleName: String = "",
39:     val sourceChapterName: String = "",
41:     val complete: Boolean get() = files.isNotEmpty() && files.all { it.state == RemoteDownloadState.Complete }
42:     val terminal: Boolean get() = files.isNotEmpty() && files.all { it.state in setOf(RemoteDownloadState.Complete, RemoteDownloadState.Removed) }
46: data class DbRemoteDownloadFile(
47:     val gid: String,
48:     val name: String,
50:     val url: String = "",
51:     val headers: Map<String, String> = emptyMap(),
52:     val state: RemoteDownloadState = RemoteDownloadState.Pending,
53:     val totalBytes: Long = 0,
54:     val completedBytes: Long = 0,
55:     val errorCode: Int? = null,
57:     val resourceBinding: String = "",
```

## [DbFeaturePreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbFeaturePreferences.kt)

```kotlin
11: data class DbFeaturePreferences(
12:     val home: DbHomePreferences = DbHomePreferences(),
13:     val downloads: DbDownloadPolicy = DbDownloadPolicy(),
14:     val imageDataSaver: DbImageDataSaver = DbImageDataSaver(),
15:     val externalDownloads: DbExternalDownloads = DbExternalDownloads(),
16:     val library: DbLibraryPreferences = DbLibraryPreferences(),
17:     val activity: DbActivityPreferences = DbActivityPreferences(),
18:     val tracking: DbTrackingPreferences = DbTrackingPreferences(),
19:     val browse: DbBrowsePreferences = DbBrowsePreferences(),
20:     val syncTriggers: DbSyncTriggerPreferences = DbSyncTriggerPreferences(),
21:     val player: DbPlayerPreferences = DbPlayerPreferences(),
22:     val reader: DbReaderPreferences = DbReaderPreferences(),
23:     val discord: DbDiscordPreferences = DbDiscordPreferences(),
24:     val privacy: DbPrivacyPreferences = DbPrivacyPreferences(),
25:     val torrent: DbTorrentPreferences = DbTorrentPreferences(),
29: data class DbTrackingPreferences(
31:     val autoBindOnAdd: Boolean = false,
36: class DbFeaturePreferencesSerializer : JsonTransformingSerializer<DbFeaturePreferences>(DbFeaturePreferences.serializer()) {
37:     private val legacyHomeKeys = DbHomePreferences.serializer().descriptor.let { descriptor ->
41:         val obj = element as? JsonObject ?: return element
47: data class DbDownloadPolicy(
48:     val splitTallImages: Boolean = false,
49:     val splitImageHeight: Int = 4096,
50:     val autoDownloadNew: Boolean = false,
51:     val includeCategoryIds: Set<Long> = emptySet(),
52:     val excludeCategoryIds: Set<Long> = emptySet(),
53:     val unreadOnly: Boolean = true,
54:     val includeFiller: Boolean = false,
55:     val aheadManga: Int = 0,
56:     val aheadAnime: Int = 0,
57:     val aheadNovel: Int = 0,
58:     val cleanupAfterConsumption: Boolean = false,
59:     val cleanupAfterManualMark: Boolean = false,
60:     val keepLastConsumed: Int = 0,
61:     val protectBookmarks: Boolean = true,
62:     val cleanupExcludedCategoryIds: Set<Long> = emptySet(),
64:     val pendingNewChapterIds: Set<Long> = emptySet(),
66:     val consumedChapterIds: Set<Long> = emptySet(),
67:     val manuallyMarkedChapterIds: Set<Long> = emptySet(),
```

## [DbHomePreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbHomePreferences.kt)

```kotlin
6: enum class HomeMediaFilter { All, Anime, Manga, Novel, Movie, Series }
10: enum class HomeSection { Continue, Recommended, BecauseYouRead, PopularAnime, PopularManga, PopularNovels, PopularMovies, PopularSeries, Sources, TmdbRecommended }
13: data class DbHomePreferences(
14:     val filter: HomeMediaFilter = HomeMediaFilter.All,
15:     val showFeatured: Boolean = true,
16:     val autoAdvanceFeatured: Boolean = false,
17:     val featuredLibraryOnly: Boolean = false,
18:     val itemsPerShelf: Int = 12,
19:     val hideCompleted: Boolean = false,
20:     val enableAniList: Boolean = true,
21:     val enableTmdb: Boolean = false,
22:     val hiddenSections: Set<HomeSection> = emptySet(),
23:     val sourceFeeds: List<DbHomeSourceFeed> = emptyList(),
24:     val tmdbReadAccessToken: String = "",
32: enum class HomeFeedMode { Popular, Latest, SavedSearch }
36: data class DbHomeSourceFeed(
37:     val sourceId: Long,
38:     val mode: HomeFeedMode = HomeFeedMode.Popular,
39:     val presetId: String? = null,
41:     val key: String get() = "$sourceId:${mode.name}:${presetId.orEmpty()}"
```

## [DbImageDataSaver.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbImageDataSaver.kt)

```kotlin
9: data class DbImageDataSaver(
10:     val provider: ImageSaverProvider = ImageSaverProvider.Off,
11:     val forReader: Boolean = true,
12:     val forDownloads: Boolean = false,
13:     val quality: Int = 80,
14:     val format: ImageSaverFormat = ImageSaverFormat.Webp,
15:     val grayscale: Boolean = false,
16:     val skipJpeg: Boolean = false,
17:     val skipGif: Boolean = true,
18:     val excludedSourceIds: Set<Long> = emptySet(),
19:     val bandwidthHeroUrl: String = "",
```

## [DbLibraryPreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbLibraryPreferences.kt)

```kotlin
6: data class DbLibraryPreferences(
8:     val defaultCategoryIds: Map<DbItemType, Long> = emptyMap(),
9:     val groupingByType: Map<DbItemType, DbLibraryGrouping> = emptyMap(),
10:     val categoryPreferences: Map<DbItemType, Map<Long, DbCategoryLibraryPreferences>> = emptyMap(),
11:     val extraFilters: Map<DbItemType, DbLibraryExtraFilters> = emptyMap(),
12:     val randomSeeds: Map<DbItemType, Long> = emptyMap(),
13:     val updateRulesByType: Map<DbItemType, DbSmartUpdateRules> = emptyMap(),
14:     val updateGroupModes: Map<DbItemType, DbGroupUpdateMode> = emptyMap(),
15:     val deviceConstraints: DbAutomaticUpdateConstraints = DbAutomaticUpdateConstraints(),
17:     val chapterListDefaults: Map<DbItemType, DbChapterListDefaults> = emptyMap(),
19:     val chapterFillerFilters: Map<Long, Int> = emptyMap(),
45:         val updated = if (preferences == null) categories(type) - id else categories(type) + (id to preferences)
57: data class DbSmartUpdateRules(
58:     val skipCompleted: Boolean = false,
59:     val onlyCaughtUp: Boolean = false,
60:     val onlyStarted: Boolean = false,
62:     val respectExpectedReleasePeriod: Boolean = true,
67: data class DbChapterListDefaults(
68:     val sortIndex: Int = 1,
69:     val sortReverse: Boolean = false,
70:     val downloaded: Int = 0,
71:     val unread: Int = 0,
72:     val bookmarked: Int = 0,
73:     val filler: Int = 0,
77: enum class DbGroupUpdateMode { Global, CurrentGroup, CurrentExceptUngrouped }
80: data class DbLibraryExtraFilters(
82:     val providerTracking: Map<Int, Int> = emptyMap(),
83:     val customInterval: Int = 0,
87: enum class DbLibraryGrouping { Categories, Source, Status, TrackerStatus, Tags, Ungrouped }
90: data class DbCategoryLibraryPreferences(
91:     val sort: DbSortLibraryManga? = null,
92:     val display: DbCategoryLibraryDisplay? = null,
97: data class DbCategoryLibraryDisplay(
98:     val displayType: DbDisplayType = DbDisplayType.ComfortableGrid,
99:     val gridSize: Int = 0,
100:     val downloadBadges: Boolean = true,
101:     val language: Boolean = false,
102:     val source: Boolean = false,
103:     val localBadge: Boolean = true,
104:     val continueButton: Boolean = true,
```

## [DbPlayerPreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbPlayerPreferences.kt)

```kotlin
6: val DefaultPlaybackSpeedPresets: List<Double> = listOf(0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0)
10: data class DbPlayerPreferences(
11:     val speedPresets: List<Double> = DefaultPlaybackSpeedPresets,
12:     val rememberVolume: Boolean = false,
14:     val volume: Int = -1,
15:     val rememberBrightness: Boolean = false,
17:     val brightness: Float = -1f,
19:     val switchStreamOnFailure: Boolean = false,
21:     val subtitleLanguages: List<String> = emptyList(),
23:     val subtitleWhitelist: List<String> = emptyList(),
25:     val subtitleBlacklist: List<String> = emptyList(),
26:     val screenshotSubtitles: Boolean = false,
28:     val pipEnabled: Boolean = true,
30:     val pipOnExit: Boolean = false,
31:     val pipEpisodeToasts: Boolean = true,
33:     val pipReplaceWithPrevious: Boolean = false,
34:     val alwaysUseExternalPlayer: Boolean = false,
36:     val externalPlayer: String = "",
```

## [DbPrivacyPreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbPrivacyPreferences.kt)

```kotlin
7: enum class DbSecureScreen { Never, Incognito, Always }
10: data class DbPrivacyPreferences(
11:     val secureScreen: DbSecureScreen = DbSecureScreen.Never,
13:     val hideNotificationContent: Boolean = false,
15:     val appLockTimeoutMinutes: Int = 0,
17:     val incognitoSourceIds: Set<Long> = emptySet(),
30: val AppLockTimeoutChoices = listOf(0, 1, 2, 5, 10, -1)
```

## [DbReaderPreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbReaderPreferences.kt)

```kotlin
7: data class DbReaderModePreferences(
8:     val cropBorders: Boolean = false,
9:     val animatePageTransitions: Boolean = true,
10:     val usePageTapZones: Boolean = true,
11:     val navigationLayout: Int = 0,
13:     val splitWidePages: Boolean = false,
14:     val invertSplit: Boolean = false,
16:     val rotateWidePages: Boolean = false,
17:     val invertRotation: Boolean = false,
22: data class DbReaderPreferences(
24:     val paged: DbReaderModePreferences? = null,
25:     val webtoon: DbReaderModePreferences? = null,
26:     val skipReadChapters: Boolean = false,
27:     val skipFilteredChapters: Boolean = true,
28:     val alwaysShowChapterTransition: Boolean = true,
29:     val saveImagesInTitleFolder: Boolean = false,
30:     val volumeKeyNavigation: Boolean = false,
31:     val invertVolumeKeys: Boolean = false,
47:     val updated = transform(readerModePreferences(paged))
```

## [DbSettings.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbSettings.kt)

```kotlin
8: enum class DbNovelReadingMode { Scroll, Paged }
11: enum class DbNovelPageMode { Single, Double, Auto }
14: enum class DbGlobalStatusVisibility {
21: data class DbTitleMetadata(
22:     val mangaId: Long,
23:     val metadataServerId: String? = null,
24:     val metadataSource: String? = null,
25:     val titles: List<String> = emptyList(),
26:     val updatedAt: Long = 0,
30: data class DbAutomaticReaderLayout(val mangaId: Long, val enabled: Boolean = true, val fallback: DbReaderMode? = null)
34: data class DbSettings(
37:     val features: DbFeaturePreferences = DbFeaturePreferences(),
38:     val id: Long = 227,
39:     val updatedAt: Long = 0,
40:     val completedOnboardingVersion: Int = 0,
41:     val displayType: DbDisplayType = DbDisplayType.CompactGrid,
42:     val libraryFilterMangasDownloadType: Int = 0,
43:     val libraryFilterMangasUnreadType: Int = 0,
44:     val libraryFilterMangasStartedType: Int = 0,
45:     val libraryFilterMangasBookMarkedType: Int = 0,
46:     val libraryShowCategoryTabs: Boolean = false,
47:     val libraryDownloadedChapters: Boolean = false,
48:     val libraryShowLanguage: Boolean = false,
49:     val libraryShowSource: Boolean = false,
50:     val libraryShowNumbersOfItems: Boolean = false,
51:     val libraryShowContinueReadingButton: Boolean = false,
52:     val libraryLocalSource: Boolean? = null,
53:     val librarySearchQuery: String = "",
54:     val sortLibraryManga: DbSortLibraryManga? = null,
55:     val sortChapterList: List<DbSortChapter>? = null,
56:     val chapterFilterDownloadedList: List<DbChapterFilter>? = null,
57:     val chapterFilterUnreadList: List<DbChapterFilter>? = null,
58:     val chapterFilterBookmarkedList: List<DbChapterFilter>? = null,
59:     val flexColorSchemeBlendLevel: Double = 10.0,
60:     val dateFormat: String = "M/d/y",
61:     val relativeTimesTamps: Int = 2,
62:     val flexSchemeColorIndex: Int = 2,
63:     val themeIsDark: Boolean = false,
64:     val followSystemTheme: Boolean = false,
65:     val incognitoMode: Boolean = false,
66:     val showPagesNumber: Boolean = true,
67:     val chapterPageIndexList: List<DbChapterPageIndex>? = null,
68:     val userAgent: String = DefaultUserAgent,
69:     val cookiesList: List<DbCookie>? = null,
70:     val defaultReaderMode: DbReaderMode = DbReaderMode.Vertical,
71:     val automaticReaderLayout: Boolean = false,
72:     val readerHoldToScroll: Boolean = false,
74:     val einkMode: Boolean = false,
75:     val einkPreset: DbEinkPreset = DbEinkPreset.KindlePaperwhite,
76:     val einkRefreshEveryPages: Int = 6,
78:     val einkOptimizeDownloads: Boolean = false,
79:     val automaticReaderLayouts: List<DbAutomaticReaderLayout> = emptyList(),
80:     val personalReaderModeList: List<DbPersonalReaderMode>? = null,
81:     val animatePageTransitions: Boolean = true,
82:     val doubleTapAnimationSpeed: Int = 1,
83:     val onlyIncludePinnedSources: Boolean = false,
84:     val pureBlackDarkMode: Boolean = false,
85:     val downloadOnlyOnWifi: Boolean = false,
86:     val saveAsCBZArchive: Boolean = false,
87:     val deleteDownloadAfterReading: Boolean = false,
88:     val concurrentDownloads: Int = 2,
89:     val allowConcurrentDownloads: Boolean = true,
90:     val downloadDelaySeconds: Int = 0,
91:     val downloadQueueOrder: List<Long> = emptyList(),
92:     val networkDownloadSpeedLimitKib: Int = 0,
93:     val networkUploadSpeedLimitKib: Int = 0,
94:     val downloadLocation: String = "",
95:     val filterScanlatorList: List<DbFilterScanlator>? = null,
96:     val chapterReleasePreferences: List<DbChapterReleasePreference> = emptyList(),
97:     val autoExtensionsUpdates: Boolean = false,
99:     val developerMode: Boolean = false,
101:     val customHubServers: List<String> = emptyList(),
102:     val cropBorders: Boolean = false,
103:     val locale: DbL10nLocale? = null,
104:     val defaultSubtitleLang: DbL10nLocale? = null,
105:     val animeDisplayType: DbDisplayType = DbDisplayType.CompactGrid,
106:     val libraryFilterAnimeDownloadType: Int = 0,
107:     val libraryFilterAnimeUnreadType: Int = 0,
108:     val libraryFilterAnimeStartedType: Int = 0,
109:     val libraryFilterAnimeBookMarkedType: Int = 0,
110:     val animeLibraryShowCategoryTabs: Boolean = false,
111:     val animeLibraryDownloadedChapters: Boolean = false,
112:     val animeLibraryShowLanguage: Boolean = false,
113:     val animeLibraryShowSource: Boolean = false,
114:     val animeLibraryShowNumbersOfItems: Boolean = false,
115:     val animeLibraryShowContinueReadingButton: Boolean = false,
116:     val animeLibraryLocalSource: Boolean? = null,
117:     val animeLibrarySearchQuery: String = "",
118:     val sortLibraryAnime: DbSortLibraryManga? = null,
119:     val pagePreloadAmount: Int = 6,
120:     val enableLogs: Boolean = false,
121:     val checkForAppUpdates: Boolean = true,
122:     val checkForExtensionUpdates: Boolean = true,
123:     val scaleType: DbScaleType = DbScaleType.FitScreen,
124:     val backgroundColor: DbBackgroundColor = DbBackgroundColor.Black,
125:     val personalPageModeList: List<DbPersonalPageMode>? = null,
126:     val startDateBackup: Long? = null,
127:     val backupFrequency: Int? = null,
128:     val backupListOptions: List<Int>? = null,
129:     val autoBackupLocation: String? = null,
130:     val usePageTapZones: Boolean = true,
131:     val alwaysShowChrome: Boolean = false,
132:     val autoScrollPages: List<DbAutoScrollPages>? = null,
133:     val autoScrollSpeed: Double = 4.0,
140:     val enableFileLogging: Boolean = false,
141:     val markEpisodeAsSeenType: Int = 85,
142:     val defaultSkipIntroLength: Int = 85,
143:     val defaultDoubleTapToSkipLength: Int = 10,
144:     val defaultPlaybackSpeed: Double = 1.0,
145:     val fullScreenPlayer: Boolean = false,
146:     val forceLandscapePlayer: Boolean = false,
148:     val desktopUseVlcj: Boolean = false,
149:     val updateProgressAfterReading: Boolean = true,
150:     val enableAniSkip: Boolean? = null,
151:     val enableAutoSkip: Boolean? = null,
152:     val aniSkipTimeoutLength: Int? = null,
153:     val customDns: String = "",
154:     val dohEnabled: Boolean = false,
155:     val dohProviderId: Int = 0,
156:     val customDohUrl: String = "",
157:     val cloudflareBypassProxyUrl: String = "",
158:     val btServerAddress: String = "127.0.0.1",
159:     val btServerPort: Int? = null,
160:     val fullScreenReader: Boolean = true,
161:     val customColorFilter: DbCustomColorFilter? = null,
162:     val enableCustomColorFilter: Boolean = false,
163:     val colorFilterBlendMode: DbColorFilterBlendMode = DbColorFilterBlendMode.None,
164:     val playerSubtitleSettings: DbPlayerSubtitleSettings? = null,
165:     val mangaHomeDisplayType: DbDisplayType = DbDisplayType.ComfortableGrid,
166:     val appFontFamily: String? = null,
168:     val uiScale: Double = 1.0,
169:     val autoUiScale: Boolean = false,
170:     val mangaGridSize: Int? = null,
171:     val animeGridSize: Int? = null,
172:     val novelGridSize: Int? = null,
173:     val mangaExtensionsRepo: List<DbRepo>? = null,
174:     val animeExtensionsRepo: List<DbRepo>? = null,
175:     val novelExtensionsRepo: List<DbRepo>? = null,
176:     val androidProxyServer: String? = null,
177:     val jrePath: String = "",
178:     val extensionServerPath: String = "",
179:     val disableSectionType: DbSectionType = DbSectionType.All,
180:     val useLibass: Boolean = true,
181:     val hwdecMode: String = "auto",
182:     val enableHardwareAcceleration: Boolean? = null,
183:     val libraryFilterNovelDownloadType: Int = 0,
184:     val libraryFilterNovelUnreadType: Int = 0,
185:     val libraryFilterNovelStartedType: Int = 0,
186:     val libraryFilterNovelBookMarkedType: Int = 0,
187:     val novelLibraryShowCategoryTabs: Boolean = false,
188:     val novelLibraryDownloadedChapters: Boolean = false,
189:     val novelLibraryShowLanguage: Boolean = false,
190:     val novelLibraryShowSource: Boolean = false,
191:     val novelLibraryShowNumbersOfItems: Boolean = false,
192:     val novelLibraryShowContinueReadingButton: Boolean = false,
193:     val novelLibraryLocalSource: Boolean? = null,
194:     val novelLibrarySearchQuery: String = "",
195:     val sortLibraryNovel: DbSortLibraryManga? = null,
196:     val novelDisplayType: DbDisplayType = DbDisplayType.ComfortableGrid,
197:     val novelFontSize: Int = 14,
198:     val novelReadingMode: DbNovelReadingMode = DbNovelReadingMode.Scroll,
199:     val novelPageMode: DbNovelPageMode = DbNovelPageMode.Auto,
200:     val novelFontFamily: String = "Default",
201:     val novelTextAlign: DbNovelTextAlign = DbNovelTextAlign.Left,
202:     val novelReaderTheme: String = "#292832",
203:     val novelReaderTextColor: String = "#CCCCCC",
204:     val novelReaderPadding: Int = 16,
205:     val novelReaderLineHeight: Double = 1.5,
206:     val novelShowScrollPercentage: Boolean = true,
207:     val novelRemoveExtraParagraphSpacing: Boolean = false,
208:     val novelTapToScroll: Boolean = false,
209:     val navigationOrder: List<String>? = null,
210:     val hideItems: List<String>? = null,
211:     val clearChapterCacheOnAppLaunch: Boolean = false,
212:     val lastTrackerLibraryLocation: String? = null,
213:     val mergeLibraryNavMobile: Boolean = false,
214:     val showLocalLibraryNavigation: Boolean = false,
215:     val enableDiscordRpc: Boolean = true,
216:     val hideDiscordRpcInIncognito: Boolean = true,
217:     val rpcShowReadingWatchingProgress: Boolean = true,
218:     val rpcShowTitle: Boolean = true,
219:     val rpcShowCoverImage: Boolean = true,
220:     val useMpvConfig: Boolean = true,
221:     val debandingType: DbDebandingType = DbDebandingType.None,
222:     val enableGpuNext: Boolean = false,
223:     val useYuv420p: Boolean = false,
224:     val audioPreferredLanguages: String? = null,
225:     val enableAudioPitchCorrection: Boolean? = null,
226:     val audioChannels: DbAudioChannel = DbAudioChannel.AutoSafe,
227:     val volumeBoostCap: Int? = null,
228:     val downloadedOnlyMode: Boolean = false,
229:     val globalStatusVisibility: DbGlobalStatusVisibility = DbGlobalStatusVisibility.Automatic,
230:     val algorithmWeights: DbAlgorithmWeights? = null,
231:     val sourcePreferences: List<DbSourcePreference>? = null,
232:     val savedSearches: List<DbSavedSearch>? = null,
233:     val updateErrors: List<DbUpdateError>? = null,
234:     val tvUiScale: Double? = null,
235:     val animeOnlyTvMode: Boolean? = null,
236:     val tvHomeStyle: Boolean? = null,
237:     val trackerOrder: List<Int>? = null,
239:     val localFolders: List<String>? = null,
240:     val namedLocalFolders: List<DbLocalFolder>? = null,
241:     val downloadLocalFolderName: String? = null,
242:     val askDownloadDestination: Boolean = true,
244:     val themeSeedColor: Int? = null,
246:     val themeSeedImagePath: String? = null,
248:     val materialYou: Boolean = false,
250:     val materialExpressive: Boolean = false,
252:     val themePaletteStyle: String = "TonalSpot",
253:     val appLockEnabled: Boolean = false,
254:     val libraryFilterMangasCompletedType: Int = 0,
255:     val libraryFilterAnimeCompletedType: Int = 0,
256:     val libraryFilterNovelCompletedType: Int = 0,
257:     val libraryFilterMangasTrackingType: Int = 0,
258:     val libraryFilterAnimeTrackingType: Int = 0,
259:     val libraryFilterNovelTrackingType: Int = 0,
260:     val keepScreenOnReader: Boolean = true,
261:     val webtoonSidePadding: Int = 0,
262:     val showPageGaps: Boolean = true,
263:     val autoReadDuplicateChapters: Boolean = false,
264:     val invertColors: Boolean = false,
265:     val grayscale: Boolean = false,
266:     val readerBrightness: Double = 0.0,
267:     val readerContrast: Double = 1.0,
268:     val readerSaturation: Double = 1.0,
269:     val readerNavigationLayout: Int = 0,
270:     val backupCompressionLevel: Int? = null,
271:     val backupEncryptionEnabled: Boolean = false,
272:     val backupEncryptionPassword: String? = null,
273:     val showNsfw: Boolean = false,
274:     val ttsSpeechRate: Double = 0.5,
275:     val ttsPitch: Double = 1.0,
276:     val ttsLanguage: String? = null,
277:     val ttsVoice: String? = null,
279:     val metadataServerUrl: String = "http://127.0.0.1:3000",
281:     val metadataServerEnabled: Boolean = false,
283:     val metadataRefreshFrequencySeconds: Int = 0,
285:     val metadataServerToken: String = "",
287:     val libraryUpdateFrequencySeconds: Int = 0,
292:     val libraryUpdateDailyAtMinutes: Int = -1,
294:     val desktopCloseToTray: Boolean = false,
296:     val desktopLaunchAtLogin: Boolean = false,
298:     val titleMetadata: List<DbTitleMetadata>? = null,
300:     val syncIdentityVersion: Int = 0,
302:     val home: DbHomePreferences get() = features.home
305: const val DefaultUserAgent =
```

## [DbSourcePreset.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbSourcePreset.kt)

```kotlin
8: data class DbPresetSource(
9:     val name: String,
10:     val baseUrl: String,
11:     val lang: String,
12:     val itemType: DbItemType,
13:     val runtime: DbSourceCodeLanguage,
14:     val typeSource: String,
15:     val repository: String,
19: data class DbPresetOption(val label: String, val value: String)
22: data class DbPresetFilter(
23:     val id: String,
24:     val name: String,
25:     val type: String,
26:     val kind: String,
27:     val stableId: Boolean,
28:     val options: List<DbPresetOption>,
29:     val defaultValue: String?,
30:     val defaultAscending: Boolean = true,
31:     val selection: DbPresetSelection? = null,
35: sealed interface DbPresetSelection {
53:     val byId = sources.associateBy { it.id }
56:             val source = byId[preset.sourceId]
```

## [DbSyncTriggerPreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbSyncTriggerPreferences.kt)

```kotlin
7: data class DbSyncTriggerPreferences(
8:     val onChapterRead: Boolean = false,
9:     val onChapterOpen: Boolean = false,
10:     val onEpisodeSeen: Boolean = false,
11:     val onEpisodeOpen: Boolean = false,
12:     val onAppStart: Boolean = false,
13:     val onAppResume: Boolean = false,
```

## [DbTorrentPreferences.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbTorrentPreferences.kt)

```kotlin
12: data class DbTorrentPreferences(
13:     val enabled: Boolean = false,
14:     val mode: TorrServerMode = TorrServerMode.Managed,
15:     val port: Int = 8090,
17:     val executablePath: String = "",
18:     val remoteUrl: String = "",
19:     val username: String = "",
20:     val password: String = "",
22:     val trackers: String = DefaultTorrentTrackers,
23:     val proxyMode: TorrServerProxyMode = TorrServerProxyMode.None,
24:     val proxyUrl: String = "",
31: val DefaultTorrentTrackers = """
```

## [InMemoryYokanDatabase.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/InMemoryYokanDatabase.kt)

```kotlin
17: internal const val MAX_PAGE_CACHE = 100
19: class InMemoryYokanDatabase(
22:     private val lock = PlatformLock()
23:     private var settings = initial.settings
24:     private val mangas = Table(initial.mangas, DbManga::id)
25:     private val chapters = Table(initial.chapters, DbChapter::id)
26:     private val categories = Table(initial.categories, DbCategory::id)
27:     private val sources = Table(initial.sources, DbSource::id)
28:     private val histories = Table(initial.histories, DbHistory::id)
29:     private val updates = Table(initial.updates, DbUpdate::id)
30:     private val downloads = Table(initial.downloads, DbDownload::id)
31:     private val tracks = Table(initial.tracks, DbTrack::id)
32:     private val trackPreferences = initial.trackPreferences.toMutableList()
33:     private val trackSearches = initial.trackSearches.toMutableList()
34:     private val syncPreferences = initial.syncPreferences.toMutableList()
35:     private val changedParts = Table(initial.changedParts, DbChangedPart::id)
36:     private val customButtons = Table(initial.customButtons, DbCustomButton::id)
37:     private val pageCache = initial.pageCache.toMutableList()
40:     private val outbox = LinkedHashMap<OutboxKey, DbOutboxOp>()
41:     private var outboxSeq = initial.outbox.maxOfOrNull { it.seq } ?: 0L
42:     private var suppressOutbox = 0
43:     private var batchDepth = 0
44:     private var newOutboxOps: MutableList<DbOutboxOp>? = null
45:     private var lastDocValue: Any? = null
46:     private var lastDoc: JsonObject? = null
47:     private val dirtySnapshotParts = mutableSetOf<SnapshotPart>()
56:     private val snapshotState = MutableStateFlow(createSnapshot())
83:         val before = current()
84:         val replacement = if (suppressOutbox > 0) snapshot else snapshot.withMangayomiLocalSyncTimestamps(before)
139:         val before = this.settings
154:         val identified = if (manga.id == 0L) assignId(manga) else manga
155:         val old = mangas[identified.id]
156:         val value = localTimestamp(identified, old, SyncPaths.KIND_MANGA, DbManga.serializer(), DbManga::updatedAt) { row, at -> row.copy(updatedAt = at) }
172:         val identified = if (chapter.id == 0L) assignId(chapter) else chapter
173:         val old = chapters[identified.id]
174:         val value = localTimestamp(identified, old, SyncPaths.KIND_CHAPTER, DbChapter.serializer(), DbChapter::updatedAt) { row, at -> row.copy(updatedAt = at) }
189:         val identified = if (category.id == 0L) assignId(category) else category
190:         val old = categories[identified.id]
191:         val value = localTimestamp(identified, old, SyncPaths.KIND_CATEGORY, DbCategory.serializer(), DbCategory::updatedAt) { row, at -> row.copy(updatedAt = at) }
225:         val identified = if (history.id == 0L) assignId(history) else history
226:         val old = histories[identified.id]
227:         val value = localTimestamp(identified, old, SyncPaths.KIND_HISTORY, DbHistory.serializer(), DbHistory::updatedAt) { row, at -> row.copy(updatedAt = at) }
239:         val identified = if (update.id == 0L) assignId(update) else update
240:         val old = updates[identified.id]
241:         val value = localTimestamp(identified, old, SyncPaths.KIND_UPDATE, DbUpdate.serializer(), DbUpdate::updatedAt) { row, at -> row.copy(updatedAt = at) }
268:         val identified = if (track.id == 0L) assignId(track) else track
269:         val old = tracks[identified.id]
270:         val value = localTimestamp(identified, old, SyncPaths.KIND_TRACK, DbTrack.serializer(), DbTrack::updatedAt) { row, at -> row.copy(updatedAt = at) }
304:         val current = syncPreferences.firstOrNull { it.syncId == syncId }
306:         val updated = transform(current).copy(syncId = syncId)
315:         val used = changedParts.rows.mapTo(HashSet(), DbChangedPart::id)
316:         var id = change.id.takeIf { it > 0 && it !in used } ?: SyncIds.random()
369:         val outer = newOutboxOps
370:         val ops = ArrayList<DbOutboxOp>()
383:             val key = op.key()
390:         val current = syncPreferences.firstOrNull { it.syncId == syncId }
392:         val (updated, dropBefore) = current.hubResync(epoch)
426:         val epoch = activeHubEpoch() ?: return
427:         val beforeDoc = before?.let { docOf(kind, serializer, it) }
433:         val epoch = activeHubEpoch() ?: return
439:             val op = DbOutboxOp(
456:         val cached = lastDoc
465:         val key = op.key()
505:         var next = snapshotState.value
530:     private enum class SnapshotPart {
555:         val normalized = if (table.key(item) == 0L) assignId(item) else item
556:         val id = table.key(normalized)
557:         val index = table.indexOf(id)
558:         val previous = if (index >= 0) table.rows[index] else null
569:         val itemKey = key(item)
570:         val index = if (itemKey == null) -1 else items.indexOfFirst { key(it) == itemKey }
603: private class Table<T>(initial: List<T>, val key: (T) -> Long) {
604:     val rows = ArrayList(initial)
605:     private var index: HashMap<Long, Int>? = null
608:         val map = index ?: HashMap<Long, Int>(rows.size).also { built ->
632: private data class OutboxKey(val kind: Int, val id: Long, val path: String)
```

## [LocalFolders.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/LocalFolders.kt)

```kotlin
22: const val DefaultLocalFolderName: String = "local"
31:     val legacy = localFolders ?: return emptyList()
41:     val configured = configuredLocalFolders()
62:     val folderName = folder.name.trim()
63:     val folderPath = folder.path
65:     val relative = relativePath(folderPath, entityPath)
77:     val normalized = normalizePath(storedPath)
78:     val firstSegment = normalized.substringBefore('/', missingDelimiterValue = normalized)
83:         val normalizedFolderPath = normalizePath(folder.path)
89:     val legacyMarker = "Mangayomi/local"
90:     val legacyIndex = normalized.indexOf(legacyMarker)
92:         val relative = normalized.substring(legacyIndex + legacyMarker.length).trimStart('/')
106:     val normalized = normalizePath(virtualPath)
107:     val firstSeparator = normalized.indexOf('/')
108:     val (name, rest) = if (firstSeparator < 0) normalized to "" else
110:     val folder = folders.firstOrNull { it.name == name } ?: return virtualPath
112:     val base = folder.path.trimEnd('/', '\\')
121:     val used = mutableSetOf(DefaultLocalFolderName)
122:     val result = mutableListOf<DbLocalFolder>()
124:         val path = folder.path.trim()
126:         val rawName = folder.name.trim().ifEmpty { nameFromPath(path) }
127:         val name = uniqueLocalFolderName(rawName, used)
135:     val sanitized = value.replace('/', '_').replace('\\', '_').trim()
136:     val base = sanitized.ifEmpty { "Local" }
138:     var candidate = if (base.equals(DefaultLocalFolderName, ignoreCase = true)) "Local" else base
139:     var index = 2
148:     val parts = path.replace('\\', '/').split('/').filter { it.isNotBlank() }
156:     val normalizedBase = normalizePath(base)
157:     val normalizedTarget = normalizePath(target)
```

## [PersistentDatabase.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/PersistentDatabase.kt)

```kotlin
29: data class PersistedDatabaseSnapshot(
30:     val schemaVersion: Int = CurrentDatabaseSchemaVersion,
31:     val snapshot: YokanDatabaseSnapshot,
34: const val CurrentDatabaseSchemaVersion = 1
36: val DatabaseJson = Json {
```

## [SeedDatabase.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/SeedDatabase.kt)

```kotlin
11:     val settings = DbSettings(
```

## [SnapshotYokanDatabase.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/SnapshotYokanDatabase.kt)

```kotlin
13: internal class SnapshotYokanDatabase(
14:     private val store: DatabaseSnapshotStore,
15:     private val memory: InMemoryYokanDatabase = InMemoryYokanDatabase(store.load() ?: seedDatabaseSnapshot()),
16:     private val stopPersistence: suspend () -> Unit = {},
18:     private val retirementLock = Mutex()
19:     private var closed = false
20:     private val _saveFailed = MutableStateFlow(false)
21:     val saveFailed = _saveFailed.asStateFlow()
24:     private var persisted: YokanDatabaseSnapshot? = null
59:             val preview = InMemoryYokanDatabase(memory.snapshot())
61:             val target = preview.snapshot()
```

## [YokanDatabase.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/YokanDatabase.kt)

```kotlin
8: data class YokanDatabaseSnapshot(
9:     val settings: DbSettings,
10:     val mangas: List<DbManga>,
11:     val chapters: List<DbChapter>,
12:     val categories: List<DbCategory>,
13:     val sources: List<DbSource>,
14:     val histories: List<DbHistory>,
15:     val updates: List<DbUpdate>,
16:     val downloads: List<DbDownload>,
17:     val tracks: List<DbTrack>,
18:     val trackPreferences: List<DbTrackPreference>,
19:     val trackSearches: List<DbTrackSearch>,
20:     val syncPreferences: List<DbSyncPreference>,
21:     val changedParts: List<DbChangedPart>,
22:     val customButtons: List<DbCustomButton>,
23:     val pageCache: List<DbChapterPageUrls>,
25:     val outbox: List<DbOutboxOp> = emptyList(),
28: class SnapshotReplacementConflictException : IllegalStateException(
125:         val current = syncPreferences().firstOrNull { it.syncId == syncId }
166:         val oldById = oldRows.associateBy(id)
168:             val old = oldById[id(row)] ?: return@map row
```

## [HubResync.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/sync/HubResync.kt)

```kotlin
10:     val initialNegotiation = hubEpoch == 0 && !hubBootstrapComplete && epoch == 1
11:     val rollback = !initialNegotiation && (hubEpoch > 0 || hubBootstrapComplete || epoch > 1)
12:     val dropBefore = epoch.takeIf { rollback && it > hubEpoch }
13:     val updated = copy(
```

## [MangayomiNamespace.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/sync/MangayomiNamespace.kt)

```kotlin
16:     val raw = value.trim().trimEnd('/')
17:     val match = Regex("^([A-Za-z][A-Za-z0-9+.-]*://)([^/]+)(.*)$").matchEntire(raw) ?: return null
26:     val result = linkedMapOf<String, MutableSet<String>>()
28:         val raw = pref.mangayomiIdMappings ?: continue
29:         val namespaces = runCatching { Json.parseToJsonElement(raw).jsonObject["namespaces"] as? JsonObject }.getOrNull() ?: continue
31:             val rows = result.getOrPut(namespace) { linkedSetOf() }
49:     val bound = mangayomiBoundRows(before.syncPreferences + after.syncPreferences)
51:     val removed = buildList {
72: private class RemovedRow(val kind: Int, val id: Long, val action: DbActionType)
75:     val kept = after.toHashSet()
86:     val queued = existing.mapNotNullTo(HashSet()) { it.mangayomiDeleteKey() }
87:     val usedIds = existing.mapTo(HashSet(), DbChangedPart::id)
91:             val data = buildJsonObject {
97:             var recordId = SyncIds.random()
106:     val record = runCatching { Json.parseToJsonElement(data).jsonObject }.getOrNull() ?: return null
108:     val namespace = record["namespace"]?.jsonPrimitive?.content ?: return null
109:     val kind = record["kind"]?.jsonPrimitive?.content?.toIntOrNull() ?: return null
110:     val id = record["localId"]?.jsonPrimitive?.content?.toLongOrNull() ?: return null
114: private const val MANGAYOMI_PROVIDER = "mangayomi"
```

## [SyncClock.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/sync/SyncClock.kt)

```kotlin
13: object SyncClock {
14:     private val last = AtomicLong(0L)
22:             val prev = last.load()
23:             val now = nowMillis()
24:             val next = when {
35:             val prev = last.load()
```

## [SyncIdentityMigration.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/sync/SyncIdentityMigration.kt)

```kotlin
12: object SyncIdentityMigration {
13:     const val VERSION = 1
16:         val current = db.snapshot()
18:         val remapped = remap(current)
26:         val mangaIds = HashMap<Long, Long>()
27:         val mangas = s.mangas
31:         val categoryIds = HashMap<Long, Long>()
32:         val categories = s.categories.map { c -> c.copy(id = SyncIds.random()).also { categoryIds[c.id] = it.id } }
33:         val mangasWithCategories = mangas.map { m -> m.copy(categories = m.categories?.map { categoryIds[it] ?: it }?.distinct()) }
35:         val chapterIds = HashMap<Long, Long>()
36:         val chapters = s.chapters
38:                 val moved = c.copy(mangaId = c.mangaId?.let { mangaIds[it] ?: it })
46:         val histories = s.histories
48:                 val moved = h.copy(mangaId = manga(h.mangaId), chapterId = chapter(h.chapterId))
52:         val updates = s.updates
54:                 val moved = u.copy(mangaId = manga(u.mangaId), chapterId = chapter(u.chapterId))
58:         val tracks = s.tracks
60:                 val moved = t.copy(mangaId = manga(t.mangaId))
64:         val downloads = s.downloads.map { d -> d.copy(chapterId = chapter(d.chapterId)) }
65:         val pageCache = s.pageCache.map { p -> p.copy(chapterId = chapter(p.chapterId)) }
67:         val st = s.settings
68:         val settings = st.copy(
100:         val best = LinkedHashMap<Long, T>()
102:             val (id, stamp) = key(item)
103:             val current = best[id]
```

## [SyncIds.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/sync/SyncIds.kt)

```kotlin
16: object SyncIds {
17:     private const val FNV_OFFSET: Long = -3750763034362895579L // 0xcbf29ce484222325
18:     private const val FNV_PRIME: Long = 1099511628211L
21:         var h = FNV_OFFSET
26:         val v = h and Long.MAX_VALUE
40:         val link = m.link?.takeIf { it.isNotBlank() } ?: return null
41:         val source = m.sourceId?.toString() ?: m.source?.takeIf { it.isNotBlank() } ?: return null
46:         val mangaId = c.mangaId?.takeIf { it != 0L } ?: return null
47:         val key = c.url.takeIf { it.isNotBlank() } ?: c.archivePath.takeIf { it.isNotBlank() } ?: return null
54:         val mangaId = u.mangaId?.takeIf { it != 0L } ?: return null
55:         val chapterId = u.chapterId?.takeIf { it != 0L } ?: return null
60:         val mangaId = t.mangaId?.takeIf { it != 0L } ?: return null
61:         val syncId = t.syncId ?: return null
```

## [SyncPaths.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/sync/SyncPaths.kt)

```kotlin
36: object SyncPaths {
37:     const val KIND_CATEGORY = 1
38:     const val KIND_MANGA = 2
39:     const val KIND_CHAPTER = 3
40:     const val KIND_TRACK = 4
41:     const val KIND_HISTORY = 5
42:     const val KIND_UPDATE = 6
43:     const val KIND_SETTINGS = 7
44:     const val SETTINGS_ID = 1L
45:     const val DELETED = "_deleted"
47:     val json: Json = Json {
54:     data class PathChange(val path: String, val value: JsonElement?)
61:     private val settingsDeviceLocal = setOf(
82:     private val excludedByKind: Map<Int, Set<String>> = mapOf(
91:     private const val SOURCE_PREF_KEY = "sourceId+key"
93:     private val settingsKeyed: Map<String, String> = mapOf(
114:         val s = element["sourceId"]?.jsonPrimitive?.content ?: return null
115:         val k = element["key"]?.jsonPrimitive?.content ?: return null
126:         val old = doc(kind, serializer, before).filterKeys { it != "updatedAt" }
127:         val next = doc(kind, serializer, after).filterKeys { it != "updatedAt" }
132:         val incomingAt = timestamp(incoming)
135:         val priorAt = timestamp(previous)
136:         val nextAt = if (priorAt == Long.MAX_VALUE) priorAt else priorAt + 1
141:         val excluded = excluded(kind)
142:         val keyed = keyedFields(kind)
143:         val idSets = idSetFields(kind)
157:                             val spec = keyed.getValue(k)
159:                                 val o = el as? JsonObject ?: return@forEach
171:         val keyed = keyedFields(kind)
172:         val idSets = idSetFields(kind)
187:         val nested = keyedFields(kind).keys + idSetFields(kind)
188:         val out = ArrayList<PathChange>()
190:             val a = before?.get(k)
191:             val b = after[k]
194:                 val ao = a
195:                 val bo = b
197:                     val x = ao?.get(sub)
198:                     val y = bo?.get(sub)
215:         val excluded = excluded(kind)
216:         val incoming = fromDoc(kind, incomingDoc)
235:         val top = LinkedHashMap<String, JsonElement>(doc)
238:             val value = op.value?.let(json::parseToJsonElement)
239:             val dot = op.path.indexOf('.')
243:                 val field = op.path.substring(0, dot)
244:                 val sub = op.path.substring(dot + 1)
245:                 val inner = LinkedHashMap<String, JsonElement>((top[field] as? JsonObject).orEmpty())
266:     val ALL_KINDS: Set<Int> = (KIND_CATEGORY..KIND_SETTINGS).toSet()
284:         val epoch = activeHubEpoch(after.syncPreferences) ?: return after.outbox
285:         val old = docs(before).associate { (kind, id, doc) -> (kind to id) to doc }.toMutableMap()
286:         var seq = after.outbox.maxOfOrNull { it.seq } ?: 0L
287:         val added = ArrayList<DbOutboxOp>()
296:         val replaced = added.mapTo(HashSet()) { Triple(it.kind, it.id, it.path) }
306:     val json = SyncPaths.json
307:     val local = json.encodeToJsonElement(DbSettings.serializer(), current).jsonObject
308:     val merged = json.encodeToJsonElement(DbSettings.serializer(), incoming).jsonObject.toMutableMap()
311:         val value = local[key]
```

## [ChapterRecognition.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/domain/ChapterRecognition.kt)

```kotlin
15: object ChapterRecognition {
17:         val inferred = rawSeasonAndNumber(mangaTitle, chapter.numberingName?.takeIf(String::isNotBlank) ?: chapter.name)
23:     private val unwanted = Regex(
26:     private val unwantedWhiteSpace = Regex("\\s(?=extra|special|omake)")
27:     private val seasonKeyword = Regex(
30:     private val episodeKeyword = Regex(
35:     private val chNotation = Regex(
38:     private val bareNumber = Regex("([0-9]+)(\\.[0-9]+)?(\\.?[a-z]+)?")
45:         val (season, ep) = rawSeasonAndNumber(mangaTitle, chapterName)
55:         val (_, ep) = rawSeasonAndNumber(mangaTitle, chapterName)
79:         val title = mangaTitle.orEmpty()
80:         val name = chapterName?.takeIf { it.isNotBlank() } ?: return null
81:         val (season, ep) = rawSeasonAndNumber(title, name)
93:         val name = chapterName
101:         val season = seasonKeyword.find(name)?.groupValues?.getOrNull(1)?.toIntOrNull() ?: 0
104:             val ep = match.groupValues.getOrNull(1)?.toDoubleOrNull()
109:         val stripped = name.replace(unwanted, "")
110:         val ep = extractNumber(stripped)
120:         val raw = chapters.associate { it.id to rawSeasonAndNumber(mangaTitle, it) }
121:         val episodeToSeasons = mutableMapOf<Double, MutableSet<Int>>()
124:             val ep = pair.second ?: continue
128:         val collisions = episodeToSeasons.values.count { it.size > 1 }
129:         val resets = collisions >= 3
132:             val ep = pair.second ?: return@mapValues null
147:         val numbers = mutableSetOf<Int>()
149:             val (_, ep) = rawSeasonAndNumber(mangaTitle, chapter)
155:         val lowest = numbers.minOrNull() ?: return 0
156:         val highest = numbers.maxOrNull() ?: return 0
157:         val expectedCount = highest - lowest + 1
181:         val groups = match.groupValues
182:         val base = groups.getOrNull(1)?.toDoubleOrNull() ?: return 0.0
183:         val decimal = groups.getOrNull(2)?.takeIf { it.isNotEmpty() }
184:         val alpha = groups.getOrNull(3)?.takeIf { it.isNotEmpty() }
194:             val trimmed = alpha.removePrefix(".")
201:         val number = c.code - ('a'.code - 1)
```

## [ChapterReleasePolicy.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/domain/ChapterReleasePolicy.kt)

```kotlin
3: data class ChapterReleasePreferences(
4:     val scanlatorPriority: List<String> = emptyList(),
5:     val skipDuplicates: Boolean = false,
9: data class ChapterReleaseIdentity(
10:     val number: Double,
11:     val season: Int?,
12:     val volume: Int?,
13:     val part: String,
14:     val language: String,
15:     val edition: String,
18: private val explicitNumber = Regex("\\b(?:chapter|chap|ch|episode|ep|folge)\\.?\\s*#?\\s*(\\d+(?:[.,]\\d+)?)([a-z]?)(?=\\s|[:.\\-]|$)")
19: private val leadingNumber = Regex("^#?(\\d+(?:[.,]\\d+)?)([a-z]?)(?=\\s|[:.\\-]|$)")
20: private val seasonLabel = Regex("\\b(?:season|staffel|saison|temporada|s)\\.?\\s*(\\d+)\\b")
21: private val volumeLabel = Regex("\\b(?:volume|vol|v)\\.?\\s*(\\d+)\\b")
22: private val editionLabel = Regex("\\b(?:special|extra|omake|oneshot|one-shot|colored|coloured|color|colour|remaster(?:ed)?|uncensored|censored|revised|bonus|part\\s*\\d+)\\b")
23: private val languageLabel = Regex("\\[(?:lang[:=]\\s*)?([a-z]{2}(?:-[a-z]{2})?)\\]")
24: private val whitespace = Regex("\\s+")
25: private val numberRange = Regex("^\\s*(?:[-–/&]|and|\\.)\\s*\\d")
26: private val namedLanguage = Regex("\\b(?:english|spanish|french|german|russian|portuguese|japanese|chinese|korean|italian|turkish)\\b")
38:     val named = namedChapterReleaseIdentity(mangaTitle, numberingName?.takeIf(String::isNotBlank) ?: chapterName)
39:     val validSeason = season?.takeIf { it >= 0 }
40:     val explicit = number?.takeIf { it.isFinite() && it >= 0 }
48:     var name = chapterName.lowercase().trim()
50:     val matches = explicitNumber.findAll(name).toList()
52:     val number = matches.singleOrNull() ?: leadingNumber.find(name) ?: return null
53:     val value = number.groupValues[1].replace(',', '.').toDoubleOrNull()?.takeIf { it.isFinite() } ?: return null
86:     val hidden = excludedScanlators.map(::normalizeScanlator).toSet()
88:     val eligible = chapters.filter { normalizeScanlator(it.scanlator) !in hidden && (!offlineOnly || downloaded(it)) }
90:     val identities = chapters.associate { it.id to it.releaseIdentity(mangaTitle) }
91:     val groups = chapters.groupBy { identities[it.id] ?: it.id }
92:     val ranks = preferences.scanlatorPriority.map(::normalizeScanlator).distinct().withIndex().associate { it.value to it.index }
93:     val comparator = compareBy<Chapter> { ranks[normalizeScanlator(it.scanlator)] ?: Int.MAX_VALUE }
97:         val winner = releases.minWith(comparator)
98:         val equivalents = groups.getValue(key)
105:     val identities = chapters.associate { it.id to it.releaseIdentity(mangaTitle) }
106:     val selectedKeys = selectedIds.mapNotNull { identities[it] }.toSet()
111:     val identities = chapters.associate { it.id to it.releaseIdentity(mangaTitle) }
```

## [ChapterUpdateSchedule.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/domain/ChapterUpdateSchedule.kt)

```kotlin
9: private const val DayMillis = 86_400_000L
13:     val dates = uploadDates.mapNotNull { raw ->
14:         val value = raw.trim()
15:         val date = value.toLongOrNull()?.let {
23:     val mean = (dates.last() - dates.first()).toDouble() / (dates.size - 1) / DayMillis
```

## [Models.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/domain/Models.kt)

```kotlin
3: enum class ItemType(val label: String) {
9: enum class Status(val label: String) {
20: enum class SourceCodeLanguage(val label: String) {
27: enum class TrackStatus(val label: String) {
39: enum class ReaderMode(val label: String) {
46: data class Repo(
47:     val name: String,
48:     val jsonUrl: String,
49:     val website: String? = null,
52: data class Source(
53:     val id: Long,
54:     val name: String,
55:     val baseUrl: String,
56:     val lang: String,
57:     val itemType: ItemType,
58:     val typeSource: String,
59:     val iconUrl: String? = null,
60:     val isActive: Boolean = true,
61:     val isAdded: Boolean = false,
62:     val isPinned: Boolean = false,
63:     val isNsfw: Boolean = false,
64:     val hasCloudflare: Boolean = false,
65:     val supportLatest: Boolean = false,
66:     val version: String = "0.0.1",
67:     val versionLast: String = "0.0.1",
68:     val lastUsed: Boolean = false,
69:     val isObsolete: Boolean = false,
70:     val sourceCodeLanguage: SourceCodeLanguage = SourceCodeLanguage.JavaScript,
71:     val repo: Repo? = null,
72:     val notes: String = "",
75: data class Category(
76:     val id: Long,
77:     val name: String,
78:     val forItemType: ItemType,
79:     val position: Int,
80:     val hidden: Boolean = false,
81:     val shouldUpdate: Boolean = true,
84: data class Manga(
85:     val id: Long,
86:     val name: String,
87:     val alternativeTitles: List<String> = emptyList(),
88:     val link: String,
89:     val imageUrl: String? = null,
90:     val customCoverImage: ByteArray? = null,
91:     val customCoverFromTracker: String? = null,
92:     val description: String,
93:     val author: String? = null,
94:     val artist: String? = null,
95:     val status: Status,
96:     val itemType: ItemType,
97:     val genres: List<String> = emptyList(),
98:     val favorite: Boolean = false,
99:     val source: String,
100:     val lang: String,
101:     val dateAddedMillis: Long,
102:     val lastUpdateMillis: Long,
103:     val lastReadMillis: Long = 0L,
104:     val categories: List<Long> = emptyList(),
105:     val isLocalArchive: Boolean = false,
106:     val smartUpdateDays: Int? = null,
107:     val sourceId: Long? = null,
108:     val metadataServerId: String? = null,
109:     val metadataSource: String? = null,
110:     val metadataUpdatedAt: Long = 0L,
111:     val privateNote: String = "",
112:     val nextEpisodeAiringAt: Long = 0,
113:     val nextEpisodeNumber: Int? = null,
114:     val cast: List<TitleCredit> = emptyList(),
116:     val parentId: Long? = null,
118:     val fetchesSeasons: Boolean = false,
119:     val seasonNumber: Double? = null,
166:         var result = id.hashCode()
203: data class Chapter(
204:     val id: Long,
205:     val mangaId: Long,
206:     val name: String,
207:     val url: String,
208:     val dateUpload: String = "",
209:     val scanlator: String = "",
210:     val isBookmarked: Boolean = false,
211:     val isRead: Boolean = false,
212:     val lastPageRead: String = "",
213:     val archivePath: String = "",
215:     val isFiller: Boolean = false,
216:     val thumbnailUrl: String? = null,
217:     val description: String? = null,
218:     val downloadSize: String? = null,
219:     val duration: String? = null,
220:     val fetchedAt: Long = 0,
221:     val number: Double? = null,
222:     val season: Int? = null,
223:     val numberingName: String? = null,
224:     val fillerOverride: Boolean? = null,
227: data class History(
228:     val id: Long,
229:     val mangaId: Long,
230:     val chapterId: Long,
231:     val itemType: ItemType,
232:     val title: String,
233:     val chapterName: String,
234:     val date: String,
235:     val readingTimeSeconds: Int,
236:     val updatedAt: Long,
238:     val lastPageRead: String = "",
240:     val chapterIsRead: Boolean = false,
243: data class Track(
244:     val id: Long,
245:     val libraryId: Long,
246:     val mediaId: Long,
247:     val mangaId: Long,
248:     val syncId: Int,
249:     val title: String,
250:     val progress: Int,
251:     val total: Int,
252:     val score: Int,
253:     val status: TrackStatus,
254:     val trackingUrl: String,
255:     val itemType: ItemType,
258: data class UpdateEntry(
259:     val id: Long,
260:     val mangaId: Long,
261:     val chapterId: Long,
262:     val itemType: ItemType,
263:     val title: String,
264:     val chapterName: String,
265:     val source: String,
266:     val date: String,
267:     val isRead: Boolean,
268:     val updatedAt: Long,
271: data class UserSettings(
272:     val displayType: DisplayType = DisplayType.ComfortableGrid,
273:     val followSystemTheme: Boolean = true,
274:     val darkTheme: Boolean = false,
275:     val incognitoMode: Boolean = false,
276:     val downloadedOnly: Boolean = false,
277:     val defaultReaderMode: ReaderMode = ReaderMode.Paged,
278:     val libraryShowCategoryTabs: Boolean = true,
279:     val libraryShowLanguage: Boolean = true,
280:     val libraryShowSource: Boolean = false,
281:     val libraryShowNumbersOfItems: Boolean = true,
282:     val showPagesNumber: Boolean = true,
283:     val concurrentDownloads: Int = 3,
284:     val allowConcurrentDownloads: Boolean = true,
285:     val downloadDelaySeconds: Int = 0,
286:     val checkForAppUpdates: Boolean = true,
287:     val checkForExtensionUpdates: Boolean = true,
290: enum class DisplayType(val label: String) {
```

## [PrivateNotes.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/domain/PrivateNotes.kt)

```kotlin
5:     val separator = "\n\n---\n\n"
```

## [ProfileId.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/domain/ProfileId.kt)

```kotlin
12:         val Default = ProfileId("default")
18: data class ProfileStorageNamespace(val id: ProfileId) {
19:     val relativeRoot: String? get() = if (id == ProfileId.Default) null else "profiles/${id.value}"
20:     val databaseRelativePath: String get() = relativeRoot?.let { "$it/yokan-room.db" } ?: "yokan-room.db"
21:     val browserSnapshotKey: String get() = if (id == ProfileId.Default) "yokan-database-v1" else "yokan-database-v1:${id.value}"
```

## [TitleCredit.kt](/Users/duongph/Projects/yokan/composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/domain/TitleCredit.kt)

```kotlin
7: data class TitleCredit(
8:     val name: String,
9:     val role: String? = null,
10:     val character: String? = null,
```

