using System;
using System.Reflection;
using Avalonia.Svg.Skia;
using InABox.Avalonia.Components;
using Syncfusion.Pdf.Parsing;

namespace InABox.Avalonia;

public static class Images
{
    
    public static SvgImage? LoadSVG(string image, Assembly? assembly = null)
    {
        SvgImage? result = null;
        if (!string.IsNullOrWhiteSpace(image))
        {
            SvgSource.EnableThrowOnMissingResource = false;
            var source = assembly != null 
                ? SvgSource.Load($"avares://{assembly.GetName().Name}{image}")
                : SvgSource.Load($"avares://{Assembly.GetCallingAssembly().GetName().Name}{image}"); 
            result = new SvgImage { Source = source };
        }

        return result;
    }
    
    public static SvgImage? search => LoadSVG("/Images/search.svg");
}