<template name="eventEditVenue">
	<div class="form-group">
		<label>
			{{mf 'course.event.edit.location' 'Venue'}}
			<small> {{mf '_inputField.optional'}}</small>
		</label>
		<div class="event-edit-location-info">
			{{mf 'event.edit.location.info' 'You can search the venues, choose from the recently used, click on the map, or create a new venue.'}}
		</div>
		<div class="event-edit-location">
			<div class="event-edit-location-search">
				{{#if locationIsPreset}}
					<div class="event-edit-location-selected">
						<span class="fa fa-map-marker fa-fw" aria-hidden="true"></span>
						{{> venueLink venue=location openInNewTab=true}}
						{{#if location.address}}
							<div class="event-edit-location-address">
								{{location.address}}
							</div>
						{{/if}}
						{{#if location.editor}}
							<div class="event-edit-location-contact">
								{{#mf KEY='event.editVenue.pleaseContactHost'}}
									Please contact the host of this venue to check for availability and other details:
								{{/mf}}
								<a href="{{hostProfileLink}}" target="_blank">
									<i class="fa fa-send" aria-hidden="true"></i>
									{{mf 'event.editVenue.contactHost' 'Contact host'}}
								</a>
							</div>
						{{/if}}
					</div>
					<button type="button" class="btn btn-edit js-location-change">
						{{mf 'event.edit.locationChange' "Change venue"}}
					</button>
				{{else}}
					<div class="input-group event-edit-location-searchbar">
						<input type="text" class="form-control js-location-search-input"
							placeholder="{{mf 'event.edit.locationNamePlaceholder' 'Where?'}}"
							value="{{location.name}}"/>
						<span class="input-group-btn">
							<button type="submit" class="btn btn-go js-location-search-btn">
								<span class="fa fa-search fa-fw" aria-hidden="true"></span>
								{{mf 'event.edit.addressSearch' "Search"}}
							</button>
						</span>
					</div>
					{{#if searching}}
						<input type="text" class="form-control js-location-address-search"
							placeholder="{{mf 'event.edit.locationAddressPlaceholder' 'Address'}}"
							size="40"
							value="{{location.address}}"/>
					{{/if}}
					{{#if haveLocationCandidates}}
						{{#if searching}}
							{{mf 'event.edit.locations.proposed' 'Matching locations:'}}
						{{else}}
							{{mf 'event.edit.locations.previouslyUsed' 'Recently used locations:'}}
						{{/if}}
						<ul class="event-edit-location-candidates">
							{{#each locationCandidates}}
								<li class='event-edit-location-candidate js-location-candidate {{hoverClass}}'>
									{{name}}
									<div class="address">{{address}}</div>
								</li>
							{{/each}}
						</ul>
					{{else}}
						{{mf 'event.edit.locations.foundnone' 'No locations found.'}}
					{{/if}}
					<a class="btn btn-{{#if haveLocationCandidates}}default{{else}}add{{/if}} event-edit-location-create-venue"
					   href="{{pathFor 'venueDetails' _id='create'}}"
					   target="_blank">
					   {{mf 'profile.createNewVenue.button'}}
					</a>
				{{/if}}
			</div>
			<div class="event-edit-location-map">
				{{> map markers=eventMarkers allowPlacing=allowPlacing allowRemoving=allowRemoving}}
			</div>
		</div>
	</div>
</template>
