<commit_before>const { app, Menu, BrowserWindow, Notification, ipcMain } = require('electron');
const path = require('path');
const url = require('url');
const os = require('os');

const appConfig = require(path.join(
  __dirname,
  '/../www/assets/appConfig.json'
));
console.log('Desktop: ' + appConfig.nameCase + ' v' + appConfig.version);

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;

// Deep linked url
let deeplinkingUrl;

const isDevMode = process.execPath.match(/[\\/]electron/);

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({
    width: 400,
    height: 650,
    minWidth: 400,
    maxWidth: 800,
    minHeight: 650,
    show: false,
    webPreferences: {
      nodeIntegration: true,
      worldSafeExecuteJavaScript: true,
      enableRemoteModule: true
    }
  });

  // and load the index.html of the app.
  win.loadURL(
    url.format({
      pathname: path.join(__dirname, '/../www/index.html'),
      protocol: 'file:',
      slashes: true
    })
  );

  // Open the DevTools.
  if (isDevMode) {
    win.webContents.openDevTools();
  }
  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null;
  });

  win.webContents.on('did-finish-load', () => {
    // Windows - Linux: Handle deeplink url
    if (process.platform == 'win32' || process.platform == 'linux') {
      // Keep only command line / deep linked arguments
      deeplinkingUrl = process.argv ? process.argv[1] : null;
    }
    if (deeplinkingUrl) {
      setTimeout(() => {
        win.webContents.send('open-url-event', deeplinkingUrl);
      }, 1000);
    }
    if (Notification.isSupported()) {
      ipcMain.on('new-notification', (event, data) => {
        new Notification(data).show();
      });
    }
  });

  win.once('ready-to-show', () => {
    win.show();
  });
}

function createMenu() {
  const template = [
    {
      label: 'Edit',
      submenu: [
        { role: 'cut' },
        { role: 'copy' },
        { role: 'paste' },
        { role: 'selectall' }
      ]
    },
    {
      role: 'window',
      submenu: [{ role: 'minimize' }, { role: 'close' }]
    },
    {
      role: 'help',
      submenu: [
        {
          label: 'Open Help Center',
          click() {
            require('electron').shell.openExternal(
              'https://support.bitpay.com/hc/en-us'
            );
          }
        }
      ]
    }
  ];

  if (process.platform === 'darwin') {
    template.unshift({
      label: appConfig.nameCase,
      submenu: [
        { role: 'about' },
        { type: 'separator' },
        { role: 'hide' },
        { role: 'hideothers' },
        { role: 'unhide' },
        { type: 'separator' },
        { role: 'quit' }
      ]
    });
  }

  Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
// The setAsDefaultProtocolClient only works on packaged versions of the application

app.setAsDefaultProtocolClient('bitcoin');
app.setAsDefaultProtocolClient('bitcoincash');
app.setAsDefaultProtocolClient('bchtest');
app.setAsDefaultProtocolClient('ethereum');
app.setAsDefaultProtocolClient('ripple');
app.setAsDefaultProtocolClient('dogecoin');
app.setAsDefaultProtocolClient(appConfig.name);
app.setVersion(appConfig.version);
app.name = appConfig.nameCase;

const getHomeDirPath = platform => {<commit_msg>Fix(snap): do not register URL if it has already registered<commit_after>const { app, Menu, BrowserWindow, Notification, ipcMain } = require('electron');
const path = require('path');
const url = require('url');
const os = require('os');

const appConfig = require(path.join(
  __dirname,
  '/../www/assets/appConfig.json'
));
console.log('Desktop: ' + appConfig.nameCase + ' v' + appConfig.version);

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;

// Deep linked url
let deeplinkingUrl;

const isDevMode = process.execPath.match(/[\\/]electron/);

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({
    width: 400,
    height: 650,
    minWidth: 400,
    maxWidth: 800,
    minHeight: 650,
    show: false,
    webPreferences: {
      nodeIntegration: true,
      worldSafeExecuteJavaScript: true,
      enableRemoteModule: true
    }
  });

  // and load the index.html of the app.
  win.loadURL(
    url.format({
      pathname: path.join(__dirname, '/../www/index.html'),
      protocol: 'file:',
      slashes: true
    })
  );

  // Open the DevTools.
  if (isDevMode) {
    win.webContents.openDevTools();
  }
  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null;
  });

  win.webContents.on('did-finish-load', () => {
    // Windows - Linux: Handle deeplink url
    if (process.platform == 'win32' || process.platform == 'linux') {
      // Keep only command line / deep linked arguments
      deeplinkingUrl = process.argv ? process.argv[1] : null;
    }
    if (deeplinkingUrl) {
      setTimeout(() => {
        win.webContents.send('open-url-event', deeplinkingUrl);
      }, 1000);
    }
    if (Notification.isSupported()) {
      ipcMain.on('new-notification', (event, data) => {
        new Notification(data).show();
      });
    }
  });

  win.once('ready-to-show', () => {
    win.show();
  });
}

function createMenu() {
  const template = [
    {
      label: 'Edit',
      submenu: [
        { role: 'cut' },
        { role: 'copy' },
        { role: 'paste' },
        { role: 'selectall' }
      ]
    },
    {
      role: 'window',
      submenu: [{ role: 'minimize' }, { role: 'close' }]
    },
    {
      role: 'help',
      submenu: [
        {
          label: 'Open Help Center',
          click() {
            require('electron').shell.openExternal(
              'https://support.bitpay.com/hc/en-us'
            );
          }
        }
      ]
    }
  ];

  if (process.platform === 'darwin') {
    template.unshift({
      label: appConfig.nameCase,
      submenu: [
        { role: 'about' },
        { type: 'separator' },
        { role: 'hide' },
        { role: 'hideothers' },
        { role: 'unhide' },
        { type: 'separator' },
        { role: 'quit' }
      ]
    });
  }

  Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
// The setAsDefaultProtocolClient only works on packaged versions of the application

if (!app.isDefaultProtocolClient('bitcoin'))
  app.setAsDefaultProtocolClient('bitcoin');
if (!app.isDefaultProtocolClient('bitcoincash'))
  app.setAsDefaultProtocolClient('bitcoincash');
if (!app.isDefaultProtocolClient('bchtest'))
  app.setAsDefaultProtocolClient('bchtest');
if (!app.isDefaultProtocolClient('ethereum'))
  app.setAsDefaultProtocolClient('ethereum');
if (!app.isDefaultProtocolClient('ripple'))
  app.setAsDefaultProtocolClient('ripple');
if (!app.isDefaultProtocolClient('dogecoin'))
  app.setAsDefaultProtocolClient('dogecoin');
if (!app.isDefaultProtocolClient(appConfig.name))
  app.setAsDefaultProtocolClient(appConfig.name);

app.setVersion(appConfig.version);
app.name = appConfig.nameCase;

const getHomeDirPath = platform => {
{'fraction_non_alphanumeric': 0.14854597851716006, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 2.7045123726346434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4178362', 'n_tokens_mistral': 2424, 'n_tokens_neox': 2332, 'n_words': 545}