{{ define "tpl" }}
<div class="ui container">
	{{ $regEnabled := qb "SELECT value_int FROM system_settings WHERE name = 'registrations_enabled'" }}
	{{ if .Context.User.ID }}
		<div class="ui segment">
			{{ .T "You're already logged in!" }}
		</div>
	{{ else if not ($regEnabled.value_int.Bool) }}
		<div class="ui error message">
			{{ .T "Sorry, it's not possible to register at the moment. Please try again later." }}
		</div>
	{{ else }}
		{{ if eq (.Gin.Query "stopsign") "1" }}
			<div class="ui warning message">
				{{ .T "Remember: this seems like it's your second account! Do not multiaccount, or you're likely to get restricted!" }}
			</div>
		{{ end }}
		<div class="tiny container">
			<div class="ui raised segments">
				<div class="ui segment">
					<form id="register-form" class="ui form" method="post" action="/register">
						<div class="field">
							<label>{{ .T "Username (2 to 15 characters, alphanumeric, spaces, <code>_[]-</code>)" | html }}</label>
							<input tabindex="1" type="text" name="username" placeholder="{{ .T "Username" }}" value="{{ .FormData.username }}" required pattern="^[A-Za-z0-9 _\[\]-]{2,15}$">
						</div>
						<div class="field">
							<label>{{ .T "Password (at least 8 characters)" }}</label>
							<input tabindex="2" type="password" name="password" placeholder="{{ .T "Password" }}" value="{{ .FormData.password }}" required pattern="^.{8,}$">
						</div>
						<div class="field">
							<label>{{ .T "Email" }}</label>
							<input tabindex="3" type="email" name="email" placeholder="{{ .T "Email" }}" value="{{ .FormData.email }}" required>
						</div>
						<div class="field">
							<label>{{ .T "Registration Key" }}</label>
							<input tabindex="3" type="text" name="key" placeholder="{{ .T "Key" }}" value="{{ .FormData.key }}" required>
						</div>
						{{ with config "RecaptchaSite" }}
						<div class="field">
							<div class="g-recaptcha" data-sitekey="{{ . }}"></div>
						</div>
						{{ end }}
						{{ ieForm .Gin }}
					</form>
				</div>
				<div class="ui right aligned segment">
					<button tabindex="4" class="ui primary button" type="submit" form="register-form">{{ .T "Submit" }}</button>
				</div>
			</div>
		</div>
	{{ end }}
</div>
{{ end }}