{{template "base/alert" .}}
<form class="issue-content ui comment form form-fetch-action" id="new-issue" action="{{.Link}}" method="post">
	<div class="issue-content-left">
		<div class="ui comments">
			<div class="comment">
				<div class=" tw-mr-4 not-mobile">{{ctx.AvatarUtils.Avatar .SignedUser 40}}</div>
				<div class="ui segment content tw-my-0 avatar-content-left-arrow">
					<div class="field">
						<input name="title" data-global-init="autoFocusEnd" id="issue_title" required maxlength="255" autocomplete="off"
								placeholder="{{ctx.Locale.Tr "repo.milestones.title"}}"
								value="{{if .TitleQuery}}{{.TitleQuery}}{{else if .IssueTemplateTitle}}{{.IssueTemplateTitle}}{{else}}{{.title}}{{end}}"
						>
						{{if .PageIsComparePull}}
							<div class="title_wip_desc" data-wip-prefixes="{{JsonUtils.EncodeToString .PullRequestWorkInProgressPrefixes}}">{{ctx.Locale.Tr "repo.pulls.title_wip_desc" (index .PullRequestWorkInProgressPrefixes 0)}}</div>
						{{end}}
					</div>
					{{if .Fields}}
						<input type="hidden" name="template-file" value="{{.TemplateFile}}">
						{{range .Fields}}
							{{if eq .Type "input"}}
								{{template "repo/issue/fields/input" dict "item" .}}
							{{else if eq .Type "markdown"}}
								{{template "repo/issue/fields/markdown" dict "item" .}}
							{{else if eq .Type "textarea"}}
								{{template "repo/issue/fields/textarea" dict "item" . "root" $}}
							{{else if eq .Type "dropdown"}}
								{{template "repo/issue/fields/dropdown" dict "item" .}}
							{{else if eq .Type "checkboxes"}}
								{{template "repo/issue/fields/checkboxes" dict "item" .}}
							{{end}}
						{{end}}
					{{else}}
						{{template "repo/issue/comment_tab" .}}
					{{end}}
					<div class="flex-text-block tw-justify-end">
						<button class="ui primary button">
							{{if .PageIsComparePull}}
								{{ctx.Locale.Tr "repo.pulls.create"}}
							{{else}}
								{{ctx.Locale.Tr "repo.issues.create"}}
							{{end}}
						</button>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="issue-content-right ui segment" data-global-init="initRepoIssueSidebar">
		{{if .PageIsComparePull}}
			{{template "repo/issue/sidebar/reviewer_list" $.IssuePageMetaData}}
			<div class="divider"></div>
		{{end}}

		{{template "repo/issue/sidebar/label_list" $.IssuePageMetaData}}
		{{template "repo/issue/sidebar/milestone_list" $.IssuePageMetaData}}
		{{if .IsProjectsEnabled}}
			{{template "repo/issue/sidebar/project_list" $.IssuePageMetaData}}
		{{end}}
		{{template "repo/issue/sidebar/assignee_list" $.IssuePageMetaData}}

		{{if .IssueTypeDefs}}
		<div class="divider"></div>
		<div class="tw-flex tw-items-center tw-justify-between tw-gap-2">
			<span class="text grey tw-text-sm">{{ctx.Locale.Tr "repo.issues.type"}} <span class="tw-text-red">*</span></span>
			<select name="type_id" class="ui compact mini dropdown tw-max-w-48" required>
				<option value="">—</option>
				{{range .IssueTypeDefs}}
					<option value="{{.ID}}" {{if .IsDefault}}selected{{end}}
						{{if .Color}}style="border-left: 3px solid {{.Color}}"{{end}}>
						{{.Name}}
					</option>
				{{end}}
			</select>
		</div>
		{{end}}

		{{if .IssuePriorityDefs}}
		<div class="tw-flex tw-items-center tw-justify-between tw-gap-2 tw-mt-2">
			<span class="text grey tw-text-sm">{{ctx.Locale.Tr "repo.issues.priority"}} <span class="tw-text-red">*</span></span>
			<select name="priority_id" class="ui compact mini dropdown tw-max-w-48" required>
				<option value="">—</option>
				{{range .IssuePriorityDefs}}
					<option value="{{.ID}}" {{if .IsDefault}}selected{{end}}
						{{if .Color}}style="border-left: 3px solid {{.Color}}"{{end}}>
						{{.Name}}
					</option>
				{{end}}
			</select>
		</div>
		{{end}}

		{{if .IssueStatusDefs}}
		<div class="tw-flex tw-items-center tw-justify-between tw-gap-2 tw-mt-2">
			<span class="text grey tw-text-sm">{{ctx.Locale.Tr "repo.issues.status"}} <span class="tw-text-red">*</span></span>
			<select name="status_id" class="ui compact mini dropdown tw-max-w-48" required>
				<option value="">—</option>
				{{range .IssueStatusDefs}}
					<option value="{{.ID}}" {{if and (eq .SortOrder 1) (not .ClosesIssue)}}selected{{end}}
						{{if .Color}}style="border-left: 3px solid {{.Color}}"{{end}}>
						{{.Name}}{{if .ClosesIssue}} ⏻{{end}}
					</option>
				{{end}}
			</select>
		</div>
		{{end}}

		{{if .CustomFieldDefs}}
		<div class="divider"></div>
		<div class="tw-flex tw-flex-col tw-gap-2">
			{{$values := .CustomFieldValues}}
			{{$fieldOptions := .CustomFieldOptions}}
			{{range .CustomFieldDefs}}
				{{$currentVal := index $values .ID}}
				<div class="tw-flex tw-items-center tw-justify-between tw-gap-2">
					<span class="text grey tw-text-sm" {{if .Description}}title="{{.Description}}"{{end}}>{{.Name}}{{if .Required}} <span class="tw-text-red">*</span>{{end}}</span>
					{{if ne .Options ""}}
						{{$opts := index $fieldOptions .ID}}
						<select name="custom-field-{{.ID}}" class="ui compact mini dropdown tw-max-w-48" {{if .Required}}required{{end}}>
							<option value="">—</option>
							{{range $opts}}
								<option value="{{.}}" {{if eq . $currentVal}}selected{{end}}>{{.}}</option>
							{{end}}
						</select>
					{{else}}
						<input name="custom-field-{{.ID}}" type="text" class="tw-max-w-48 tw-text-sm" value="{{$currentVal}}" placeholder="—" {{if .Required}}required{{end}}>
					{{end}}
				</div>
			{{end}}
		</div>
		{{end}}

		{{if and .PageIsComparePull (not (eq .HeadRepo.FullName .BaseCompareRepo.FullName)) .CanWriteToHeadRepo}}
			<div class="divider"></div>
			<div class="ui checkbox">
				<label data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.allow_edits_from_maintainers_desc"}}"><strong>{{ctx.Locale.Tr "repo.pulls.allow_edits_from_maintainers"}}</strong></label>
				<input name="allow_maintainer_edit" type="checkbox" {{if .AllowMaintainerEdit}}checked{{end}}>
			</div>
		{{end}}
	</div>
	<input type="hidden" name="redirect_after_creation" value="{{.redirect_after_creation}}">
</form>
