 import AppKit
 import EmitterKit
 import Cocoa
-import SwiftyUserDefaults
 
 /**
   Represents an item in the menu bar

    instead of using isVisible = false or hide()
*/
class Tray: NSObject, NSMenuDelegate, ItemBaseDelegate {
  private var listeners = [Listener]()
  private let openEvent = Event<Void>()
  private let closeEvent = Event<Void>()
  private let openInTerminalClickEvent = Event<Void>()
  private var isOpen = false
  private var updatedAgoItem: UpdatedAgoItem?
  private let menu = NSMenu()
  private var defaultCount = 0
  private let item: NSStatusItem = NSStatusBar.system()
    .statusItem(withLength: NSVariableStatusItemLength)
  internal weak var delegate: TrayDelegate?

  /**

    listeners.append(closeEvent.on(block))
  }

  func item(didClick: ItemBase) {
     delegate?.bar(didClickOpenInTerminal: self)
  }

  private func separator() {
    menu.addItem(NSMenuItem.separator())
  }

  private func setPrefs() {
    // TODO: These should be static
    separator()
    updatedAgoItem = UpdatedAgoItem()
    menu.addItem(updatedAgoItem!)
    menu.addItem(ItemBase("Run in Terminal…", key: "o", delegate: self))
    menu.addItem(PrefItem())
  }

  // Private, not to be called
