{"version":3,"sources":["src/app/shared/directives/sticky-popover.ts","src/app/shared/components/followable-link/followable-link.component.ts","src/app/shared/components/followable-link/followable-link.component.html"],"sourcesContent":["import {\n ElementRef,\n Directive, TemplateRef,\n Renderer2,\n inject,\n input\n} from \"@angular/core\";\nimport { NgbPopover } from \"@ng-bootstrap/ng-bootstrap\"\n\n@Directive({\n selector: \"[stickyPopover]\",\n exportAs: \"stickyPopover\",\n standalone: true\n})\nexport class StickyPopoverDirective extends NgbPopover {\n readonly stickyPopover = input>();\n\n ngpPopover: TemplateRef | undefined\n canClosePopover: boolean = false\n\n private _render = inject(Renderer2)\n private _elRef = inject(ElementRef)\n\n constructor() {\n super();\n this.triggers = \"manual\"\n this.container = \"body\"\n }\n\n override ngOnInit(): void {\n super.ngOnInit();\n this.ngbPopover = this.stickyPopover();\n\n this._render.listen(this._elRef.nativeElement, \"mouseenter\", () => {\n this.canClosePopover = true;\n this.open()\n });\n\n this._render.listen(this._elRef.nativeElement, \"mouseleave\", (event: Event) => {\n setTimeout(() => { if (this.canClosePopover) this.close() }, 100)\n\n })\n\n this._render.listen(this._elRef.nativeElement, \"click\", () => {\n this.close();\n })\n }\n\n override open() {\n super.open();\n let popover = window.document.querySelector(\".popover\")\n this._render.listen(popover, \"mouseover\", () => {\n this.canClosePopover = false;\n });\n\n this._render.listen(popover, \"mouseout\", () => {\n this.canClosePopover = true;\n setTimeout(() => { if (this.canClosePopover) this.close() }, 0)\n });\n }\n}","import { AfterViewInit, ChangeDetectorRef, Component, Directive, ElementRef, inject, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren, input, Input } from '@angular/core'\nimport { Router } from '@angular/router'\nimport { NgbPopover, NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'\nimport { Store } from '@ngrx/store'\nimport { Subscription } from 'rxjs'\nimport { SavedSearchService } from 'src/app/services/saved-search.service'\nimport { selectUser } from 'src/app/state/user.reducer'\nimport { followOptionsByArea } from '../../follow-options'\nimport { StickyPopoverDirective } from '../../directives/sticky-popover'\nimport { NgIcon, provideIcons } from '@ng-icons/core'\nimport { bootstrapAlarm, bootstrapAlarmFill } from '@ng-icons/bootstrap-icons'\n\n\n@Component({\n selector: 'followable-link',\n imports: [\n NgbPopoverModule,\n NgIcon,\n StickyPopoverDirective,\n ],\n templateUrl: './followable-link.component.html',\n styleUrl: './followable-link.component.scss',\n providers: [provideIcons({ bootstrapAlarm, bootstrapAlarmFill })]\n})\nexport class FollowableLinkComponent implements AfterViewInit, OnDestroy {\n readonly articleid = input(0)\n readonly area = input('')\n readonly label = input('')\n @Input() clickable: boolean = true\n readonly size = input('14px')\n\n @ViewChild('popover') popover: NgbPopover | undefined\n\n public user$: Subscription = Subscription.EMPTY\n public followArticleSearch: any | undefined = undefined\n\n public icon = 'bootstrapAlarm'\n public title = ''\n public titleDescription = ''\n public popoverContent = ''\n\n public router = inject(Router)\n public store = inject(Store)\n public savedSearchService = inject(SavedSearchService)\n private cdr = inject(ChangeDetectorRef)\n\n public words = ''\n public lastWord: string = ''\n public labelAsText: string = ''\n public wordCount: number = 0\n\n ngAfterViewInit(): void {\n let temporalDivElement = document.createElement(\"div\")\n temporalDivElement.innerHTML = this.label()\n this.labelAsText = temporalDivElement.textContent || temporalDivElement.innerText || \"\"\n\n let words = this.labelAsText.split(' ')\n this.lastWord = words?.pop() ?? ''\n this.words = words?.join(' ') ?? ''\n this.wordCount = words.length\n\n this.user$ = this.store.select(selectUser).subscribe(user => {\n this.followArticleSearch = user?.searches?.[this.area()]?.find((search: any) => search.parameters.id == this.articleid())\n if (this.followArticleSearch ?? 0 > 0) {\n this.icon = 'bootstrapAlarmFill'\n this.title = \"Unfollow\"\n this.titleDescription = \"You are following \"\n this.popoverContent = this.labelAsText\n } else {\n this.icon = 'bootstrapAlarm'\n this.title = \"Follow\"\n this.titleDescription = \"Follow\"\n this.popoverContent = this.labelAsText\n }\n this.cdr.detectChanges()\n })\n this.cdr.detectChanges()\n }\n\n ngOnDestroy(): void {\n this.user$.unsubscribe()\n }\n\n gotoPage() {\n if (this.clickable) {\n const url = `/${this.area()}/${this.articleid()}`\n window.open(url, \"_blank\")\n }\n }\n\n followUnfollow() {\n if (this.title === 'Follow') {\n this.savedSearchService.saveSearch({\n parameters: {\n area: this.area(),\n id: this.articleid(),\n options: structuredClone(followOptionsByArea[this.area() as keyof typeof followOptionsByArea])\n },\n area: this.area(),\n type: 'follow',\n name: 'Follow: ' + this.popoverContent\n })\n } else {\n this.savedSearchService.deleteSearch(this.followArticleSearch)\n }\n this.cdr.detectChanges()\n }\n}\n","@if (wordCount > 6) {\n \n \n\n} @else {\n \n \n {{words}}\n \n {{lastWord}}\n \n \n \n \n}\n\n\n
{{ titleDescription }} {{ popoverContent }}
\n \n
"],"names":["StickyPopoverDirective","NgbPopover","stickyPopover","input","ngpPopover","canClosePopover","_render","inject","Renderer2","_elRef","ElementRef","constructor","triggers","container","ngOnInit","ngbPopover","listen","nativeElement","open","event","setTimeout","close","popover","window","document","querySelector","selectors","inputs","exportAs","features","ɵɵInheritDefinitionFeature","ɵɵelementStart","ɵɵlistener","ɵɵrestoreView","_r1","ctx_r1","ɵɵnextContext","ɵɵresetView","gotoPage","ɵɵelementEnd","ɵɵclassProp","clickable","ɵɵproperty","label","ɵɵsanitizeHtml","_r3","ɵɵtext","ɵɵelement","popContent_r4","ɵɵadvance","ɵɵtextInterpolate1","words","lastWord","size","icon","_r5","followUnfollow","ɵɵtextInterpolate2","titleDescription","popoverContent","ɵɵtextInterpolate","title","FollowableLinkComponent","articleid","input","area","popover","user$","Subscription","EMPTY","followArticleSearch","undefined","router","inject","Router","store","Store","savedSearchService","SavedSearchService","cdr","ChangeDetectorRef","labelAsText","wordCount","ngAfterViewInit","temporalDivElement","document","createElement","innerHTML","textContent","innerText","split","pop","join","length","select","selectUser","subscribe","user","searches","find","search","parameters","id","detectChanges","ngOnDestroy","unsubscribe","url","window","open","saveSearch","options","structuredClone","followOptionsByArea","type","name","deleteSearch","selectors","viewQuery","rf","ctx","provideIcons","bootstrapAlarm","bootstrapAlarmFill","decls","vars","consts","template","ɵɵtemplate","FollowableLinkComponent_Conditional_0_Template","FollowableLinkComponent_Conditional_1_Template","FollowableLinkComponent_ng_template_2_Template","ɵɵtemplateRefExtractor","ɵɵconditional","NgbPopoverModule","NgIcon","StickyPopoverDirective","styles"],"mappings":";;6jBAcA,IAAaA,GAAuB,IAAA,CAA9B,MAAOA,UAA+BC,CAAU,CACzCC,cAAgBC,EAAK,EAE9BC,WACAC,gBAA2B,GAEnBC,QAAUC,EAAOC,CAAS,EAC1BC,OAASF,EAAOG,CAAU,EAElCC,aAAA,CACI,MAAK,EACL,KAAKC,SAAW,SAChB,KAAKC,UAAY,MACrB,CAESC,UAAQ,CACb,MAAMA,SAAQ,EACd,KAAKC,WAAa,KAAKb,cAAa,EAEpC,KAAKI,QAAQU,OAAO,KAAKP,OAAOQ,cAAe,aAAc,IAAK,CAC9D,KAAKZ,gBAAkB,GACvB,KAAKa,KAAI,CACb,CAAC,EAED,KAAKZ,QAAQU,OAAO,KAAKP,OAAOQ,cAAe,aAAeE,GAAgB,CAC1EC,WAAW,IAAK,CAAO,KAAKf,iBAAiB,KAAKgB,MAAK,CAAG,EAAG,GAAG,CAEpE,CAAC,EAED,KAAKf,QAAQU,OAAO,KAAKP,OAAOQ,cAAe,QAAS,IAAK,CACzD,KAAKI,MAAK,CACd,CAAC,CACL,CAESH,MAAI,CACT,MAAMA,KAAI,EACV,IAAII,EAAUC,OAAOC,SAASC,cAAc,UAAU,EACtD,KAAKnB,QAAQU,OAAOM,EAAS,YAAa,IAAK,CAC3C,KAAKjB,gBAAkB,EAC3B,CAAC,EAED,KAAKC,QAAQU,OAAOM,EAAS,WAAY,IAAK,CAC1C,KAAKjB,gBAAkB,GACvBe,WAAW,IAAK,CAAO,KAAKf,iBAAiB,KAAKgB,MAAK,CAAG,EAAG,CAAC,CAClE,CAAC,CACL,4CA7CSrB,EAAsB,2BAAtBA,EAAsB0B,UAAA,CAAA,CAAA,GAAA,gB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