'use strict';

/* ────────────────────────────────────────────────────────────────
   Phase 7 Sprint 7.3-7.4 — Documentation & Release utilities
   
   API Doc generation, Migration helpers, Changelog, Benchmarks
──────────────────────────────────────────────────────────────── */
/** Engine module manifest — used for documentation generation. */
const ENGINE_MODULES = [
    { name: 'Core', path: 'core/', description: 'Fundamental types, math, events, service locator', entries: [] },
    { name: 'ECS', path: 'ecs/', description: 'Entity-Component-System world, components, queries', entries: [] },
    { name: 'Input', path: 'input/', description: 'Keyboard, mouse, gamepad, touch input management', entries: [] },
    { name: 'Audio', path: 'audio/', description: 'Sound playback, music, spatial audio', entries: [] },
    { name: 'Rendering', path: 'rendering/', description: '2D camera, sprite rendering, debug drawing', entries: [] },
    { name: 'Physics', path: 'physics/', description: '2D physics engine, collisions, spatial hash', entries: [] },
    { name: 'Scene', path: 'scene/', description: 'Scene management, transitions, prefabs, serialization', entries: [] },
    { name: 'UI', path: 'ui/', description: 'Game UI elements, HUD, focus navigation', entries: [] },
    { name: 'Multiplayer', path: 'multiplayer/', description: 'Local multiplayer, split-screen (up to 12 players)', entries: [] },
    { name: 'Procedural', path: 'procedural/', description: 'Random generation, noise, waves, loot tables, procedural sprites', entries: [] },
    { name: 'Engine', path: 'engine/', description: 'Main NiceGameEngine wrapper class', entries: [] },
    { name: 'Editor', path: 'editor/', description: 'React-based game editor, scene editor, asset manager, debug tools', entries: [] },
    { name: 'Scripting', path: 'scripting/', description: 'Visual node-based scripting system', entries: [] },
    { name: 'Tilemap', path: 'tilemap/', description: 'Tilemap rendering, auto-tiling, collision layers', entries: [] },
    { name: 'Animation', path: 'animation/', description: 'Sprite animation, tweens, state machines, easing', entries: [] },
    { name: 'Pathfinding', path: 'pathfinding/', description: 'A*, flow fields, navigation meshes', entries: [] },
    { name: 'Network', path: 'network/', description: 'WebRTC networking, lobbies, state sync, RPCs', entries: [] },
    { name: '3D Runtime', path: 'runtime3d/', description: '3D world, camera, renderer, physics, materials', entries: [] },
    { name: 'Templates', path: 'templates/', description: 'Game genre templates (30+ templates)', entries: [] },
    { name: 'Performance', path: 'performance/', description: 'Object pooling, LOD, culling, asset streaming', entries: [] },
    { name: 'Accessibility', path: 'accessibility/', description: 'Screen reader, colorblind, subtitles, difficulty', entries: [] },
];
/* ══════════════════════════════════════════════════════════════
   Version & Migration
   ══════════════════════════════════════════════════════════════ */
