import { Element_ } from '../../../../../Class/Element'
import { Functional } from '../../../../../Class/Functional'
import { Done } from '../../../../../Class/Functional/Done'
import { System } from '../../../../../system'
import { ID_HIDE_POPOVER } from '../../../../_ids'

interface I<T> {
  component: Element_
  any: any
}

interface O<T> {}

export default class HidePopover<T> extends Functional<I<T>, O<T>> {
  constructor(system: System) {
    super(
      {
        i: ['component', 'any'],
        o: [],
      },
      {
        input: {
          component: {
            ref: true,
          },
        },
      },
      system,
      ID_HIDE_POPOVER
    )
  }

  async f({ component }: I<T>, done: Done<O<T>>) {
    component.emit('call', {
      method: 'hidePopover',
      data: [],
    })

    done()
  }
}
