import { Component, Input } from '@angular/core';
import { CommonNzModule } from './../../../common.nz.module';
import { BasicDataService } from './../../../services/basic.service';

const colors = ['#f50', '#2db7f5', '#87d068', '#108ee9'];

@Component({
  selector: 'position-visual',
  standalone: true,
  imports: [CommonNzModule],
  templateUrl: './position-visual.component.html',
  styleUrl: './position-visual.component.less',
})
export class PositionVisualComponent {
  @Input({ required: true }) position!: BasicData.Position;
  constructor(private basic: BasicDataService) {}
  getColors = (index: number) => colors[index % colors.length];
  getLineName(lineId: number) {
    return this.basic.getLineName(lineId);
  }
  getCategoryName(categoryId: number) {
    return this.basic.getPositionCategoryName(categoryId);
  }
  isStation(position: BasicData.Position) {
    const stationCategory = this.categories.find(c => c.name === '车站');
    return position.category === stationCategory?.id;
  }
  get categories() {
    return this.basic.positionCategories;
  }
}
