const { app, BrowserWindow, globalShortcut, Menu } = require('electron');


const path = require('path');

function createWindow() {
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    show: false, 
    fullscreenable: false, 
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false,
      devTools: true
    }
  });

  win.loadFile('KU9hJDsvSUtcWzpzfkxFLjhQTS9s/MkgwVkYmdDlqIXlmdTNwVi09dGZQSy10SnRwMyYiRT8aZBd3ew.html');

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

 
  win.webContents.on('context-menu', (e) => {
    e.preventDefault();
  });
}
function createMenu() {
  const template = [
    {
      label: 'أدوات',
      submenu: [
        { role: 'quit', label: 'إنهاء الجلسة' }
      ]
    },

    {
      label: 'مهم',
      submenu: [
        {
          label: 'الشروحات',
          click: async () => {
            const { shell } = require('electron');
            await shell.openExternal('https://www.youtube.com/@ibtikarsoft');
          }
        },
        {
          label: 'تواصل معنا',
          click: () => {
            // تقدر تفتح نافذة جديدة أو موقع
            const { shell } = require('electron');
            shell.openExternal('https://wa.me/01153469912');
          }
        }
      ]
    },
    {
      label: 'عن التطبيق',
      submenu: [
        {
          label: 'عن التطبيق',
          click: () => {
            const { dialog } = require('electron');
            dialog.showMessageBox({
              type: 'info',
              title: 'ابتكار',
              message: 'مدير المرور المشفر من ابتكار',
              detail: 'تم التطوير بالكامل وبشكلٍ مُشفّر تمامًا من ابتكار سوفت',
              buttons: ['OK']
            });
          }
        }
      ]
    }
  ];

  const menu = Menu.buildFromTemplate(template);
  Menu.setApplicationMenu(menu);
}

app.whenReady().then(() => {
  createWindow();
  createMenu(); 
});

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow();
  }
});
