<html>
	<head>
		<title>n8n - SAML Connection Test Result</title>
		<style>
			body { background: rgb(251,252,254); font-family: 'Open Sans', sans-serif; padding: 10px; margin: auto; max-width: 700px; }
			h1 { color: rgb(240, 60, 60); font-size: 16px; font-weight: 400; margin: 0 0 10px 0; }
			h2 { color: rgb(0, 0, 0); font-size: 12px; font-weight: 400; margin: 0 0 10px 0; }
			button { border: 1px solid rgb(219, 223, 231); background: rgb(255, 255, 255); border-radius: 4px; padding: 10px; cursor: pointer; font: inherit; }
			ul { border: 1px solid rgb(219, 223, 231); border-radius: 4px; padding: 10px; }
			li { decoration: none; list-style: none; margin: 0 0 0px 0; color: rgb(125, 125, 125); font-size: 12px;}
			details { margin-top: 24px; text-align: left; border: 1px solid rgb(219, 223, 231); border-radius: 4px; padding: 8px 12px; }
			summary { cursor: pointer; font-size: 12px; color: rgb(70, 70, 70); padding: 4px 0; }
			.claims-warning { color: rgb(125, 125, 125); font-size: 11px; margin: 6px 0 12px 0; }
			pre.saml-raw-attributes { background: white; border: 1px solid rgb(219, 223, 231); border-radius: 4px; padding: 10px; margin: 0; max-height: 320px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; white-space: pre; }
		</style>
	</head>
	<body>
		<div style="text-align:center">
			<h1>SAML Connection Test failed</h1>
			<h2>{{#if message}}{{message}}{{else}}A common issue could be that no email attribute is set{{/if}}</h2>
			<button onclick="window.close()">You can close this window now</button>
			<p></p>
			{{#with attributes}}
			<h2>Here are the attributes returned by your SAML IdP:</h2>
			<ul>
				<li><strong>Email:</strong> {{#if email}}{{email}}{{else}}(n/a){{/if}}</li>
				<li><strong>First Name:</strong> {{#if firstName}}{{firstName}}{{else}}(n/a){{/if}}</li>
				<li><strong>Last Name:</strong> {{#if lastName}}{{lastName}}{{else}}(n/a){{/if}}</li>
				<li><strong>UPN:</strong> {{#if userPrincipalName}}{{userPrincipalName}}{{else}}(n/a){{/if}}</li>
			</ul>
			{{/with}}
			{{#if rawAttributesJson}}
			<details>
				<summary>Show full raw SAML attributes (for debugging role mapping)</summary>
				<p class="claims-warning">Contains identity data from your IdP. Avoid sharing publicly.</p>
				<pre class="saml-raw-attributes">{{rawAttributesJson}}</pre>
			</details>
			{{/if}}
		</div>
	</body>
</html>
