<template name="sidebarItemIcon">
	{{#if icon}}
		<div class="{{#if isRoom}}sidebar-item__room-type{{else}}sidebar-item__icon{{/if}} {{#if status}}sidebar-item__icon-status--{{status}}{{/if}}">
			{{> icon block="sidebar-item__icon" icon=icon}}
		</div>
	{{else}}
		<div class="sidebar-item__user-status {{#if status}}sidebar-item__user-status--{{status}}{{/if}}"></div>
	{{/if}}
</template>

<template name="sidebarItem">
	<li class="sidebar-item{{#if or unread alert }} sidebar-item--unread{{/if}}{{#if active}} sidebar-item--active{{/if}}{{#if toolbar}} popup-item{{/if}}" data-id="{{_id}}">
		<a class="sidebar-item__link" href="{{#if route}}{{route}}{{else}}{{pathFor pathSection group=pathGroup}}{{/if}}" aria-label="{{name}}">
			{{#unless isLivechatQueue}}

				<div class=" {{#if isRoom}}sidebar-item__picture{{else}}sidebar-item-option-icon{{/if}}">
					{{#if darken}}
						{{#if icon}}
							<div class="{{#if isRoom}}sidebar-item__room-type{{else}}sidebar-item__icon{{/if}}">
								{{> icon block="sidebar-item__icon" icon=icon}}
							</div>
						{{/if}}
					{{else}}
						<div class="sidebar-item__user-thumb">
							{{> avatar username=username roomIcon=icon lazy=true}}
						</div>
					{{/if}}
				</div>
			{{/unless}}
			<div class="sidebar-item__body">
				{{# let extended=isExtendedViewMode}}
				<div class="sidebar-item__message">
					<div class="sidebar-item__message-top">
						<div class="sidebar-item__name">
							{{#unless darken}}
								{{> sidebarItemIcon}}
							{{/unless}}

							<div class="sidebar-item__ellipsis">
								{{name}}
								{{#if mySelf}}
									<span class="sidebar-item__me">({{_ "You"}})</span>
								{{/if}}
							</div>
							 <!-- {{#if streaming}} VIDEO {{/if}} -->
						</div>
						{{#if extended}}
							{{#if lastMessageTs}}
								<span class="sidebar-item__time">{{lastMessageTs}}</span>
							{{/if}}
						{{/if}}
					</div>
					<div class="sidebar-item__message-bottom">
						{{#if extended}}
							{{#if lastMessage}}
								<div class="sidebar-item__last-message">{{{lastMessage}}}</div>
							{{/if}}
						{{/if}}
						{{#if unread}}
							<span class="badge badge--unread">{{#if userMentions}}@ {{/if}}{{unread}}</span>
						{{/if}}
					</div>
				</div>
				{{/let}}

				{{#if isRoom}}
					<div class="sidebar-item__menu">
						{{> icon block="sidebar-item__menu-icon" icon="menu"}}
					</div>
				{{/if}}
			</div>
		</a>
	</li>
</template>
