{#if type == 'community'} { const results = await getClient(instance).search({ q: q || ' ', type_: 'Communities', limit: 20, listing_type: listing_type, sort: 'TopAll', }) return results.communities.map((c) => c.community) }} extractName={(c) => `${c.title}@${new URL(c.actor_id).hostname}`} bind:query={q} {...rest} > {#snippet noresults()} {#if q == '' && showWhenEmpty} dispatcher('select', undefined)}> None {:else} No results. {/if} {/snippet} {#snippet children({ item, select })} select(item)}> {item.title} {new URL(item.actor_id).hostname} {/snippet} {:else if type == 'instance'} { const results = (await instances) || {} return q ? (results.federated_instances?.linked || []).filter( (i) => i.software === 'lemmy' && i.domain.includes(q), ) : [] }} extractName={(i) => `${i.domain}`} bind:query={q} {...rest} > {#snippet noresults()} {#if q == '' && showWhenEmpty} dispatcher('select', undefined)}> None (Start typing to search) {:else} No results. {/if} {/snippet} {#snippet children({ item, select })} select(item)}> {item.domain} {/snippet} {/if}