import type { CallNotificationActionIntent, CallNotificationPayload } from '../logic/call-notification.rules';
import type { RuntimePlatform } from '../logic/platform-detection.rules';

export interface MobileNotificationAdapter {
  initialize(): Promise<void>;
  requestPermission(): Promise<boolean>;
  showCallNotification(payload: CallNotificationPayload): Promise<void>;
  dismissCallNotification(callId: string, kind: CallNotificationPayload['kind']): Promise<void>;
  onActionSelected(handler: (input: { callId: string; intent: CallNotificationActionIntent }) => void): void;
}

export interface MobileMediaAdapter {
  pickAttachments(): Promise<File[]>;
  setSpeakerphoneEnabled(enabled: boolean): Promise<void>;
  startBackgroundAudioSession(): Promise<void>;
  stopBackgroundAudioSession(): Promise<void>;
  isScreenShareSupported(): boolean;
  isPictureInPictureSupported(): boolean;
}

export interface MobilePictureInPictureAdapter {
  isSupported(): boolean;
  enter(videoElement: HTMLVideoElement): Promise<void>;
  exit(): Promise<void>;
}

export interface MobilePersistenceAdapter {
  readonly isNativeSqlite: boolean;
  initialize(): Promise<void>;
}

export interface MobileAppLifecycleAdapter {
  initialize(): Promise<void>;
  onAppStateChange(handler: (isActive: boolean) => void): void;
}

export interface MobileCallKitAdapter {
  startActiveCall(callId: string, displayName: string): Promise<void>;
  endActiveCall(callId: string): Promise<void>;
}

export interface MobilePlatformSnapshot {
  runtime: RuntimePlatform;
  isNativeMobile: boolean;
  isCapacitor: boolean;
}

export type MobileAppUpdateAvailability = 'unknown' | 'update-available' | 'update-not-available';

export interface MobileAppUpdateInfo {
  availableVersion: string | null;
  currentVersion: string;
  flexibleUpdateAllowed: boolean;
  immediateUpdateAllowed: boolean;
  platform: 'android' | 'ios' | null;
  updateAvailability: MobileAppUpdateAvailability;
}

export interface MobileAppUpdateAdapter {
  readonly isSupported: boolean;
  getAppUpdateInfo(): Promise<MobileAppUpdateInfo>;
  openAppStore(): Promise<void>;
  performImmediateUpdate(): Promise<void>;
  startFlexibleUpdate(): Promise<void>;
  completeFlexibleUpdate(): Promise<void>;
}
