{#if mode === "categories"} {#if show_legend}
{#each Object.entries(resolved_color_map) as [category, colors]} {/each}
{/if}
{#each value as { token, class_or_confidence }, i} {@const lines = token.split("\n")} {#each lines as line, j} {#if line.trim()} {@const bg_color = get_background_color(class_or_confidence)} { if (class_or_confidence === null) return; if (interactive) { onselect?.({ index: i, value: [token, class_or_confidence] }); label_to_edit = i; } else { onselect?.({ index: i, value: [token, class_or_confidence] }); } }} onkeydown={(e) => { if (!interactive) return; if (e.key === "Enter" && class_or_confidence !== null) { label_to_edit = i; } }} onfocus={() => (active_element_index = i)} onmouseenter={() => (active_element_index = i)} > {line} {#if !show_legend && show_inline_category && class_or_confidence !== null && label_to_edit !== i} {class_or_confidence} {/if} {#if interactive && label_to_edit === i && class_or_confidence !== null} {/if} {#if interactive && class_or_confidence !== null} {/if} {/if} {#if j < lines.length - 1} {/if} {/each} {/each}
{:else} {#if show_legend}
-1 0 +1
{/if}
{#each value as { token, class_or_confidence }, i} {@const score = typeof class_or_confidence === "string" ? parseFloat(class_or_confidence) : class_or_confidence} (active_element_index = i)} onfocus={() => (active_element_index = i)} onclick={() => { if (interactive) { label_to_edit = i; } else { onselect?.({ index: i, value: [token, class_or_confidence] }); } }} onkeydown={(e) => { if (e.key === "Enter") { if (interactive) { label_to_edit = i; } else { onselect?.({ index: i, value: [token, class_or_confidence] }); } } }} > {token} {#if interactive && class_or_confidence !== null && label_to_edit === i} {/if} {#if interactive && class_or_confidence !== null && active_element_index === i} {/if} {/each}
{/if}