/*deprecated*/
import {
    Directive,
    ElementRef,
    HostListener,
    Input,
    Renderer2,
    OnDestroy,
    Output,
    EventEmitter
  } from '@angular/core';
  import { ViewportScroller } from '@angular/common';
  import { CardModalService } from './card-modal.service';
  import { CardInterface } from './card-modal.interface';

  
  @Directive({
    selector: '[appCouponPopup]'
  })
  export class CouponPopupDirective {
    @Input() couponProps: CardInterface;
  
    constructor(
      private el: ElementRef,
      private renderer2: Renderer2,
      private vpS: ViewportScroller,
      private cpService: CardModalService
    ) {
    }
  
    @Input() type?: string;
  
    @HostListener('window:resize', ['$event'])
  
  
    @HostListener('click', ['$event']) onClick(event: any) {
      if (!this.type || this.type === 'click') {
        const cmp = this.cpService.appendComponentToBody();
        if (cmp !== null) {
          const instance = cmp.instance;
          instance.couponProps = this.couponProps;
  
          instance.display.subscribe((x: boolean) => {
            if (!x) {
              this.cpService.removeComponentFromBody();
            }
          });
        }
      }
    }
  
    @HostListener('mouseover')
    onMouseOver() {
      this.renderer2.setStyle(this.el.nativeElement, 'cursor', 'pointer');
    }
  }
  