import { Injectable, inject } from '@angular/core';
import { detectRuntimePlatform, isCapacitorNativeRuntime } from '../../infrastructure/mobile/logic/platform-detection.rules';
import { ElectronBridgeService } from './electron/electron-bridge.service';

@Injectable({ providedIn: 'root' })
export class PlatformService {
  readonly isElectron: boolean;
  readonly isCapacitor: boolean;
  readonly isBrowser: boolean;
  private readonly electronBridge = inject(ElectronBridgeService);

  constructor() {
    this.isElectron = this.electronBridge.isAvailable;

    const runtime = detectRuntimePlatform({
      hasElectronApi: this.isElectron,
      capacitorIsNative: isCapacitorNativeRuntime()
    });

    this.isCapacitor = runtime === 'capacitor';
    this.isBrowser = runtime === 'browser';
  }
}
