use std::collections::BTreeMap;
use crate::ast::span::Span;
use crate::ast::value::PropertyValue;
#[derive(Debug, Clone, PartialEq)]
pub struct UnknownStyleProp {
pub raw: String,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Style {
pub id: String,
pub properties: BTreeMap<String, PropertyValue>,
pub unknown_props: BTreeMap<String, UnknownStyleProp>,
pub source_span: Option<Span>,
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct StyleBlock {
pub styles: Vec<Style>,
pub source_span: Option<Span>,
}
pub const STYLE_RECOGNIZED_KEYS: &[&str] = &[
"fill",
"stroke",
"stroke-width",
"stroke-alignment",
"font-family",
"font-size",
"font-weight",
"line-height",
"radius",
"padding",
"gap",
];
pub fn canonicalize_style_key(name: &str) -> Option<&'static str> {
let normalized: &str = match name {
"stroke_width" => "stroke-width",
"stroke_alignment" => "stroke-alignment",
"font_family" => "font-family",
"font_size" => "font-size",
"font_weight" => "font-weight",
"line_height" => "line-height",
other => other,
};
STYLE_RECOGNIZED_KEYS
.iter()
.copied()
.find(|&k| k == normalized)
}