const ENGINE_VERSION = '1.0.0';
const ENGINE_NAME = '@nice2dev/game-engine';
const CHANGELOG = [
    {
        from: '0.1.0',
        to: '1.0.0',
        changes: [
            { type: 'new', module: 'core', description: 'Initial stable release with full 2D + 3D engine' },
            { type: 'new', module: 'ecs', description: 'ECS world with 11 built-in component types' },
            { type: 'new', module: 'multiplayer', description: 'Split-screen up to 12 players' },
            { type: 'new', module: 'network', description: 'WebRTC P2P networking with lobby system' },
            { type: 'new', module: 'runtime3d', description: '3D rendering, physics, materials' },
            { type: 'new', module: 'templates', description: '30+ game genre templates' },
            { type: 'new', module: 'performance', description: 'Object pooling, LOD, frustum culling' },
            { type: 'new', module: 'accessibility', description: 'Full accessibility support' },
        ],
    },
];
function runBenchmark(name, fn, iterations = 1000) {
    // Warmup
    for (let i = 0; i < 10; i++)
        fn();
    let total = 0;
    let min = Infinity;
    let max = 0;
    for (let i = 0; i < iterations; i++) {
        const start = performance.now();
        fn();
        const elapsed = performance.now() - start;
        total += elapsed;
        if (elapsed < min)
            min = elapsed;
        if (elapsed > max)
            max = elapsed;
    }
    const avg = total / iterations;
    return {
        name, iterations, totalMs: total, avgMs: avg,
        minMs: min, maxMs: max,
        opsPerSecond: 1000 / avg,
    };
}
function formatBenchmark(result) {
    return `${result.name}: ${result.avgMs.toFixed(4)}ms avg (${result.opsPerSecond.toFixed(0)} ops/s) [${result.iterations} iterations, min=${result.minMs.toFixed(4)}ms, max=${result.maxMs.toFixed(4)}ms]`;
}
function detectCapabilities() {
    var _a, _b;
    const isBrowser = typeof window !== 'undefined';
    const hasDocument = typeof document !== 'undefined';
    const hasNavigator = typeof navigator !== 'undefined';
    const testCanvas = () => {
        if (!hasDocument)
            return null;
        try {
            return document.createElement('canvas');
        }
        catch (_a) {
            return null;
        }
    };
    const canvas = testCanvas();
    return {
        webgl: !!((_a = canvas === null || canvas === void 0 ? void 0 : canvas.getContext) === null || _a === void 0 ? void 0 : _a.call(canvas, 'webgl')),
        webgl2: !!((_b = canvas === null || canvas === void 0 ? void 0 : canvas.getContext) === null || _b === void 0 ? void 0 : _b.call(canvas, 'webgl2')),
        webgpu: isBrowser && 'gpu' in navigator,
        webAudio: isBrowser && ('AudioContext' in window || 'webkitAudioContext' in window),
        gamepad: hasNavigator && 'getGamepads' in navigator,
        touch: isBrowser && ('ontouchstart' in window || (hasNavigator && navigator.maxTouchPoints > 0)),
        webrtc: isBrowser && 'RTCPeerConnection' in window,
        webSocket: isBrowser && 'WebSocket' in window,
        sharedArrayBuffer: typeof SharedArrayBuffer !== 'undefined',
        offscreenCanvas: isBrowser && 'OffscreenCanvas' in window,
        pointerLock: hasDocument && 'exitPointerLock' in document,
        fullscreen: hasDocument && ('exitFullscreen' in document || 'webkitExitFullscreen' in document),
        vibration: hasNavigator && 'vibrate' in navigator,
        performance: typeof performance !== 'undefined' && 'now' in performance,
    };
}
const DEFAULT_EXPORT_CONFIG = {
    target: 'web',
    minify: true,
    sourceMaps: false,
    treeshake: true,
    splitChunks: true,
    publicPath: '/',
    outputDir: 'dist',
    serviceWorker: false,
    manifest: false,
};
/** Generate a minimal PWA manifest. */
function generatePWAManifest(name, shortName, description, themeColor = '#000000') {
    return {
        name,
        short_name: shortName,
        description,
        start_url: '/',
        display: 'fullscreen',
        orientation: 'landscape',
        theme_color: themeColor,
        background_color: '#000000',
        icons: [
            { src: '/icon-192.png', sizes: '192x192', type: 'image/png' },
            { src: '/icon-512.png', sizes: '512x512', type: 'image/png' },
        ],
    };
}

exports.CHANGELOG = CHANGELOG;
exports.DEFAULT_EXPORT_CONFIG = DEFAULT_EXPORT_CONFIG;
exports.ENGINE_MODULES = ENGINE_MODULES;
exports.ENGINE_NAME = ENGINE_NAME;
exports.ENGINE_VERSION = ENGINE_VERSION;
exports.detectCapabilities = detectCapabilities;
exports.formatBenchmark = formatBenchmark;
exports.generatePWAManifest = generatePWAManifest;
exports.runBenchmark = runBenchmark;
//# sourceMappingURL=Release.js.map
