// In an app: import { setupStockCard } from '@aparte/plugin-cards/stock';
const { setupStockCard } = window.apartePlugins.cards.stock;
// A made-up price walk: n values ending at end, spread over span, the same for a seed.
const walk = (seed, n, end, span) => {
let v = 0;
const raw = Array.from({ length: n }, (_, i) => (v += Math.sin(i * 0.7 + seed) * 1.6 + Math.cos(i * 0.23 + seed * 2) + 0.12));
const last = raw[n - 1];
const scale = span / (Math.max(...raw) - Math.min(...raw));
return raw.map((x) => Math.round((end - (last - x) * scale) * 100) / 100);
};
setupStockCard({ tool: 'get_watchlist', variant: 'compact' });
document.querySelector('aparte-chat-bubble').setSegments([{
id: 's1', type: 'tool_call', status: 'resolved',
toolCall: { id: 'c-s1', name: 'get_watchlist', input: { list: 'Tech' } },
structuredResult: {
title: 'Tech watchlist',
quotes: [
{ symbol: 'ACME', name: 'Acme Corp.', currency: 'USD', price: 184.6, changePercent: 1.29, series: walk(1, 40, 184.6, 3.6) },
{ symbol: 'GLBX', name: 'Globex', currency: 'USD', price: 62.18, changePercent: -0.84, series: walk(4, 40, 62.18, 1.4) },
{ symbol: 'INIT', name: 'Initech', currency: 'USD', price: 23.4, changePercent: 3.12, series: walk(7, 40, 23.4, 1.1) },
{ symbol: 'HOOL', name: 'Hooli', currency: 'USD', price: 412.05, changePercent: 0.06, series: walk(9, 40, 412.05, 4) },
],
},
}]);