{% set files_by_license = func.group_by(files, 'license_expr') %}
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>SBOM Report</title>
	<style>
		@import url('https://fonts.googleapis.com/css2?family=Lato&family=Roboto+Slab&display=swap');
		/* Nordic Default Theme */
		body {
			font-family: Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;
			color: #404040;
			margin: 51px;
			font-size: 16px;
			background-color: white;
		}
		pre {
			font-family: SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;
			font-size: 12px;
			line-height: 1.4;
			padding: 12px;
			border: 1px solid #e1e4e5;
			margin: 1px 0 24px;
			background: #f8f8f8;
			min-width: fit-content;
		}
		pre.list {
			padding: 0px 12px 12px;
		}
		h1 {
			font-family: Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif;
			border-top: 1px solid #ddd;
			padding-top: 20px;
			margin-top: 0px;
			margin-bottom: 24px;
		}
		h2 {
			font-family: Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif;
			border-top: 1px solid #ddd;
			padding-top: 24px;
			margin-top: 0px;
			margin-bottom: 24px;
		}
		a {
			color: #00a9ce;
			text-decoration: none;
		}
		a:hover {
			color: #0077C8;
		}
		div, p {
			line-height: 24px;
			margin-block-start: 1em;
			margin-block-end: 1em;
			margin-inline-start: 0px;
			margin-inline-end: 0px;
		}
		.src {
			font-family: SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace;
			font-size: 12px;
		}
		.fa {
			text-decoration: none;
			color: #404040;
		}
		.fa:hover {
			text-decoration: none;
			color: #0077C8;
		}
		div.package {
			background: #e7f2fa;
			color: #404040;
			padding: 8px 12px;
			margin: 16px 0px 8px;
			line-height: 1.7;
			border: 1px solid #e1e4e5;
		}
		span.modifications {
			font-weight: bold;
			display: inline-block;
			border: 1px solid #e1e4e5;
			padding: 3px 7px 2px;
			border-radius: 4px;
			background-color: white;
		}
		div.note-header {
			background: #6ab0de;
			color: white;
			font-weight: bold;
			padding: 4px 4px 4px 12px;
			margin-bottom: 0px;
		}
		div.note-content {
			background: #e7f2fa;
			color: #404040;
			padding: 12px;
			margin-top: 0px;
		}
		a#scroll-up {
			line-height: normal;
			position: fixed;
			bottom: 20px;
			right: 20px;
			display: block;
			background: #6ab0de;
			width: 56px;
			height: 50px;
			border-radius: 28px;
			color: white;
			text-align: center;
			font-size: 30px;
			padding-top: 6px;
			box-shadow: 1px 3px 10px 0px #222222
		}
		a#scroll-up:hover {
			box-shadow: 1px 3px 14px 3px #222222
		}
		span[class^="-icon-"] {
			width: 14px;
			height: 14px;
			vertical-align: -1px;
			display: inline-block;
			background-size: 100% 100%;
		}
		span.-icon-exclamation {
			background-image: url('data:image/svg+xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3Csvg%20version%3D%221.1%22%20viewBox%3D%220%200%2016%2016%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Ccircle%20cx%3D%228%22%20cy%3D%228%22%20r%3D%228%22%20fill%3D%22%23fff%22%2F%3E%3Crect%20x%3D%226.5%22%20y%3D%222.5%22%20width%3D%223%22%20height%3D%227%22%20fill%3D%22%236ab0de%22%2F%3E%3Crect%20x%3D%226.5%22%20y%3D%2210.5%22%20width%3D%223%22%20height%3D%223%22%20fill%3D%22%236ab0de%22%2F%3E%3C%2Fsvg%3E');
		}
		/* Dark Color Theme */
		@media (prefers-color-scheme: dark) {
			body {
				color: #cccccc;
				background-color: #292929;
			}
			pre {
				border: 1px solid #474747;
				background: #333333;
			}
			h2, h1 {
				border-top-color: #444444;
			}
			a:hover {
				color: #66d1e9;
			}
			.fa {
				color: #cccccc;
			}
			.fa:hover {
				color: #66d1e9;
			}
			div.package {
				background: #2c3e49;
				color: #cccccc;
				border: 1px solid #474747;
			}
			span.modifications {
				border: 1px solid #474747;
				background-color: #292929;
			}
			div.note-header, a#scroll-up {
				background: #447291;
			}
			div.note-content {
				background: #2c3e49;
				color: #cccccc;
			}
		}
		/* Visual Studio Code Color Theme */
		html[style*="--vscode"] body {
			color: var(--vscode-editor-foreground);
			background-color: var(--vscode-editor-background);
		}
		html[style*="--vscode"] pre {
			border: 1px solid var(--vscode-panel-border);
			background: var(--vscode-sideBar-background);
		}
		html[style*="--vscode"] h2, html[style*="--vscode"] h1 {
			border-top-color: var(--vscode-panel-border);
		}
		html[style*="--vscode"] a {
			color: var(--vscode-textLink-foreground);
			text-decoration: none;
		}
		html[style*="--vscode"] a:hover {
			text-decoration: underline;
			color: var(--vscode-textLink-activeForeground);
		}
		html[style*="--vscode"] .fa {
			color: var(--vscode-foreground);
		}
		html[style*="--vscode"] .fa:hover {
			text-decoration: none;
			color: var(--vscode-textLink-activeForeground);
		}
		html[style*="--vscode"] div.package {
			background: var(--vscode-quickInput-background);
			color: var(--vscode-quickInput-foreground);
			border: 1px solid var(--vscode-panel-border);
		}
		html[style*="--vscode"] span.modifications {
			border: 1px solid var(--vscode-panel-border);
			background-color: var(--vscode-quickInput-background);
		}
		html[style*="--vscode"] div.note-header, html[style*="--vscode"] a#scroll-up {
			text-decoration: none;
			background: var(--vscode-button-background);
			color: var(--vscode-button-foreground);
		}
		html[style*="--vscode"] div.note-content {
			background: var(--vscode-quickInput-background);
			color: var(--vscode-quickInput-foreground);
		}
	</style>
