/* ────────────────────────────────────────────────────────────────
   ServiceLocator — Dependency injection container
──────────────────────────────────────────────────────────────── */
class ServiceLocator {
    constructor() {
        this.services = new Map();
    }
    static get instance() {
        if (!ServiceLocator._instance) {
            ServiceLocator._instance = new ServiceLocator();
        }
        return ServiceLocator._instance;
    }
    /** Register a service by key. */
    register(key, service) {
        this.services.set(key, service);
    }
    /** Retrieve a service by key. Throws if not registered. */
    get(key) {
        const svc = this.services.get(key);
        if (svc === undefined) {
            throw new Error(`[ServiceLocator] Service "${key}" not registered.`);
        }
        return svc;
    }
    /** Retrieve a service, or undefined if not registered. */
    tryGet(key) {
        return this.services.get(key);
    }
    /** Check if a service is registered. */
    has(key) {
        return this.services.has(key);
    }
    /** Remove a service. */
    unregister(key) {
        return this.services.delete(key);
    }
    /** Remove all services. */
    clear() {
        this.services.clear();
    }
    /** Reset static singleton (for testing). */
    static reset() {
        var _a;
        (_a = ServiceLocator._instance) === null || _a === void 0 ? void 0 : _a.clear();
        ServiceLocator._instance = null;
    }
}
ServiceLocator._instance = null;
/* ── Convenience service keys ─────────────────────────────────── */
const SERVICE_KEYS = {
    CONFIG: 'GameConfig',
    CLOCK: 'GameClock',
    LOOP: 'GameLoop',
    EVENTS: 'EventBus',
    EVENT_BUS: 'EventBus',
    INPUT: 'InputManager',
    AUDIO: 'AudioManager',
    RENDERER: 'Renderer2D',
    CAMERA: 'Camera2D',
    PHYSICS: 'PhysicsEngine',
    SCENES: 'SceneManager',
    SCENE_MANAGER: 'SceneManager',
    PLAYERS: 'PlayerManager',
    PLAYER_MANAGER: 'PlayerManager',
    WORLD: 'World',
};

export { SERVICE_KEYS, ServiceLocator };
//# sourceMappingURL=ServiceLocator.js.map
