const { app, BrowserWindow } = require("electron");

const createWindow = () => {
  const win = new BrowserWindow({
    width: 1080,
    height: 1920,
    fullscreen: true,
    frame: false,
    autoHideMenuBar: true,
    kiosk: true,
    webPreferences: {
      nodeIntegration: true,
    },
  });

  console.log("Running URL: ", process.env.KIOSK_URL);
  win.loadURL(process.env.KIOSK_URL);
};

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

app.on("web-contents-created", (event, contents) => {
  contents.on("new-window", (event, navigationUrl) => {
    event.preventDefault();
  });
});

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