text: // This is free and unencumbered software released into the public domain.
  // See LICENSE for details
  
  const {app, BrowserWindow, Menu, protocol, ipcMain} = require('electron');
  const log = require('electron-log');
  const {autoUpdater} = require("electron-updater");
  const {Updater } = require('./lol.js');
  
  //-------------------------------------------------------------------
  // Logging
  //
  // THIS SECTION IS NOT REQUIRED
  //
  // This logging setup is not required for auto-updates to work,
  // but it sure makes debugging easier :)
  //-------------------------------------------------------------------
  autoUpdater.logger = log;
  autoUpdater.logger.transports.file.level = 'info';
  log.info('App starting...');
  console.log('i am here')
  
  //-------------------------------------------------------------------
  // Define the menu
  //
  // THIS SECTION IS NOT REQUIRED
  //-------------------------------------------------------------------
  let template = []
  if (process.platform === 'darwin') {
    // OS X
    const name = app.getName();
    template.unshift({
      label: name,
      submenu: [
        {
          label: 'About ' + name,
          role: 'about'
        },
        {
          label: 'Quit',
          accelerator: 'Command+Q',
          click() { app.quit(); }
        },
      ]
    })
  }
  
  
  //-------------------------------------------------------------------
  // Open a window that displays the version
  //
  // THIS SECTION IS NOT REQUIRED
  //
  // This isn't required for auto-updates to work, but it's easier
  // for the app to show a window than to have to click "About" to see
  // that updates are working.
  //-------------------------------------------------------------------
  var win;
  
  function sendStatusToWindow(text) {
    win.webContents.send('message', text);
  }
  function createDefaultWindow() {
    win = new BrowserWindow();
    win.webContents.openDevTools();
    win.on('closed', () => {
      win = null;
    });
    win.loadURL(`file://${__dirname}/version.html#v${app.getVersion()}`);
    return win;
  }
  app.on('error', function (error) {
    sendStatusToWindow('err Update downloaded');
  })
  app.on('ready', function() {
    // Create the Menu
    const menu = Menu.buildFromTemplate(template);
    Menu.setApplicationMenu(menu);
    createDefaultWindow();
  });
  app.on('window-all-closed', () => {
    app.quit();
  });
  
  //
  // CHOOSE one of the following options for Auto updates
  //
  
  //-------------------------------------------------------------------
  // Auto updates - Option 1 - Simplest version
  //
  // This will immediately download an update, then install when the
  // app quits.
  //-------------------------------------------------------------------
  app.on('ready', function()  {
    sendStatusToWindow('herllo really')
    var lol = Updater.getInstance(win,app);
    lol.onStart().then();
    console.log(lol.win===win)
  });
  
  //-------------------------------------------------------------------
  // Auto updates - Option 2 - More control
  //
  // For details about these events, see the Wiki:
  // https://github.com/electron-userland/electron-builder/wiki/Auto-Update#events
  //
  // The app doesn't need to listen to any events except `update-downloaded`
  //
  // Uncomment any of the below events to listen for them.  Also,
  // look in the previous section to see them being used.
  //-------------------------------------------------------------------
  // app.on('ready', function()  {
  //   autoUpdater.checkForUpdates();
  // });
  // autoUpdater.on('checking-for-update', () => {
  // })
  // autoUpdater.on('update-available', (info) => {
  // })
  // autoUpdater.on('update-not-available', (info) => {
  // })
  // autoUpdater.on('error', (err) => {
  // })
  // autoUpdater.on('download-progress', (progressObj) => {
  // })
  // autoUpdater.on('update-downloaded', (info) => {
  //   autoUpdater.quitAndInstall();
  // })