@smallwebco/tinypivot-core 1.0.53 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/demo.d.ts +60 -0
- package/dist/ai/demo.d.ts.map +1 -0
- package/dist/ai/demo.js +460 -0
- package/dist/ai/demo.js.map +1 -0
- package/dist/ai/index.d.ts +9 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +11 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/prompts.d.ts +39 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/prompts.js +221 -0
- package/dist/ai/prompts.js.map +1 -0
- package/dist/ai/session.d.ts +69 -0
- package/dist/ai/session.d.ts.map +1 -0
- package/dist/ai/session.js +145 -0
- package/dist/ai/session.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/license/index.d.ts +4 -0
- package/dist/license/index.d.ts.map +1 -1
- package/dist/license/index.js +10 -0
- package/dist/license/index.js.map +1 -1
- package/dist/types/index.d.ts +302 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyPivot Core - AI Demo Mode
|
|
3
|
+
* Canned responses for public demo without requiring API keys
|
|
4
|
+
*/
|
|
5
|
+
import type { AIDataSource, AITableSchema } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Demo trigger matching a user query to a canned response
|
|
8
|
+
*/
|
|
9
|
+
export interface DemoTrigger {
|
|
10
|
+
/** Keywords that trigger this response (case-insensitive, any match) */
|
|
11
|
+
keywords: string[];
|
|
12
|
+
/** AI response text */
|
|
13
|
+
response: string;
|
|
14
|
+
/** SQL query to "execute" */
|
|
15
|
+
query?: string;
|
|
16
|
+
/** Mock data to return */
|
|
17
|
+
mockData?: Record<string, unknown>[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Demo scenario for a specific data source
|
|
21
|
+
*/
|
|
22
|
+
export interface DemoScenario {
|
|
23
|
+
/** Data source ID this scenario applies to */
|
|
24
|
+
dataSourceId: string;
|
|
25
|
+
/** Triggers for this scenario */
|
|
26
|
+
triggers: DemoTrigger[];
|
|
27
|
+
/** Default response when no trigger matches */
|
|
28
|
+
defaultResponse: string;
|
|
29
|
+
/** Initial sample data shown when dataset is first selected */
|
|
30
|
+
initialData?: Record<string, unknown>[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Demo data sources for the public demo
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEMO_DATA_SOURCES: AIDataSource[];
|
|
36
|
+
/**
|
|
37
|
+
* Demo schemas for the data sources
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEMO_SCHEMAS: Map<string, AITableSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Demo scenarios with canned responses
|
|
42
|
+
*/
|
|
43
|
+
export declare const DEMO_SCENARIOS: DemoScenario[];
|
|
44
|
+
/**
|
|
45
|
+
* Find a matching demo response for a user message
|
|
46
|
+
*/
|
|
47
|
+
export declare function findDemoResponse(dataSourceId: string, userMessage: string): DemoTrigger | null;
|
|
48
|
+
/**
|
|
49
|
+
* Get the default response for a data source when no trigger matches
|
|
50
|
+
*/
|
|
51
|
+
export declare function getDefaultDemoResponse(dataSourceId: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Get demo schema for a data source
|
|
54
|
+
*/
|
|
55
|
+
export declare function getDemoSchema(dataSourceId: string): AITableSchema | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get initial sample data for a data source (shown when first selected)
|
|
58
|
+
*/
|
|
59
|
+
export declare function getInitialDemoData(dataSourceId: string): Record<string, unknown>[] | undefined;
|
|
60
|
+
//# sourceMappingURL=demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,SAAS,CAG9F"}
|
package/dist/ai/demo.js
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Demo data sources for the public demo
|
|
3
|
+
*/
|
|
4
|
+
export const DEMO_DATA_SOURCES = [
|
|
5
|
+
{
|
|
6
|
+
id: 'sales',
|
|
7
|
+
table: 'sales_transactions',
|
|
8
|
+
name: 'Sales Transactions',
|
|
9
|
+
description: 'E-commerce sales data from 2022-2024 including orders, revenue, and customer information',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: 'customers',
|
|
13
|
+
table: 'customers',
|
|
14
|
+
name: 'Customer Data',
|
|
15
|
+
description: 'Customer profiles including demographics, segments, and lifetime value',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'products',
|
|
19
|
+
table: 'products',
|
|
20
|
+
name: 'Product Catalog',
|
|
21
|
+
description: 'Product information including categories, pricing, and inventory',
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Demo schemas for the data sources
|
|
26
|
+
*/
|
|
27
|
+
export const DEMO_SCHEMAS = new Map([
|
|
28
|
+
['sales', {
|
|
29
|
+
table: 'sales_transactions',
|
|
30
|
+
columns: [
|
|
31
|
+
{ name: 'id', type: 'number', nullable: false, description: 'Transaction ID' },
|
|
32
|
+
{ name: 'date', type: 'date', nullable: false, description: 'Transaction date' },
|
|
33
|
+
{ name: 'customer_id', type: 'number', nullable: false, description: 'Customer reference' },
|
|
34
|
+
{ name: 'product_id', type: 'number', nullable: false, description: 'Product reference' },
|
|
35
|
+
{ name: 'quantity', type: 'number', nullable: false, description: 'Units sold' },
|
|
36
|
+
{ name: 'revenue', type: 'number', nullable: false, description: 'Total sale amount in USD' },
|
|
37
|
+
{ name: 'region', type: 'string', nullable: false, description: 'Sales region (North, South, East, West)' },
|
|
38
|
+
{ name: 'channel', type: 'string', nullable: false, description: 'Sales channel (Online, Retail, Wholesale)' },
|
|
39
|
+
],
|
|
40
|
+
}],
|
|
41
|
+
['customers', {
|
|
42
|
+
table: 'customers',
|
|
43
|
+
columns: [
|
|
44
|
+
{ name: 'id', type: 'number', nullable: false, description: 'Customer ID' },
|
|
45
|
+
{ name: 'name', type: 'string', nullable: false, description: 'Customer name' },
|
|
46
|
+
{ name: 'email', type: 'string', nullable: false, description: 'Email address' },
|
|
47
|
+
{ name: 'segment', type: 'string', nullable: false, description: 'Customer segment (Enterprise, SMB, Consumer)' },
|
|
48
|
+
{ name: 'country', type: 'string', nullable: false, description: 'Country' },
|
|
49
|
+
{ name: 'created_at', type: 'date', nullable: false, description: 'Account creation date' },
|
|
50
|
+
{ name: 'lifetime_value', type: 'number', nullable: true, description: 'Total lifetime spend in USD' },
|
|
51
|
+
],
|
|
52
|
+
}],
|
|
53
|
+
['products', {
|
|
54
|
+
table: 'products',
|
|
55
|
+
columns: [
|
|
56
|
+
{ name: 'id', type: 'number', nullable: false, description: 'Product ID' },
|
|
57
|
+
{ name: 'name', type: 'string', nullable: false, description: 'Product name' },
|
|
58
|
+
{ name: 'category', type: 'string', nullable: false, description: 'Product category' },
|
|
59
|
+
{ name: 'price', type: 'number', nullable: false, description: 'Unit price in USD' },
|
|
60
|
+
{ name: 'cost', type: 'number', nullable: false, description: 'Unit cost in USD' },
|
|
61
|
+
{ name: 'stock', type: 'number', nullable: false, description: 'Current inventory' },
|
|
62
|
+
],
|
|
63
|
+
}],
|
|
64
|
+
]);
|
|
65
|
+
/**
|
|
66
|
+
* Demo scenarios with canned responses
|
|
67
|
+
*/
|
|
68
|
+
export const DEMO_SCENARIOS = [
|
|
69
|
+
{
|
|
70
|
+
dataSourceId: 'sales',
|
|
71
|
+
initialData: [
|
|
72
|
+
{ id: 1, date: '2024-12-01', customer_id: 1001, product_id: 101, quantity: 2, revenue: 599.98, region: 'West', channel: 'Online' },
|
|
73
|
+
{ id: 2, date: '2024-12-01', customer_id: 1042, product_id: 203, quantity: 1, revenue: 849.99, region: 'North', channel: 'Retail' },
|
|
74
|
+
{ id: 3, date: '2024-12-02', customer_id: 1015, product_id: 105, quantity: 5, revenue: 149.95, region: 'East', channel: 'Online' },
|
|
75
|
+
{ id: 4, date: '2024-12-02', customer_id: 1088, product_id: 302, quantity: 1, revenue: 1299.00, region: 'West', channel: 'Wholesale' },
|
|
76
|
+
{ id: 5, date: '2024-12-03', customer_id: 1023, product_id: 118, quantity: 3, revenue: 89.97, region: 'South', channel: 'Online' },
|
|
77
|
+
{ id: 6, date: '2024-12-03', customer_id: 1056, product_id: 209, quantity: 2, revenue: 459.98, region: 'North', channel: 'Retail' },
|
|
78
|
+
{ id: 7, date: '2024-12-04', customer_id: 1077, product_id: 115, quantity: 1, revenue: 199.99, region: 'East', channel: 'Online' },
|
|
79
|
+
{ id: 8, date: '2024-12-04', customer_id: 1034, product_id: 301, quantity: 4, revenue: 2199.96, region: 'West', channel: 'Wholesale' },
|
|
80
|
+
{ id: 9, date: '2024-12-05', customer_id: 1091, product_id: 122, quantity: 2, revenue: 339.98, region: 'South', channel: 'Retail' },
|
|
81
|
+
{ id: 10, date: '2024-12-05', customer_id: 1012, product_id: 207, quantity: 1, revenue: 749.99, region: 'North', channel: 'Online' },
|
|
82
|
+
],
|
|
83
|
+
defaultResponse: `I can help you explore the sales transactions data. Here are some things you can ask me:
|
|
84
|
+
|
|
85
|
+
- "Show me total revenue by region"
|
|
86
|
+
- "What are the top selling products?"
|
|
87
|
+
- "Show me sales trends over time"
|
|
88
|
+
- "Which sales channel performs best?"
|
|
89
|
+
|
|
90
|
+
What would you like to know?`,
|
|
91
|
+
triggers: [
|
|
92
|
+
{
|
|
93
|
+
keywords: ['revenue', 'region'],
|
|
94
|
+
response: `I'll query the sales table to show total revenue broken down by region.
|
|
95
|
+
|
|
96
|
+
Here's my approach:
|
|
97
|
+
1. **regional_summary**: Group all transactions by region and calculate totals
|
|
98
|
+
|
|
99
|
+
\`\`\`sql
|
|
100
|
+
-- Calculate revenue and transaction counts for each region
|
|
101
|
+
WITH regional_summary AS (
|
|
102
|
+
SELECT
|
|
103
|
+
region,
|
|
104
|
+
SUM(revenue) as total_revenue,
|
|
105
|
+
COUNT(*) as transaction_count
|
|
106
|
+
FROM sales_transactions
|
|
107
|
+
GROUP BY region
|
|
108
|
+
)
|
|
109
|
+
-- Return regions sorted by revenue (highest first)
|
|
110
|
+
SELECT * FROM regional_summary
|
|
111
|
+
ORDER BY total_revenue DESC
|
|
112
|
+
\`\`\`
|
|
113
|
+
|
|
114
|
+
The results show revenue performance across all four regions. The data is now loaded in the grid - you can use the Pivot or Chart views to visualize it further.`,
|
|
115
|
+
query: 'WITH regional_summary AS (SELECT region, SUM(revenue) as total_revenue, COUNT(*) as transaction_count FROM sales_transactions GROUP BY region) SELECT * FROM regional_summary ORDER BY total_revenue DESC',
|
|
116
|
+
mockData: [
|
|
117
|
+
{ region: 'West', total_revenue: 1250000, transaction_count: 3420 },
|
|
118
|
+
{ region: 'North', total_revenue: 980000, transaction_count: 2890 },
|
|
119
|
+
{ region: 'East', total_revenue: 875000, transaction_count: 2650 },
|
|
120
|
+
{ region: 'South', total_revenue: 720000, transaction_count: 2140 },
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
keywords: ['top', 'product', 'best', 'selling'],
|
|
125
|
+
response: `I'll find the top selling products by revenue.
|
|
126
|
+
|
|
127
|
+
Here's my approach:
|
|
128
|
+
1. **product_totals**: Sum up revenue and units for each product
|
|
129
|
+
2. **ranked_products**: Take only the top 10 performers
|
|
130
|
+
|
|
131
|
+
\`\`\`sql
|
|
132
|
+
-- Aggregate sales by product
|
|
133
|
+
WITH product_totals AS (
|
|
134
|
+
SELECT
|
|
135
|
+
product_id,
|
|
136
|
+
SUM(revenue) as total_revenue,
|
|
137
|
+
SUM(quantity) as units_sold
|
|
138
|
+
FROM sales_transactions
|
|
139
|
+
GROUP BY product_id
|
|
140
|
+
),
|
|
141
|
+
-- Rank and limit to top performers
|
|
142
|
+
ranked_products AS (
|
|
143
|
+
SELECT * FROM product_totals
|
|
144
|
+
ORDER BY total_revenue DESC
|
|
145
|
+
LIMIT 10
|
|
146
|
+
)
|
|
147
|
+
SELECT * FROM ranked_products
|
|
148
|
+
\`\`\`
|
|
149
|
+
|
|
150
|
+
Here are the top 10 products by revenue. You might want to join this with the Products table to see product names.`,
|
|
151
|
+
query: 'WITH product_totals AS (SELECT product_id, SUM(revenue) as total_revenue, SUM(quantity) as units_sold FROM sales_transactions GROUP BY product_id), ranked_products AS (SELECT * FROM product_totals ORDER BY total_revenue DESC LIMIT 10) SELECT * FROM ranked_products',
|
|
152
|
+
mockData: [
|
|
153
|
+
{ product_id: 101, total_revenue: 425000, units_sold: 1250 },
|
|
154
|
+
{ product_id: 203, total_revenue: 380000, units_sold: 890 },
|
|
155
|
+
{ product_id: 105, total_revenue: 315000, units_sold: 2100 },
|
|
156
|
+
{ product_id: 302, total_revenue: 290000, units_sold: 560 },
|
|
157
|
+
{ product_id: 118, total_revenue: 245000, units_sold: 1800 },
|
|
158
|
+
{ product_id: 209, total_revenue: 220000, units_sold: 750 },
|
|
159
|
+
{ product_id: 115, total_revenue: 195000, units_sold: 1400 },
|
|
160
|
+
{ product_id: 301, total_revenue: 180000, units_sold: 320 },
|
|
161
|
+
{ product_id: 122, total_revenue: 165000, units_sold: 980 },
|
|
162
|
+
{ product_id: 207, total_revenue: 155000, units_sold: 620 },
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
keywords: ['trend', 'time', 'month', 'over time'],
|
|
167
|
+
response: `I'll show you the sales trends over time, grouped by month.
|
|
168
|
+
|
|
169
|
+
Here's my approach:
|
|
170
|
+
1. **monthly_metrics**: Truncate dates to month and aggregate revenue/transactions
|
|
171
|
+
|
|
172
|
+
\`\`\`sql
|
|
173
|
+
-- Group transactions by month and calculate totals
|
|
174
|
+
WITH monthly_metrics AS (
|
|
175
|
+
SELECT
|
|
176
|
+
DATE_TRUNC('month', date) as month,
|
|
177
|
+
SUM(revenue) as monthly_revenue,
|
|
178
|
+
COUNT(*) as transactions
|
|
179
|
+
FROM sales_transactions
|
|
180
|
+
GROUP BY DATE_TRUNC('month', date)
|
|
181
|
+
)
|
|
182
|
+
-- Return in chronological order
|
|
183
|
+
SELECT * FROM monthly_metrics
|
|
184
|
+
ORDER BY month
|
|
185
|
+
\`\`\`
|
|
186
|
+
|
|
187
|
+
The data shows monthly revenue trends. Try using the Chart view with a Line chart to visualize this trend!`,
|
|
188
|
+
query: 'WITH monthly_metrics AS (SELECT DATE_TRUNC(\'month\', date) as month, SUM(revenue) as monthly_revenue, COUNT(*) as transactions FROM sales_transactions GROUP BY DATE_TRUNC(\'month\', date)) SELECT * FROM monthly_metrics ORDER BY month',
|
|
189
|
+
mockData: [
|
|
190
|
+
{ month: '2024-01-01', monthly_revenue: 285000, transactions: 820 },
|
|
191
|
+
{ month: '2024-02-01', monthly_revenue: 310000, transactions: 890 },
|
|
192
|
+
{ month: '2024-03-01', monthly_revenue: 345000, transactions: 950 },
|
|
193
|
+
{ month: '2024-04-01', monthly_revenue: 320000, transactions: 910 },
|
|
194
|
+
{ month: '2024-05-01', monthly_revenue: 380000, transactions: 1050 },
|
|
195
|
+
{ month: '2024-06-01', monthly_revenue: 410000, transactions: 1120 },
|
|
196
|
+
{ month: '2024-07-01', monthly_revenue: 395000, transactions: 1080 },
|
|
197
|
+
{ month: '2024-08-01', monthly_revenue: 425000, transactions: 1150 },
|
|
198
|
+
{ month: '2024-09-01', monthly_revenue: 390000, transactions: 1060 },
|
|
199
|
+
{ month: '2024-10-01', monthly_revenue: 445000, transactions: 1200 },
|
|
200
|
+
{ month: '2024-11-01', monthly_revenue: 520000, transactions: 1380 },
|
|
201
|
+
{ month: '2024-12-01', monthly_revenue: 480000, transactions: 1290 },
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
keywords: ['channel', 'online', 'retail', 'wholesale'],
|
|
206
|
+
response: `I'll compare performance across sales channels.
|
|
207
|
+
|
|
208
|
+
Here's my approach:
|
|
209
|
+
1. **channel_metrics**: Calculate total revenue, transaction count, and average order value per channel
|
|
210
|
+
|
|
211
|
+
\`\`\`sql
|
|
212
|
+
-- Aggregate key metrics by sales channel
|
|
213
|
+
WITH channel_metrics AS (
|
|
214
|
+
SELECT
|
|
215
|
+
channel,
|
|
216
|
+
SUM(revenue) as total_revenue,
|
|
217
|
+
COUNT(*) as transactions,
|
|
218
|
+
AVG(revenue) as avg_order_value
|
|
219
|
+
FROM sales_transactions
|
|
220
|
+
GROUP BY channel
|
|
221
|
+
)
|
|
222
|
+
-- Return sorted by total revenue
|
|
223
|
+
SELECT * FROM channel_metrics
|
|
224
|
+
ORDER BY total_revenue DESC
|
|
225
|
+
\`\`\`
|
|
226
|
+
|
|
227
|
+
This shows revenue and average order value by channel. Online has the highest volume while Wholesale has the highest average order value.`,
|
|
228
|
+
query: 'WITH channel_metrics AS (SELECT channel, SUM(revenue) as total_revenue, COUNT(*) as transactions, AVG(revenue) as avg_order_value FROM sales_transactions GROUP BY channel) SELECT * FROM channel_metrics ORDER BY total_revenue DESC',
|
|
229
|
+
mockData: [
|
|
230
|
+
{ channel: 'Online', total_revenue: 1850000, transactions: 6500, avg_order_value: 284.62 },
|
|
231
|
+
{ channel: 'Retail', total_revenue: 1200000, transactions: 3800, avg_order_value: 315.79 },
|
|
232
|
+
{ channel: 'Wholesale', total_revenue: 775000, transactions: 800, avg_order_value: 968.75 },
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
dataSourceId: 'customers',
|
|
239
|
+
initialData: [
|
|
240
|
+
{ id: 1001, name: 'Acme Corporation', email: 'contact@acme.com', segment: 'Enterprise', country: 'United States', created_at: '2022-03-15', lifetime_value: 45000 },
|
|
241
|
+
{ id: 1002, name: 'Jane Smith', email: 'jane.smith@email.com', segment: 'Consumer', country: 'United Kingdom', created_at: '2023-06-22', lifetime_value: 850 },
|
|
242
|
+
{ id: 1003, name: 'TechStart Inc', email: 'info@techstart.io', segment: 'SMB', country: 'Germany', created_at: '2023-01-10', lifetime_value: 3200 },
|
|
243
|
+
{ id: 1004, name: 'Global Industries', email: 'sales@globalind.com', segment: 'Enterprise', country: 'United States', created_at: '2021-11-08', lifetime_value: 78500 },
|
|
244
|
+
{ id: 1005, name: 'John Doe', email: 'johndoe@gmail.com', segment: 'Consumer', country: 'Canada', created_at: '2024-02-14', lifetime_value: 320 },
|
|
245
|
+
{ id: 1006, name: 'Boutique Shop', email: 'hello@boutique.fr', segment: 'SMB', country: 'France', created_at: '2023-08-30', lifetime_value: 1800 },
|
|
246
|
+
{ id: 1007, name: 'Maria Garcia', email: 'maria.g@outlook.com', segment: 'Consumer', country: 'Spain', created_at: '2024-05-19', lifetime_value: 450 },
|
|
247
|
+
{ id: 1008, name: 'Nordic Solutions', email: 'contact@nordic.se', segment: 'Enterprise', country: 'Sweden', created_at: '2022-07-03', lifetime_value: 32000 },
|
|
248
|
+
{ id: 1009, name: 'Local Crafts Co', email: 'orders@localcrafts.au', segment: 'SMB', country: 'Australia', created_at: '2023-11-25', lifetime_value: 2100 },
|
|
249
|
+
{ id: 1010, name: 'Alex Johnson', email: 'alex.j@proton.me', segment: 'Consumer', country: 'United States', created_at: '2024-09-02', lifetime_value: 180 },
|
|
250
|
+
],
|
|
251
|
+
defaultResponse: `I can help you explore the customer data. Here are some things you can ask me:
|
|
252
|
+
|
|
253
|
+
- "Show me customers by segment"
|
|
254
|
+
- "What's the average lifetime value?"
|
|
255
|
+
- "Which countries have the most customers?"
|
|
256
|
+
- "Show me recent signups"
|
|
257
|
+
|
|
258
|
+
What would you like to know?`,
|
|
259
|
+
triggers: [
|
|
260
|
+
{
|
|
261
|
+
keywords: ['segment', 'breakdown'],
|
|
262
|
+
response: `I'll show you the customer breakdown by segment.
|
|
263
|
+
|
|
264
|
+
\`\`\`sql
|
|
265
|
+
SELECT segment, COUNT(*) as customer_count, AVG(lifetime_value) as avg_ltv
|
|
266
|
+
FROM customers
|
|
267
|
+
GROUP BY segment
|
|
268
|
+
ORDER BY customer_count DESC
|
|
269
|
+
\`\`\`
|
|
270
|
+
|
|
271
|
+
Here's the distribution across segments. Enterprise customers have the highest average lifetime value.`,
|
|
272
|
+
query: 'SELECT segment, COUNT(*) as customer_count, AVG(lifetime_value) as avg_ltv FROM customers GROUP BY segment ORDER BY customer_count DESC',
|
|
273
|
+
mockData: [
|
|
274
|
+
{ segment: 'Consumer', customer_count: 8500, avg_ltv: 450 },
|
|
275
|
+
{ segment: 'SMB', customer_count: 2800, avg_ltv: 2200 },
|
|
276
|
+
{ segment: 'Enterprise', customer_count: 450, avg_ltv: 18500 },
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
keywords: ['lifetime', 'value', 'ltv'],
|
|
281
|
+
response: `I'll calculate lifetime value statistics across the customer base.
|
|
282
|
+
|
|
283
|
+
\`\`\`sql
|
|
284
|
+
SELECT
|
|
285
|
+
COUNT(*) as total_customers,
|
|
286
|
+
AVG(lifetime_value) as avg_ltv,
|
|
287
|
+
MAX(lifetime_value) as max_ltv,
|
|
288
|
+
MIN(lifetime_value) as min_ltv,
|
|
289
|
+
SUM(lifetime_value) as total_ltv
|
|
290
|
+
FROM customers
|
|
291
|
+
\`\`\`
|
|
292
|
+
|
|
293
|
+
The average customer lifetime value is $1,250 with significant variation between segments.`,
|
|
294
|
+
query: 'SELECT COUNT(*) as total_customers, AVG(lifetime_value) as avg_ltv, MAX(lifetime_value) as max_ltv, MIN(lifetime_value) as min_ltv, SUM(lifetime_value) as total_ltv FROM customers',
|
|
295
|
+
mockData: [
|
|
296
|
+
{ total_customers: 11750, avg_ltv: 1250, max_ltv: 85000, min_ltv: 25, total_ltv: 14687500 },
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
keywords: ['country', 'countries', 'location'],
|
|
301
|
+
response: `I'll show you the customer distribution by country.
|
|
302
|
+
|
|
303
|
+
\`\`\`sql
|
|
304
|
+
SELECT country, COUNT(*) as customer_count, SUM(lifetime_value) as total_ltv
|
|
305
|
+
FROM customers
|
|
306
|
+
GROUP BY country
|
|
307
|
+
ORDER BY customer_count DESC
|
|
308
|
+
LIMIT 10
|
|
309
|
+
\`\`\`
|
|
310
|
+
|
|
311
|
+
Here are the top 10 countries by customer count.`,
|
|
312
|
+
query: 'SELECT country, COUNT(*) as customer_count, SUM(lifetime_value) as total_ltv FROM customers GROUP BY country ORDER BY customer_count DESC LIMIT 10',
|
|
313
|
+
mockData: [
|
|
314
|
+
{ country: 'United States', customer_count: 4200, total_ltv: 5800000 },
|
|
315
|
+
{ country: 'United Kingdom', customer_count: 1850, total_ltv: 2100000 },
|
|
316
|
+
{ country: 'Germany', customer_count: 1200, total_ltv: 1450000 },
|
|
317
|
+
{ country: 'Canada', customer_count: 980, total_ltv: 1100000 },
|
|
318
|
+
{ country: 'France', customer_count: 750, total_ltv: 890000 },
|
|
319
|
+
{ country: 'Australia', customer_count: 620, total_ltv: 720000 },
|
|
320
|
+
{ country: 'Japan', customer_count: 480, total_ltv: 650000 },
|
|
321
|
+
{ country: 'Netherlands', customer_count: 350, total_ltv: 420000 },
|
|
322
|
+
{ country: 'Spain', customer_count: 290, total_ltv: 340000 },
|
|
323
|
+
{ country: 'Italy', customer_count: 250, total_ltv: 280000 },
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
dataSourceId: 'products',
|
|
330
|
+
initialData: [
|
|
331
|
+
{ id: 101, name: 'Wireless Mouse Pro', category: 'Electronics', price: 79.99, cost: 35.00, stock: 450 },
|
|
332
|
+
{ id: 102, name: 'Cotton T-Shirt Basic', category: 'Clothing', price: 24.99, cost: 8.50, stock: 1200 },
|
|
333
|
+
{ id: 103, name: 'Standing Desk Frame', category: 'Home & Garden', price: 349.99, cost: 180.00, stock: 85 },
|
|
334
|
+
{ id: 104, name: 'Running Shoes Elite', category: 'Sports', price: 129.99, cost: 55.00, stock: 320 },
|
|
335
|
+
{ id: 105, name: 'JavaScript: The Good Parts', category: 'Books', price: 29.99, cost: 10.00, stock: 580 },
|
|
336
|
+
{ id: 106, name: 'Bluetooth Headphones', category: 'Electronics', price: 149.99, cost: 65.00, stock: 280 },
|
|
337
|
+
{ id: 107, name: 'Denim Jeans Classic', category: 'Clothing', price: 69.99, cost: 28.00, stock: 890 },
|
|
338
|
+
{ id: 108, name: 'Garden Tool Set', category: 'Home & Garden', price: 89.99, cost: 38.00, stock: 150 },
|
|
339
|
+
{ id: 109, name: 'Yoga Mat Premium', category: 'Sports', price: 45.99, cost: 18.00, stock: 420 },
|
|
340
|
+
{ id: 110, name: 'Clean Code', category: 'Books', price: 34.99, cost: 12.00, stock: 340 },
|
|
341
|
+
],
|
|
342
|
+
defaultResponse: `I can help you explore the product catalog. Here are some things you can ask me:
|
|
343
|
+
|
|
344
|
+
- "Show me products by category"
|
|
345
|
+
- "What are the profit margins?"
|
|
346
|
+
- "Which products are low on stock?"
|
|
347
|
+
- "Show me the price distribution"
|
|
348
|
+
|
|
349
|
+
What would you like to know?`,
|
|
350
|
+
triggers: [
|
|
351
|
+
{
|
|
352
|
+
keywords: ['category', 'categories'],
|
|
353
|
+
response: `I'll show you the product breakdown by category.
|
|
354
|
+
|
|
355
|
+
\`\`\`sql
|
|
356
|
+
SELECT category, COUNT(*) as product_count, AVG(price) as avg_price, SUM(stock) as total_stock
|
|
357
|
+
FROM products
|
|
358
|
+
GROUP BY category
|
|
359
|
+
ORDER BY product_count DESC
|
|
360
|
+
\`\`\`
|
|
361
|
+
|
|
362
|
+
Here's the distribution of products across categories.`,
|
|
363
|
+
query: 'SELECT category, COUNT(*) as product_count, AVG(price) as avg_price, SUM(stock) as total_stock FROM products GROUP BY category ORDER BY product_count DESC',
|
|
364
|
+
mockData: [
|
|
365
|
+
{ category: 'Electronics', product_count: 450, avg_price: 299.99, total_stock: 12500 },
|
|
366
|
+
{ category: 'Clothing', product_count: 380, avg_price: 59.99, total_stock: 28000 },
|
|
367
|
+
{ category: 'Home & Garden', product_count: 290, avg_price: 89.99, total_stock: 15000 },
|
|
368
|
+
{ category: 'Sports', product_count: 220, avg_price: 79.99, total_stock: 9500 },
|
|
369
|
+
{ category: 'Books', product_count: 180, avg_price: 24.99, total_stock: 22000 },
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
keywords: ['margin', 'profit', 'cost'],
|
|
374
|
+
response: `I'll calculate the profit margins by category.
|
|
375
|
+
|
|
376
|
+
\`\`\`sql
|
|
377
|
+
SELECT category, AVG(price) as avg_price, AVG(cost) as avg_cost, AVG(price - cost) as avg_margin, AVG((price - cost) / price * 100) as margin_percent
|
|
378
|
+
FROM products
|
|
379
|
+
GROUP BY category
|
|
380
|
+
ORDER BY margin_percent DESC
|
|
381
|
+
\`\`\`
|
|
382
|
+
|
|
383
|
+
Here are the profit margins. Electronics has the highest absolute margin while Books has the best percentage margin.`,
|
|
384
|
+
query: 'SELECT category, AVG(price) as avg_price, AVG(cost) as avg_cost, AVG(price - cost) as avg_margin, AVG((price - cost) / price * 100) as margin_percent FROM products GROUP BY category ORDER BY margin_percent DESC',
|
|
385
|
+
mockData: [
|
|
386
|
+
{ category: 'Books', avg_price: 24.99, avg_cost: 8.50, avg_margin: 16.49, margin_percent: 65.99 },
|
|
387
|
+
{ category: 'Clothing', avg_price: 59.99, avg_cost: 22.00, avg_margin: 37.99, margin_percent: 63.33 },
|
|
388
|
+
{ category: 'Home & Garden', avg_price: 89.99, avg_cost: 38.00, avg_margin: 51.99, margin_percent: 57.77 },
|
|
389
|
+
{ category: 'Sports', avg_price: 79.99, avg_cost: 35.00, avg_margin: 44.99, margin_percent: 56.24 },
|
|
390
|
+
{ category: 'Electronics', avg_price: 299.99, avg_cost: 180.00, avg_margin: 119.99, margin_percent: 40.00 },
|
|
391
|
+
],
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
keywords: ['stock', 'inventory', 'low'],
|
|
395
|
+
response: `I'll find products with low stock levels.
|
|
396
|
+
|
|
397
|
+
\`\`\`sql
|
|
398
|
+
SELECT name, category, stock, price
|
|
399
|
+
FROM products
|
|
400
|
+
WHERE stock < 50
|
|
401
|
+
ORDER BY stock ASC
|
|
402
|
+
LIMIT 20
|
|
403
|
+
\`\`\`
|
|
404
|
+
|
|
405
|
+
These products are running low on inventory and may need restocking soon.`,
|
|
406
|
+
query: 'SELECT name, category, stock, price FROM products WHERE stock < 50 ORDER BY stock ASC LIMIT 20',
|
|
407
|
+
mockData: [
|
|
408
|
+
{ name: 'Premium Headphones Pro', category: 'Electronics', stock: 5, price: 349.99 },
|
|
409
|
+
{ name: 'Vintage Leather Jacket', category: 'Clothing', stock: 8, price: 299.99 },
|
|
410
|
+
{ name: 'Smart Home Hub', category: 'Electronics', stock: 12, price: 199.99 },
|
|
411
|
+
{ name: 'Designer Sunglasses', category: 'Clothing', stock: 15, price: 189.99 },
|
|
412
|
+
{ name: 'Ergonomic Office Chair', category: 'Home & Garden', stock: 18, price: 449.99 },
|
|
413
|
+
{ name: 'Wireless Earbuds Elite', category: 'Electronics', stock: 22, price: 179.99 },
|
|
414
|
+
{ name: 'Cashmere Sweater', category: 'Clothing', stock: 25, price: 249.99 },
|
|
415
|
+
{ name: 'Smart Watch Series X', category: 'Electronics', stock: 28, price: 399.99 },
|
|
416
|
+
{ name: 'Premium Yoga Mat', category: 'Sports', stock: 32, price: 89.99 },
|
|
417
|
+
{ name: 'Espresso Machine Pro', category: 'Home & Garden', stock: 35, price: 599.99 },
|
|
418
|
+
],
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
},
|
|
422
|
+
];
|
|
423
|
+
/**
|
|
424
|
+
* Find a matching demo response for a user message
|
|
425
|
+
*/
|
|
426
|
+
export function findDemoResponse(dataSourceId, userMessage) {
|
|
427
|
+
const scenario = DEMO_SCENARIOS.find(s => s.dataSourceId === dataSourceId);
|
|
428
|
+
if (!scenario) {
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
const lowerMessage = userMessage.toLowerCase();
|
|
432
|
+
for (const trigger of scenario.triggers) {
|
|
433
|
+
const hasMatch = trigger.keywords.some(keyword => lowerMessage.includes(keyword.toLowerCase()));
|
|
434
|
+
if (hasMatch) {
|
|
435
|
+
return trigger;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Get the default response for a data source when no trigger matches
|
|
442
|
+
*/
|
|
443
|
+
export function getDefaultDemoResponse(dataSourceId) {
|
|
444
|
+
const scenario = DEMO_SCENARIOS.find(s => s.dataSourceId === dataSourceId);
|
|
445
|
+
return scenario?.defaultResponse || 'Please select a data source to get started.';
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Get demo schema for a data source
|
|
449
|
+
*/
|
|
450
|
+
export function getDemoSchema(dataSourceId) {
|
|
451
|
+
return DEMO_SCHEMAS.get(dataSourceId);
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Get initial sample data for a data source (shown when first selected)
|
|
455
|
+
*/
|
|
456
|
+
export function getInitialDemoData(dataSourceId) {
|
|
457
|
+
const scenario = DEMO_SCENARIOS.find(s => s.dataSourceId === dataSourceId);
|
|
458
|
+
return scenario?.initialData;
|
|
459
|
+
}
|
|
460
|
+
//# sourceMappingURL=demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.js","sourceRoot":"","sources":["../../src/ai/demo.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C;QACE,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,0FAA0F;KACxG;IACD;QACE,EAAE,EAAE,WAAW;QACf,KAAK,E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AQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAC7C,CAAA;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,OAAO,CAAA;QAChB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAoB;IACzD,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,CAAA;IAC1E,OAAO,QAAQ,EAAE,eAAe,IAAI,6CAA6C,CAAA;AACnF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,YAAoB;IAChD,OAAO,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAAoB;IACrD,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,CAAA;IAC1E,OAAO,QAAQ,EAAE,WAAW,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyPivot Core - AI Data Analyst
|
|
3
|
+
* Exports for AI-related functionality
|
|
4
|
+
*/
|
|
5
|
+
export { DEMO_DATA_SOURCES, DEMO_SCENARIOS, DEMO_SCHEMAS, findDemoResponse, getDefaultDemoResponse, getDemoSchema, getInitialDemoData, } from './demo';
|
|
6
|
+
export type { DemoScenario, DemoTrigger } from './demo';
|
|
7
|
+
export { buildResultsSummary, buildSystemPrompt, buildUserMessage, extractSQLFromResponse, stripSQLFromContent, validateSQLSafety, } from './prompts';
|
|
8
|
+
export { addMessageToConversation, createAssistantMessage, createConversation, createSystemMessage, createUserMessage, deserializeConversation, generateMessageId, generateSessionId, getConversationStats, getMessagesForAPI, serializeConversation, setConversationDataSource, trimConversation, } from './session';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,GACnB,MAAM,QAAQ,CAAA;AAEf,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAGvD,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,WAAW,CAAA"}
|
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyPivot Core - AI Data Analyst
|
|
3
|
+
* Exports for AI-related functionality
|
|
4
|
+
*/
|
|
5
|
+
// Demo mode
|
|
6
|
+
export { DEMO_DATA_SOURCES, DEMO_SCENARIOS, DEMO_SCHEMAS, findDemoResponse, getDefaultDemoResponse, getDemoSchema, getInitialDemoData, } from './demo';
|
|
7
|
+
// Prompt engineering
|
|
8
|
+
export { buildResultsSummary, buildSystemPrompt, buildUserMessage, extractSQLFromResponse, stripSQLFromContent, validateSQLSafety, } from './prompts';
|
|
9
|
+
// Session management
|
|
10
|
+
export { addMessageToConversation, createAssistantMessage, createConversation, createSystemMessage, createUserMessage, deserializeConversation, generateMessageId, generateSessionId, getConversationStats, getMessagesForAPI, serializeConversation, setConversationDataSource, trimConversation, } from './session';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY;AACZ,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,GACnB,MAAM,QAAQ,CAAA;AAIf,qBAAqB;AACrB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,WAAW,CAAA;AAClB,qBAAqB;AACrB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyPivot Core - AI Prompt Engineering
|
|
3
|
+
* System prompts and context builders for the AI Data Analyst
|
|
4
|
+
*/
|
|
5
|
+
import type { AIDataSource, AITableSchema } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Build the system prompt for the AI Data Analyst
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildSystemPrompt(dataSources: AIDataSource[], schemas: Map<string, AITableSchema>, selectedSourceId?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Build a user message with additional context
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildUserMessage(userInput: string, context?: {
|
|
14
|
+
previousQueryFailed?: boolean;
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
rowCount?: number;
|
|
17
|
+
}): string;
|
|
18
|
+
/**
|
|
19
|
+
* Extract SQL query from AI response
|
|
20
|
+
* Returns the SQL if found, null otherwise
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractSQLFromResponse(response: string): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Validate that a SQL query is safe (read-only)
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateSQLSafety(sql: string): {
|
|
27
|
+
valid: boolean;
|
|
28
|
+
error?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Build a summary message after query results are returned
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildResultsSummary(rowCount: number, truncated: boolean, maxRows: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Strip SQL code blocks from message content for display
|
|
36
|
+
* The SQL is stored in metadata and shown via a button instead
|
|
37
|
+
*/
|
|
38
|
+
export declare function stripSQLFromContent(content: string): string;
|
|
39
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAkB,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE3E;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,YAAY,EAAE,EAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EACnC,gBAAgB,CAAC,EAAE,MAAM,GACxB,MAAM,CAmER;AAmED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GACA,MAAM,CAQR;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CA8CjF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,GACd,MAAM,CAUR;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK3D"}
|