@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
@using Dynamicweb
@using System.IO

@{
	string logoLink = Pageview.CurrentParagraph?.Item["LogoLink"] != null ? Pageview.CurrentParagraph.Item["LogoLink"].ToString() : string.Empty;

	string logoImage = Pageview.CurrentParagraph?.Item["Logo"] != null ? Pageview.CurrentParagraph.Item["Logo"].ToString() : string.Empty;
	string title = Pageview.CurrentParagraph?.Item["Title"] != null ? Pageview.CurrentParagraph.Item["Title"].ToString() : Pageview.Area.Name;

	string maxWidth = Pageview.CurrentParagraph?.Item["MaxWidth"] != null ? "max-width: " + Pageview.CurrentParagraph.Item["MaxWidth"].ToString() + "px" : string.Empty;
	maxWidth = maxWidth == "max-width: 0px" ? string.Empty : maxWidth;
}

<div class="mb-4 text-center">
	@if (!string.IsNullOrWhiteSpace(logoLink))
	{
		@:<a href="@logoLink" class="text-decoration-none" title="@Translate("Leave checkout")">
	}

	@if (logoImage != "")
	{
		if (Path.GetExtension(logoImage).ToLower() == ".svg")
		{
			<div class="icon-auto" style="@maxWidth">
				@ReadFile(logoImage)
			</div>
		}
		else
		{
			string imageWidth = Pageview.CurrentParagraph.Item["MaxWidth"] != null ? Pageview.CurrentParagraph.Item["MaxWidth"].ToString() : "400";
			string imagePath = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&image=" + logoImage;

			<picture class="mx-auto d-block">
				<img src="@logoImage" alt="@title" style="@maxWidth">
			</picture>
		}
	}
	else
	{
		<div class="fs-3 p-0">@title</div>
	}

	@if (!string.IsNullOrWhiteSpace(logoLink))
	{
		@:</a>
	}
</div>
