(sources = DEMO_MODE ? demoSources : [])
| 4240 | } |
| 4241 | |
| 4242 | function renderChatSources(sources = DEMO_MODE ? demoSources : []) { |
| 4243 | const items = Array.isArray(sources) ? sources.map((source, index) => normalizeCitationSource(source, index)) : []; |
| 4244 | state.chatSources = items; |
| 4245 | $("chatSources").className = items.length ? "source-list" : "source-list empty"; |
| 4246 | $("chatSources").innerHTML = items.length ? items.map((source) => { |
| 4247 | const openControl = source.url |
| 4248 | ? `<a href="${escapeHtml(source.url)}" target="_blank" rel="noreferrer">${escapeHtml(ui().chat.openSource)}</a>` |
| 4249 | : `<button type="button" data-open-citation-source data-node-id="${escapeHtml(source.node_id)}" data-title="${escapeHtml(source.title)}">${escapeHtml(ui().chat.viewSource)}</button>`; |
| 4250 | return ` |
| 4251 | <div class="source-card citation-card" tabindex="0" data-citation-index="${escapeHtml(source.index)}" data-node-id="${escapeHtml(source.node_id)}" data-title="${escapeHtml(source.title)}"> |
| 4252 | <h3>[${escapeHtml(source.index)}] ${escapeHtml(source.title)}</h3> |
| 4253 | <p>${escapeHtml(source.meta)}</p> |
| 4254 | ${source.snippet ? `<p>${escapeHtml(source.snippet)}</p>` : ""} |
| 4255 | ${openControl} |
| 4256 | </div> |
| 4257 | `; |
| 4258 | }).join("") : ui().chat.sourcesEmpty; |
| 4259 | } |
| 4260 | |
| 4261 | function chatIntroHtml() { |
| 4262 | return ` |
no test coverage detected