import {ChangeDetectionStrategy, Component, computed, inject, input, output, viewChild} from '@angular/core';
import {AppMenuComponent} from '../../../../shared/ui/menu/app-menu.component';
import {AppMenuContentDirective} from '../../../../shared/ui/menu/app-menu-content.directive';
import {UserService} from '../../../settings/user-management/user.service';
import {type LibraryShelfMenuTarget} from '../../../../shared/layout/navigation/library-shelf-menu-target.model';
import {libraryShelfMenuAvailable, LibraryShelfMenuItemsComponent} from './library-shelf-menu-items.component';
@Component({
selector: 'app-library-shelf-menu',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {class: 'contents'},
imports: [AppMenuComponent, AppMenuContentDirective, LibraryShelfMenuItemsComponent],
template: `
@if (available()) {
}
`,
})
export class LibraryShelfMenuComponent {
readonly target = input.required();
readonly ariaLabel = input.required();
readonly opened = output();
readonly closed = output();
readonly menu = viewChild.required(AppMenuComponent);
private readonly currentUser = inject(UserService).currentUser;
readonly available = computed(
() => libraryShelfMenuAvailable(this.target(), this.currentUser()),
);
}