use crate::column_types::models::Warehouse;
use crate::load_naming::_helpers::spellings::{kept_as_written, reaches};
use crate::load_naming::main::existing_spelling::existing_spelling;
pub fn ambiguous_spellings<'a>(
(existing, warehouse): (&'a [String], Option<Warehouse>),
source: &str,
named: &str,
) -> Vec<&'a str> {
let matching: Vec<&'a str> = existing
.iter()
.filter(|column| column.eq_ignore_ascii_case(source))
.filter(|column| kept_as_written(column, warehouse))
.map(String::as_str)
.collect();
let decided = matching.len() <= 1
|| matching.contains(&source)
|| existing_spelling((existing, warehouse), source, named).is_some()
|| matching
.iter()
.any(|column| reaches(column, named, warehouse));
match decided {
true => Vec::new(),
false => matching,
}
}