{ "version": 3, "sources": ["src/app/cards/entity-title/entity-title.component.ts", "src/app/cards/entity-title/entity-title.component.html"], "sourcesContent": ["import {ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, Input, OnInit} from '@angular/core';\nimport { UtilityService } from 'src/app/shared/_services/utility.service';\nimport { Chapter, LooseLeafOrDefaultNumber } from 'src/app/_models/chapter';\nimport { LibraryType } from 'src/app/_models/library/library';\nimport { Volume } from 'src/app/_models/volume';\nimport {translate, TranslocoModule} from \"@jsverse/transloco\";\nimport {DefaultValuePipe} from \"../../_pipes/default-value.pipe\";\n\n/**\n * This is primarily used for list item\n */\n@Component({\n selector: 'app-entity-title',\n standalone: true,\n imports: [\n TranslocoModule,\n DefaultValuePipe\n ],\n templateUrl: './entity-title.component.html',\n styleUrls: ['./entity-title.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class EntityTitleComponent implements OnInit {\n\n private readonly utilityService = inject(UtilityService);\n private readonly cdRef = inject(ChangeDetectorRef);\n\n protected readonly LooseLeafOrSpecial = LooseLeafOrDefaultNumber + \"\";\n protected readonly LibraryType = LibraryType;\n\n /**\n * Library type for which the entity belongs\n */\n @Input() libraryType: LibraryType = LibraryType.Manga;\n @Input({required: true}) entity!: Volume | Chapter;\n /**\n * When generating the title, should this prepend 'Volume number' before the Chapter wording\n */\n @Input() includeVolume: boolean = false;\n /**\n * When generating the title, should this prepend 'Chapter number' before the Chapter titlename\n */\n @Input() includeChapter: boolean = false;\n /**\n * When a titleName (aka a title) is available on the entity, show it over Volume X Chapter Y\n */\n @Input() prioritizeTitleName: boolean = true;\n /**\n * When there is no meaningful title to display and the chapter is just a single volume, show the volume number\n */\n @Input() fallbackToVolume: boolean = true;\n\n isChapter = false;\n titleName: string = '';\n volumeTitle: string = '';\n number: string = '';\n renderText: string = '';\n\n\n ngOnInit(): void {\n this.isChapter = this.utilityService.isChapter(this.entity);\n\n if (this.isChapter) {\n const c = (this.entity as Chapter);\n this.volumeTitle = c.volumeTitle || '';\n this.titleName = c.titleName || '';\n this.number = c.range;\n } else {\n const v = this.utilityService.asVolume(this.entity);\n this.volumeTitle = v.name || '';\n this.titleName = v.name || '';\n if (v.chapters[0].titleName) {\n this.titleName += ' - ' + v.chapters[0].titleName;\n }\n this.number = v.name;\n }\n\n this.calculateRenderText();\n\n this.cdRef.markForCheck();\n }\n\n private calculateRenderText() {\n switch (this.libraryType) {\n case LibraryType.Manga:\n this.renderText = this.calculateMangaRenderText();\n break;\n case LibraryType.Comic:\n this.renderText = this.calculateComicRenderText();\n break;\n case LibraryType.Book:\n this.renderText = this.calculateBookRenderText();\n break;\n case LibraryType.Images:\n this.renderText = this.calculateImageRenderText();\n break;\n case LibraryType.LightNovel:\n this.renderText = this.calculateLightNovelRenderText();\n break;\n case LibraryType.ComicVine:\n this.renderText = this.calculateComicRenderText();\n break;\n }\n this.cdRef.markForCheck();\n }\n\n private calculateBookRenderText() {\n let renderText = '';\n if (this.titleName !== '' && this.prioritizeTitleName) {\n renderText = this.titleName;\n } else if (this.fallbackToVolume && this.isChapter) { // (his is a single volume on volume detail page\n renderText = translate('entity-title.single-volume');\n } else if (this.number === this.LooseLeafOrSpecial) {\n renderText = '';\n } else {\n renderText = translate('entity-title.book-num', {num: this.volumeTitle});\n }\n return renderText;\n }\n\n private calculateLightNovelRenderText() {\n let renderText = '';\n if (this.titleName !== '' && this.prioritizeTitleName) {\n renderText = this.titleName;\n } else if (this.fallbackToVolume && this.isChapter) { // (his is a single volume on volume detail page\n renderText = translate('entity-title.single-volume');\n } else if (this.number === this.LooseLeafOrSpecial) {\n renderText = '';\n } else {\n const bookNum = this.isChapter ? this.number : this.volumeTitle;\n renderText = translate('entity-title.book-num', {num: bookNum});\n }\n return renderText;\n }\n\n private calculateMangaRenderText() {\n let renderText = '';\n\n if (this.titleName !== '' && this.prioritizeTitleName) {\n if (this.isChapter && this.includeChapter) {\n if (this.number === this.LooseLeafOrSpecial) {\n renderText = translate('entity-title.chapter') + ' - ';\n } else {\n renderText = translate('entity-title.chapter') + ' ' + this.number + ' - ';\n }\n }\n\n renderText += this.titleName;\n } else {\n if (this.includeVolume && this.volumeTitle !== '') {\n if (this.number !== this.LooseLeafOrSpecial && this.isChapter && this.includeVolume) {\n renderText = this.volumeTitle;\n }\n }\n\n if (this.number !== this.LooseLeafOrSpecial) {\n if (this.isChapter) {\n renderText = translate('entity-title.chapter') + ' ' + this.number;\n } else {\n renderText = this.volumeTitle;\n }\n } else if (this.fallbackToVolume && this.isChapter && this.volumeTitle) {\n renderText = translate('entity-title.vol-num', {num: this.volumeTitle});\n } else if (this.fallbackToVolume && this.isChapter) { // this.volumeTitle === '' (this is a single volume on volume detail page)\n renderText = translate('entity-title.single-volume');\n } else {\n renderText = translate('entity-title.special');\n }\n }\n\n\n return renderText;\n }\n\n private calculateImageRenderText() {\n let renderText = '';\n\n if (this.number !== this.LooseLeafOrSpecial) {\n if (this.isChapter) {\n renderText = translate('entity-title.chapter') + ' ' + this.number;\n } else {\n renderText = this.volumeTitle;\n }\n } else {\n renderText = translate('entity-title.special');\n }\n\n return renderText;\n }\n\n\n private calculateComicRenderText() {\n let renderText = '';\n\n // If titleName is provided and prioritized\n if (this.titleName && this.prioritizeTitleName) {\n if (this.isChapter && this.includeChapter) {\n renderText = translate('entity-title.issue-num') + ' ' + this.number + ' - ';\n }\n renderText += this.titleName;\n } else {\n // Otherwise, check volume and number logic\n if (this.includeVolume && this.volumeTitle) {\n if (this.number !== this.LooseLeafOrSpecial) {\n renderText = this.isChapter ? this.volumeTitle : '';\n }\n }\n // Render either issue number or volume title, or \"special\" if applicable\n renderText += this.number !== this.LooseLeafOrSpecial\n ? (this.isChapter ? translate('entity-title.issue-num') + ' ' + this.number : this.volumeTitle)\n : translate('entity-title.special');\n }\n\n return renderText;\n }\n}\n", "\n {{renderText | defaultValue}}\n\n"], "mappings": "yRCAAA,EAAA,CAAA,EACEC,EAAA,CAAA,0CAAAC,EAAA,EAAAC,EAAA,IAAAC,EAAA,EAAA,EAAAC,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,SAAAC,EAAAC,EAAA,CAAAD,EAAA,GCtBjCE,EAAA,EAAAC,EAAA,EAAA,EAAA,eAAA,CAAA,OAAiCC,EAAA,gBAAA,cAAA,iBDe7BC,EAAeC,EACfC,CAAgB,EAAAC,gBAAA,CAAA,CAAA,CAAA,SAMP5D,CAAoB,GAAA", "names": ["\u0275\u0275elementContainerStart", "\u0275\u0275text", "\u0275\u0275advance", "\u0275\u0275textInterpolate1", "\u0275\u0275pipeBind1", "ctx_r0", "renderText", "EntityTitleComponent", "constructor", "utilityService", "inject", "UtilityService", "cdRef", "ChangeDetectorRef", "LooseLeafOrSpecial", "LooseLeafOrDefaultNumber", "LibraryType", "libraryType", "Manga", "includeVolume", "includeChapter", "prioritizeTitleName", "fallbackToVolume", "isChapter", "titleName", "volumeTitle", "number", "ngOnInit", "entity", "c", "range", "v", "asVolume", "name", "chapters", "calculateRenderText", "markForCheck", "calculateMangaRenderText", "Comic", "calculateComicRenderText", "Book", "calculateBookRenderText", "Images", "calculateImageRenderText", "LightNovel", "calculateLightNovelRenderText", "ComicVine", "translate", "num", "bookNum", "selectors", "inputs", "standalone", "features", "\u0275\u0275StandaloneFeature", "decls", "vars", "consts", "template", "rf", "ctx", "\u0275\u0275template", "EntityTitleComponent_ng_container_0_Template", "\u0275\u0275property", "TranslocoModule", "TranslocoDirective", "DefaultValuePipe", "changeDetection"] }