use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpContainerProfile {
    pub profile_family: String,
    pub profile_evidence: Vec<String>,
    pub is_known_profile: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpSaveBootstrapBlock {
    pub profile_family: String,
    pub aligned_window_offset: usize,
    pub leading_word: u32,
    pub leading_word_hex: String,
    pub anchor_word: u32,
    pub anchor_word_hex: String,
    pub descriptor_word_2: u32,
    pub descriptor_word_2_hex: String,
    pub descriptor_word_3: u32,
    pub descriptor_word_3_hex: String,
    pub descriptor_word_4: u32,
    pub descriptor_word_4_hex: String,
    pub descriptor_word_5: u32,
    pub descriptor_word_5_hex: String,
    pub descriptor_word_6: u32,
    pub descriptor_word_6_hex: String,
    pub descriptor_word_7: u32,
    pub descriptor_word_7_hex: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpSaveAnchorRunBlock {
    pub profile_family: String,
    pub cycle_start_offset: usize,
    pub cycle_words: Vec<u32>,
    pub cycle_hex_words: Vec<String>,
    pub full_cycle_count: usize,
    pub partial_cycle_word_count: usize,
    pub trailer_offset: usize,
    pub trailer_words: Vec<u32>,
    pub trailer_hex_words: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpRuntimeAnchorCycleBlock {
    pub profile_family: String,
    pub cycle_start_offset: usize,
    pub cycle_words: Vec<u32>,
    pub cycle_hex_words: Vec<String>,
    pub full_cycle_count: usize,
    pub partial_cycle_word_count: usize,
    pub trailer_offset: usize,
    pub trailer_words: Vec<u32>,
    pub trailer_hex_words: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpRuntimeTrailerBlock {
    pub profile_family: String,
    pub trailer_family: String,
    pub trailer_evidence: Vec<String>,
    pub trailer_offset: usize,
    pub prefix_words_0_to_5: Vec<u32>,
    pub prefix_hex_words_0_to_5: Vec<String>,
    pub tag_word_6: u32,
    pub tag_word_6_hex: String,
    pub tag_chunk_id_u16: u16,
    pub tag_chunk_id_hex: String,
    pub tag_chunk_id_grounded_alignment: Option<String>,
    pub length_word_7: u32,
    pub length_word_7_hex: String,
    pub length_high_u16: u16,
    pub length_high_hex: String,
    pub selector_word_8: u32,
    pub selector_word_8_hex: String,
    pub selector_high_u16: u16,
    pub selector_high_hex: String,
    pub layout_word_9: u32,
    pub layout_word_9_hex: String,
    pub descriptor_word_10: u32,
    pub descriptor_word_10_hex: String,
    pub descriptor_high_u16: u16,
    pub descriptor_high_hex: String,
    pub descriptor_word_11: u32,
    pub descriptor_word_11_hex: String,
    pub counter_word_12: u32,
    pub counter_word_12_hex: String,
    pub offset_word_13: u32,
    pub offset_word_13_hex: String,
    pub span_word_14: u32,
    pub span_word_14_hex: String,
    pub mode_word_15: u32,
    pub mode_word_15_hex: String,
    pub words: Vec<u32>,
    pub hex_words: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpRuntimePostSpanProbe {
    pub profile_family: String,
    pub span_target_offset: usize,
    pub next_nonzero_offset: Option<usize>,
    pub next_aligned_candidate_offset: Option<usize>,
    pub next_aligned_candidate_words: Vec<u32>,
    pub next_aligned_candidate_hex_words: Vec<String>,
    pub header_candidates: Vec<SmpRuntimePostSpanHeaderCandidate>,
    pub grounded_progress_hits: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpRuntimePostSpanHeaderCandidate {
    pub offset: usize,
    pub words: Vec<u32>,
    pub hex_words: Vec<String>,
    pub dense_word_count: usize,
    pub high_u16_words: Vec<u16>,
    pub high_hex_words: Vec<String>,
    pub grounded_alignments: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpRt3105PostSpanBridgeProbe {
    pub profile_family: String,
    pub bridge_family: String,
    pub bridge_evidence: Vec<String>,
    pub span_target_offset: usize,
    pub next_candidate_offset: Option<usize>,
    pub next_candidate_delta_from_span_target: Option<usize>,
    pub packed_profile_offset: usize,
    pub packed_profile_delta_from_span_target: usize,
    pub next_candidate_delta_from_packed_profile: Option<i64>,
    pub selector_high_u16: u16,
    pub selector_high_hex: String,
    pub descriptor_high_u16: u16,
    pub descriptor_high_hex: String,
    pub next_candidate_high_u16_words: Vec<u16>,
    pub next_candidate_high_hex_words: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SmpRt3105SaveBridgePayloadProbe {
    pub profile_family: String,
    pub bridge_family: String,
    pub primary_block_offset: usize,
    pub primary_block_len: usize,
    pub primary_block_len_hex: String,
    pub primary_words: Vec<u32>,
    pub primary_hex_words: Vec<String>,
    pub secondary_block_offset: usize,
    pub secondary_block_delta_from_primary: usize,
    pub secondary_block_delta_from_primary_hex: String,
    pub secondary_block_end_offset: usize,
    pub secondary_block_len: usize,
    pub secondary_block_len_hex: String,
    pub secondary_preview_word_count: usize,
    pub secondary_words: Vec<u32>,
    pub secondary_hex_words: Vec<String>,
    pub evidence: Vec<String>,
}
