import {html, nothing} from '//resources/lit/v3_0/lit.rollup.js';
import type {SideType} from '//resources/mojo/components/omnibox/browser/searchbox.mojom-webui.js';
import type {SearchboxDropdownElement} from './searchbox_dropdown.js';
export function getMatchesForGroupHtml(
this: SearchboxDropdownElement, sideType: SideType, groupId: number) {
const hasHeader = this.hasHeaderForGroup_(groupId);
const matchesHtml = html`
<div class="matches ${this.renderTypeClassForGroup_(groupId)}">
${this.matchesForGroup_(groupId).map(match => html`
<cr-searchbox-match tabindex="0" role="option"
aria-describedby="${hasHeader ? `hg_${groupId}` : nothing}"
.match="${match}" match-index="${this.matchIndex_(match)}"
side-type="${sideType}"
?selected="${this.isSelected_(match)}"
?show-thumbnail="${this.showThumbnail}">
</cr-searchbox-match>
`)}
</div>
`;
return hasHeader ? html`
stops the dropdown from losing focus and closing as a result. -->
<h3 class="header" data-id="${groupId}" tabindex="-1"
id="hg_${groupId}"
@mousedown="${this.onHeaderMousedown_}">
<span class="text">${this.headerForGroup_(groupId)}</span>
</h3>
${matchesHtml}` : matchesHtml;
}
export function getHtml(this: SearchboxDropdownElement) {
return html`
<div id="content" part="dropdown-content">
${this.sideTypes_().map(sideType => html`
<div class="${this.sideTypeClass_(sideType)}">
${this.groupIdsForSideType_(sideType)
.map(groupId => getMatchesForGroupHtml.bind(this)(sideType, groupId))}
</div>
`)}
</div>
`;
}