"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const electron_1 = require("electron"); const node_path_1 = __importDefault(require("node:path")); const db_1 = require("./db"); const handlers_1 = require("./ipc/handlers"); const isDev = !electron_1.app.isPackaged; let mainWindow = null; function createWindow() { mainWindow = new electron_1.BrowserWindow({ width: 1400, height: 900, minWidth: 1000, minHeight: 600, show: false, titleBarStyle: "hiddenInset", webPreferences: { contextIsolation: true, nodeIntegration: false, preload: node_path_1.default.join(__dirname, "preload.js"), }, }); (0, handlers_1.registerIpcHandlers)(mainWindow); if (isDev) { const url = process.env.VITE_DEV_SERVER_URL ?? "http://localhost:5173"; mainWindow.loadURL(url).finally(() => { mainWindow.show(); mainWindow.webContents.openDevTools({ mode: "detach" }); }); } else { const indexHtml = node_path_1.default.join(electron_1.app.getAppPath(), "renderer", "dist", "index.html"); mainWindow.loadFile(indexHtml).finally(() => mainWindow.show()); } } electron_1.app.whenReady().then(() => { // Initialize database (0, db_1.getDb)(); createWindow(); electron_1.app.on("activate", () => { if (electron_1.BrowserWindow.getAllWindows().length === 0) { createWindow(); } }); }); electron_1.app.on("window-all-closed", () => { (0, db_1.closeDb)(); if (process.platform !== "darwin") { electron_1.app.quit(); } });