pub(in crate::inspect::smp) fn classify_real_grouped_effect_semantic_family(
    opcode: u8,
    raw_scalar_value: i32,
    value_byte_0x11: u8,
    value_byte_0x12: u8,
    value_word_0x14: u16,
    value_word_0x16: u16,
) -> &'static str {
    if opcode == 8 {
        return "multivalue_scalar";
    }
    if value_byte_0x11 != 0 || value_byte_0x12 != 0 || value_word_0x14 != 0 || value_word_0x16 != 0
    {
        return "timed_duration";
    }
    if raw_scalar_value == 0 || raw_scalar_value == 1 {
        return "bool_toggle";
    }
    "scalar_assignment"
}

pub(in crate::inspect::smp) fn classify_real_grouped_effect_row_shape(
    opcode: u8,
    raw_scalar_value: i32,
    value_byte_0x11: u8,
    value_byte_0x12: u8,
    value_word_0x14: u16,
    value_word_0x16: u16,
) -> &'static str {
    if opcode == 8 {
        return "multivalue_scalar";
    }
    if value_byte_0x11 != 0 || value_byte_0x12 != 0 || value_word_0x14 != 0 || value_word_0x16 != 0
    {
        return "timed_duration";
    }
    if raw_scalar_value == 0 || raw_scalar_value == 1 {
        return "bool_toggle";
    }
    "scalar_assignment"
}

pub(in crate::inspect::smp) fn build_real_grouped_effect_semantic_preview(
    descriptor_label: Option<&str>,
    semantic_family: &str,
    raw_scalar_value: i32,
    value_byte_0x11: u8,
    value_byte_0x12: u8,
    value_word_0x14: u16,
    value_word_0x16: u16,
) -> String {
    let label = descriptor_label.unwrap_or("descriptor");
    match semantic_family {
        "bool_toggle" => {
            let state = if raw_scalar_value == 0 {
                "FALSE"
            } else {
                "TRUE"
            };
            format!("Set {label} to {state}")
        }
        "building_spawn_batch" => format!(
            "Batch place {label} with scalar {raw_scalar_value}, count {value_byte_0x11}, and span words [{value_word_0x14}, {value_word_0x16}]"
        ),
        "timed_duration" => format!(
            "Set {label} to {raw_scalar_value} for {value_word_0x14} years {value_word_0x16} months"
        ),
        "multivalue_scalar" => format!(
            "Set {label} to {raw_scalar_value} with aux [{value_byte_0x11}, {value_byte_0x12}, {value_word_0x14}, {value_word_0x16}]"
        ),
        _ => format!("Set {label} to {raw_scalar_value}"),
    }
}
