{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content organization wiki">
	{{template "org/header" .}}
	{{template "org/menu" .}}
	<div class="ui container">
		{{if .WikiEmpty}}
			<div class="ui placeholder segment">
				<div class="ui icon header">
					{{svg "octicon-book" 48}}
					<br>
					This organization doesn't have a wiki yet.
				</div>
				<p class="tw-text-center">
					Enable the wiki on the <code>.profile</code> (public) or <code>.profile-private</code> (members-only)
					repository to get started.
				</p>
			</div>
		{{else}}
			<div class="repo-button-row tw-flex tw-items-center tw-gap-2 tw-mb-4">
				<div class="tw-flex-1 tw-flex tw-items-center tw-gap-2">
					{{svg "octicon-book" 16}}
					<strong>{{.CurrentPage}}</strong>
				</div>
				{{if .ShowWikiViewSelector}}
					<div class="ui dropdown jump">
						{{- $viewAsRole := Iif (.IsViewingWikiAsMember) (ctx.Locale.Tr "org.members.member") (ctx.Locale.Tr "settings.visibility.public") -}}
						<span class="text">{{svg "octicon-eye"}} {{ctx.Locale.Tr "org.view_as_role" $viewAsRole}}</span>
						{{svg "octicon-triangle-down" 14 "dropdown icon"}}
						<div class="menu">
							<a href="{{$.Org.HomeLink}}/-/wiki/{{.CurrentPage}}?view_as=public" class="item {{if not .IsViewingWikiAsMember}}selected{{end}}">
								{{svg "octicon-check" 14 (Iif (not .IsViewingWikiAsMember) "" "tw-invisible")}} {{ctx.Locale.Tr "settings.visibility.public"}}
							</a>
							<a href="{{$.Org.HomeLink}}/-/wiki/{{.CurrentPage}}?view_as=member" class="item {{if .IsViewingWikiAsMember}}selected{{end}}">
								{{svg "octicon-check" 14 (Iif .IsViewingWikiAsMember "" "tw-invisible")}} {{ctx.Locale.Tr "org.members.member"}}
							</a>
						</div>
					</div>
				{{end}}
			</div>

			{{if .WikiPageNotFound}}
				<div class="ui segment">
					<div class="ui icon message">
						{{svg "octicon-alert" 24}}
						<div class="content">
							<div class="header">Page not found</div>
							<p>The page "{{.CurrentPage}}" does not exist in this wiki.</p>
						</div>
					</div>
					{{if .Pages}}
						<h4>Available pages:</h4>
						<ul>
							{{range .Pages}}
								<li><a href="{{$.Org.HomeLink}}/-/wiki/{{.SubURL}}">{{.Name}}</a></li>
							{{end}}
						</ul>
					{{end}}
				</div>
			{{else}}
				<div class="wiki-content-parts">
					<div class="render-content markup wiki-content-main {{if or .WikiSidebarHTML .Pages}}with-sidebar{{end}}">
						{{.WikiContent}}
					</div>

					{{if or .WikiSidebarHTML .Pages}}
					<div class="render-content markup wiki-content-sidebar">
						{{if .WikiSidebarHTML}}
							{{.WikiSidebarHTML}}
							<div class="ui divider"></div>
						{{end}}
						{{if .Pages}}
							<strong>{{svg "octicon-list-unordered" 14}} Pages</strong>
							<ul class="wiki-tree-list">
								{{range .Pages}}
									<li>
										{{svg "octicon-file" 14}}
										<a href="{{$.Org.HomeLink}}/-/wiki/{{.SubURL}}" {{if eq $.CurrentPage .Name}}class="active"{{end}}>{{.Name}}</a>
									</li>
								{{end}}
							</ul>
						{{end}}
					</div>
					{{end}}

					<div class="tw-clear-both"></div>

					{{if .WikiFooterHTML}}
						<div class="render-content markup wiki-content-footer">
							{{.WikiFooterHTML}}
						</div>
					{{end}}
				</div>
			{{end}}
		{{end}}
	</div>
</div>
{{template "base/footer" .}}
