import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/foundation.dart' show kIsWeb;

import '../services/permission_service.dart';

/// Helpers for requesting and checking the platform notification permission.
///
/// This file exists mostly for backwards‑compatibility; the real logic lives in
/// [permission_service].

Future<PermissionStatus> requestNotificationPermission() async {
  if (kIsWeb) {
    return PermissionStatus.granted;
  }
  return requestPermission(Permission.notification);
}

Future<bool> ensureNotificationPermission() async {
  if (kIsWeb) return true;
  final status = await Permission.notification.status;
  if (status.isGranted) return true;
  if (status.isDenied || status.isRestricted || status.isLimited) {
    final newStatus = await requestNotificationPermission();
    return newStatus.isGranted;
  }
  // permanently denied requires user to open settings
  return false;
}
