import { CommonModule } from '@angular/common'
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
import {
  SettingsListResponseApiModel,
  SiteApiService,
} from '../../../../../../libs/data-access/gn4/src'
import { CatalogTitleComponent } from '../../../../../../libs/ui/catalog/src'
import { Observable } from 'rxjs'
import { shareReplay } from 'rxjs/operators'

@Component({
  selector: 'gn-ui-site-title',
  templateUrl: './site-title.component.html',
  styleUrls: ['./site-title.component.css'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: true,
  imports: [CommonModule, CatalogTitleComponent],
})
export class SiteTitleComponent {
  private siteApiService = inject(SiteApiService)

  info$: Observable<SettingsListResponseApiModel>

  constructor() {
    this.info$ = this.siteApiService
      .getSiteOrPortalDescription()
      .pipe(shareReplay(1))
  }
}
