import AppIntents

/// Friendly, spoken-safe failures for Nucleic's App Intents. The phone is a thin client with no
/// local authority (docs/APP_INTENTS_OPPORTUNITIES §3.1): an intent that can't reach the paired
/// Mac must fail *clean* with a dialog, never silently or with a raw error.
enum IntentError: Error, CustomLocalizedStringResourceConvertible {
    /// No live channel to any paired Mac (and none came up within the wait window).
    case macUnreachable
    /// Not paired with a Mac yet — nothing to act on.
    case notPaired
    /// The action needs `control` scope, which this device hasn't been granted.
    case controlScopeRequired
    /// A high-risk approval (destructive/network/host-exec) can't be allowed inline — it must be
    /// confirmed on the app's guarded card (docs/APP_INTENTS_OPPORTUNITIES §3.3).
    case needsAppConfirmation
    /// Cloud lock-screen approvals are off (SyncedSettings.resolveApprovalsViaCloud) — the decision
    /// won't be sent over Nucleic's relay, so open the app to resolve it locally instead.
    case resolveInApp

    var localizedStringResource: LocalizedStringResource {
        switch self {
        case .macUnreachable:
            "Your Mac isn't reachable right now. Try again when it's online."
        case .notPaired:
            "Pair this iPhone with your Mac in Nucleic first."
        case .controlScopeRequired:
            "This device can view and approve, but isn't allowed to control sessions."
        case .needsAppConfirmation:
            "This one's high-risk — open Nucleic to confirm it on the approval card."
        case .resolveInApp:
            "Open Nucleic to approve. Turn on relay approvals in Settings to answer from the lock screen."
        }
    }
}
