tokmon 0.25.0 → 0.27.0
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/{bootstrap-ink-O55MPGXJ.js → bootstrap-ink-3YNJFKCW.js} +60 -20
- package/dist/{chunk-QUGH2XA6.js → chunk-4CY725NY.js} +1 -1
- package/dist/{chunk-IOIAXKW2.js → chunk-OWPJUG4C.js} +2 -2
- package/dist/{chunk-INBZLHJQ.js → chunk-RTGMDE7U.js} +5 -3
- package/dist/{chunk-45YYP2FJ.js → chunk-VGYBQH5I.js} +1 -1
- package/dist/{cli-command-YQ5T4R73.js → cli-command-U7RZ2GTD.js} +2 -2
- package/dist/cli.js +4 -4
- package/dist/{daemon-QBOXJFRA.js → daemon-PQWKWRC6.js} +3 -3
- package/dist/{server-23ERUOJ7.js → server-5WIWS27N.js} +3 -3
- package/dist/web/assets/{Area-DbVPPS7M.js → Area-Tx1mUuqM.js} +1 -1
- package/dist/web/assets/{analytics-DS5p9Duq.js → analytics-CAzklhXc.js} +2 -2
- package/dist/web/assets/{breakdown-zYF0TXN5.js → breakdown-BoPnOv7Y.js} +1 -1
- package/dist/web/assets/{chart-BZHliIXk.js → chart-jK7A9m7R.js} +1 -1
- package/dist/web/assets/{explore-DYv8bb2r.js → explore-e8wtwk7s.js} +1 -1
- package/dist/web/assets/{index-BO8m4dq1.js → index-C8oe6EfM.js} +6 -6
- package/dist/web/assets/{models-P3OwakgO.js → models-_4IZNDxW.js} +2 -2
- package/dist/web/assets/{overview-5WswYjWK.js → overview-BBOfd_Fd.js} +2 -2
- package/dist/web/assets/{panel-CpwRWsNg.js → panel-CstB4hPm.js} +1 -1
- package/dist/web/assets/{primitives-Do0zWLZ4.js → primitives-G9ALG7ih.js} +1 -1
- package/dist/web/assets/{settings-sheet-uD6-A3tV.js → settings-sheet-rq6vbYXM.js} +1 -1
- package/dist/web/assets/{share-sheet-CimegH2K.js → share-sheet-BwmnebRB.js} +1 -1
- package/dist/web/assets/{timeline-Ch94Yv4z.js → timeline-DkYWH6XW.js} +1 -1
- package/dist/web/assets/{use-dialog-trap-LxEFLutK.js → use-dialog-trap-Jci2xaMX.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createDaemonRpcClient
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4CY725NY.js";
|
|
5
5
|
import {
|
|
6
6
|
accountsByProvider,
|
|
7
7
|
buildAccounts,
|
|
8
8
|
fetchPeak,
|
|
9
9
|
modelColor
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VGYBQH5I.js";
|
|
11
11
|
import {
|
|
12
12
|
PROVIDERS,
|
|
13
13
|
PROVIDER_ORDER,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
time,
|
|
24
24
|
tokens,
|
|
25
25
|
withTimeout
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RTGMDE7U.js";
|
|
27
27
|
import {
|
|
28
28
|
COLOR_PALETTE,
|
|
29
29
|
DEFAULTS,
|
|
@@ -217,6 +217,25 @@ function metricValueText(m) {
|
|
|
217
217
|
// src/ui/dashboard.tsx
|
|
218
218
|
import { memo as memo2 } from "react";
|
|
219
219
|
import { Box as Box2, Text as Text2 } from "ink";
|
|
220
|
+
|
|
221
|
+
// src/ui/provider-card.logic.ts
|
|
222
|
+
function normalizePlan(plan) {
|
|
223
|
+
if (plan == null) return null;
|
|
224
|
+
const t = plan.trim();
|
|
225
|
+
return t === "" ? null : t;
|
|
226
|
+
}
|
|
227
|
+
function planDisplay(rawPlans) {
|
|
228
|
+
const plans = rawPlans.map(normalizePlan);
|
|
229
|
+
const named = plans.filter((p) => p != null);
|
|
230
|
+
if (named.length === 0) return { mode: "none" };
|
|
231
|
+
if (plans.length === 1) return { mode: "header", plan: named[0] };
|
|
232
|
+
const allNamed = named.length === plans.length;
|
|
233
|
+
const allEqual = named.every((p) => p === named[0]);
|
|
234
|
+
if (allNamed && allEqual) return { mode: "header", plan: named[0] };
|
|
235
|
+
return { mode: "perRow", count: plans.length };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/ui/dashboard.tsx
|
|
220
239
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
221
240
|
var GAP = 2;
|
|
222
241
|
var MIN_CARD = 56;
|
|
@@ -325,7 +344,7 @@ function ProviderCard({ provider, accounts, stats, width, variant, privacyMode =
|
|
|
325
344
|
const items = accounts.map((a) => ({ account: a, s: stats.get(a.id) }));
|
|
326
345
|
const dashboards = items.map((i) => i.s?.dashboard).filter((d) => !!d);
|
|
327
346
|
const agg = meta.hasUsage && dashboards.length > 0 ? aggregate(dashboards) : null;
|
|
328
|
-
const
|
|
347
|
+
const planView = planDisplay(items.map((i) => i.s?.billing?.plan));
|
|
329
348
|
const activity = items.map((i) => i.s?.billing?.activity).find(Boolean) ?? null;
|
|
330
349
|
const inner = width - 4;
|
|
331
350
|
const hasSpark = !!agg && agg.series.some((v) => v > 0);
|
|
@@ -339,7 +358,11 @@ function ProviderCard({ provider, accounts, stats, width, variant, privacyMode =
|
|
|
339
358
|
] }),
|
|
340
359
|
/* @__PURE__ */ jsx2(Text2, { bold: true, color: meta.color, children: meta.name }),
|
|
341
360
|
/* @__PURE__ */ jsx2(Box2, { flexGrow: 1 }),
|
|
342
|
-
|
|
361
|
+
planView.mode === "header" && /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: planView.plan }),
|
|
362
|
+
planView.mode === "perRow" && /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
363
|
+
planView.count,
|
|
364
|
+
" accounts"
|
|
365
|
+
] })
|
|
343
366
|
] }),
|
|
344
367
|
meta.hasUsage && (agg ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
345
368
|
/* @__PURE__ */ jsx2(Box2, { height: 1 }),
|
|
@@ -356,7 +379,7 @@ function ProviderCard({ provider, accounts, stats, width, variant, privacyMode =
|
|
|
356
379
|
] })),
|
|
357
380
|
meta.hasBilling && showBars && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
358
381
|
meta.hasUsage && /* @__PURE__ */ jsx2(Rule, { inner }),
|
|
359
|
-
/* @__PURE__ */ jsx2(LimitsBlock, { items, inner, privacyMode, resetDisplay, tz })
|
|
382
|
+
/* @__PURE__ */ jsx2(LimitsBlock, { items, inner, showRowPlans: planView.mode === "perRow", privacyMode, resetDisplay, tz })
|
|
360
383
|
] }),
|
|
361
384
|
meta.hasBilling && !showBars && !meta.hasUsage && /* @__PURE__ */ jsx2(CompactBilling, { items, privacyMode }),
|
|
362
385
|
hasSpark && showSpark && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
@@ -429,7 +452,7 @@ function accountTitle(account, billing, privacyMode = false) {
|
|
|
429
452
|
const title = email && !account.name.includes("@") ? `${account.name} ${email}` : account.name;
|
|
430
453
|
return privacyMode ? redactEmail(title) : title;
|
|
431
454
|
}
|
|
432
|
-
function LimitsBlock({ items, inner, privacyMode, resetDisplay, tz }) {
|
|
455
|
+
function LimitsBlock({ items, inner, showRowPlans, privacyMode, resetDisplay, tz }) {
|
|
433
456
|
const showName = items.length > 1;
|
|
434
457
|
const labels = items.flatMap((i) => i.s?.billing?.metrics ?? []).map((m) => m.label.length);
|
|
435
458
|
const labelW = Math.min(Math.max(7, ...labels) + 1, 14);
|
|
@@ -438,13 +461,24 @@ function LimitsBlock({ items, inner, privacyMode, resetDisplay, tz }) {
|
|
|
438
461
|
return /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", children: items.map(({ account, s }, idx) => {
|
|
439
462
|
const billing = s?.billing;
|
|
440
463
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", marginTop: showName && idx > 0 ? 1 : 0, children: [
|
|
441
|
-
showName &&
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
464
|
+
showName && (() => {
|
|
465
|
+
const rowPlan = showRowPlans ? normalizePlan(billing?.plan) : null;
|
|
466
|
+
const planCap = Math.max(0, inner - 25);
|
|
467
|
+
const shownPlan = rowPlan && planCap >= 4 ? truncateName(rowPlan, planCap) : "";
|
|
468
|
+
const planReserve = shownPlan ? shownPlan.length + 1 : 0;
|
|
469
|
+
const nameBudget = Math.max(22, inner - 2 - planReserve);
|
|
470
|
+
return /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
471
|
+
/* @__PURE__ */ jsxs2(Text2, { color: account.color, children: [
|
|
472
|
+
glyphs().dot,
|
|
473
|
+
" "
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, children: truncateName(accountTitle(account, billing, privacyMode), nameBudget) }),
|
|
476
|
+
shownPlan && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
477
|
+
/* @__PURE__ */ jsx2(Box2, { flexGrow: 1 }),
|
|
478
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: shownPlan })
|
|
479
|
+
] })
|
|
480
|
+
] });
|
|
481
|
+
})(),
|
|
448
482
|
!billing ? /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
449
483
|
"Fetching",
|
|
450
484
|
glyphs().ellipsis
|
|
@@ -481,12 +515,13 @@ function SparkFooter({ series, month, color }) {
|
|
|
481
515
|
] });
|
|
482
516
|
}
|
|
483
517
|
function aggregate(list) {
|
|
484
|
-
const zero = () => ({ cost: 0, tokens: 0, cacheRead: 0, cacheSavings: 0 });
|
|
518
|
+
const zero = () => ({ cost: 0, tokens: 0, input: 0, cacheRead: 0, cacheSavings: 0 });
|
|
485
519
|
const z = { today: zero(), week: zero(), month: zero(), burnRate: 0, series: [] };
|
|
486
520
|
for (const d of list) {
|
|
487
521
|
for (const k of ["today", "week", "month"]) {
|
|
488
522
|
z[k].cost += d[k].cost;
|
|
489
523
|
z[k].tokens += d[k].tokens;
|
|
524
|
+
z[k].input += d[k].input ?? 0;
|
|
490
525
|
z[k].cacheRead += d[k].cacheRead;
|
|
491
526
|
z[k].cacheSavings += d[k].cacheSavings;
|
|
492
527
|
}
|
|
@@ -498,7 +533,7 @@ function aggregate(list) {
|
|
|
498
533
|
return z;
|
|
499
534
|
}
|
|
500
535
|
var TotalsRow = memo2(function TotalsRow2({ groups, stats, cols }) {
|
|
501
|
-
const zero = () => ({ cost: 0, tokens: 0, cacheRead: 0, cacheSavings: 0 });
|
|
536
|
+
const zero = () => ({ cost: 0, tokens: 0, input: 0, cacheRead: 0, cacheSavings: 0 });
|
|
502
537
|
const t = zero(), w = zero(), m = zero();
|
|
503
538
|
for (const g of groups) {
|
|
504
539
|
if (!PROVIDERS[g.provider].hasUsage) continue;
|
|
@@ -507,18 +542,23 @@ var TotalsRow = memo2(function TotalsRow2({ groups, stats, cols }) {
|
|
|
507
542
|
if (!d) continue;
|
|
508
543
|
t.cost += d.today.cost;
|
|
509
544
|
t.tokens += d.today.tokens;
|
|
545
|
+
t.input += d.today.input ?? 0;
|
|
510
546
|
w.cost += d.week.cost;
|
|
511
547
|
w.tokens += d.week.tokens;
|
|
548
|
+
w.input += d.week.input ?? 0;
|
|
512
549
|
m.cost += d.month.cost;
|
|
513
550
|
m.tokens += d.month.tokens;
|
|
551
|
+
m.input += d.month.input ?? 0;
|
|
514
552
|
}
|
|
515
553
|
}
|
|
516
554
|
const inner = cols - 4;
|
|
517
555
|
const dot = glyphs().middot;
|
|
518
|
-
const
|
|
519
|
-
const
|
|
556
|
+
const monthNonCached = m.input > 0 ? `, ${tokens(m.input)} non-cached` : "";
|
|
557
|
+
const full = `${glyphs().dotAll} Today ${currency(t.cost)} (${tokens(t.tokens)} tok) ${dot} Week ${currency(w.cost)} (${tokens(w.tokens)} tok) ${dot} Month ${currency(m.cost)} (${tokens(m.tokens)} tok${monthNonCached})`;
|
|
558
|
+
const monthOnly = `${glyphs().dotAll} This Month ${currency(m.cost)} (${tokens(m.tokens)} tok${monthNonCached})`;
|
|
559
|
+
const noTok = `${glyphs().dotAll} Today ${currency(t.cost)} ${dot} Week ${currency(w.cost)} ${dot} Month ${currency(m.cost)}${m.input > 0 ? ` (${tokens(m.input)} non-cached)` : ""}`;
|
|
520
560
|
const tight = `${glyphs().dotAll} ${currency(t.cost)} ${dot} ${currency(w.cost)} ${dot} ${currency(m.cost)}`;
|
|
521
|
-
const text = full.length <= inner ? full : noTok.length <= inner ? noTok : tight;
|
|
561
|
+
const text = full.length <= inner ? full : monthOnly.length <= inner ? monthOnly : noTok.length <= inner ? noTok : tight;
|
|
522
562
|
return /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: text }) });
|
|
523
563
|
});
|
|
524
564
|
|
|
@@ -3401,7 +3441,7 @@ function App({ interval: cliInterval, initialConfig, baseUrl = null, mode = "deg
|
|
|
3401
3441
|
if (webStartingRef.current) return;
|
|
3402
3442
|
webStartingRef.current = true;
|
|
3403
3443
|
try {
|
|
3404
|
-
const { startWebServer } = await import("./server-
|
|
3444
|
+
const { startWebServer } = await import("./server-5WIWS27N.js");
|
|
3405
3445
|
const ctrl = await startWebServer({ config: cfg, log: false });
|
|
3406
3446
|
webRef.current = ctrl;
|
|
3407
3447
|
openUrl(ctrl.url);
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TOKMON_WS_METHODS,
|
|
4
4
|
TOKMON_WS_PATH,
|
|
5
5
|
TokmonRpcGroup
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RTGMDE7U.js";
|
|
7
7
|
|
|
8
8
|
// src/client/daemon-rpc-client.ts
|
|
9
9
|
import { Cause, Context, Duration, Effect, Exit, Fiber, Layer, ManagedRuntime, Schedule, Stream } from "effect";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
colorHex,
|
|
12
12
|
fetchPeak,
|
|
13
13
|
namedHex
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VGYBQH5I.js";
|
|
15
15
|
import {
|
|
16
16
|
PROVIDERS,
|
|
17
17
|
TOKMON_CAPABILITIES,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
detectProviders,
|
|
23
23
|
resolveTimezone,
|
|
24
24
|
withTimeout
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-RTGMDE7U.js";
|
|
26
26
|
import {
|
|
27
27
|
cacheDir,
|
|
28
28
|
expandHome,
|
|
@@ -590,15 +590,16 @@ function summarize(entries, tz) {
|
|
|
590
590
|
const todayStart = startOfDay(now, tz);
|
|
591
591
|
const weekStart = startOfWeek(now, tz);
|
|
592
592
|
const monthStart = startOfMonth(now, tz);
|
|
593
|
-
const today = { cost: 0, tokens: 0, cacheRead: 0, cacheSavings: 0 };
|
|
594
|
-
const week = { cost: 0, tokens: 0, cacheRead: 0, cacheSavings: 0 };
|
|
595
|
-
const month = { cost: 0, tokens: 0, cacheRead: 0, cacheSavings: 0 };
|
|
593
|
+
const today = { cost: 0, tokens: 0, input: 0, cacheRead: 0, cacheSavings: 0 };
|
|
594
|
+
const week = { cost: 0, tokens: 0, input: 0, cacheRead: 0, cacheSavings: 0 };
|
|
595
|
+
const month = { cost: 0, tokens: 0, input: 0, cacheRead: 0, cacheSavings: 0 };
|
|
596
596
|
const byDay = /* @__PURE__ */ new Map();
|
|
597
597
|
let oldestToday = now;
|
|
598
598
|
let hadToday = false;
|
|
599
599
|
const add = (s, e) => {
|
|
600
600
|
s.cost += e.cost;
|
|
601
601
|
s.tokens += e.input + e.output + e.cacheCreate + e.cacheRead;
|
|
602
|
+
s.input += e.input;
|
|
602
603
|
s.cacheRead += e.cacheRead;
|
|
603
604
|
s.cacheSavings += e.cacheSavings;
|
|
604
605
|
};
|
|
@@ -825,6 +826,7 @@ var FsListingSchema = Schema.Struct({
|
|
|
825
826
|
var UsageSummarySchema = Schema.Struct({
|
|
826
827
|
cost: Schema.Finite,
|
|
827
828
|
tokens: Schema.Finite,
|
|
829
|
+
input: Schema.Finite,
|
|
828
830
|
cacheRead: Schema.Finite,
|
|
829
831
|
cacheSavings: Schema.Finite
|
|
830
832
|
});
|
|
@@ -6,7 +6,7 @@ import "./chunk-QM5E5RJZ.js";
|
|
|
6
6
|
import "./chunk-SMPY52EV.js";
|
|
7
7
|
import {
|
|
8
8
|
createDaemonRpcClient
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4CY725NY.js";
|
|
10
10
|
import {
|
|
11
11
|
PROVIDERS,
|
|
12
12
|
antigravityStateDb,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
startOfMonth,
|
|
27
27
|
startOfWeek,
|
|
28
28
|
withTimeout
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-RTGMDE7U.js";
|
|
30
30
|
import {
|
|
31
31
|
PROVIDER_IDS,
|
|
32
32
|
configLocation
|
package/dist/cli.js
CHANGED
|
@@ -41,7 +41,7 @@ function validateServeArgs(serveArgs) {
|
|
|
41
41
|
}
|
|
42
42
|
async function main() {
|
|
43
43
|
if (subcommand && ["usage", "models", "query", "providers", "snapshot", "config"].includes(subcommand)) {
|
|
44
|
-
const { runQueryCommand } = await import("./cli-command-
|
|
44
|
+
const { runQueryCommand } = await import("./cli-command-U7RZ2GTD.js");
|
|
45
45
|
try {
|
|
46
46
|
const output = await runQueryCommand(
|
|
47
47
|
subcommand,
|
|
@@ -60,14 +60,14 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
if (subcommand === "__daemon") {
|
|
63
|
-
const { runDaemon } = await import("./daemon-
|
|
63
|
+
const { runDaemon } = await import("./daemon-PQWKWRC6.js");
|
|
64
64
|
await runDaemon(args.slice(1), { foreground: false });
|
|
65
65
|
process.exitCode ??= 0;
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (subcommand === "serve" || subcommand === "web") {
|
|
69
69
|
validateServeArgs(args.slice(1));
|
|
70
|
-
const { runDaemon } = await import("./daemon-
|
|
70
|
+
const { runDaemon } = await import("./daemon-PQWKWRC6.js");
|
|
71
71
|
await runDaemon(args.slice(1), { foreground: true });
|
|
72
72
|
process.exitCode ??= 0;
|
|
73
73
|
return;
|
|
@@ -128,7 +128,7 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
128
128
|
}));
|
|
129
129
|
const daemon = await attachOrSpawn();
|
|
130
130
|
const mode = daemon.kind === "spawned" ? "connected" : "degraded";
|
|
131
|
-
const { bootstrapInk } = await import("./bootstrap-ink-
|
|
131
|
+
const { bootstrapInk } = await import("./bootstrap-ink-3YNJFKCW.js");
|
|
132
132
|
await bootstrapInk({ interval, config, daemon, mode });
|
|
133
133
|
}
|
|
134
134
|
void main().catch((error) => {
|
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
} from "./chunk-QM5E5RJZ.js";
|
|
12
12
|
import {
|
|
13
13
|
startWebServer
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OWPJUG4C.js";
|
|
15
15
|
import {
|
|
16
16
|
appVersion
|
|
17
17
|
} from "./chunk-SMPY52EV.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-VGYBQH5I.js";
|
|
19
19
|
import {
|
|
20
20
|
flushDisk
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-RTGMDE7U.js";
|
|
22
22
|
import {
|
|
23
23
|
loadConfig
|
|
24
24
|
} from "./chunk-E2YXYU73.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
startWebServer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OWPJUG4C.js";
|
|
5
5
|
import "./chunk-SMPY52EV.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-VGYBQH5I.js";
|
|
7
|
+
import "./chunk-RTGMDE7U.js";
|
|
8
8
|
import "./chunk-E2YXYU73.js";
|
|
9
9
|
export {
|
|
10
10
|
startWebServer
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{R as v,r as ht}from"./index-
|
|
1
|
+
import{R as v,r as ht}from"./index-C8oe6EfM.js";import{j as J,c as Q,D as vt,J as jt,W as kt,L as F,d as I,q as G,w as dt,y as N,z as nt,t as U,$ as yt,E as mt,v as Z,F as bt,H as gt,_ as tt,a0 as q,B as V,a1 as Lt}from"./chart-jK7A9m7R.js";var $t=["type","layout","connectNulls","ref"],Nt=["key"];function K(t){"@babel/helpers - typeof";return K=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},K(t)}function lt(t,r){if(t==null)return{};var n=It(t,r),e,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a<o.length;a++)e=o[a],!(r.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}function It(t,r){if(t==null)return{};var n={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(r.indexOf(e)>=0)continue;n[e]=t[e]}return n}function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},Y.apply(this,arguments)}function ut(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function j(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ut(Object(n),!0).forEach(function(e){$(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ut(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function z(t){return Ct(t)||Tt(t)||Rt(t)||Bt()}function Bt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rt(t,r){if(t){if(typeof t=="string")return at(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return at(t,r)}}function Tt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ct(t){if(Array.isArray(t))return at(t)}function at(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function Wt(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function ct(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,xt(e.key),e)}}function Ft(t,r,n){return r&&ct(t.prototype,r),n&&ct(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Mt(t,r,n){return r=et(r),zt(t,At()?Reflect.construct(r,n||[],et(t).constructor):r.apply(t,n))}function zt(t,r){if(r&&(K(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Vt(t)}function Vt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function At(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(At=function(){return!!t})()}function et(t){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},et(t)}function Kt(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&it(t,r)}function it(t,r){return it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,a){return e.__proto__=a,e},it(t,r)}function $(t,r,n){return r=xt(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function xt(t){var r=Ht(t,"string");return K(r)=="symbol"?r:r+""}function Ht(t,r){if(K(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var e=n.call(t,r);if(K(e)!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var st=(function(t){function r(){var n;Wt(this,r);for(var e=arguments.length,a=new Array(e),o=0;o<e;o++)a[o]=arguments[o];return n=Mt(this,r,[].concat(a)),$(n,"state",{isAnimationFinished:!0,totalLength:0}),$(n,"generateSimpleStrokeDasharray",function(i,s){return"".concat(s,"px ").concat(i-s,"px")}),$(n,"getStrokeDasharray",function(i,s,l){var u=l.reduce(function(x,A){return x+A});if(!u)return n.generateSimpleStrokeDasharray(s,i);for(var f=Math.floor(i/u),c=i%u,p=s-i,d=[],h=0,y=0;h<l.length;y+=l[h],++h)if(y+l[h]>c){d=[].concat(z(l.slice(0,h)),[c-y]);break}var b=d.length%2===0?[0,p]:[p];return[].concat(z(r.repeat(l,f)),z(d),b).map(function(x){return"".concat(x,"px")}).join(", ")}),$(n,"id",bt("recharts-line-")),$(n,"pathRef",function(i){n.mainCurve=i}),$(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),$(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Kt(r,t),Ft(r,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();this.setState({totalLength:e})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();e!==this.state.totalLength&&this.setState({totalLength:e})}}},{key:"getTotalLength",value:function(){var e=this.mainCurve;try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(e,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,i=o.points,s=o.xAxis,l=o.yAxis,u=o.layout,f=o.children,c=jt(f,kt);if(!c)return null;var p=function(y,b){return{x:y.x,y:y.y,value:y.value,errorVal:Z(y.payload,b)}},d={clipPath:e?"url(#clipPath-".concat(a,")"):null};return v.createElement(F,d,c.map(function(h){return v.cloneElement(h,{key:"bar-".concat(h.props.dataKey),data:i,xAxis:s,yAxis:l,layout:u,dataPointFormatter:p})}))}},{key:"renderDots",value:function(e,a,o){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var s=this.props,l=s.dot,u=s.points,f=s.dataKey,c=I(this.props,!1),p=I(l,!0),d=u.map(function(y,b){var x=j(j(j({key:"dot-".concat(b),r:3},c),p),{},{index:b,cx:y.x,cy:y.y,value:y.value,dataKey:f,payload:y.payload,points:u});return r.renderDotItem(l,x)}),h={clipPath:e?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return v.createElement(F,Y({className:"recharts-line-dots",key:"dots"},h),d)}},{key:"renderCurveStatically",value:function(e,a,o,i){var s=this.props,l=s.type,u=s.layout,f=s.connectNulls;s.ref;var c=lt(s,$t),p=j(j(j({},I(c,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:e},i),{},{type:l,layout:u,connectNulls:f});return v.createElement(G,Y({},p,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(e,a){var o=this,i=this.props,s=i.points,l=i.strokeDasharray,u=i.isAnimationActive,f=i.animationBegin,c=i.animationDuration,p=i.animationEasing,d=i.animationId,h=i.animateNewValues,y=i.width,b=i.height,x=this.state,A=x.prevPoints,_=x.totalLength;return v.createElement(dt,{begin:f,duration:c,isActive:u,easing:p,from:{t:0},to:{t:1},key:"line-".concat(d),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(g){var m=g.t;if(A){var P=A.length/s.length,w=s.map(function(O,R){var T=Math.floor(R*P);if(A[T]){var C=A[T],L=N(C.x,O.x),_t=N(C.y,O.y);return j(j({},O),{},{x:L(m),y:_t(m)})}if(h){var Et=N(y*2,O.x),Dt=N(b/2,O.y);return j(j({},O),{},{x:Et(m),y:Dt(m)})}return j(j({},O),{},{x:O.x,y:O.y})});return o.renderCurveStatically(w,e,a)}var S=N(0,_),k=S(m),E;if(l){var D="".concat(l).split(/[,\s]+/gim).map(function(O){return parseFloat(O)});E=o.getStrokeDasharray(k,_,D)}else E=o.generateSimpleStrokeDasharray(_,k);return o.renderCurveStatically(s,e,a,{strokeDasharray:E})})}},{key:"renderCurve",value:function(e,a){var o=this.props,i=o.points,s=o.isAnimationActive,l=this.state,u=l.prevPoints,f=l.totalLength;return s&&i&&i.length&&(!u&&f>0||!nt(u,i))?this.renderCurveWithAnimation(e,a):this.renderCurveStatically(i,e,a)}},{key:"render",value:function(){var e,a=this.props,o=a.hide,i=a.dot,s=a.points,l=a.className,u=a.xAxis,f=a.yAxis,c=a.top,p=a.left,d=a.width,h=a.height,y=a.isAnimationActive,b=a.id;if(o||!s||!s.length)return null;var x=this.state.isAnimationFinished,A=s.length===1,_=Q("recharts-line",l),g=u&&u.allowDataOverflow,m=f&&f.allowDataOverflow,P=g||m,w=U(b)?this.id:b,S=(e=I(i,!1))!==null&&e!==void 0?e:{r:3,strokeWidth:2},k=S.r,E=k===void 0?3:k,D=S.strokeWidth,O=D===void 0?2:D,R=yt(i)?i:{},T=R.clipDot,C=T===void 0?!0:T,L=E*2+O;return v.createElement(F,{className:_},g||m?v.createElement("defs",null,v.createElement("clipPath",{id:"clipPath-".concat(w)},v.createElement("rect",{x:g?p:p-d/2,y:m?c:c-h/2,width:g?d:d*2,height:m?h:h*2})),!C&&v.createElement("clipPath",{id:"clipPath-dots-".concat(w)},v.createElement("rect",{x:p-L/2,y:c-L/2,width:d+L,height:h+L}))):null,!A&&this.renderCurve(P,w),this.renderErrorBar(P,w),(A||i)&&this.renderDots(P,C,w),(!y||x)&&mt.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(e,a){return e.animationId!==a.prevAnimationId?{prevAnimationId:e.animationId,curPoints:e.points,prevPoints:a.curPoints}:e.points!==a.curPoints?{curPoints:e.points}:null}},{key:"repeat",value:function(e,a){for(var o=e.length%2!==0?[].concat(z(e),[0]):e,i=[],s=0;s<a;++s)i=[].concat(z(i),z(o));return i}},{key:"renderDotItem",value:function(e,a){var o;if(v.isValidElement(e))o=v.cloneElement(e,a);else if(J(e))o=e(a);else{var i=a.key,s=lt(a,Nt),l=Q("recharts-line-dot",typeof e!="boolean"?e.className:"");o=v.createElement(vt,Y({key:i},s,{className:l}))}return o}}])})(ht.PureComponent);$(st,"displayName","Line");$(st,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!gt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});$(st,"getComposedData",function(t){var r=t.props,n=t.xAxis,e=t.yAxis,a=t.xAxisTicks,o=t.yAxisTicks,i=t.dataKey,s=t.bandSize,l=t.displayedData,u=t.offset,f=r.layout,c=l.map(function(p,d){var h=Z(p,i);return f==="horizontal"?{x:tt({axis:n,ticks:a,bandSize:s,entry:p,index:d}),y:U(h)?null:e.scale(h),value:h,payload:p}:{x:U(h)?null:n.scale(h),y:tt({axis:e,ticks:o,bandSize:s,entry:p,index:d}),value:h,payload:p}});return j({points:c,layout:f},u)});var Xt=["layout","type","stroke","connectNulls","isRange","ref"],Yt=["key"],Pt;function H(t){"@babel/helpers - typeof";return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},H(t)}function Ot(t,r){if(t==null)return{};var n=Ut(t,r),e,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a<o.length;a++)e=o[a],!(r.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}function Ut(t,r){if(t==null)return{};var n={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(r.indexOf(e)>=0)continue;n[e]=t[e]}return n}function M(){return M=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},M.apply(this,arguments)}function ft(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function W(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ft(Object(n),!0).forEach(function(e){B(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ft(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function qt(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function pt(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,St(e.key),e)}}function Gt(t,r,n){return r&&pt(t.prototype,r),n&&pt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Jt(t,r,n){return r=rt(r),Qt(t,wt()?Reflect.construct(r,n||[],rt(t).constructor):r.apply(t,n))}function Qt(t,r){if(r&&(H(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zt(t)}function Zt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function wt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(wt=function(){return!!t})()}function rt(t){return rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},rt(t)}function te(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ot(t,r)}function ot(t,r){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,a){return e.__proto__=a,e},ot(t,r)}function B(t,r,n){return r=St(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function St(t){var r=ee(t,"string");return H(r)=="symbol"?r:r+""}function ee(t,r){if(H(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var e=n.call(t,r);if(H(e)!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var X=(function(t){function r(){var n;qt(this,r);for(var e=arguments.length,a=new Array(e),o=0;o<e;o++)a[o]=arguments[o];return n=Jt(this,r,[].concat(a)),B(n,"state",{isAnimationFinished:!0}),B(n,"id",bt("recharts-area-")),B(n,"handleAnimationEnd",function(){var i=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),J(i)&&i()}),B(n,"handleAnimationStart",function(){var i=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),J(i)&&i()}),n}return te(r,t),Gt(r,[{key:"renderDots",value:function(e,a,o){var i=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(i&&!s)return null;var l=this.props,u=l.dot,f=l.points,c=l.dataKey,p=I(this.props,!1),d=I(u,!0),h=f.map(function(b,x){var A=W(W(W({key:"dot-".concat(x),r:3},p),d),{},{index:x,cx:b.x,cy:b.y,dataKey:c,value:b.value,payload:b.payload,points:f});return r.renderDotItem(u,A)}),y={clipPath:e?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return v.createElement(F,M({className:"recharts-area-dots"},y),h)}},{key:"renderHorizontalRect",value:function(e){var a=this.props,o=a.baseLine,i=a.points,s=a.strokeWidth,l=i[0].x,u=i[i.length-1].x,f=e*Math.abs(l-u),c=q(i.map(function(p){return p.y||0}));return V(o)&&typeof o=="number"?c=Math.max(o,c):o&&Array.isArray(o)&&o.length&&(c=Math.max(q(o.map(function(p){return p.y||0})),c)),V(c)?v.createElement("rect",{x:l<u?l:l-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(e){var a=this.props,o=a.baseLine,i=a.points,s=a.strokeWidth,l=i[0].y,u=i[i.length-1].y,f=e*Math.abs(l-u),c=q(i.map(function(p){return p.x||0}));return V(o)&&typeof o=="number"?c=Math.max(o,c):o&&Array.isArray(o)&&o.length&&(c=Math.max(q(o.map(function(p){return p.x||0})),c)),V(c)?v.createElement("rect",{x:0,y:l<u?l:l-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(e){var a=this.props.layout;return a==="vertical"?this.renderVerticalRect(e):this.renderHorizontalRect(e)}},{key:"renderAreaStatically",value:function(e,a,o,i){var s=this.props,l=s.layout,u=s.type,f=s.stroke,c=s.connectNulls,p=s.isRange;s.ref;var d=Ot(s,Xt);return v.createElement(F,{clipPath:o?"url(#clipPath-".concat(i,")"):null},v.createElement(G,M({},I(d,!0),{points:e,connectNulls:c,type:u,baseLine:a,layout:l,stroke:"none",className:"recharts-area-area"})),f!=="none"&&v.createElement(G,M({},I(this.props,!1),{className:"recharts-area-curve",layout:l,type:u,connectNulls:c,fill:"none",points:e})),f!=="none"&&p&&v.createElement(G,M({},I(this.props,!1),{className:"recharts-area-curve",layout:l,type:u,connectNulls:c,fill:"none",points:a})))}},{key:"renderAreaWithAnimation",value:function(e,a){var o=this,i=this.props,s=i.points,l=i.baseLine,u=i.isAnimationActive,f=i.animationBegin,c=i.animationDuration,p=i.animationEasing,d=i.animationId,h=this.state,y=h.prevPoints,b=h.prevBaseLine;return v.createElement(dt,{begin:f,duration:c,isActive:u,easing:p,from:{t:0},to:{t:1},key:"area-".concat(d),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(x){var A=x.t;if(y){var _=y.length/s.length,g=s.map(function(S,k){var E=Math.floor(k*_);if(y[E]){var D=y[E],O=N(D.x,S.x),R=N(D.y,S.y);return W(W({},S),{},{x:O(A),y:R(A)})}return S}),m;if(V(l)&&typeof l=="number"){var P=N(b,l);m=P(A)}else if(U(l)||Lt(l)){var w=N(b,0);m=w(A)}else m=l.map(function(S,k){var E=Math.floor(k*_);if(b[E]){var D=b[E],O=N(D.x,S.x),R=N(D.y,S.y);return W(W({},S),{},{x:O(A),y:R(A)})}return S});return o.renderAreaStatically(g,m,e,a)}return v.createElement(F,null,v.createElement("defs",null,v.createElement("clipPath",{id:"animationClipPath-".concat(a)},o.renderClipRect(A))),v.createElement(F,{clipPath:"url(#animationClipPath-".concat(a,")")},o.renderAreaStatically(s,l,e,a)))})}},{key:"renderArea",value:function(e,a){var o=this.props,i=o.points,s=o.baseLine,l=o.isAnimationActive,u=this.state,f=u.prevPoints,c=u.prevBaseLine,p=u.totalLength;return l&&i&&i.length&&(!f&&p>0||!nt(f,i)||!nt(c,s))?this.renderAreaWithAnimation(e,a):this.renderAreaStatically(i,s,e,a)}},{key:"render",value:function(){var e,a=this.props,o=a.hide,i=a.dot,s=a.points,l=a.className,u=a.top,f=a.left,c=a.xAxis,p=a.yAxis,d=a.width,h=a.height,y=a.isAnimationActive,b=a.id;if(o||!s||!s.length)return null;var x=this.state.isAnimationFinished,A=s.length===1,_=Q("recharts-area",l),g=c&&c.allowDataOverflow,m=p&&p.allowDataOverflow,P=g||m,w=U(b)?this.id:b,S=(e=I(i,!1))!==null&&e!==void 0?e:{r:3,strokeWidth:2},k=S.r,E=k===void 0?3:k,D=S.strokeWidth,O=D===void 0?2:D,R=yt(i)?i:{},T=R.clipDot,C=T===void 0?!0:T,L=E*2+O;return v.createElement(F,{className:_},g||m?v.createElement("defs",null,v.createElement("clipPath",{id:"clipPath-".concat(w)},v.createElement("rect",{x:g?f:f-d/2,y:m?u:u-h/2,width:g?d:d*2,height:m?h:h*2})),!C&&v.createElement("clipPath",{id:"clipPath-dots-".concat(w)},v.createElement("rect",{x:f-L/2,y:u-L/2,width:d+L,height:h+L}))):null,A?null:this.renderArea(P,w),(i||A)&&this.renderDots(P,C,w),(!y||x)&&mt.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(e,a){return e.animationId!==a.prevAnimationId?{prevAnimationId:e.animationId,curPoints:e.points,curBaseLine:e.baseLine,prevPoints:a.curPoints,prevBaseLine:a.curBaseLine}:e.points!==a.curPoints||e.baseLine!==a.curBaseLine?{curPoints:e.points,curBaseLine:e.baseLine}:null}}])})(ht.PureComponent);Pt=X;B(X,"displayName","Area");B(X,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!gt.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});B(X,"getBaseValue",function(t,r,n,e){var a=t.layout,o=t.baseValue,i=r.props.baseValue,s=i??o;if(V(s)&&typeof s=="number")return s;var l=a==="horizontal"?e:n,u=l.scale.domain();if(l.type==="number"){var f=Math.max(u[0],u[1]),c=Math.min(u[0],u[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(u[0],u[1]),0)}return s==="dataMin"?u[0]:s==="dataMax"?u[1]:u[0]});B(X,"getComposedData",function(t){var r=t.props,n=t.item,e=t.xAxis,a=t.yAxis,o=t.xAxisTicks,i=t.yAxisTicks,s=t.bandSize,l=t.dataKey,u=t.stackedData,f=t.dataStartIndex,c=t.displayedData,p=t.offset,d=r.layout,h=u&&u.length,y=Pt.getBaseValue(r,n,e,a),b=d==="horizontal",x=!1,A=c.map(function(g,m){var P;h?P=u[f+m]:(P=Z(g,l),Array.isArray(P)?x=!0:P=[y,P]);var w=P[1]==null||h&&Z(g,l)==null;return b?{x:tt({axis:e,ticks:o,bandSize:s,entry:g,index:m}),y:w?null:a.scale(P[1]),value:P,payload:g}:{x:w?null:e.scale(P[1]),y:tt({axis:a,ticks:i,bandSize:s,entry:g,index:m}),value:P,payload:g}}),_;return h||x?_=A.map(function(g){var m=Array.isArray(g.value)?g.value[0]:null;return b?{x:g.x,y:m!=null&&g.y!=null?a.scale(m):null}:{x:m!=null?e.scale(m):null,y:g.y}}):_=b?a.scale(y):e.scale(y),W({points:A,baseLine:_,layout:d,isRange:x},p)});B(X,"renderDotItem",function(t,r){var n;if(v.isValidElement(t))n=v.cloneElement(t,r);else if(J(t))n=t(r);else{var e=Q("recharts-area-dot",typeof t!="boolean"?t.className:""),a=r.key,o=Ot(r,Yt);n=v.createElement(vt,M({},o,{key:a,className:e}))}return n});export{X as A,st as L};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./breakdown-
|
|
2
|
-
import{h as D,i as j,k as A,D as k,M as z,r as x,j as e,e as T,f as C,a as E,b as I,m as $,s as B,_ as M}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./breakdown-BoPnOv7Y.js","./index-C8oe6EfM.js","./index-NnKaHxPO.css","./chart-jK7A9m7R.js","./panel-CstB4hPm.js","./primitives-G9ALG7ih.js","./timeline-DkYWH6XW.js","./Area-Tx1mUuqM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{h as D,i as j,k as A,D as k,M as z,r as x,j as e,e as T,f as C,a as E,b as I,m as $,s as B,_ as M}from"./index-C8oe6EfM.js";import{P as F}from"./panel-CstB4hPm.js";import{a as w}from"./primitives-G9ALG7ih.js";const R=[0,.32,.55,.78,1],S=t=>t===0?"var(--color-bg-2)":`color-mix(in oklab, var(--color-cost) ${R[t]*100}%, var(--color-bg-2))`,L=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function O(t,n){const i=t,c=i.filter(l=>n(l)>0);if(c.length===0)return null;const h=i.reduce((l,a)=>l+n(a),0),d=c.reduce((l,a)=>n(a)>n(l)?a:l),p=new Array(7).fill(0);for(const l of i)p[D(j(l.date))]+=n(l);const m=p.indexOf(Math.max(...p)),f=new Set(c.map(l=>l.date));let v=0;for(let l=j(c[c.length-1].date);f.has(A(l));l-=k)v++;return{active:c.length,total:h,top:d,avg:h/c.length,busiest:m,streak:v,costed:t.some(l=>l.cost>0)}}function V(t,n,i){const c=new Map(t.map(s=>[s.date,i(s)]));if(t.length===0)return null;const h=t[t.length-1].date,d=t[0].date;let p=j(h),m=j(d);(p-m)/(k*7)>n&&(m=p-n*7*k),m-=D(m)*k;const f=Math.max(...t.map(i),0),v=s=>{if(s<=0||f<=0)return 0;const r=s/f;return r>.66?4:r>.4?3:r>.15?2:1},l=[];let a=new Array(7).fill(null);const u=[];let b=-1,N=0;for(let s=m;s<=p;s+=k){const r=A(s),o=D(s);o===0&&a.some(Boolean)&&(l.push(a),a=new Array(7).fill(null),N++);const g=new Date(s).getUTCMonth();g!==b&&o===0&&(u.push({col:N,text:z[g]}),b=g);const y=s>=j(d);a[o]=y?{date:r,cost:c.get(r)??0,level:v(c.get(r)??0)}:null}return a.some(Boolean)&&l.push(a),{weeks:l,monthLabels:u}}function H({derived:t,maxWeeks:n=26,periodLabel:i}){const[c,h]=x.useState(null),[d,p]=x.useState(null),m=c??d,f=x.useMemo(()=>new Map(t.calendar.map(s=>[s.date,s])),[t.calendar]),v=x.useMemo(()=>t.calendar.some(s=>s.cost>0),[t.calendar]),l=s=>v?s.cost:s.tokens,a=x.useMemo(()=>O(t.calendar,l),[t,v]),u=x.useMemo(()=>V(t.calendar,n,l),[t,n]),b=u?`repeat(${u.weeks.length}, minmax(0,1fr))`:void 0,N=u?u.weeks.length*25:void 0;return e.jsx(e.Fragment,{children:e.jsx(F,{title:"daily spend",titleTag:i,captureName:"calendar",children:!u||!a?e.jsx("div",{className:"py-6 text-center text-xs text-fg-faint",children:"no usage yet"}):e.jsxs("div",{className:"grid gap-x-8 gap-y-5 pt-1 md:grid-cols-[minmax(0,1fr)_210px] md:items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("div",{className:"pl-6",children:e.jsx("div",{className:"grid gap-[3px] text-[9px] text-fg-faint",style:{gridTemplateColumns:b,maxWidth:N},children:u.weeks.map((s,r)=>{const o=u.monthLabels.find(g=>g.col===r);return e.jsx("div",{className:"truncate",children:(o==null?void 0:o.text)??""},r)})})}),e.jsxs("div",{className:"flex gap-[3px]",children:[e.jsx("div",{className:"flex w-5 shrink-0 flex-col gap-[3px] text-[9px] text-fg-faint",children:["M","","W","","F","",""].map((s,r)=>e.jsx("div",{className:"flex flex-1 items-center",children:s},r))}),e.jsx("div",{className:"grid min-w-0 flex-1 gap-[3px]",style:{gridTemplateColumns:b,maxWidth:N},onMouseLeave:()=>h(null),children:u.weeks.map((s,r)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:s.map((o,g)=>o===null?e.jsx("div",{className:"aspect-square"},g):e.jsx("button",{type:"button","aria-label":`${T(o.date)} — click to pin`,"aria-pressed":(d==null?void 0:d.date)===o.date,className:`aspect-square block rounded-[3px] p-0 transition duration-150 hover:scale-[1.18] hover:ring-1 hover:ring-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent ${(d==null?void 0:d.date)===o.date?"ring-1 ring-fg-bright":""}`,style:{background:S(o.level)},onMouseEnter:()=>h(f.get(o.date)??null),onFocus:()=>h(f.get(o.date)??null),onClick:()=>p(y=>(y==null?void 0:y.date)===o.date?null:f.get(o.date)??null)},g))},r))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 pl-6 pt-1 text-[9px] text-fg-faint",children:["less",[0,1,2,3,4].map(s=>e.jsx("span",{className:"size-[11px] rounded-[2px]",style:{background:S(s)}},s)),"more"]})]}),e.jsxs("div",{className:"relative border-line-faint md:border-l md:pl-6",children:[e.jsxs("div",{className:`grid grid-cols-2 gap-x-6 gap-y-4 transition-opacity duration-200 md:grid-cols-1 ${m?"opacity-0":"opacity-100"}`,children:[e.jsx(w,{label:"busiest day",value:a.costed?C(a.top.cost):E(a.top.tokens),sub:T(a.top.date),valueClass:"text-cost"}),e.jsx(w,{label:"daily average",value:a.costed?C(a.avg):E(a.avg),sub:`across ${a.active} active days`}),e.jsx(w,{label:"top weekday",value:L[a.busiest],valueClass:"text-fg-bright"}),e.jsx(w,{label:"latest streak",value:`${a.streak}d`,sub:a.streak>0?"in a row":"idle today",valueClass:"text-positive"})]}),m&&e.jsx("div",{className:"dialog-fade absolute inset-0 md:pl-6",children:e.jsx(W,{day:m,pinned:!c&&m===d})})]})]})})})}function W({day:t,pinned:n=!1}){return e.jsxs("div",{className:"font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 border-b border-line-faint pb-2",children:[e.jsxs("span",{className:"text-fg-dim",children:[L[D(j(t.date))]," · ",T(t.date),n&&e.jsx("span",{className:"ml-1.5 text-[9px] uppercase tracking-wide text-accent",children:"pinned"})]}),e.jsx("span",{className:"tnum text-cost",children:t.cost>0?C(t.cost):"—"})]}),t.cost>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 py-2 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"calls"}),e.jsx("div",{className:"tnum text-fg",children:I(t.calls)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"tokens"}),e.jsx("div",{className:"tnum text-fg",children:E(t.tokens)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"saved"}),e.jsx("div",{className:"tnum text-positive",children:C(t.cacheSavings)})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 border-t border-line-faint pt-2",children:[t.models.slice(0,5).map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{background:$(i.name)}}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-fg-dim",children:B(i.name)}),e.jsx("span",{className:"tnum w-16 shrink-0 text-right text-fg",children:C(i.cost)})]},i.name)),t.models.length>5&&e.jsxs("div",{className:"pt-0.5 text-fg-faint",children:["+",t.models.length-5," more"]})]})]}):e.jsx("div",{className:"pt-2 text-fg-faint",children:"no spend this day"})]})}const Y=x.lazy(()=>M(()=>import("./breakdown-BoPnOv7Y.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.CostByModel}))),q=x.lazy(()=>M(()=>import("./breakdown-BoPnOv7Y.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.ProviderDonut}))),P=x.lazy(()=>M(()=>import("./breakdown-BoPnOv7Y.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.TokenComposition}))),G=x.lazy(()=>M(()=>import("./timeline-DkYWH6XW.js"),__vite__mapDeps([6,1,2,3,4,5,7]),import.meta.url).then(t=>({default:t.CacheSavings}))),K=x.lazy(()=>M(()=>import("./timeline-DkYWH6XW.js"),__vite__mapDeps([6,1,2,3,4,5,7]),import.meta.url).then(t=>({default:t.CumulativeSpend})));function _({children:t}){return e.jsx(x.Suspense,{fallback:e.jsx("div",{className:"min-h-64",role:"status","aria-label":"Loading chart"}),children:t})}function X({derived:t,scopeLabel:n}){const i=t.byProvider.length>1;return e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx(H,{derived:t,periodLabel:n})}),e.jsx(_,{children:e.jsx(Y,{derived:t,periodLabel:n})}),e.jsx(_,{children:i?e.jsx(q,{derived:t,periodLabel:n}):e.jsx(P,{derived:t,periodLabel:n})}),i?e.jsx(_,{children:e.jsx(P,{derived:t,periodLabel:n})}):null,e.jsx("div",{className:i?void 0:"md:col-span-2",children:e.jsx(_,{children:e.jsx(G,{derived:t,periodLabel:n})})}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(_,{children:e.jsx(K,{derived:t,height:300,periodLabel:n})})})]})}export{X as AnalyticsTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as h,l as Qe,r as J,j as u,g as Ye,s as ee,f as G,a as z,n as Je,o as xt,T as ne}from"./index-
|
|
1
|
+
import{R as h,l as Qe,r as J,j as u,g as Ye,s as ee,f as G,a as z,n as Je,o as xt,T as ne}from"./index-C8oe6EfM.js";import{c as I,d as k,r as et,e as At,h as tt,i as kt,j as C,k as Pe,p as S,L as _,l as rt,n as Oe,o as nt,D as Pt,q as Ot,t as W,v as F,S as jt,w as _t,x as wt,y as De,z as Tt,B as M,E as je,F as St,H as Et,I as ae,J as Rt,K as _e,M as It,N as ie,O as Be,g as it,X as we,Y as Te,P as Se,f as Nt,Q as Lt,u as Ee,U as at,C as Re,R as Ie,a as ot,G as st,A as se,T as ct,s as Ne}from"./chart-jK7A9m7R.js";import{P as fe}from"./panel-CstB4hPm.js";import{E as pe}from"./primitives-G9ALG7ih.js";var $t=["points","className","baseLinePoints","connectNulls"];function V(){return V=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},V.apply(this,arguments)}function Ct(r,e){if(r==null)return{};var n=Dt(r,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}function Dt(r,e){if(r==null)return{};var n={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(e.indexOf(t)>=0)continue;n[t]=r[t]}return n}function Ke(r){return Mt(r)||Ft(r)||Kt(r)||Bt()}function Bt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kt(r,e){if(r){if(typeof r=="string")return be(r,e);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor&&(n=r.constructor.name),n==="Map"||n==="Set")return Array.from(r);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return be(r,e)}}function Ft(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Mt(r){if(Array.isArray(r))return be(r)}function be(r,e){(e==null||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}var Fe=function(e){return e&&e.x===+e.x&&e.y===+e.y},Vt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=[[]];return e.forEach(function(t){Fe(t)?n[n.length-1].push(t):n[n.length-1].length>0&&n.push([])}),Fe(e[0])&&n[n.length-1].push(e[0]),n[n.length-1].length<=0&&(n=n.slice(0,-1)),n},Q=function(e,n){var t=Vt(e);n&&(t=[t.reduce(function(a,o){return[].concat(Ke(a),Ke(o))},[])]);var i=t.map(function(a){return a.reduce(function(o,c,f){return"".concat(o).concat(f===0?"M":"L").concat(c.x,",").concat(c.y)},"")}).join("");return t.length===1?"".concat(i,"Z"):i},qt=function(e,n,t){var i=Q(e,t);return"".concat(i.slice(-1)==="Z"?i.slice(0,-1):i,"L").concat(Q(n.reverse(),t).slice(1))},zt=function(e){var n=e.points,t=e.className,i=e.baseLinePoints,a=e.connectNulls,o=Ct(e,$t);if(!n||!n.length)return null;var c=I("recharts-polygon",t);if(i&&i.length){var f=o.stroke&&o.stroke!=="none",s=qt(n,i,a);return h.createElement("g",{className:c},h.createElement("path",V({},k(o,!0),{fill:s.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:s})),f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(n,a)})):null,f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(i,a)})):null)}var p=Q(n,a);return h.createElement("path",V({},k(o,!0),{fill:p.slice(-1)==="Z"?o.fill:"none",className:c,d:p}))},ye,Me;function Wt(){if(Me)return ye;Me=1;var r=et(),e=At(),n=tt();function t(i,a){return i&&i.length?r(i,n(a,2),e):void 0}return ye=t,ye}var Gt=Wt();const Ht=Qe(Gt);var ge,Ve;function Ut(){if(Ve)return ge;Ve=1;var r=et(),e=tt(),n=kt();function t(i,a){return i&&i.length?r(i,e(a,2),n):void 0}return ge=t,ge}var Zt=Ut();const Xt=Qe(Zt);var Qt=["cx","cy","angle","ticks","axisLine"],Yt=["ticks","tick","angle","tickFormatter","stroke"];function H(r){"@babel/helpers - typeof";return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},H(r)}function Y(){return Y=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},Y.apply(this,arguments)}function qe(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),n.push.apply(n,t)}return n}function L(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qe(Object(n),!0).forEach(function(t){de(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):qe(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function ze(r,e){if(r==null)return{};var n=Jt(r,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}function Jt(r,e){if(r==null)return{};var n={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(e.indexOf(t)>=0)continue;n[t]=r[t]}return n}function er(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function We(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,ut(t.key),t)}}function tr(r,e,n){return e&&We(r.prototype,e),n&&We(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function rr(r,e,n){return e=ce(e),nr(r,lt()?Reflect.construct(e,n||[],ce(r).constructor):e.apply(r,n))}function nr(r,e){if(e&&(H(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ir(r)}function ir(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function lt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lt=function(){return!!r})()}function ce(r){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ce(r)}function ar(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&xe(r,e)}function xe(r,e){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},xe(r,e)}function de(r,e,n){return e=ut(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function ut(r){var e=or(r,"string");return H(e)=="symbol"?e:e+""}function or(r,e){if(H(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(H(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var me=(function(r){function e(){return er(this,e),rr(this,e,arguments)}return ar(e,r),tr(e,[{key:"getTickValueCoord",value:function(t){var i=t.coordinate,a=this.props,o=a.angle,c=a.cx,f=a.cy;return S(c,f,i,o)}},{key:"getTickTextAnchor",value:function(){var t=this.props.orientation,i;switch(t){case"left":i="end";break;case"right":i="start";break;default:i="middle";break}return i}},{key:"getViewBox",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=Ht(c,function(p){return p.coordinate||0}),s=Xt(c,function(p){return p.coordinate||0});return{cx:i,cy:a,startAngle:o,endAngle:o,innerRadius:s.coordinate||0,outerRadius:f.coordinate||0}}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=t.axisLine,s=ze(t,Qt),p=c.reduce(function(m,l){return[Math.min(m[0],l.coordinate),Math.max(m[1],l.coordinate)]},[1/0,-1/0]),d=S(i,a,p[0],o),v=S(i,a,p[1],o),A=L(L(L({},k(s,!1)),{},{fill:"none"},k(f,!1)),{},{x1:d.x,y1:d.y,x2:v.x,y2:v.y});return h.createElement("line",Y({className:"recharts-polar-radius-axis-line"},A))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.angle,f=i.tickFormatter,s=i.stroke,p=ze(i,Yt),d=this.getTickTextAnchor(),v=k(p,!1),A=k(o,!1),m=a.map(function(l,g){var b=t.getTickValueCoord(l),x=L(L(L(L({textAnchor:d,transform:"rotate(".concat(90-c,", ").concat(b.x,", ").concat(b.y,")")},v),{},{stroke:"none",fill:s},A),{},{index:g},b),{},{payload:l});return h.createElement(_,Y({className:I("recharts-polar-radius-axis-tick",rt(o)),key:"tick-".concat(l.coordinate)},Oe(t.props,l,g)),e.renderTickItem(o,x,f?f(l.value,g):l.value))});return h.createElement(_,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.axisLine,o=t.tick;return!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-radius-axis",this.props.className)},a&&this.renderAxisLine(),o&&this.renderTicks(),nt.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Pe,Y({},i,{className:"recharts-polar-radius-axis-tick-value"}),a),o}}])})(J.PureComponent);de(me,"displayName","PolarRadiusAxis");de(me,"axisType","radiusAxis");de(me,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function U(r){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(r)}function D(){return D=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},D.apply(this,arguments)}function Ge(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),n.push.apply(n,t)}return n}function $(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ge(Object(n),!0).forEach(function(t){ve(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ge(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function sr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function He(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,pt(t.key),t)}}function cr(r,e,n){return e&&He(r.prototype,e),n&&He(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function lr(r,e,n){return e=le(e),ur(r,ft()?Reflect.construct(e,n||[],le(r).constructor):e.apply(r,n))}function ur(r,e){if(e&&(U(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fr(r)}function fr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function ft(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ft=function(){return!!r})()}function le(r){return le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},le(r)}function pr(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&Ae(r,e)}function Ae(r,e){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},Ae(r,e)}function ve(r,e,n){return e=pt(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function pt(r){var e=dr(r,"string");return U(e)=="symbol"?e:e+""}function dr(r,e){if(U(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(U(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var mr=Math.PI/180,Ue=1e-5,he=(function(r){function e(){return sr(this,e),lr(this,e,arguments)}return pr(e,r),cr(e,[{key:"getTickLineCoord",value:function(t){var i=this.props,a=i.cx,o=i.cy,c=i.radius,f=i.orientation,s=i.tickSize,p=s||8,d=S(a,o,c,t.coordinate),v=S(a,o,c+(f==="inner"?-1:1)*p,t.coordinate);return{x1:d.x,y1:d.y,x2:v.x,y2:v.y}}},{key:"getTickTextAnchor",value:function(t){var i=this.props.orientation,a=Math.cos(-t.coordinate*mr),o;return a>Ue?o=i==="outer"?"start":"end":a<-Ue?o=i==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.radius,c=t.axisLine,f=t.axisLineType,s=$($({},k(this.props,!1)),{},{fill:"none"},k(c,!1));if(f==="circle")return h.createElement(Pt,D({className:"recharts-polar-angle-axis-line"},s,{cx:i,cy:a,r:o}));var p=this.props.ticks,d=p.map(function(v){return S(i,a,o,v.coordinate)});return h.createElement(zt,D({className:"recharts-polar-angle-axis-line"},s,{points:d}))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.tickLine,f=i.tickFormatter,s=i.stroke,p=k(this.props,!1),d=k(o,!1),v=$($({},p),{},{fill:"none"},k(c,!1)),A=a.map(function(m,l){var g=t.getTickLineCoord(m),b=t.getTickTextAnchor(m),x=$($($({textAnchor:b},p),{},{stroke:"none",fill:s},d),{},{index:l,payload:m,x:g.x2,y:g.y2});return h.createElement(_,D({className:I("recharts-polar-angle-axis-tick",rt(o)),key:"tick-".concat(m.coordinate)},Oe(t.props,m,l)),c&&h.createElement("line",D({className:"recharts-polar-angle-axis-tick-line"},v,g)),o&&e.renderTickItem(o,x,f?f(m.value,l):m.value))});return h.createElement(_,{className:"recharts-polar-angle-axis-ticks"},A)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.radius,o=t.axisLine;return a<=0||!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Pe,D({},i,{className:"recharts-polar-angle-axis-tick-value"}),a),o}}])})(J.PureComponent);ve(he,"displayName","PolarAngleAxis");ve(he,"axisType","angleAxis");ve(he,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var oe;function Z(r){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Z(r)}function q(){return q=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},q.apply(this,arguments)}function Ze(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),n.push.apply(n,t)}return n}function y(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ze(Object(n),!0).forEach(function(t){O(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function vr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Xe(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,mt(t.key),t)}}function hr(r,e,n){return e&&Xe(r.prototype,e),n&&Xe(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function yr(r,e,n){return e=ue(e),gr(r,dt()?Reflect.construct(e,n||[],ue(r).constructor):e.apply(r,n))}function gr(r,e){if(e&&(Z(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return br(r)}function br(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function dt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dt=function(){return!!r})()}function ue(r){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ue(r)}function xr(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&ke(r,e)}function ke(r,e){return ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},ke(r,e)}function O(r,e,n){return e=mt(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function mt(r){var e=Ar(r,"string");return Z(e)=="symbol"?e:e+""}function Ar(r,e){if(Z(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(Z(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var E=(function(r){function e(n){var t;return vr(this,e),t=yr(this,e,[n]),O(t,"pieRef",null),O(t,"sectorRefs",[]),O(t,"id",St("recharts-pie-")),O(t,"handleAnimationEnd",function(){var i=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),C(i)&&i()}),O(t,"handleAnimationStart",function(){var i=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),C(i)&&i()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return xr(e,r),hr(e,[{key:"isActiveIndex",value:function(t){var i=this.props.activeIndex;return Array.isArray(i)?i.indexOf(t)!==-1:t===i}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.label,c=a.labelLine,f=a.dataKey,s=a.valueKey,p=k(this.props,!1),d=k(o,!1),v=k(c,!1),A=o&&o.offsetRadius||20,m=t.map(function(l,g){var b=(l.startAngle+l.endAngle)/2,x=S(l.cx,l.cy,l.outerRadius+A,b),j=y(y(y(y({},p),l),{},{stroke:"none"},d),{},{index:g,textAnchor:e.getTextAnchor(x.x,l.cx)},x),B=y(y(y(y({},p),l),{},{fill:"none",stroke:l.fill},v),{},{index:g,points:[S(l.cx,l.cy,l.outerRadius,b),x]}),w=f;return W(f)&&W(s)?w="value":W(f)&&(w=s),h.createElement(_,{key:"label-".concat(l.startAngle,"-").concat(l.endAngle,"-").concat(l.midAngle,"-").concat(g)},c&&e.renderLabelLineItem(c,B,"line"),e.renderLabelItem(o,j,F(l,w)))});return h.createElement(_,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(t){var i=this,a=this.props,o=a.activeShape,c=a.blendStroke,f=a.inactiveShape;return t.map(function(s,p){if((s==null?void 0:s.startAngle)===0&&(s==null?void 0:s.endAngle)===0&&t.length!==1)return null;var d=i.isActiveIndex(p),v=f&&i.hasActiveIndex()?f:null,A=d?o:v,m=y(y({},s),{},{stroke:c?s.fill:s.stroke,tabIndex:-1});return h.createElement(_,q({ref:function(g){g&&!i.sectorRefs.includes(g)&&i.sectorRefs.push(g)},tabIndex:-1,className:"recharts-pie-sector"},Oe(i.props,s,p),{key:"sector-".concat(s==null?void 0:s.startAngle,"-").concat(s==null?void 0:s.endAngle,"-").concat(s.midAngle,"-").concat(p)}),h.createElement(jt,q({option:A,isActive:d,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,i=this.props,a=i.sectors,o=i.isAnimationActive,c=i.animationBegin,f=i.animationDuration,s=i.animationEasing,p=i.animationId,d=this.state,v=d.prevSectors,A=d.prevIsAnimationActive;return h.createElement(_t,{begin:c,duration:f,isActive:o,easing:s,from:{t:0},to:{t:1},key:"pie-".concat(p,"-").concat(A),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var l=m.t,g=[],b=a&&a[0],x=b.startAngle;return a.forEach(function(j,B){var w=v&&v[B],N=B>0?wt(j,"paddingAngle",0):0;if(w){var X=De(w.endAngle-w.startAngle,j.endAngle-j.startAngle),P=y(y({},j),{},{startAngle:x+N,endAngle:x+X(l)+N});g.push(P),x=P.endAngle}else{var K=j.endAngle,T=j.startAngle,te=De(0,K-T),re=te(l),R=y(y({},j),{},{startAngle:x+N,endAngle:x+re+N});g.push(R),x=R.endAngle}}),h.createElement(_,null,t.renderSectorsStatically(g))})}},{key:"attachKeyboardHandlers",value:function(t){var i=this;t.onkeydown=function(a){if(!a.altKey)switch(a.key){case"ArrowLeft":{var o=++i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[o].focus(),i.setState({sectorToFocus:o});break}case"ArrowRight":{var c=--i.state.sectorToFocus<0?i.sectorRefs.length-1:i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[c].focus(),i.setState({sectorToFocus:c});break}case"Escape":{i.sectorRefs[i.state.sectorToFocus].blur(),i.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,i=t.sectors,a=t.isAnimationActive,o=this.state.prevSectors;return a&&i&&i.length&&(!o||!Tt(o,i))?this.renderSectorsWithAnimation():this.renderSectorsStatically(i)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,i=this.props,a=i.hide,o=i.sectors,c=i.className,f=i.label,s=i.cx,p=i.cy,d=i.innerRadius,v=i.outerRadius,A=i.isAnimationActive,m=this.state.isAnimationFinished;if(a||!o||!o.length||!M(s)||!M(p)||!M(d)||!M(v))return null;var l=I("recharts-pie",c);return h.createElement(_,{tabIndex:this.props.rootTabIndex,className:l,ref:function(b){t.pieRef=b}},this.renderSectors(),f&&this.renderLabels(o),nt.renderCallByParent(this.props,null,!1),(!A||m)&&je.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,i){return i.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==i.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:i.curSectors,isAnimationFinished:!0}:t.sectors!==i.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,i){return t>i?"start":t<i?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);if(C(t))return t(i);var o=I("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return h.createElement(Ot,q({},i,{key:a,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);var o=a;if(C(t)&&(o=t(i),h.isValidElement(o)))return o;var c=I("recharts-pie-label-text",typeof t!="boolean"&&!C(t)?t.className:"");return h.createElement(Pe,q({},i,{alignmentBaseline:"middle",className:c}),o)}}])})(J.PureComponent);oe=E;O(E,"displayName","Pie");O(E,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Et.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});O(E,"parseDeltaAngle",function(r,e){var n=ae(e-r),t=Math.min(Math.abs(e-r),360);return n*t});O(E,"getRealPieData",function(r){var e=r.data,n=r.children,t=k(r,!1),i=Rt(n,_e);return e&&e.length?e.map(function(a,o){return y(y(y({payload:a},t),a),i&&i[o]&&i[o].props)}):i&&i.length?i.map(function(a){return y(y({},t),a.props)}):[]});O(E,"parseCoordinateOfPie",function(r,e){var n=e.top,t=e.left,i=e.width,a=e.height,o=It(i,a),c=t+ie(r.cx,i,i/2),f=n+ie(r.cy,a,a/2),s=ie(r.innerRadius,o,0),p=ie(r.outerRadius,o,o*.8),d=r.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:c,cy:f,innerRadius:s,outerRadius:p,maxRadius:d}});O(E,"getComposedData",function(r){var e=r.item,n=r.offset,t=e.type.defaultProps!==void 0?y(y({},e.type.defaultProps),e.props):e.props,i=oe.getRealPieData(t);if(!i||!i.length)return null;var a=t.cornerRadius,o=t.startAngle,c=t.endAngle,f=t.paddingAngle,s=t.dataKey,p=t.nameKey,d=t.valueKey,v=t.tooltipType,A=Math.abs(t.minAngle),m=oe.parseCoordinateOfPie(t,n),l=oe.parseDeltaAngle(o,c),g=Math.abs(l),b=s;W(s)&&W(d)?(Be(!1,`Use "dataKey" to specify the value of pie,
|
|
3
3
|
the props "valueKey" will be deprecated in 1.1.0`),b="value"):W(s)&&(Be(!1,`Use "dataKey" to specify the value of pie,
|
|
4
4
|
the props "valueKey" will be deprecated in 1.1.0`),b=d);var x=i.filter(function(P){return F(P,b,0)!==0}).length,j=(g>=360?x:x-1)*f,B=g-x*A-j,w=i.reduce(function(P,K){var T=F(K,b,0);return P+(M(T)?T:0)},0),N;if(w>0){var X;N=i.map(function(P,K){var T=F(P,b,0),te=F(P,p,K),re=(M(T)?T:0)/w,R;K?R=X.endAngle+ae(l)*f*(T!==0?1:0):R=o;var Le=R+ae(l)*((T!==0?A:0)+re*B),$e=(R+Le)/2,Ce=(m.innerRadius+m.outerRadius)/2,gt=[{name:te,value:T,payload:P,dataKey:b,type:v}],bt=S(m.cx,m.cy,Ce,$e);return X=y(y(y({percent:re,cornerRadius:a,name:te,tooltipPayload:gt,midAngle:$e,middleRadius:Ce,tooltipPosition:bt},P),m),{},{value:F(P,b),startAngle:R,endAngle:Le,payload:P,paddingAngle:ae(l)*f}),X})}return y(y({},m),{},{sectors:N,data:i})});var vt=it({chartName:"BarChart",GraphicalChild:Se,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:we},{axisType:"yAxis",AxisComp:Te}],formatAxisMap:Nt}),kr=it({chartName:"PieChart",GraphicalChild:E,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:he},{axisType:"radiusAxis",AxisComp:me}],formatAxisMap:Lt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const ht={fill:"var(--color-bg-2)"},yt={fill:"var(--color-fg-dim)",fontSize:10,fontFamily:"var(--font-mono)"},Pr=Ne("cost",G,r=>{var e;return(e=r[0])==null?void 0:e.color},{title:r=>ee(r)}),Or=Ne("tokens",z,r=>{var e;return(e=r[0])==null?void 0:e.color},{title:r=>ee(r)}),jr=Ne("saved",G,r=>{var e;return(e=r[0])==null?void 0:e.color},{title:r=>ee(r)});function Er({derived:r,height:e=280,limit:n=10,metric:t="cost",periodLabel:i}){const a=Ee(),o=at("(min-width: 768px)"),c=o?124:92,f=o?60:44,s=t==="tokens",p=[...r.byModel].sort((d,v)=>s?v.tokens-d.tokens:v.cost-d.cost).slice(0,n);return u.jsx(fe,{title:s?"tokens by model":"cost by model",titleTag:i,captureName:s?"tokens-by-model":"cost-by-model",children:p.length===0?u.jsx(pe,{children:"no models in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:p,layout:"vertical",margin:{top:4,right:f,left:4,bottom:0},children:[u.jsx(ot,{...st,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:s?z:Ye}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:c,tickFormatter:ee}),u.jsx(ct,{content:s?Or:Pr,cursor:ht}),u.jsxs(Se,{dataKey:s?"tokens":"cost",radius:[0,3,3,0],isAnimationActive:a,animationDuration:350,children:[p.map(d=>u.jsx(_e,{fill:d.color},d.model)),u.jsx(je,{dataKey:s?"tokens":"cost",position:"right",offset:6,...yt,formatter:d=>s?z(d):G(d)})]})]})})})})}function Rr({derived:r,height:e=240,limit:n=12,periodLabel:t}){const i=Ee(),a=at("(min-width: 768px)"),o=a?124:92,c=a?60:44,f=[...r.byModel].filter(s=>s.cacheSavings>0).sort((s,p)=>p.cacheSavings-s.cacheSavings).slice(0,n);return u.jsx(fe,{title:"cache savings by model",titleTag:t,captureName:"cache-savings-by-model",children:f.length===0?u.jsx(pe,{children:"no cache savings in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:f,layout:"vertical",margin:{top:4,right:c,left:4,bottom:0},children:[u.jsx(ot,{...st,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:Ye}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:o,tickFormatter:ee}),u.jsx(ct,{content:jr,cursor:ht}),u.jsx(Se,{dataKey:"cacheSavings",radius:[0,3,3,0],fill:"var(--color-positive)",isAnimationActive:i,animationDuration:350,children:u.jsx(je,{dataKey:"cacheSavings",position:"right",offset:6,...yt,formatter:s=>G(s)})})]})})})})}function Ir({derived:r,height:e=280,periodLabel:n}){const t=Ee(),i=r.byProvider,a=r.totals.cost,[o,c]=J.useState(null),[f,s]=J.useState(null),p=f?i.findIndex(m=>m.id===f):-1,d=o??(p>=0?p:null),v=d!=null?i[d]:null,A=v&&a>0?v.cost/a:0;return u.jsx(fe,{title:"provider split",titleTag:n,captureName:"provider-split",children:i.length===0?u.jsx(pe,{children:"no spend in period"}):u.jsxs("div",{className:"relative",onMouseLeave:()=>c(null),children:[u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsx(kr,{children:u.jsx(E,{data:i,dataKey:"cost",nameKey:"name",innerRadius:"60%",outerRadius:"88%",paddingAngle:i.length>1?2:0,stroke:"var(--color-bg-1)",strokeWidth:2,isAnimationActive:t,animationDuration:350,style:{cursor:"pointer"},onMouseEnter:(m,l)=>c(l),onClick:(m,l)=>s(g=>{var b,x;return g===((b=i[l])==null?void 0:b.id)?null:((x=i[l])==null?void 0:x.id)??null}),children:i.map((m,l)=>u.jsx(_e,{fill:m.color,"aria-label":`${m.name}: ${G(m.cost)}`,fillOpacity:d==null||d===l?1:.32,style:{transition:"fill-opacity 150ms ease"}},m.id))})})})}),u.jsxs("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"tnum text-xl",style:{color:v?v.color:"var(--color-fg-bright)"},children:G(v?v.cost:a)}),u.jsxs("div",{className:"font-display text-[10px] uppercase tracking-wide text-fg-faint",children:[v?`${v.name} · ${Je(A,A>0&&A<.01?1:0)}`:"total",v&&o==null&&p>=0&&u.jsx("span",{className:"text-accent",children:" · pinned"})]})]})]})})}function Nr({derived:r,periodLabel:e}){const n=r.tokenComposition,t=xt(n),i=[{key:"cacheRead",label:"cache read",value:n.cacheRead,color:ne.cacheRead},{key:"input",label:"input",value:n.input,color:ne.input},{key:"output",label:"output",value:n.output,color:ne.output},{key:"cacheCreate",label:"cache write",value:n.cacheCreate,color:ne.cacheCreate}];return u.jsx(fe,{title:"token composition",titleTag:e,captureName:"token-composition",right:u.jsx("span",{className:"tnum text-xs text-fg-dim",children:z(t)}),children:t===0?u.jsx(pe,{children:"no tokens in period"}):u.jsxs("div",{className:"flex flex-col gap-4 pt-1",children:[u.jsx("div",{className:"flex h-3 w-full overflow-hidden rounded-full bg-bg-3",children:i.map(a=>a.value>0&&u.jsx("div",{style:{width:`${a.value/t*100}%`,minWidth:"2px",background:a.color},title:`${a.label}: ${z(a.value)}`},a.key))}),u.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2.5",children:i.map(a=>{const o=t>0?a.value/t:0;return u.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[u.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim",children:[u.jsx("span",{className:"inline-block size-2 rounded-[2px]",style:{background:a.color}}),a.label]}),u.jsxs("span",{className:"text-fg",children:[u.jsx("span",{className:"tnum text-fg-bright",children:z(a.value)}),u.jsx("span",{className:"ml-1.5 text-fg-faint",children:Je(o,o>0&&o<.01?1:0)})]})]},a.key)})})]})})}export{Rr as CacheByModel,Er as CostByModel,Ir as ProviderDonut,Nr as TokenComposition};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a4 as Kn,l as ue,r as N,R as T,j as ot,e as Zx}from"./index-
|
|
1
|
+
import{a4 as Kn,l as ue,r as N,R as T,j as ot,e as Zx}from"./index-C8oe6EfM.js";function Lm(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=Lm(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function te(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=Lm(e))&&(n&&(n+=" "),n+=t);return n}var Na,oh;function Re(){if(oh)return Na;oh=1;var e=Array.isArray;return Na=e,Na}var qa,uh;function Fm(){if(uh)return qa;uh=1;var e=typeof Kn=="object"&&Kn&&Kn.Object===Object&&Kn;return qa=e,qa}var Ba,ch;function it(){if(ch)return Ba;ch=1;var e=Fm(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Ba=r,Ba}var La,sh;function Nn(){if(sh)return La;sh=1;var e=it(),t=e.Symbol;return La=t,La}var Fa,lh;function Jx(){if(lh)return Fa;lh=1;var e=Nn(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function a(o){var u=r.call(o,i),c=o[i];try{o[i]=void 0;var s=!0}catch{}var f=n.call(o);return s&&(u?o[i]=c:delete o[i]),f}return Fa=a,Fa}var Ua,fh;function Qx(){if(fh)return Ua;fh=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Ua=r,Ua}var za,hh;function mt(){if(hh)return za;hh=1;var e=Nn(),t=Jx(),r=Qx(),n="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function o(u){return u==null?u===void 0?i:n:a&&a in Object(u)?t(u):r(u)}return za=o,za}var Wa,ph;function bt(){if(ph)return Wa;ph=1;function e(t){return t!=null&&typeof t=="object"}return Wa=e,Wa}var Ha,dh;function $r(){if(dh)return Ha;dh=1;var e=mt(),t=bt(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return Ha=n,Ha}var Ga,vh;function Ql(){if(vh)return Ga;vh=1;var e=Re(),t=$r(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(a,o){if(e(a))return!1;var u=typeof a;return u=="number"||u=="symbol"||u=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||o!=null&&a in Object(o)}return Ga=i,Ga}var Ka,yh;function Tt(){if(yh)return Ka;yh=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Ka=e,Ka}var Xa,gh;function ef(){if(gh)return Xa;gh=1;var e=mt(),t=Tt(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(u){if(!t(u))return!1;var c=e(u);return c==n||c==i||c==r||c==a}return Xa=o,Xa}var Va,mh;function ew(){if(mh)return Va;mh=1;var e=it(),t=e["__core-js_shared__"];return Va=t,Va}var Ya,bh;function tw(){if(bh)return Ya;bh=1;var e=ew(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Ya=r,Ya}var Za,xh;function Um(){if(xh)return Za;xh=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Za=r,Za}var Ja,wh;function rw(){if(wh)return Ja;wh=1;var e=ef(),t=tw(),r=Tt(),n=Um(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,u=Object.prototype,c=o.toString,s=u.hasOwnProperty,f=RegExp("^"+c.call(s).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function l(h){if(!r(h)||t(h))return!1;var d=e(h)?f:a;return d.test(n(h))}return Ja=l,Ja}var Qa,Oh;function nw(){if(Oh)return Qa;Oh=1;function e(t,r){return t==null?void 0:t[r]}return Qa=e,Qa}var eo,_h;function Vt(){if(_h)return eo;_h=1;var e=rw(),t=nw();function r(n,i){var a=t(n,i);return e(a)?a:void 0}return eo=r,eo}var to,Sh;function ia(){if(Sh)return to;Sh=1;var e=Vt(),t=e(Object,"create");return to=t,to}var ro,Ah;function iw(){if(Ah)return ro;Ah=1;var e=ia();function t(){this.__data__=e?e(null):{},this.size=0}return ro=t,ro}var no,Ph;function aw(){if(Ph)return no;Ph=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return no=e,no}var io,Th;function ow(){if(Th)return io;Th=1;var e=ia(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(a){var o=this.__data__;if(e){var u=o[a];return u===t?void 0:u}return n.call(o,a)?o[a]:void 0}return io=i,io}var ao,Eh;function uw(){if(Eh)return ao;Eh=1;var e=ia(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var a=this.__data__;return e?a[i]!==void 0:r.call(a,i)}return ao=n,ao}var oo,jh;function cw(){if(jh)return oo;jh=1;var e=ia(),t="__lodash_hash_undefined__";function r(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&i===void 0?t:i,this}return oo=r,oo}var uo,Mh;function sw(){if(Mh)return uo;Mh=1;var e=iw(),t=aw(),r=ow(),n=uw(),i=cw();function a(o){var u=-1,c=o==null?0:o.length;for(this.clear();++u<c;){var s=o[u];this.set(s[0],s[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,uo=a,uo}var co,Ch;function lw(){if(Ch)return co;Ch=1;function e(){this.__data__=[],this.size=0}return co=e,co}var so,$h;function tf(){if($h)return so;$h=1;function e(t,r){return t===r||t!==t&&r!==r}return so=e,so}var lo,Ih;function aa(){if(Ih)return lo;Ih=1;var e=tf();function t(r,n){for(var i=r.length;i--;)if(e(r[i][0],n))return i;return-1}return lo=t,lo}var fo,Rh;function fw(){if(Rh)return fo;Rh=1;var e=aa(),t=Array.prototype,r=t.splice;function n(i){var a=this.__data__,o=e(a,i);if(o<0)return!1;var u=a.length-1;return o==u?a.pop():r.call(a,o,1),--this.size,!0}return fo=n,fo}var ho,kh;function hw(){if(kh)return ho;kh=1;var e=aa();function t(r){var n=this.__data__,i=e(n,r);return i<0?void 0:n[i][1]}return ho=t,ho}var po,Dh;function pw(){if(Dh)return po;Dh=1;var e=aa();function t(r){return e(this.__data__,r)>-1}return po=t,po}var vo,Nh;function dw(){if(Nh)return vo;Nh=1;var e=aa();function t(r,n){var i=this.__data__,a=e(i,r);return a<0?(++this.size,i.push([r,n])):i[a][1]=n,this}return vo=t,vo}var yo,qh;function oa(){if(qh)return yo;qh=1;var e=lw(),t=fw(),r=hw(),n=pw(),i=dw();function a(o){var u=-1,c=o==null?0:o.length;for(this.clear();++u<c;){var s=o[u];this.set(s[0],s[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,yo=a,yo}var go,Bh;function rf(){if(Bh)return go;Bh=1;var e=Vt(),t=it(),r=e(t,"Map");return go=r,go}var mo,Lh;function vw(){if(Lh)return mo;Lh=1;var e=sw(),t=oa(),r=rf();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return mo=n,mo}var bo,Fh;function yw(){if(Fh)return bo;Fh=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return bo=e,bo}var xo,Uh;function ua(){if(Uh)return xo;Uh=1;var e=yw();function t(r,n){var i=r.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return xo=t,xo}var wo,zh;function gw(){if(zh)return wo;zh=1;var e=ua();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return wo=t,wo}var Oo,Wh;function mw(){if(Wh)return Oo;Wh=1;var e=ua();function t(r){return e(this,r).get(r)}return Oo=t,Oo}var _o,Hh;function bw(){if(Hh)return _o;Hh=1;var e=ua();function t(r){return e(this,r).has(r)}return _o=t,_o}var So,Gh;function xw(){if(Gh)return So;Gh=1;var e=ua();function t(r,n){var i=e(this,r),a=i.size;return i.set(r,n),this.size+=i.size==a?0:1,this}return So=t,So}var Ao,Kh;function nf(){if(Kh)return Ao;Kh=1;var e=vw(),t=gw(),r=mw(),n=bw(),i=xw();function a(o){var u=-1,c=o==null?0:o.length;for(this.clear();++u<c;){var s=o[u];this.set(s[0],s[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,Ao=a,Ao}var Po,Xh;function zm(){if(Xh)return Po;Xh=1;var e=nf(),t="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var o=arguments,u=i?i.apply(this,o):o[0],c=a.cache;if(c.has(u))return c.get(u);var s=n.apply(this,o);return a.cache=c.set(u,s)||c,s};return a.cache=new(r.Cache||e),a}return r.Cache=e,Po=r,Po}var To,Vh;function ww(){if(Vh)return To;Vh=1;var e=zm(),t=500;function r(n){var i=e(n,function(o){return a.size===t&&a.clear(),o}),a=i.cache;return i}return To=r,To}var Eo,Yh;function Ow(){if(Yh)return Eo;Yh=1;var e=ww(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(o,u,c,s){a.push(c?s.replace(r,"$1"):u||o)}),a});return Eo=n,Eo}var jo,Zh;function af(){if(Zh)return jo;Zh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,a=Array(i);++n<i;)a[n]=r(t[n],n,t);return a}return jo=e,jo}var Mo,Jh;function _w(){if(Jh)return Mo;Jh=1;var e=Nn(),t=af(),r=Re(),n=$r(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(u){if(typeof u=="string")return u;if(r(u))return t(u,o)+"";if(n(u))return a?a.call(u):"";var c=u+"";return c=="0"&&1/u==-1/0?"-0":c}return Mo=o,Mo}var Co,Qh;function Wm(){if(Qh)return Co;Qh=1;var e=_w();function t(r){return r==null?"":e(r)}return Co=t,Co}var $o,ep;function Hm(){if(ep)return $o;ep=1;var e=Re(),t=Ql(),r=Ow(),n=Wm();function i(a,o){return e(a)?a:t(a,o)?[a]:r(n(a))}return $o=i,$o}var Io,tp;function ca(){if(tp)return Io;tp=1;var e=$r();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Io=t,Io}var Ro,rp;function of(){if(rp)return Ro;rp=1;var e=Hm(),t=ca();function r(n,i){i=e(i,n);for(var a=0,o=i.length;n!=null&&a<o;)n=n[t(i[a++])];return a&&a==o?n:void 0}return Ro=r,Ro}var ko,np;function Gm(){if(np)return ko;np=1;var e=of();function t(r,n,i){var a=r==null?void 0:e(r,n);return a===void 0?i:a}return ko=t,ko}var Sw=Gm();const ze=ue(Sw);var Do,ip;function Aw(){if(ip)return Do;ip=1;function e(t){return t==null}return Do=e,Do}var Pw=Aw();const Z=ue(Pw);var No,ap;function Tw(){if(ap)return No;ap=1;var e=mt(),t=Re(),r=bt(),n="[object String]";function i(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==n}return No=i,No}var Ew=Tw();const Ht=ue(Ew);var jw=ef();const Y=ue(jw);var Mw=Tt();const Ir=ue(Mw);var qo={exports:{}},re={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-is.production.min.js
|
|
4
4
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as ne,t as me,u as Pe,w as Ee,o as L,v as De,r as $,j as h,m as Ge,s as oe,a as J,f as z,b as ze,x as Se,e as he,y as He,S as Ae,z as Le,c as je,A as Ne,X as Oe}from"./index-
|
|
1
|
+
import{q as ne,t as me,u as Pe,w as Ee,o as L,v as De,r as $,j as h,m as Ge,s as oe,a as J,f as z,b as ze,x as Se,e as he,y as He,S as Ae,z as Le,c as je,A as Ne,X as Oe}from"./index-C8oe6EfM.js";import{P as ke}from"./panel-CstB4hPm.js";function Be(e){return e.reduce((n,t)=>(n.input+=t.input,n.output+=t.output,n.cacheCreate+=t.cacheCreate,n.cacheRead+=t.cacheRead,n.cacheSavings+=t.cacheSavings,n.cost+=t.cost,n.count+=t.count,n),{input:0,output:0,cacheCreate:0,cacheRead:0,cacheSavings:0,cost:0,count:0})}function Te(e,n,t){var d;if(!e)return[];const o=ne(e,n),i=me(o),r=Pe(n.period,t,i,e.tz),s=r?t==="monthly"?r.slice(0,7):t==="weekly"?Ee(r):r:null,u=n.models.length?new Set(n.models):null,g=new Map;for(const f of o)for(const m of((d=f.table)==null?void 0:d[t])??[]){if(s&&m.label<s)continue;const a=u?m.breakdown.filter(p=>u.has(p.name)):m.breakdown;if(u&&a.length===0)continue;const l=g.get(m.label),c=Be(a);if(!l)g.set(m.label,{label:m.label,models:a.map(p=>p.name).sort(),...c,total:L(c),breakdown:a.map(p=>({...p}))});else{l.input+=c.input,l.output+=c.output,l.cacheCreate+=c.cacheCreate,l.cacheRead+=c.cacheRead,l.cacheSavings+=c.cacheSavings,l.total+=L(c),l.cost+=c.cost,l.count+=c.count;const p=new Map(l.breakdown.map(S=>[S.name,S]));for(const S of a){const C=p.get(S.name);C?(C.input+=S.input,C.output+=S.output,C.cacheCreate+=S.cacheCreate,C.cacheRead+=S.cacheRead,C.cacheSavings+=S.cacheSavings,C.cost+=S.cost,C.count+=S.count):p.set(S.name,{...S})}l.breakdown=[...p.values()].sort((S,C)=>C.cost-S.cost),l.models=l.breakdown.map(S=>S.name)}}return[...g.values()]}function de(){return{input:0,output:0,cacheCreate:0,cacheRead:0,cost:0,count:0}}function ce(e,n){e.input+=n.input,e.output+=n.output,e.cacheCreate+=n.cacheCreate,e.cacheRead+=n.cacheRead,e.cost+=n.cost,e.count+=n.count}function qe(e,n,t){var m;if(!e)return null;const o=ne(e,n),i=me(o),r=De(n.period,i,e.tz),s=a=>!r||a>=r,u=new Map(e.providers.map(a=>[a.id,a.name])),g=de(),d=new Map,f=[];for(const a of o){const l=de();for(const p of((m=a.table)==null?void 0:m.daily)??[]){if(!s(p.label))continue;const S=p.breakdown.find(x=>x.name===t);if(!S)continue;const C=L(S);ce(g,S),ce(l,S);const R=d.get(p.label)??{day:p.label,cost:0,tokens:0};R.cost+=S.cost,R.tokens+=C,d.set(p.label,R)}const c=L(l);(c>0||l.cost>0||l.count>0)&&f.push({name:a.name,color:a.color,provider:u.get(a.providerId)??a.providerId,providerId:a.providerId,tokens:c,cost:l.cost})}return{accounts:f.sort((a,l)=>l.cost-a.cost||l.tokens-a.tokens||a.name.localeCompare(l.name)),totals:g,daily:[...d.values()].sort((a,l)=>a.day.localeCompare(l.day))}}/**
|
|
2
2
|
* table-core
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) TanStack
|