tokmon 0.28.1 → 0.28.3
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/README.md +156 -234
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/dist/{bootstrap-ink-L7QSJBMS.js → bootstrap-ink-WG4WG3R2.js} +1579 -1135
- package/dist/chunk-7CH6S7BR.js +447 -0
- package/dist/{chunk-CVKCVHS7.js → chunk-CFKUZCMB.js} +70 -310
- package/dist/chunk-HNWEJ6MS.js +1094 -0
- package/dist/chunk-JZSZEHVD.js +406 -0
- package/dist/{chunk-S33XIUAW.js → chunk-P57DVFNH.js} +277 -49
- package/dist/{chunk-4HU4EI5T.js → chunk-P5JN5DDX.js} +25 -46
- package/dist/chunk-TN6V7XSL.js +512 -0
- package/dist/chunk-USKOQIE3.js +278 -0
- package/dist/chunk-UYPDMVW5.js +21 -0
- package/dist/{cli-command-75LP4IDS.js → cli-command-MD3RJRP4.js} +249 -15
- package/dist/cli.js +6 -6
- package/dist/{config-HXFJTNLM.js → config-3DGZ47F7.js} +23 -3
- package/dist/daemon-EMOA36WB.js +377 -0
- package/dist/daemon-handle-JHE5MKMI.js +11 -0
- package/dist/server-EPSH52DR.js +12 -0
- package/dist/web/assets/{Area-CMXvOw33.js → Area-stRnp8Km.js} +1 -1
- package/dist/web/assets/analytics-moZZt9L_.js +2 -0
- package/dist/web/assets/breakdown-km9w7myU.js +4 -0
- package/dist/web/assets/button-DrX04Cc2.js +1 -0
- package/dist/web/assets/{chart-cZoLgpmG.js → chart-D0CtuL2k.js} +1 -1
- package/dist/web/assets/explore-B11uNJV1.js +22 -0
- package/dist/web/assets/index-RDhXsCNG.js +83 -0
- package/dist/web/assets/index-ZmOS8p9O.css +1 -0
- package/dist/web/assets/models-DYbZnY34.js +2 -0
- package/dist/web/assets/overview-CruICbfJ.js +2 -0
- package/dist/web/assets/panel-xckM3_GC.js +1 -0
- package/dist/web/assets/settings-sheet-G-BTSIF6.js +1 -0
- package/dist/web/assets/share-sheet-weIdd4DW.js +2 -0
- package/dist/web/assets/timeline-BHgniliZ.js +1 -0
- package/dist/web/index.html +30 -4
- package/package.json +13 -4
- package/site/THIRD_PARTY_NOTICES.md +83 -0
- package/site/public/fonts/OFL.txt +93 -0
- package/dist/chunk-3RTWFGGD.js +0 -275
- package/dist/chunk-FMP3P2WV.js +0 -299
- package/dist/chunk-HP5UZCXP.js +0 -436
- package/dist/chunk-SMPY52EV.js +0 -125
- package/dist/chunk-XDA5RJST.js +0 -193
- package/dist/daemon-CL4FJW26.js +0 -219
- package/dist/daemon-handle-QQLJE46Y.js +0 -10
- package/dist/server-EUO7CWYH.js +0 -11
- package/dist/web/assets/analytics-DqdZXOJL.js +0 -2
- package/dist/web/assets/breakdown-kOSSJ3mI.js +0 -4
- package/dist/web/assets/explore-vcsM8K9I.js +0 -22
- package/dist/web/assets/index-BErCXT7f.css +0 -1
- package/dist/web/assets/index-DH3dOnbg.js +0 -83
- package/dist/web/assets/models-B5ikm83_.js +0 -2
- package/dist/web/assets/overview-DD1kP8CP.js +0 -2
- package/dist/web/assets/panel-DTQBwExW.js +0 -1
- package/dist/web/assets/primitives-C36qJlA2.js +0 -1
- package/dist/web/assets/settings-sheet-_i2zTQjf.js +0 -1
- package/dist/web/assets/share-sheet-BLHmrFbm.js +0 -2
- package/dist/web/assets/timeline-B4uG-Emo.js +0 -1
- package/dist/web/assets/use-dialog-trap-bfaXEMz9.js +0 -1
|
@@ -3,10 +3,15 @@ import {
|
|
|
3
3
|
ACCENT_COLORS,
|
|
4
4
|
COLOR_PALETTE,
|
|
5
5
|
DEFAULTS,
|
|
6
|
+
DEFAULT_ACCOUNT_DETECTION_CONFIG,
|
|
7
|
+
DEFAULT_TRAY_CONFIG,
|
|
8
|
+
DESKTOP_GRAPH_RANGES,
|
|
9
|
+
MAX_PINNED_PROVIDERS,
|
|
6
10
|
PROVIDER_IDS,
|
|
7
11
|
PROVIDER_META,
|
|
8
12
|
cacheDir,
|
|
9
13
|
clampNum,
|
|
14
|
+
cleanProviderSelection,
|
|
10
15
|
configLocation,
|
|
11
16
|
containsEmail,
|
|
12
17
|
envDir,
|
|
@@ -15,26 +20,36 @@ import {
|
|
|
15
20
|
generateAccountId,
|
|
16
21
|
getTrackedAccountRows,
|
|
17
22
|
loadConfig,
|
|
23
|
+
moveProviderSelection,
|
|
18
24
|
normalizeAllowedHost,
|
|
19
25
|
normalizeAllowedHosts,
|
|
20
26
|
normalizeConfig,
|
|
21
27
|
pickAccentColor,
|
|
28
|
+
providerDetectionEnabled,
|
|
22
29
|
redactEmail,
|
|
23
30
|
repairConfig,
|
|
24
31
|
sanitizeTyped,
|
|
25
32
|
saveConfig,
|
|
26
33
|
saveConfigSync,
|
|
34
|
+
setDetectedAccountExcluded,
|
|
35
|
+
setProviderDetectionEnabled,
|
|
27
36
|
slugify,
|
|
28
|
-
snapshotCacheFile
|
|
29
|
-
|
|
37
|
+
snapshotCacheFile,
|
|
38
|
+
toggleProviderSelection
|
|
39
|
+
} from "./chunk-HNWEJ6MS.js";
|
|
30
40
|
export {
|
|
31
41
|
ACCENT_COLORS,
|
|
32
42
|
COLOR_PALETTE,
|
|
33
43
|
DEFAULTS,
|
|
44
|
+
DEFAULT_ACCOUNT_DETECTION_CONFIG,
|
|
45
|
+
DEFAULT_TRAY_CONFIG,
|
|
46
|
+
DESKTOP_GRAPH_RANGES,
|
|
47
|
+
MAX_PINNED_PROVIDERS,
|
|
34
48
|
PROVIDER_IDS,
|
|
35
49
|
PROVIDER_META,
|
|
36
50
|
cacheDir,
|
|
37
51
|
clampNum,
|
|
52
|
+
cleanProviderSelection,
|
|
38
53
|
configLocation,
|
|
39
54
|
containsEmail,
|
|
40
55
|
envDir,
|
|
@@ -43,15 +58,20 @@ export {
|
|
|
43
58
|
generateAccountId,
|
|
44
59
|
getTrackedAccountRows,
|
|
45
60
|
loadConfig,
|
|
61
|
+
moveProviderSelection,
|
|
46
62
|
normalizeAllowedHost,
|
|
47
63
|
normalizeAllowedHosts,
|
|
48
64
|
normalizeConfig,
|
|
49
65
|
pickAccentColor,
|
|
66
|
+
providerDetectionEnabled,
|
|
50
67
|
redactEmail,
|
|
51
68
|
repairConfig,
|
|
52
69
|
sanitizeTyped,
|
|
53
70
|
saveConfig,
|
|
54
71
|
saveConfigSync,
|
|
72
|
+
setDetectedAccountExcluded,
|
|
73
|
+
setProviderDetectionEnabled,
|
|
55
74
|
slugify,
|
|
56
|
-
snapshotCacheFile
|
|
75
|
+
snapshotCacheFile,
|
|
76
|
+
toggleProviderSelection
|
|
57
77
|
};
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
acquireLock,
|
|
4
|
+
isAlive,
|
|
5
|
+
lockfilePath,
|
|
6
|
+
readForeignLock,
|
|
7
|
+
readLock,
|
|
8
|
+
reclaimAbandonedLock,
|
|
9
|
+
reclaimDeadLock,
|
|
10
|
+
retireIncompatibleCliOwner,
|
|
11
|
+
unlinkLock,
|
|
12
|
+
verifyLock,
|
|
13
|
+
writeLock
|
|
14
|
+
} from "./chunk-USKOQIE3.js";
|
|
15
|
+
import {
|
|
16
|
+
appVersion,
|
|
17
|
+
startWebServer
|
|
18
|
+
} from "./chunk-P57DVFNH.js";
|
|
19
|
+
import {
|
|
20
|
+
resolveDaemonChannel
|
|
21
|
+
} from "./chunk-UYPDMVW5.js";
|
|
22
|
+
import "./chunk-TN6V7XSL.js";
|
|
23
|
+
import {
|
|
24
|
+
flushDisk
|
|
25
|
+
} from "./chunk-CFKUZCMB.js";
|
|
26
|
+
import {
|
|
27
|
+
TOKMON_CAPABILITIES,
|
|
28
|
+
TOKMON_PROTOCOL_VERSION
|
|
29
|
+
} from "./chunk-JZSZEHVD.js";
|
|
30
|
+
import {
|
|
31
|
+
loadConfig
|
|
32
|
+
} from "./chunk-HNWEJ6MS.js";
|
|
33
|
+
|
|
34
|
+
// src/web/daemon-controller.ts
|
|
35
|
+
import { randomBytes } from "crypto";
|
|
36
|
+
var OWNER_WAIT_ATTEMPTS = 60;
|
|
37
|
+
var OWNER_WAIT_INTERVAL_MS = 50;
|
|
38
|
+
var OWNER_VERIFY_TIMEOUT_MS = 250;
|
|
39
|
+
var OWNER_TAKEOVER_TIMEOUT_MS = 5e3;
|
|
40
|
+
var localOwners = /* @__PURE__ */ new Map();
|
|
41
|
+
var DaemonOwnerUnavailableError = class extends Error {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = "DaemonOwnerUnavailableError";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
48
|
+
function localOwnerFor(opts, protocolVersion) {
|
|
49
|
+
const owner = localOwners.get(lockfilePath(opts));
|
|
50
|
+
if (owner?.stopping) {
|
|
51
|
+
throw new DaemonOwnerUnavailableError("the in-process daemon owner is shutting down");
|
|
52
|
+
}
|
|
53
|
+
return owner && owner.lock.protocolVersion === protocolVersion ? owner.lock : null;
|
|
54
|
+
}
|
|
55
|
+
function attached(lock) {
|
|
56
|
+
return {
|
|
57
|
+
role: "attached",
|
|
58
|
+
baseUrl: lock.url,
|
|
59
|
+
lock,
|
|
60
|
+
config: null,
|
|
61
|
+
stop: async () => {
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async function waitForOwner(opts, protocolVersion) {
|
|
66
|
+
const attempts = opts.ownerWaitAttempts ?? OWNER_WAIT_ATTEMPTS;
|
|
67
|
+
const intervalMs = opts.ownerWaitIntervalMs ?? OWNER_WAIT_INTERVAL_MS;
|
|
68
|
+
const verifyTimeoutMs = opts.ownerVerifyTimeoutMs ?? OWNER_VERIFY_TIMEOUT_MS;
|
|
69
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
70
|
+
if (intervalMs > 0) await delay(intervalMs);
|
|
71
|
+
const local = localOwnerFor(opts, protocolVersion);
|
|
72
|
+
if (local) return local;
|
|
73
|
+
const current = readLock(opts);
|
|
74
|
+
const winner = await verifyLock(current, protocolVersion, verifyTimeoutMs);
|
|
75
|
+
if (winner) return winner;
|
|
76
|
+
if (!current || !isAlive(current.pid)) return null;
|
|
77
|
+
if (current.protocolVersion !== protocolVersion) return null;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function incompatibleOwnerError(lock) {
|
|
82
|
+
if (!lock) return new DaemonOwnerUnavailableError("another legacy CLI daemon owns the lock and could not be retired safely");
|
|
83
|
+
return new DaemonOwnerUnavailableError(
|
|
84
|
+
`another ${lock.ownerKind} daemon owns the lock but is not compatible with protocol ${lock.protocolVersion}`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
async function discoverOwner(opts, protocolVersion) {
|
|
88
|
+
const local = localOwnerFor(opts, protocolVersion);
|
|
89
|
+
if (local) return local;
|
|
90
|
+
let current = readLock(opts);
|
|
91
|
+
if (!current && reclaimAbandonedLock(opts)) current = readLock(opts);
|
|
92
|
+
const live = await verifyLock(current, protocolVersion);
|
|
93
|
+
if (live) return live;
|
|
94
|
+
if (current?.state === "starting" && current.protocolVersion === protocolVersion && isAlive(current.pid)) {
|
|
95
|
+
const winner = await waitForOwner(opts, protocolVersion);
|
|
96
|
+
if (winner) return winner;
|
|
97
|
+
current = readLock(opts);
|
|
98
|
+
}
|
|
99
|
+
if (current && isAlive(current.pid)) {
|
|
100
|
+
const retired = await retireIncompatibleCliOwner(
|
|
101
|
+
opts,
|
|
102
|
+
protocolVersion,
|
|
103
|
+
opts.ownerTakeoverTimeoutMs ?? OWNER_TAKEOVER_TIMEOUT_MS
|
|
104
|
+
);
|
|
105
|
+
if (retired) return null;
|
|
106
|
+
throw incompatibleOwnerError(current);
|
|
107
|
+
}
|
|
108
|
+
if (current) reclaimDeadLock(opts);
|
|
109
|
+
const foreign = readForeignLock(opts);
|
|
110
|
+
if (foreign && isAlive(foreign.pid)) {
|
|
111
|
+
if (await retireIncompatibleCliOwner(
|
|
112
|
+
opts,
|
|
113
|
+
protocolVersion,
|
|
114
|
+
opts.ownerTakeoverTimeoutMs ?? OWNER_TAKEOVER_TIMEOUT_MS
|
|
115
|
+
)) return null;
|
|
116
|
+
throw incompatibleOwnerError(
|
|
117
|
+
foreign.ownerKind && foreign.protocolVersion ? { ownerKind: foreign.ownerKind, protocolVersion: foreign.protocolVersion } : null
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
function reservationFor(opts, version, protocolVersion, capabilities) {
|
|
123
|
+
return {
|
|
124
|
+
pid: process.pid,
|
|
125
|
+
port: 0,
|
|
126
|
+
url: "",
|
|
127
|
+
wsToken: randomBytes(32).toString("base64url"),
|
|
128
|
+
version,
|
|
129
|
+
protocolVersion,
|
|
130
|
+
capabilities: [...capabilities],
|
|
131
|
+
ownerKind: opts.ownerKind,
|
|
132
|
+
channel: resolveDaemonChannel(opts.channel),
|
|
133
|
+
startedAt: Date.now(),
|
|
134
|
+
ownerId: randomBytes(32).toString("base64url"),
|
|
135
|
+
state: "starting"
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async function reserveOwnership(opts, reservation) {
|
|
139
|
+
if (acquireLock(reservation, opts)) return null;
|
|
140
|
+
const winner = await waitForOwner(opts, reservation.protocolVersion);
|
|
141
|
+
if (winner) return winner;
|
|
142
|
+
const current = readLock(opts);
|
|
143
|
+
if (current && isAlive(current.pid)) {
|
|
144
|
+
const retired = await retireIncompatibleCliOwner(
|
|
145
|
+
opts,
|
|
146
|
+
reservation.protocolVersion,
|
|
147
|
+
opts.ownerTakeoverTimeoutMs ?? OWNER_TAKEOVER_TIMEOUT_MS
|
|
148
|
+
);
|
|
149
|
+
if (!retired) throw incompatibleOwnerError(current);
|
|
150
|
+
if (acquireLock(reservation, opts)) return null;
|
|
151
|
+
const successor2 = await waitForOwner(opts, reservation.protocolVersion);
|
|
152
|
+
if (successor2) return successor2;
|
|
153
|
+
}
|
|
154
|
+
if (current) reclaimDeadLock(opts);
|
|
155
|
+
const foreign = readForeignLock(opts);
|
|
156
|
+
if (foreign && isAlive(foreign.pid)) {
|
|
157
|
+
const retired = await retireIncompatibleCliOwner(
|
|
158
|
+
opts,
|
|
159
|
+
reservation.protocolVersion,
|
|
160
|
+
opts.ownerTakeoverTimeoutMs ?? OWNER_TAKEOVER_TIMEOUT_MS
|
|
161
|
+
);
|
|
162
|
+
if (!retired) throw incompatibleOwnerError(
|
|
163
|
+
foreign.ownerKind && foreign.protocolVersion ? { ownerKind: foreign.ownerKind, protocolVersion: foreign.protocolVersion } : null
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (acquireLock(reservation, opts)) return null;
|
|
167
|
+
const successor = await waitForOwner(opts, reservation.protocolVersion);
|
|
168
|
+
if (successor) return successor;
|
|
169
|
+
throw new DaemonOwnerUnavailableError("daemon startup is already in progress");
|
|
170
|
+
}
|
|
171
|
+
function owned(opts, lock, config, server) {
|
|
172
|
+
let stopPromise = null;
|
|
173
|
+
const owner = { lock, stopping: false };
|
|
174
|
+
const ownerKey = lockfilePath(opts);
|
|
175
|
+
localOwners.set(ownerKey, owner);
|
|
176
|
+
return {
|
|
177
|
+
role: "owner",
|
|
178
|
+
baseUrl: lock.url,
|
|
179
|
+
lock,
|
|
180
|
+
config,
|
|
181
|
+
stop: () => {
|
|
182
|
+
stopPromise ??= (async () => {
|
|
183
|
+
owner.stopping = true;
|
|
184
|
+
try {
|
|
185
|
+
await server.stop();
|
|
186
|
+
} catch {
|
|
187
|
+
}
|
|
188
|
+
await flushDisk().catch(() => {
|
|
189
|
+
});
|
|
190
|
+
unlinkLock(lock.ownerId, opts);
|
|
191
|
+
if (localOwners.get(ownerKey) === owner) localOwners.delete(ownerKey);
|
|
192
|
+
})();
|
|
193
|
+
return stopPromise;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
async function acquireOrAttachDaemon(opts) {
|
|
198
|
+
const protocolVersion = opts.protocolVersion ?? TOKMON_PROTOCOL_VERSION;
|
|
199
|
+
const capabilities = opts.capabilities ?? TOKMON_CAPABILITIES;
|
|
200
|
+
const existing = await discoverOwner(opts, protocolVersion);
|
|
201
|
+
if (existing) return attached(existing);
|
|
202
|
+
const reservation = reservationFor(
|
|
203
|
+
opts,
|
|
204
|
+
opts.version ?? appVersion(),
|
|
205
|
+
protocolVersion,
|
|
206
|
+
capabilities
|
|
207
|
+
);
|
|
208
|
+
const winner = await reserveOwnership(opts, reservation);
|
|
209
|
+
if (winner) return attached(winner);
|
|
210
|
+
let server = null;
|
|
211
|
+
try {
|
|
212
|
+
const config = opts.config ?? await loadConfig();
|
|
213
|
+
server = await startWebServer({
|
|
214
|
+
config,
|
|
215
|
+
port: opts.port,
|
|
216
|
+
log: opts.log,
|
|
217
|
+
webRoot: opts.webRoot,
|
|
218
|
+
version: reservation.version,
|
|
219
|
+
wsToken: reservation.wsToken,
|
|
220
|
+
ownerKind: reservation.ownerKind,
|
|
221
|
+
channel: reservation.channel,
|
|
222
|
+
protocolVersion: reservation.protocolVersion,
|
|
223
|
+
capabilities: reservation.capabilities
|
|
224
|
+
});
|
|
225
|
+
const ready = {
|
|
226
|
+
...reservation,
|
|
227
|
+
port: server.port,
|
|
228
|
+
url: server.url,
|
|
229
|
+
state: "ready"
|
|
230
|
+
};
|
|
231
|
+
if (!writeLock(ready, opts)) throw new Error("lost daemon lock ownership during startup");
|
|
232
|
+
return owned(opts, ready, config, server);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
try {
|
|
235
|
+
await server?.stop();
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
unlinkLock(reservation.ownerId, opts);
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/web/open.ts
|
|
244
|
+
import { spawn } from "child_process";
|
|
245
|
+
import { appendFileSync } from "fs";
|
|
246
|
+
function openBrowser(url) {
|
|
247
|
+
const target = url;
|
|
248
|
+
if (process.env.TOKMON_OPENLOG) {
|
|
249
|
+
try {
|
|
250
|
+
appendFileSync(process.env.TOKMON_OPENLOG, target + "\n");
|
|
251
|
+
} catch {
|
|
252
|
+
}
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
if (process.platform === "darwin") {
|
|
257
|
+
spawn("open", [target], { stdio: "ignore", detached: true }).unref();
|
|
258
|
+
} else if (process.platform === "win32") {
|
|
259
|
+
spawn("cmd", ["/c", "start", "", target], { stdio: "ignore", detached: true }).unref();
|
|
260
|
+
} else {
|
|
261
|
+
spawn("xdg-open", [target], { stdio: "ignore", detached: true }).unref();
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/web/daemon.ts
|
|
268
|
+
function parseDaemonArgs(args) {
|
|
269
|
+
let port;
|
|
270
|
+
let open = true;
|
|
271
|
+
let help = false;
|
|
272
|
+
for (let i = 0; i < args.length; i++) {
|
|
273
|
+
const arg = args[i];
|
|
274
|
+
if ((arg === "--port" || arg === "-p") && args[i + 1]) port = Number(args[++i]);
|
|
275
|
+
else if (arg.startsWith("--port=")) port = Number(arg.slice("--port=".length));
|
|
276
|
+
else if (arg === "--no-open") open = false;
|
|
277
|
+
else if (arg === "--help" || arg === "-h") help = true;
|
|
278
|
+
}
|
|
279
|
+
if (port !== void 0 && (!Number.isInteger(port) || port < 0 || port > 65535)) port = void 0;
|
|
280
|
+
return { port, open, help };
|
|
281
|
+
}
|
|
282
|
+
var SERVE_HELP = `tokmon serve - Launch the tokmon web dashboard
|
|
283
|
+
|
|
284
|
+
Usage: tokmon serve [options]
|
|
285
|
+
|
|
286
|
+
Options:
|
|
287
|
+
-p, --port <n> Port to listen on (default: 4317, auto-falls back if taken)
|
|
288
|
+
--no-open Don't open the browser automatically
|
|
289
|
+
-h, --help Show this help
|
|
290
|
+
`;
|
|
291
|
+
function handshake(lock) {
|
|
292
|
+
process.stdout.write(JSON.stringify({
|
|
293
|
+
ready: 1,
|
|
294
|
+
url: lock.url,
|
|
295
|
+
port: lock.port,
|
|
296
|
+
wsToken: lock.wsToken,
|
|
297
|
+
version: lock.version,
|
|
298
|
+
protocolVersion: lock.protocolVersion,
|
|
299
|
+
capabilities: lock.capabilities,
|
|
300
|
+
ownerKind: lock.ownerKind,
|
|
301
|
+
channel: lock.channel
|
|
302
|
+
}) + "\n");
|
|
303
|
+
}
|
|
304
|
+
function describeExisting(lock, open) {
|
|
305
|
+
process.stdout.write(`
|
|
306
|
+
\u25C6 tokmon web \u2192 ${lock.url}
|
|
307
|
+
`);
|
|
308
|
+
process.stdout.write(" reusing the live singleton daemon\n\n");
|
|
309
|
+
if (open) {
|
|
310
|
+
openBrowser(lock.url);
|
|
311
|
+
process.stdout.write(" opening browser\u2026\n");
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
async function runDaemon(args, opts) {
|
|
315
|
+
const { port, open, help } = parseDaemonArgs(args);
|
|
316
|
+
if (help && opts.foreground) {
|
|
317
|
+
process.stdout.write(SERVE_HELP);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
let daemon;
|
|
321
|
+
try {
|
|
322
|
+
daemon = await acquireOrAttachDaemon({
|
|
323
|
+
ownerKind: "cli",
|
|
324
|
+
port,
|
|
325
|
+
log: opts.foreground
|
|
326
|
+
});
|
|
327
|
+
} catch (error) {
|
|
328
|
+
const message = `tokmon: failed to start web server: ${error.message}`;
|
|
329
|
+
if (opts.foreground) {
|
|
330
|
+
process.stderr.write(message + "\n");
|
|
331
|
+
process.exitCode = 1;
|
|
332
|
+
}
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (daemon.role === "attached") {
|
|
336
|
+
if (opts.foreground) describeExisting(daemon.lock, open);
|
|
337
|
+
else handshake(daemon.lock);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
let shuttingDown = false;
|
|
341
|
+
const shutdown = async (exitCode = 0) => {
|
|
342
|
+
if (shuttingDown) return;
|
|
343
|
+
shuttingDown = true;
|
|
344
|
+
if (opts.foreground) process.stdout.write("\n stopping tokmon web\u2026\n");
|
|
345
|
+
await daemon.stop();
|
|
346
|
+
process.exit(exitCode);
|
|
347
|
+
};
|
|
348
|
+
process.once("exit", () => {
|
|
349
|
+
unlinkLock(daemon.lock.ownerId);
|
|
350
|
+
});
|
|
351
|
+
process.once("SIGINT", () => {
|
|
352
|
+
void shutdown(0);
|
|
353
|
+
});
|
|
354
|
+
process.once("SIGTERM", () => {
|
|
355
|
+
void shutdown(0);
|
|
356
|
+
});
|
|
357
|
+
if (opts.foreground) {
|
|
358
|
+
process.stdout.write(`
|
|
359
|
+
\u25C6 tokmon web \u2192 ${daemon.baseUrl}
|
|
360
|
+
`);
|
|
361
|
+
process.stdout.write(" live dashboard \xB7 Ctrl-C to stop\n\n");
|
|
362
|
+
if (daemon.config?.allowNetworkAccess) {
|
|
363
|
+
process.stdout.write(" \u26A0 unsafe network access enabled \u2014 dashboard is reachable from your LAN\n\n");
|
|
364
|
+
}
|
|
365
|
+
if (open) {
|
|
366
|
+
openBrowser(daemon.baseUrl);
|
|
367
|
+
process.stdout.write(" opening browser\u2026\n");
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
handshake(daemon.lock);
|
|
371
|
+
}
|
|
372
|
+
await new Promise(() => {
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
export {
|
|
376
|
+
runDaemon
|
|
377
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
startWebServer
|
|
4
|
+
} from "./chunk-P57DVFNH.js";
|
|
5
|
+
import "./chunk-UYPDMVW5.js";
|
|
6
|
+
import "./chunk-TN6V7XSL.js";
|
|
7
|
+
import "./chunk-CFKUZCMB.js";
|
|
8
|
+
import "./chunk-JZSZEHVD.js";
|
|
9
|
+
import "./chunk-HNWEJ6MS.js";
|
|
10
|
+
export {
|
|
11
|
+
startWebServer
|
|
12
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{R as v,r as ht}from"./index-
|
|
1
|
+
import{R as v,r as ht}from"./index-RDhXsCNG.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-D0CtuL2k.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./breakdown-km9w7myU.js","./index-RDhXsCNG.js","./index-ZmOS8p9O.css","./chart-D0CtuL2k.js","./panel-xckM3_GC.js","./timeline-BHgniliZ.js","./Area-stRnp8Km.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as D,q as j,t as A,D as k,M as F,r as x,j as e,F as I,l as T,v as M,f as C,b as S,c as $,w as z,h as R,_ as w}from"./index-RDhXsCNG.js";import{P as B}from"./panel-xckM3_GC.js";const O=[0,.32,.55,.78,1],E=t=>t===0?"var(--color-bg-2)":`color-mix(in oklab, var(--color-cost) ${O[t]*100}%, var(--color-bg-2))`,L=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function V(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 H(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 N=-1,b=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),b++);const g=new Date(s).getUTCMonth();g!==N&&o===0&&(u.push({col:b,text:F[g]}),N=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 W({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(()=>V(t.calendar,l),[t,v]),u=x.useMemo(()=>H(t.calendar,n,l),[t,n]),N=u?`repeat(${u.weeks.length}, minmax(0,1fr))`:void 0,b=u?u.weeks.length*25:void 0;return e.jsx(e.Fragment,{children:e.jsx(B,{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:N,maxWidth:b},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:N,maxWidth:b},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 ${I} ${(d==null?void 0:d.date)===o.date?"ring-1 ring-fg-bright":""}`,style:{background:E(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:E(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(M,{label:"busiest day",value:a.costed?C(a.top.cost):S(a.top.tokens),sub:T(a.top.date),valueClass:"text-cost"}),e.jsx(M,{label:"daily average",value:a.costed?C(a.avg):S(a.avg),sub:`across ${a.active} active days`}),e.jsx(M,{label:"top weekday",value:L[a.busiest],valueClass:"text-fg-bright"}),e.jsx(M,{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(q,{day:m,pinned:!c&&m===d})})]})]})})})}function q({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:$(t.calls)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"tokens"}),e.jsx("div",{className:"tnum text-fg",children:S(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:z(i.name)}}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-fg-dim",children:R(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(()=>w(()=>import("./breakdown-km9w7myU.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.CostByModel}))),G=x.lazy(()=>w(()=>import("./breakdown-km9w7myU.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.ProviderDonut}))),P=x.lazy(()=>w(()=>import("./breakdown-km9w7myU.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.TokenComposition}))),U=x.lazy(()=>w(()=>import("./timeline-BHgniliZ.js"),__vite__mapDeps([5,1,2,3,4,6]),import.meta.url).then(t=>({default:t.CacheSavings}))),K=x.lazy(()=>w(()=>import("./timeline-BHgniliZ.js"),__vite__mapDeps([5,1,2,3,4,6]),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(W,{derived:t,periodLabel:n})}),e.jsx(_,{children:e.jsx(Y,{derived:t,periodLabel:n})}),e.jsx(_,{children:i?e.jsx(G,{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(U,{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};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{R as h,x as Ye,r as J,j as f,E as pe,m as Je,h as ee,f as G,b as q,y as et,u as At,z as kt,d as re,T as ie}from"./index-RDhXsCNG.js";import{c as I,d as k,r as tt,e as Pt,h as nt,i as Ot,j as C,k as Oe,p as S,L as _,l as rt,n as je,o as it,D as jt,q as _t,t as W,v as F,S as wt,w as Tt,x as St,y as Be,z as Et,B as M,E as _e,F as Rt,H as It,I as oe,J as Nt,K as we,M as Lt,N as ae,O as Ke,g as at,X as Te,Y as Se,P as Ee,f as $t,Q as Ct,u as Re,U as ot,C as Ie,R as Ne,a as st,G as ct,A as ce,T as lt,s as Le}from"./chart-D0CtuL2k.js";import{P as de}from"./panel-xckM3_GC.js";var Dt=["points","className","baseLinePoints","connectNulls"];function V(){return V=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},V.apply(this,arguments)}function Bt(n,e){if(n==null)return{};var r=Kt(n,e),t,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(i=0;i<o.length;i++)t=o[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Kt(n,e){if(n==null)return{};var r={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(e.indexOf(t)>=0)continue;r[t]=n[t]}return r}function Fe(n){return zt(n)||Vt(n)||Mt(n)||Ft()}function Ft(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mt(n,e){if(n){if(typeof n=="string")return xe(n,e);var r=Object.prototype.toString.call(n).slice(8,-1);if(r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set")return Array.from(n);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return xe(n,e)}}function Vt(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function zt(n){if(Array.isArray(n))return xe(n)}function xe(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,t=new Array(e);r<e;r++)t[r]=n[r];return t}var Me=function(e){return e&&e.x===+e.x&&e.y===+e.y},qt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return e.forEach(function(t){Me(t)?r[r.length-1].push(t):r[r.length-1].length>0&&r.push([])}),Me(e[0])&&r[r.length-1].push(e[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},Q=function(e,r){var t=qt(e);r&&(t=[t.reduce(function(o,a){return[].concat(Fe(o),Fe(a))},[])]);var i=t.map(function(o){return o.reduce(function(a,c,l){return"".concat(a).concat(l===0?"M":"L").concat(c.x,",").concat(c.y)},"")}).join("");return t.length===1?"".concat(i,"Z"):i},Wt=function(e,r,t){var i=Q(e,t);return"".concat(i.slice(-1)==="Z"?i.slice(0,-1):i,"L").concat(Q(r.reverse(),t).slice(1))},Gt=function(e){var r=e.points,t=e.className,i=e.baseLinePoints,o=e.connectNulls,a=Bt(e,Dt);if(!r||!r.length)return null;var c=I("recharts-polygon",t);if(i&&i.length){var l=a.stroke&&a.stroke!=="none",s=Wt(r,i,o);return h.createElement("g",{className:c},h.createElement("path",V({},k(a,!0),{fill:s.slice(-1)==="Z"?a.fill:"none",stroke:"none",d:s})),l?h.createElement("path",V({},k(a,!0),{fill:"none",d:Q(r,o)})):null,l?h.createElement("path",V({},k(a,!0),{fill:"none",d:Q(i,o)})):null)}var p=Q(r,o);return h.createElement("path",V({},k(a,!0),{fill:p.slice(-1)==="Z"?a.fill:"none",className:c,d:p}))},ge,Ve;function Ht(){if(Ve)return ge;Ve=1;var n=tt(),e=Pt(),r=nt();function t(i,o){return i&&i.length?n(i,r(o,2),e):void 0}return ge=t,ge}var Ut=Ht();const Zt=Ye(Ut);var be,ze;function Xt(){if(ze)return be;ze=1;var n=tt(),e=nt(),r=Ot();function t(i,o){return i&&i.length?n(i,e(o,2),r):void 0}return be=t,be}var Qt=Xt();const Yt=Ye(Qt);var Jt=["cx","cy","angle","ticks","axisLine"],en=["ticks","tick","angle","tickFormatter","stroke"];function H(n){"@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(n)}function Y(){return Y=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},Y.apply(this,arguments)}function qe(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function L(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?qe(Object(r),!0).forEach(function(t){me(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):qe(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function We(n,e){if(n==null)return{};var r=tn(n,e),t,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(i=0;i<o.length;i++)t=o[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function tn(n,e){if(n==null)return{};var r={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(e.indexOf(t)>=0)continue;r[t]=n[t]}return r}function nn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Ge(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,ft(t.key),t)}}function rn(n,e,r){return e&&Ge(n.prototype,e),r&&Ge(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function an(n,e,r){return e=le(e),on(n,ut()?Reflect.construct(e,r||[],le(n).constructor):e.apply(n,r))}function on(n,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 sn(n)}function sn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function ut(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ut=function(){return!!n})()}function le(n){return le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},le(n)}function cn(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Ae(n,e)}function Ae(n,e){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},Ae(n,e)}function me(n,e,r){return e=ft(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function ft(n){var e=ln(n,"string");return H(e)=="symbol"?e:e+""}function ln(n,e){if(H(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(H(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var ve=(function(n){function e(){return nn(this,e),an(this,e,arguments)}return cn(e,n),rn(e,[{key:"getTickValueCoord",value:function(t){var i=t.coordinate,o=this.props,a=o.angle,c=o.cx,l=o.cy;return S(c,l,i,a)}},{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,o=t.cy,a=t.angle,c=t.ticks,l=Zt(c,function(p){return p.coordinate||0}),s=Yt(c,function(p){return p.coordinate||0});return{cx:i,cy:o,startAngle:a,endAngle:a,innerRadius:s.coordinate||0,outerRadius:l.coordinate||0}}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,o=t.cy,a=t.angle,c=t.ticks,l=t.axisLine,s=We(t,Jt),p=c.reduce(function(m,u){return[Math.min(m[0],u.coordinate),Math.max(m[1],u.coordinate)]},[1/0,-1/0]),d=S(i,o,p[0],a),v=S(i,o,p[1],a),A=L(L(L({},k(s,!1)),{},{fill:"none"},k(l,!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,o=i.ticks,a=i.tick,c=i.angle,l=i.tickFormatter,s=i.stroke,p=We(i,en),d=this.getTickTextAnchor(),v=k(p,!1),A=k(a,!1),m=o.map(function(u,g){var b=t.getTickValueCoord(u),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:u});return h.createElement(_,Y({className:I("recharts-polar-radius-axis-tick",rt(a)),key:"tick-".concat(u.coordinate)},je(t.props,u,g)),e.renderTickItem(a,x,l?l(u.value,g):u.value))});return h.createElement(_,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var t=this.props,i=t.ticks,o=t.axisLine,a=t.tick;return!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-radius-axis",this.props.className)},o&&this.renderAxisLine(),a&&this.renderTicks(),it.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(t,i,o){var a;return h.isValidElement(t)?a=h.cloneElement(t,i):C(t)?a=t(i):a=h.createElement(Oe,Y({},i,{className:"recharts-polar-radius-axis-tick-value"}),o),a}}])})(J.PureComponent);me(ve,"displayName","PolarRadiusAxis");me(ve,"axisType","radiusAxis");me(ve,"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(n){"@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(n)}function D(){return D=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},D.apply(this,arguments)}function He(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function $(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?He(Object(r),!0).forEach(function(t){he(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):He(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function un(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Ue(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,dt(t.key),t)}}function fn(n,e,r){return e&&Ue(n.prototype,e),r&&Ue(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function pn(n,e,r){return e=ue(e),dn(n,pt()?Reflect.construct(e,r||[],ue(n).constructor):e.apply(n,r))}function dn(n,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 mn(n)}function mn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function pt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(pt=function(){return!!n})()}function ue(n){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(n)}function vn(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&ke(n,e)}function ke(n,e){return ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},ke(n,e)}function he(n,e,r){return e=dt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function dt(n){var e=hn(n,"string");return U(e)=="symbol"?e:e+""}function hn(n,e){if(U(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(U(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var yn=Math.PI/180,Ze=1e-5,ye=(function(n){function e(){return un(this,e),pn(this,e,arguments)}return vn(e,n),fn(e,[{key:"getTickLineCoord",value:function(t){var i=this.props,o=i.cx,a=i.cy,c=i.radius,l=i.orientation,s=i.tickSize,p=s||8,d=S(o,a,c,t.coordinate),v=S(o,a,c+(l==="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,o=Math.cos(-t.coordinate*yn),a;return o>Ze?a=i==="outer"?"start":"end":o<-Ze?a=i==="outer"?"end":"start":a="middle",a}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,o=t.cy,a=t.radius,c=t.axisLine,l=t.axisLineType,s=$($({},k(this.props,!1)),{},{fill:"none"},k(c,!1));if(l==="circle")return h.createElement(jt,D({className:"recharts-polar-angle-axis-line"},s,{cx:i,cy:o,r:a}));var p=this.props.ticks,d=p.map(function(v){return S(i,o,a,v.coordinate)});return h.createElement(Gt,D({className:"recharts-polar-angle-axis-line"},s,{points:d}))}},{key:"renderTicks",value:function(){var t=this,i=this.props,o=i.ticks,a=i.tick,c=i.tickLine,l=i.tickFormatter,s=i.stroke,p=k(this.props,!1),d=k(a,!1),v=$($({},p),{},{fill:"none"},k(c,!1)),A=o.map(function(m,u){var g=t.getTickLineCoord(m),b=t.getTickTextAnchor(m),x=$($($({textAnchor:b},p),{},{stroke:"none",fill:s},d),{},{index:u,payload:m,x:g.x2,y:g.y2});return h.createElement(_,D({className:I("recharts-polar-angle-axis-tick",rt(a)),key:"tick-".concat(m.coordinate)},je(t.props,m,u)),c&&h.createElement("line",D({className:"recharts-polar-angle-axis-tick-line"},v,g)),a&&e.renderTickItem(a,x,l?l(m.value,u):m.value))});return h.createElement(_,{className:"recharts-polar-angle-axis-ticks"},A)}},{key:"render",value:function(){var t=this.props,i=t.ticks,o=t.radius,a=t.axisLine;return o<=0||!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-angle-axis",this.props.className)},a&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(t,i,o){var a;return h.isValidElement(t)?a=h.cloneElement(t,i):C(t)?a=t(i):a=h.createElement(Oe,D({},i,{className:"recharts-polar-angle-axis-tick-value"}),o),a}}])})(J.PureComponent);he(ye,"displayName","PolarAngleAxis");he(ye,"axisType","angleAxis");he(ye,"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 se;function Z(n){"@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(n)}function z(){return z=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},z.apply(this,arguments)}function Xe(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function y(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Xe(Object(r),!0).forEach(function(t){O(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Xe(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function gn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Qe(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,vt(t.key),t)}}function bn(n,e,r){return e&&Qe(n.prototype,e),r&&Qe(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function xn(n,e,r){return e=fe(e),An(n,mt()?Reflect.construct(e,r||[],fe(n).constructor):e.apply(n,r))}function An(n,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 kn(n)}function kn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function mt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(mt=function(){return!!n})()}function fe(n){return fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},fe(n)}function Pn(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Pe(n,e)}function Pe(n,e){return Pe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},Pe(n,e)}function O(n,e,r){return e=vt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function vt(n){var e=On(n,"string");return Z(e)=="symbol"?e:e+""}function On(n,e){if(Z(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(Z(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var E=(function(n){function e(r){var t;return gn(this,e),t=xn(this,e,[r]),O(t,"pieRef",null),O(t,"sectorRefs",[]),O(t,"id",Rt("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:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},t}return Pn(e,n),bn(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 o=this.props,a=o.label,c=o.labelLine,l=o.dataKey,s=o.valueKey,p=k(this.props,!1),d=k(a,!1),v=k(c,!1),A=a&&a.offsetRadius||20,m=t.map(function(u,g){var b=(u.startAngle+u.endAngle)/2,x=S(u.cx,u.cy,u.outerRadius+A,b),j=y(y(y(y({},p),u),{},{stroke:"none"},d),{},{index:g,textAnchor:e.getTextAnchor(x.x,u.cx)},x),B=y(y(y(y({},p),u),{},{fill:"none",stroke:u.fill},v),{},{index:g,points:[S(u.cx,u.cy,u.outerRadius,b),x]}),w=l;return W(l)&&W(s)?w="value":W(l)&&(w=s),h.createElement(_,{key:"label-".concat(u.startAngle,"-").concat(u.endAngle,"-").concat(u.midAngle,"-").concat(g)},c&&e.renderLabelLineItem(c,B,"line"),e.renderLabelItem(a,j,F(u,w)))});return h.createElement(_,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(t){var i=this,o=this.props,a=o.activeShape,c=o.blendStroke,l=o.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=l&&i.hasActiveIndex()?l:null,A=d?a:v,m=y(y({},s),{},{stroke:c?s.fill:s.stroke,tabIndex:-1});return h.createElement(_,z({ref:function(g){g&&!i.sectorRefs.includes(g)&&i.sectorRefs.push(g)},tabIndex:-1,className:"recharts-pie-sector"},je(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(wt,z({option:A,isActive:d,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,i=this.props,o=i.sectors,a=i.isAnimationActive,c=i.animationBegin,l=i.animationDuration,s=i.animationEasing,p=i.animationId,d=this.state,v=d.prevSectors,A=d.prevIsAnimationActive;return h.createElement(Tt,{begin:c,duration:l,isActive:a,easing:s,from:{t:0},to:{t:1},key:"pie-".concat(p,"-").concat(A),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var u=m.t,g=[],b=o&&o[0],x=b.startAngle;return o.forEach(function(j,B){var w=v&&v[B],N=B>0?St(j,"paddingAngle",0):0;if(w){var X=Be(w.endAngle-w.startAngle,j.endAngle-j.startAngle),P=y(y({},j),{},{startAngle:x+N,endAngle:x+X(u)+N});g.push(P),x=P.endAngle}else{var K=j.endAngle,T=j.startAngle,te=Be(0,K-T),ne=te(u),R=y(y({},j),{},{startAngle:x+N,endAngle:x+ne+N});g.push(R),x=R.endAngle}}),h.createElement(_,null,t.renderSectorsStatically(g))})}},{key:"attachKeyboardHandlers",value:function(t){var i=this;t.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var a=++i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[a].focus(),i.setState({sectorToFocus:a});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,o=t.isAnimationActive,a=this.state.prevSectors;return o&&i&&i.length&&(!a||!Et(a,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,o=i.hide,a=i.sectors,c=i.className,l=i.label,s=i.cx,p=i.cy,d=i.innerRadius,v=i.outerRadius,A=i.isAnimationActive,m=this.state.isAnimationFinished;if(o||!a||!a.length||!M(s)||!M(p)||!M(d)||!M(v))return null;var u=I("recharts-pie",c);return h.createElement(_,{tabIndex:this.props.rootTabIndex,className:u,ref:function(b){t.pieRef=b}},this.renderSectors(),l&&this.renderLabels(a),it.renderCallByParent(this.props,null,!1),(!A||m)&&_e.renderCallByParent(this.props,a,!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,o){if(h.isValidElement(t))return h.cloneElement(t,i);if(C(t))return t(i);var a=I("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return h.createElement(_t,z({},i,{key:o,type:"linear",className:a}))}},{key:"renderLabelItem",value:function(t,i,o){if(h.isValidElement(t))return h.cloneElement(t,i);var a=o;if(C(t)&&(a=t(i),h.isValidElement(a)))return a;var c=I("recharts-pie-label-text",typeof t!="boolean"&&!C(t)?t.className:"");return h.createElement(Oe,z({},i,{alignmentBaseline:"middle",className:c}),a)}}])})(J.PureComponent);se=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:!It.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});O(E,"parseDeltaAngle",function(n,e){var r=oe(e-n),t=Math.min(Math.abs(e-n),360);return r*t});O(E,"getRealPieData",function(n){var e=n.data,r=n.children,t=k(n,!1),i=Nt(r,we);return e&&e.length?e.map(function(o,a){return y(y(y({payload:o},t),o),i&&i[a]&&i[a].props)}):i&&i.length?i.map(function(o){return y(y({},t),o.props)}):[]});O(E,"parseCoordinateOfPie",function(n,e){var r=e.top,t=e.left,i=e.width,o=e.height,a=Lt(i,o),c=t+ae(n.cx,i,i/2),l=r+ae(n.cy,o,o/2),s=ae(n.innerRadius,a,0),p=ae(n.outerRadius,a,a*.8),d=n.maxRadius||Math.sqrt(i*i+o*o)/2;return{cx:c,cy:l,innerRadius:s,outerRadius:p,maxRadius:d}});O(E,"getComposedData",function(n){var e=n.item,r=n.offset,t=e.type.defaultProps!==void 0?y(y({},e.type.defaultProps),e.props):e.props,i=se.getRealPieData(t);if(!i||!i.length)return null;var o=t.cornerRadius,a=t.startAngle,c=t.endAngle,l=t.paddingAngle,s=t.dataKey,p=t.nameKey,d=t.valueKey,v=t.tooltipType,A=Math.abs(t.minAngle),m=se.parseCoordinateOfPie(t,r),u=se.parseDeltaAngle(a,c),g=Math.abs(u),b=s;W(s)&&W(d)?(Ke(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
+
the props "valueKey" will be deprecated in 1.1.0`),b="value"):W(s)&&(Ke(!1,`Use "dataKey" to specify the value of pie,
|
|
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)*l,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),ne=(M(T)?T:0)/w,R;K?R=X.endAngle+oe(u)*l*(T!==0?1:0):R=a;var $e=R+oe(u)*((T!==0?A:0)+ne*B),Ce=(R+$e)/2,De=(m.innerRadius+m.outerRadius)/2,bt=[{name:te,value:T,payload:P,dataKey:b,type:v}],xt=S(m.cx,m.cy,De,Ce);return X=y(y(y({percent:ne,cornerRadius:o,name:te,tooltipPayload:bt,midAngle:Ce,middleRadius:De,tooltipPosition:xt},P),m),{},{value:F(P,b),startAngle:R,endAngle:$e,payload:P,paddingAngle:oe(u)*l}),X})}return y(y({},m),{},{sectors:N,data:i})});var ht=at({chartName:"BarChart",GraphicalChild:Ee,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Te},{axisType:"yAxis",AxisComp:Se}],formatAxisMap:$t}),jn=at({chartName:"PieChart",GraphicalChild:E,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:ye},{axisType:"radiusAxis",AxisComp:ve}],formatAxisMap:Ct,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const yt={fill:"var(--color-bg-2)"},gt={fill:"var(--color-fg-dim)",fontSize:10,fontFamily:"var(--font-mono)"},_n=Le("cost",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),wn=Le("tokens",q,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),Tn=Le("saved",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)});function In({derived:n,height:e=280,limit:r=10,metric:t="cost",periodLabel:i}){const o=Re(),a=ot("(min-width: 768px)"),c=a?124:92,l=a?60:44,s=t==="tokens",p=[...n.byModel].sort((d,v)=>s?v.tokens-d.tokens:v.cost-d.cost).slice(0,r);return f.jsx(de,{title:s?"tokens by model":"cost by model",titleTag:i,captureName:s?"tokens-by-model":"cost-by-model",children:p.length===0?f.jsx(pe,{children:"no models in period"}):f.jsx(Ie,{height:e,children:f.jsx(Ne,{children:f.jsxs(ht,{data:p,layout:"vertical",margin:{top:4,right:l,left:4,bottom:0},children:[f.jsx(st,{...ct,horizontal:!1,vertical:!0}),f.jsx(Te,{type:"number",...ce,tickFormatter:s?q:Je}),f.jsx(Se,{type:"category",dataKey:"model",...ce,width:c,tickFormatter:ee}),f.jsx(lt,{content:s?wn:_n,cursor:yt}),f.jsxs(Ee,{dataKey:s?"tokens":"cost",radius:[0,3,3,0],isAnimationActive:o,animationDuration:350,children:[p.map(d=>f.jsx(we,{fill:d.color},d.model)),f.jsx(_e,{dataKey:s?"tokens":"cost",position:"right",offset:6,...gt,formatter:d=>s?q(d):G(d)})]})]})})})})}function Nn({derived:n,height:e=240,limit:r=12,periodLabel:t}){const i=Re(),o=ot("(min-width: 768px)"),a=o?124:92,c=o?60:44,l=[...n.byModel].filter(s=>s.cacheSavings>0).sort((s,p)=>p.cacheSavings-s.cacheSavings).slice(0,r);return f.jsx(de,{title:"cache savings by model",titleTag:t,captureName:"cache-savings-by-model",children:l.length===0?f.jsx(pe,{children:"no cache savings in period"}):f.jsx(Ie,{height:e,children:f.jsx(Ne,{children:f.jsxs(ht,{data:l,layout:"vertical",margin:{top:4,right:c,left:4,bottom:0},children:[f.jsx(st,{...ct,horizontal:!1,vertical:!0}),f.jsx(Te,{type:"number",...ce,tickFormatter:Je}),f.jsx(Se,{type:"category",dataKey:"model",...ce,width:a,tickFormatter:ee}),f.jsx(lt,{content:Tn,cursor:yt}),f.jsx(Ee,{dataKey:"cacheSavings",radius:[0,3,3,0],fill:"var(--color-positive)",isAnimationActive:i,animationDuration:350,children:f.jsx(_e,{dataKey:"cacheSavings",position:"right",offset:6,...gt,formatter:s=>G(s)})})]})})})})}function Ln({derived:n,height:e=280,periodLabel:r}){const t=Re(),i=n.byProvider,o=n.totals.cost,[a,c]=J.useState(null),[l,s]=J.useState(null),p=l?i.findIndex(m=>m.id===l):-1,d=a??(p>=0?p:null),v=d!=null?i[d]:null,A=v&&o>0?v.cost/o:0;return f.jsx(de,{title:"provider split",titleTag:r,captureName:"provider-split",children:i.length===0?f.jsx(pe,{children:"no spend in period"}):f.jsxs("div",{className:"relative",onMouseLeave:()=>c(null),children:[f.jsx(Ie,{height:e,children:f.jsx(Ne,{children:f.jsx(jn,{children:f.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,u)=>c(u),onClick:(m,u)=>s(g=>{var b,x;return g===((b=i[u])==null?void 0:b.id)?null:((x=i[u])==null?void 0:x.id)??null}),children:i.map((m,u)=>f.jsx(we,{fill:m.color,"aria-label":`${m.name}: ${G(m.cost)}`,fillOpacity:d==null||d===u?1:.32,style:{transition:"fill-opacity 150ms ease"}},m.id))})})})}),f.jsxs("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[f.jsx("div",{className:"tnum text-xl",style:{color:v?v.color:"var(--color-fg-bright)"},children:G(v?v.cost:o)}),f.jsxs("div",{className:"font-display text-[10px] uppercase tracking-wide text-fg-faint",children:[v?`${v.name} · ${et(A,A>0&&A<.01?1:0)}`:"total",v&&a==null&&p>=0&&f.jsx("span",{className:"text-accent",children:" · pinned"})]})]})]})})}function $n({derived:n,periodLabel:e}){const r=At(),t=n.tokenComposition,i=kt(t),o=r.appearance.preset,a=[{key:"cacheRead",label:"cache read",value:t.cacheRead,color:re(o,0,ie.cacheRead)},{key:"input",label:"input",value:t.input,color:re(o,1,ie.input)},{key:"output",label:"output",value:t.output,color:re(o,2,ie.output)},{key:"cacheCreate",label:"cache write",value:t.cacheCreate,color:re(o,3,ie.cacheCreate)}];return f.jsx(de,{title:"token composition",titleTag:e,captureName:"token-composition",right:f.jsx("span",{className:"tnum text-xs text-fg-dim",children:q(i)}),children:i===0?f.jsx(pe,{children:"no tokens in period"}):f.jsxs("div",{className:"flex flex-col gap-4 pt-1",children:[f.jsx("div",{className:"flex h-3 w-full overflow-hidden rounded-full bg-bg-3",children:a.map(c=>c.value>0&&f.jsx("div",{style:{width:`${c.value/i*100}%`,minWidth:"2px",background:c.color},title:`${c.label}: ${q(c.value)}`},c.key))}),f.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2.5",children:a.map(c=>{const l=i>0?c.value/i:0;return f.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[f.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim",children:[f.jsx("span",{className:"inline-block size-2 rounded-[2px]",style:{background:c.color}}),c.label]}),f.jsxs("span",{className:"text-fg",children:[f.jsx("span",{className:"tnum text-fg-bright",children:q(c.value)}),f.jsx("span",{className:"ml-1.5 text-fg-faint",children:et(l,l>0&&l<.01?1:0)})]})]},c.key)})})]})})}export{Nn as CacheByModel,In as CostByModel,Ln as ProviderDonut,$n as TokenComposition};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as b,j as f,F as N,X as S}from"./index-RDhXsCNG.js";const j='button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])';function k(n,{active:i,onEscape:s,initialFocusRef:r}){const u=b.useRef(s);b.useEffect(()=>{u.current=s},[s]),b.useEffect(()=>{var a,l;if(!i)return;const o=n.current,c=document.activeElement,d=o==null?void 0:o.querySelector(j);(l=(a=(r==null?void 0:r.current)??d??o)==null?void 0:a.focus)==null||l.call(a);let m=document.activeElement;const g=e=>{var p;const t=e.target;t&&((p=n.current)!=null&&p.contains(t))&&(m=t)};document.addEventListener("focusin",g);const x=e=>{const t=n.current;if(!t||t.hasAttribute("inert"))return;if(e.key==="Escape"){e.stopPropagation(),u.current();return}if(e.key!=="Tab")return;const p=t.querySelectorAll(j),v=Array.from(p).filter(E=>E.offsetParent!==null||E===document.activeElement);if(v.length===0)return;const y=v[0],h=v[v.length-1];e.shiftKey&&document.activeElement===y?(e.preventDefault(),h.focus()):!e.shiftKey&&document.activeElement===h&&(e.preventDefault(),y.focus())};return document.addEventListener("keydown",x),()=>{var t;document.removeEventListener("keydown",x),document.removeEventListener("focusin",g);const e=c&&c.isConnected?c:m;(t=e==null?void 0:e.focus)==null||t.call(e)}},[i,r,n])}function I({onClose:n,labelledBy:i,initialFocusRef:s,panelRef:r,className:u="",panelStyle:o,active:c=!0,closeOnBackdrop:d=!0,showClose:m=!0,children:g}){const x=b.useRef(null),a=r??x;return k(a,{active:c,onEscape:n,initialFocusRef:s}),f.jsx("div",{className:"dialog-fade fixed inset-0 z-[60] flex items-start justify-center overflow-y-auto overscroll-contain bg-bg-0/70 p-4 backdrop-blur-sm",onMouseDown:l=>{d&&l.target===l.currentTarget&&n()},role:"dialog","aria-modal":"true","aria-labelledby":i,children:f.jsxs("div",{ref:a,tabIndex:-1,style:o,className:`dialog-pop relative overflow-hidden rounded-md border border-line-2 bg-bg-1 focus:outline-none ${u}`,children:[m&&f.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:`absolute right-2 top-2 z-10 rounded p-1 text-fg-faint transition hover:text-fg ${N}`,children:f.jsx(S,{className:"size-4"})}),g]})})}const w={primary:"border border-accent/60 bg-bg-1 text-accent hover:bg-bg-2",secondary:"border border-line bg-bg-1 text-fg-dim hover:border-line-2 hover:text-fg",ghost:"text-fg-faint hover:text-fg"},A={sm:"gap-1.5 px-3 py-1.5 text-xs",xs:"gap-1 px-2 py-1 text-[11px]"},$=b.forwardRef(function({variant:i="secondary",size:s="sm",className:r="",type:u="button",children:o,...c},d){return f.jsx("button",{ref:d,type:u,className:`inline-flex items-center rounded transition active:scale-[0.97] disabled:opacity-50 ${A[s]} ${w[i]} ${N} ${r}`,...c,children:o})});export{$ as B,I as D};
|