.length === 0) {
    return;
  }

  // Build the menu object from provided menu items.
  const menu = new Menu();
  items.forEach(item => {
    if (item == "-") {
      item = { type: "separator" };
    }

    const menuItem = new MenuItem(item);
    const subItems = item.submenu;

    if (subItems) {
      const subMenu = new Menu();
      subItems.forEach(subItem => {
        subMenu.append(new MenuItem(subItem));
      });
      menuItem.submenu = subMenu;
    }

    menu.append(menuItem);
  });

  // Calculate position on the screen according to
  // the parent button if available.
  if (options.button) {
    menu.popupAtTarget(options.button, window.document);
  } else {
    const screenX = options.screenX;
    const screenY = options.screenY;
    menu.popup(screenX, screenY, window.document);
  }
}

module.exports = {
  showMenu,
};
PK