use crate::relays::default_relays;
use fast_config::FastConfig;
use nostr::{EventId, Keys, PublicKey, RelayUrl};
use serde::Deserialize;
use serde::Serialize;
use std::default::Default;

/// NIP-65 Relay List
#[derive(Serialize, Deserialize, FastConfig, Clone)]
pub struct BaseRelaysConfig {
    pub read_relays: Vec<RelayUrl>,
    pub write_relays: Vec<RelayUrl>,
}

impl Default for BaseRelaysConfig {
    fn default() -> Self {
        Self {
            read_relays: default_relays(),
            write_relays: default_relays(),
        }
    }
}

#[derive(Serialize, Deserialize, FastConfig, Clone)]
pub struct UIConfig {
    pub locale: String,
}

impl Default for UIConfig {
    fn default() -> Self {
        Self {
            locale: String::from("en"),
        }
    }
}

#[derive(Serialize, Deserialize, FastConfig, Default, Clone)]
pub struct PrivateBookmarks {
    pub notes: Vec<EventId>,
    pub public_keys: Vec<PublicKey>,
}

#[derive(Serialize, Deserialize, FastConfig, Clone)]
pub struct NostrConfig {
    // Client keys
    pub client_keys: String,
    // Last working bunker NostrConnect URI
    pub last_bunker_uri: Option<String>,
}

impl Default for NostrConfig {
    fn default() -> Self {
        let keys = Keys::generate();

        Self {
            client_keys: keys.secret_key().to_secret_hex(),
            last_bunker_uri: None,
        }
    }
}
