{ if (panel && event.target instanceof Element && !event.target.closest('[data-search-panel]')) panel = null; }} />
0 || results.length > 0} aria-controls={suggestions.length ? 'workspace-search-suggestions' : 'workspace-search-results'} aria-activedescendant={suggestions.length ? suggestions[suggestionIndex] ? `search-suggestion-${suggestionIndex}` : undefined : selected ? `search-result-${selectedIndex}` : undefined} autocomplete="off" spellcheck="false" maxlength="500" on:input={(event) => { suggesting = true; suggestionIndex = event.currentTarget.value.split(' ').at(-1)?.includes(':') ? 0 : -1; }} on:blur={() => (suggesting = false)} /> {#if query}{/if}
{#if sharing !== 'all' || scope}
{#if sharing !== 'all'}{/if} {#if scope}{/if}
{/if} {#if suggestions.length}
{#each suggestions as suggestion, index}{/each}
{/if} {#if panel === 'types'}
{#each kinds as type}{/each}
{/if} {#if panel === 'filters'}
{#each [{ value: 'all', label: 'All' }, { value: 'mine', label: 'Created by you' }, { value: 'shared', label: 'Shared with you' }] as option} {/each} {#each locations as group} {#if (kind === 'all' || kind === group.type) && scopes.some((item) => item.kind === group.kind)}
{$i18n.t(group.label)}
{#each scopes.filter((item) => item.kind === group.kind) as item} {/each} {/if} {/each}
{#if kind !== 'all' || sharing !== 'all' || scope}
{/if}
{/if}
{query.trim() ? $i18n.t('Results') : $i18n.t('Pinned & recent')}{loading ? $i18n.t('Searching…') : results.length ? `${results.length}${hasMore ? '+' : ''}` : ''}
{#each results as result, index (result.id)}
(selectedIndex = index)} on:click={() => { selectedIndex = index; if (preview) input?.focus(); else open(result); }} on:dblclick={() => open(result)} >
{#if result.pinned}{/if}
{#if query.trim() && result.snippet}
{/if}
{/each}
{#if loading && !results.length}
{/if} {#if error} {:else if !loading && !results.length}

{query ? $i18n.t('No matches found') : $i18n.t('Nothing here yet')}

{$i18n.t('Try another word or broaden your filters.')}

{#if kind !== 'all' || sharing !== 'all' || scope}{/if}
{/if} {#if hasMore && !error} { if (!loading) fetchResults(page + 1); }} >
{/if}
{#if preview && selected}
{$i18n.t(labels[selected.kind])}
{#if selected.kind === 'chat'}
{selected.title}
{:else}

{selected.title}

{contextLabels.get(selected.context) ?? selected.context} · {formatSearchDate( selected.updated_at )}
{#if selected.kind === 'note'} {:else} {/if}
{/if}
{/if}
{#if panel === 'actions'}
{#if selected}
{/if}{#if canCreateNote}{/if}
{/if}
{selected ? (contextLabels.get(selected.context) ?? selected.context) : $i18n.t('Workspace search')}