using System.Collections;
namespace XFESystem.Browser;
/// A computed declaration map with a shared, immutable custom-property
/// environment. Descendants without overrides do not copy the whole theme.
internal sealed class CssPropertyMap(IReadOnlyDictionary own, IReadOnlyDictionary custom)
: IReadOnlyDictionary
{
public int Count => own.Count + custom.Count;
public IEnumerable Keys => own.Keys.Concat(custom.Keys);
public IEnumerable Values => own.Values.Concat(custom.Values);
public string this[string key] => TryGetValue(key, out var value) ? value : throw new KeyNotFoundException();
public bool ContainsKey(string key) => own.ContainsKey(key) || custom.ContainsKey(key);
public bool TryGetValue(string key, out string value) => own.TryGetValue(key, out value!) || custom.TryGetValue(key, out value!);
public IEnumerator> GetEnumerator()
{
foreach (var pair in own) yield return pair;
foreach (var pair in custom) yield return pair;
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}