import { describeRepo, getServiceInfo, resolveHandle } from '../lib/api.js' export async function renderServices(handle: string): Promise { const did = handle.startsWith('did:') ? handle : await resolveHandle(handle) const collections = await describeRepo(did) if (collections.length === 0) { return '' } // Group by service const serviceMap = new Map() for (const col of collections) { const info = getServiceInfo(col) if (info) { const key = info.domain if (!serviceMap.has(key)) { serviceMap.set(key, { name: info.name, favicon: info.favicon, collections: [] }) } serviceMap.get(key)!.collections.push(col) } } const items = Array.from(serviceMap.entries()).map(([domain, info]) => { const url = `?mode=browser&handle=${handle}&service=${encodeURIComponent(domain)}` return ` ${info.name} ` }).join('') return `
${items}
` } export async function mountServices(container: HTMLElement, handle: string): Promise { const html = await renderServices(handle) container.innerHTML = html }