import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
    selector: 'knk-wizard-step-header',
    templateUrl: './stepheader.component.html',
    styleUrls: ['./stepheader.component.scss']
})
export class WizardStepHeaderComponent {
    @Input('showRecent') showRecent: boolean = true;
    @Input('showTitle') showTitle: boolean = true;
    @Input('caption') caption: string[];
    @Input('recent') recent: Array<{item: {asset: string, pair: string, time: Date, id: number}}>; // = [{pair: '- Load Recent -', time: null, id: -1}];
    @Output() loadRecent: EventEmitter<{asset: string, pair: string, time: Date, id: number}> = new  EventEmitter<{asset: string, pair: string, time: Date, id: number}>();

    // public items: Array<string> = ['Amsterdam', 'Antwerp', 'Athens', 'Barcelona',
    // 'Berlin', 'Birmingham', 'Bradford', 'Bremen', 'Brussels', 'Bucharest',
    // 'Budapest', 'Cologne', 'Copenhagen', 'Dortmund', 'Dresden', 'Dublin',
    // 'Düsseldorf', 'Essen', 'Frankfurt', 'Genoa', 'Glasgow', 'Gothenburg',
    // 'Hamburg', 'Hannover', 'Helsinki', 'Kraków', 'Leeds', 'Leipzig', 'Lisbon',
    // 'London', 'Madrid', 'Manchester', 'Marseille', 'Milan', 'Munich', 'Málaga',
    // 'Naples', 'Palermo', 'Paris', 'Poznań', 'Prague', 'Riga', 'Rome',
    // 'Rotterdam', 'Seville', 'Sheffield', 'Sofia', 'Stockholm', 'Stuttgart',
    // 'The Hague', 'Turin', 'Valencia', 'Vienna', 'Vilnius', 'Warsaw', 'Wrocław',
    // 'Zagreb', 'Zaragoza', 'Łódź'];

//     itemId: string;
//   private value: string;
//   private _disabledV: string = '0';
//   private disabled: boolean = false;

//   public selected(value: string): void {
//     console.log('Selected value is: ', value);
//   }

//   public removed(value: string): void {
//     console.log('Removed value is: ', value);
//   }

//   public typed(value: string): void {
//     console.log('New search input: ', value);
//   }

//   public refreshValue(value: string): void {
//     this.value = value;
//   }

    loadRecentKnok(knokNumber: {asset: string, pair: string, time: Date, id: number}): void {
        if (this.loadRecent) {
            this.loadRecent.emit(knokNumber);
        }
    }

    // get items(): Array<{id: string, name: string, time: string}> {
    //     return [{id: '1', name: 'recent1', time: 'time1'},
    //     {id: '2', name: 'recent2', time: 'time2'}, {id: '3', name: 'recent3', time: 'time3'}];
    // }
    getRecentTime(recentDate: Date): string {
        let dateDiffInMs: number = (new Date()).getTime() - recentDate.getTime();

        let diffInHours: number = dateDiffInMs / 1000 / 60 / 60;

        if (diffInHours <= 24) {
            return 'Today';
        }
        if (diffInHours > 24 && diffInHours <= 48) {
            return 'Yesterday';
        }
        return '';
    }

    // private get disabledV(): string {
    //     return this._disabledV;
    //   }

    //   private set disabledV(value: string) {
    //     this._disabledV = value;
    //     this.disabled = this._disabledV === '1';
    //   }
}
