text: 'use strict'
  
  const electron = require('electron')
  const app = electron.app
  const globalShortcut = electron.globalShortcut
  const os = require('os')
  const path = require('path')
  const config = require(path.join(__dirname, 'package.json'))
  const model = require(path.join(__dirname, 'app', 'model.js'))
  const BrowserWindow = electron.BrowserWindow
  
  app.setName(config.productName)
  var mainWindow = null
  
  app.on('ready', function () {
    mainWindow = new BrowserWindow({
      backgroundColor: 'lightgray',
      title: config.productName,
      show: false,
      webPreferences: {
        nodeIntegration: true,
        defaultEncoding: 'UTF-8'
      }
    });
  
    model.initDb(app.getPath('userData'),
      // Load a DOM stub here. See renderer.js for the fully composed DOM.
      mainWindow.loadURL(`file://${__dirname}/app/html/index.html`)
    );
  
    // Enable keyboard shortcuts for Developer Tools on various platforms.
    let platform = os.platform()
    if (platform === 'darwin') {
      globalShortcut.register('Command+Option+I', () => {
        mainWindow.webContents.openDevTools()
      })
    } else if (platform === 'linux' || platform === 'win32') {
      globalShortcut.register('Control+Shift+I', () => {
        mainWindow.webContents.openDevTools()
      })
    }
  
    mainWindow.once('ready-to-show', () => {
      mainWindow.setMenu(null)
      mainWindow.show()
    })
  
    mainWindow.onbeforeunload = (e) => {
      // Prevent Command-R from unloading the window contents.
      e.returnValue = false
    }
  
    mainWindow.on('closed', function () {
      mainWindow = null
    })
  })
  
  app.on('window-all-closed', () => { app.quit() });
  