</head>

<body>
	<a id="scroll-up" href="#">▲</a>

	<h1>Software Bill of Material Report</h1>

	{% if '' in files_by_license %}
	<div class="note-header">
		<span class="-icon-exclamation"></span>&nbsp; Note
	</div>
	<div class="note-content">
		Some of the files in the report do no contain license information or it cannot be detected.
		See <a href="#no-license">license details</a> for list of such files.
		You need to evaluate them manually to get the license information.
	</div>
	{% endif %}

	{% if 'scancode-toolkit' in detectors %}
	<div class="note-header">
		<span class="-icon-exclamation"></span>&nbsp; Note
	</div>
	<div class="note-content">
		Some of the licenses were detected by an external tool <a href="https://github.com/nexB/scancode-toolkit">ScanCode Toolkit</a>.
		You can read more about it in the <a href="https://scancode-toolkit.readthedocs.io/">ScanCode Toolkit Documentation</a>.
	</div>
	{% endif %}

	<div>This report was generated from the following inputs:</div>
	<ul>
		{% for input in inputs %}
		<li><span class="src">{{input|e}}</span></li>
		{% endfor %}
	</ul>

	<div>The files are covered by the following licenses:</div>
	<ul>
		{% for license in licenses_sorted %}
		{% if license and license in files_by_license %}
		<li><a href="#{{license|e}}">{{licenses[license].friendly_id|e}}</a></li>
		{% endif %}
		{% endfor %}
		{% if '' in files_by_license %}
		<li><a href="#no-license">Unknown licenses</a> that cannot be detected automatically</li>
		{% endif %}
	</ul>

	<div>The files are obtained from the following sources:</div>
	<ul>
		{% set files_by_package = func.group_by(files, 'package') %}
		{% for package_id in packages_sorted %}
		{% if package_id and package_id in files_by_package %}
		<li><a href="#package#{{package_id|e}}">{{packages[package_id].name if packages[package_id].name else packages[package_id].url|e}}, version {{packages[package_id].version|e}}</a></li>
		{% endif %}
		{% endfor %}
		{% if '' in files_by_package %}
		<li><a href="#no-package">Unknown source</a> that cannot be detected automatically</li>
		{% endif %}
	</ul>

	<div>The texts of the following licenses are added to this report:</div>
	<ul>
		{% for license in licenses_sorted if not licenses[license].is_expr and licenses[license].text != None %}
			<li><a href="#text-{{license|e}}">{{licenses[license].friendly_id|e}}</a></li>
		{% endfor %}
	</ul>

	<h1 id="license-details">License details</h1>

	{% if '' in files_by_license %}
	<h2 id="no-license">No license information detected</h2>
	<div>Files without any license information or with license information that cannot be detected automatically.</div>
	<pre class="list">
{% set license = '' -%}
{% set files_by_package_and_license = func.group_by(files_by_license[license], 'package') -%}
{% for package_id in packages_sorted -%}
{% if package_id in files_by_package_and_license -%}
<div class="package" id="package#{{package_id|e}}#{{license|e}}">Repository:
{%- if packages[package_id].url %} <a href="#package#{{package_id|e}}">{{packages[package_id].name if packages[package_id].name else packages[package_id].url|e}}</a>
{% else %} Unknown
{% endif -%}
Version:
{%- if packages[package_id].version %}    {{packages[package_id].version|e}}
{%- else %}    Unknown
{%- endif -%}
</div>
{%- for file_info in files_by_package_and_license[package_id] -%}
<a href="file:///{{file_info.file_path|e}}" class="fa">{{file_info.file_path|e}}</a>
{%- if file_info.local_modifications %} <span class="modifications">with local modifications</span>{%- endif %}
{% endfor -%}
{% endif -%}
{% endfor -%}
	</pre>
	{% endif %}

	{% for license in licenses_sorted %}
	{% if license and license in files_by_license %}
	<h2 id="{{license|e}}">{{licenses[license].friendly_id|e}}</h2>
	<div>
		{% if licenses[license].is_expr %}
			The license expression
			{% if not licenses[license].valid %}
				that cannot be correctly interpreted
			{% endif %}
			{% if licenses[license].licenses %}
				containing the following licenses:<ul>
				{% for sub_license in licenses[license].licenses %}
					<li>
					{{licenses[sub_license].friendly_id|e}}<br />
					{% if licenses[sub_license].custom %}
						Non-standard SPDX License:
					{% endif %}
					{% if licenses[sub_license].name != None %}
						{{licenses[sub_license].name|e}}
					{% else %}
						{{licenses[sub_license].friendly_id|e}}
					{% endif %}
					{% if licenses[sub_license].url != None %}
						<br /><a href="{{licenses[sub_license].url|e}}">{{licenses[sub_license].url|e}}</a>
					{% endif %}
					{% if licenses[sub_license].text != None %}
						<br /><a href="#text-{{sub_license|e}}">The license text</a> is added to this report.
					{% endif %}
					</li>
				{% endfor %}
			{% endif %}
			</ul>
		{% else %}
			{% if licenses[license].custom %}
				Non-standard SPDX License:
			{% endif %}
			{% if licenses[license].name != None %}
				{{licenses[license].name|e}}
			{% else %}
				{{licenses[license].friendly_id|e}}
			{% endif %}
			{% if licenses[license].url != None %}
				<br /><a href="{{licenses[license].url|e}}">{{licenses[license].url|e}}</a>
			{% endif %}
			{% if licenses[license].text != None %}
				<br /><a href="#text-{{license|e}}">The license text</a> is added to this report.
			{% endif %}
		{% endif %}
	</div>
	<pre class="list">
{% set files_by_package_and_license = func.group_by(files_by_license[license], 'package') -%}
{% for package_id in packages_sorted -%}
{% if package_id in files_by_package_and_license -%}
<div class="package" id="package#{{package_id|e}}#{{license|e}}">Repository:
{%- if packages[package_id].url %} <a href="#package#{{package_id|e}}">{{packages[package_id].name if packages[package_id].name else packages[package_id].url|e}}</a>
{% else %} Unknown
{% endif -%}
Version:
{%- if packages[package_id].version %}    {{packages[package_id].version|e}}
{%- else %}    Unknown
{%- endif -%}
</div>
{%- for file_info in files_by_package_and_license[package_id] -%}
<a href="file:///{{file_info.file_path|e}}" class="fa">{{file_info.file_path|e}}</a>
{%- if file_info.local_modifications %} <span class="modifications">with local modifications</span>{%- endif %}
{% endfor -%}
{% endif -%}
{% endfor -%}
	</pre>
	{% endif %}
	{% endfor %}

	<h1>Packages details</h1>

	{% if '' in files_by_package %}
	{% set package_id = '' %}
	<h2 id="no-package">Unknown source</h2>
	The files from unknown source are covered by the following licenses:
	<ul>
		{% set files_by_license_and_package = func.group_by(files_by_package[package_id], 'license_expr') %}
		{% for license in licenses_sorted %}
		{% if license and license in files_by_license_and_package %}
		<li><a href="#package#{{package_id|e}}#{{license|e}}">{{licenses[license].friendly_id|e}}</a></li>
		{% endif %}
		{% endfor %}
		{% if '' in files_by_license_and_package %}
		<li><a href="#package#{{package_id|e}}#">Unknown licenses</a> that cannot be detected automatically</li>
		{% endif %}
	</ul>
	{% endif %}

	{% set files_by_package = func.group_by(files, 'package') %}
	{% for package_id in packages_sorted %}
	{% if package_id and package_id in files_by_package %}

	<h2 id="package#{{package_id|e}}">{{packages[package_id].name if packages[package_id].name else packages[package_id].url|e}}</h2>
	<h3>Version: {{packages[package_id].version|e}}</h3>
	<p>URL:
	{% if packages[package_id].browser_url %}
	<a href="{{packages[package_id].browser_url|e}}">{{packages[package_id].url|e}}</a>
	{% else %}
	{{packages[package_id].url|e}}
	{% endif %}
	</p>
	<p>The files from this source are covered by the following licenses:</p>
	<ul>
		{% set files_by_license_and_package = func.group_by(files_by_package[package_id], 'license_expr') %}
		{% for license in licenses_sorted %}
		{% if license and license in files_by_license_and_package %}
		<li><a href="#package#{{package_id|e}}#{{license|e}}">{{licenses[license].friendly_id|e}}</a></li>
		{% endif %}
		{% endfor %}
		{% if '' in files_by_license_and_package %}
		<li><a href="#package#{{package_id|e}}#">Unknown licenses</a> that cannot be detected automatically</li>
		{% endif %}
	</ul>
	{% endif %}
	{% endfor %}

	<h1>Custom license texts</h1>

	{% for license in licenses_sorted if not licenses[license].is_expr and licenses[license].text != None %}
	<h2 id="text-{{license|e}}">{{licenses[license].friendly_id|e}}</h2>
	<pre>{{licenses[license].text|e}}</pre>
	{% endfor %}
</body>

</html>