/** * Debug-gated console logging for the admin React bundles. * * Wraps `console.log`/`console.warn` so verbose diagnostics only print during * local development (Vite `import.meta.env.DEV`) or when an admin explicitly * opts in via `window.llmagnetDebug = true`. Production builds stay quiet. * * Genuine errors should still use `console.error` directly so they surface in * production for support. */ function debugEnabled(): boolean { try { if (typeof import.meta !== 'undefined' && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) { return true; } } catch { // import.meta not available; fall through. } return typeof window !== 'undefined' && (window as unknown as { llmagnetDebug?: boolean }).llmagnetDebug === true; } export function debugLog(...args: unknown[]): void { if (debugEnabled()) { // eslint-disable-next-line no-console console.log(...args); } } export function debugWarn(...args: unknown[]): void { if (debugEnabled()) { // eslint-disable-next-line no-console console.warn(...args); } }