tokmon 0.19.7 → 0.20.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.
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ACCENT_COLORS,
4
+ COLOR_PALETTE,
5
+ DEFAULTS,
6
+ PROVIDER_IDS,
7
+ PROVIDER_META,
8
+ cacheDir,
9
+ clampNum,
10
+ configLocation,
11
+ envDir,
12
+ expandHome,
13
+ findAccount,
14
+ generateAccountId,
15
+ getTrackedAccountRows,
16
+ loadConfig,
17
+ normalizeConfig,
18
+ pickAccentColor,
19
+ sanitizeTyped,
20
+ saveConfig,
21
+ saveConfigSync,
22
+ slugify
23
+ } from "./chunk-MVMPQJ5S.js";
24
+ export {
25
+ ACCENT_COLORS,
26
+ COLOR_PALETTE,
27
+ DEFAULTS,
28
+ PROVIDER_IDS,
29
+ PROVIDER_META,
30
+ cacheDir,
31
+ clampNum,
32
+ configLocation,
33
+ envDir,
34
+ expandHome,
35
+ findAccount,
36
+ generateAccountId,
37
+ getTrackedAccountRows,
38
+ loadConfig,
39
+ normalizeConfig,
40
+ pickAccentColor,
41
+ sanitizeTyped,
42
+ saveConfig,
43
+ saveConfigSync,
44
+ slugify
45
+ };
@@ -0,0 +1,213 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ appVersion,
4
+ startWebServer
5
+ } from "./chunk-A6RQRHRO.js";
6
+ import {
7
+ flushDisk
8
+ } from "./chunk-MB6LRSEZ.js";
9
+ import {
10
+ cacheDir,
11
+ loadConfig
12
+ } from "./chunk-MVMPQJ5S.js";
13
+
14
+ // src/web/open.ts
15
+ import { spawn } from "child_process";
16
+ import { appendFileSync } from "fs";
17
+ function openBrowser(url) {
18
+ if (process.env.TOKMON_OPENLOG) {
19
+ try {
20
+ appendFileSync(process.env.TOKMON_OPENLOG, url + "\n");
21
+ } catch {
22
+ }
23
+ return;
24
+ }
25
+ try {
26
+ if (process.platform === "darwin") {
27
+ spawn("open", [url], { stdio: "ignore", detached: true }).unref();
28
+ } else if (process.platform === "win32") {
29
+ spawn("cmd", ["/c", "start", "", url], { stdio: "ignore", detached: true }).unref();
30
+ } else {
31
+ spawn("xdg-open", [url], { stdio: "ignore", detached: true }).unref();
32
+ }
33
+ } catch {
34
+ }
35
+ }
36
+
37
+ // src/web/lockfile.ts
38
+ import { readFileSync, writeFileSync, unlinkSync, mkdirSync, renameSync } from "fs";
39
+ import { join } from "path";
40
+ var lockfilePath = () => join(cacheDir(), "daemon.json");
41
+ function readLock() {
42
+ try {
43
+ const raw = readFileSync(lockfilePath(), "utf-8");
44
+ const lock = JSON.parse(raw);
45
+ if (lock && typeof lock.pid === "number" && typeof lock.port === "number" && typeof lock.url === "string" && typeof lock.version === "string") {
46
+ if ("wsToken" in lock && typeof lock.wsToken !== "string") delete lock.wsToken;
47
+ return lock;
48
+ }
49
+ return null;
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
54
+ function writeLock(lock) {
55
+ try {
56
+ mkdirSync(cacheDir(), { recursive: true, mode: 448 });
57
+ const tmp = join(cacheDir(), `daemon.json.${process.pid}.tmp`);
58
+ writeFileSync(tmp, JSON.stringify(lock), { mode: 384 });
59
+ renameSync(tmp, lockfilePath());
60
+ } catch {
61
+ }
62
+ }
63
+ function unlinkLock() {
64
+ try {
65
+ unlinkSync(lockfilePath());
66
+ } catch {
67
+ }
68
+ }
69
+ function isAlive(pid) {
70
+ if (!Number.isInteger(pid) || pid <= 0) return false;
71
+ try {
72
+ process.kill(pid, 0);
73
+ return true;
74
+ } catch (err) {
75
+ return err.code === "EPERM";
76
+ }
77
+ }
78
+ async function probeHealth(url, timeoutMs = 300) {
79
+ try {
80
+ const res = await fetch(`${url.replace(/\/+$/, "")}/healthz`, {
81
+ signal: AbortSignal.timeout(timeoutMs)
82
+ });
83
+ return res.ok;
84
+ } catch {
85
+ return false;
86
+ }
87
+ }
88
+
89
+ // src/web/daemon.ts
90
+ function parseDaemonArgs(args) {
91
+ let port;
92
+ let open = true;
93
+ let help = false;
94
+ for (let i = 0; i < args.length; i++) {
95
+ const a = args[i];
96
+ if ((a === "--port" || a === "-p") && args[i + 1]) {
97
+ port = Number(args[++i]);
98
+ } else if (a.startsWith("--port=")) {
99
+ port = Number(a.slice("--port=".length));
100
+ } else if (a === "--no-open") {
101
+ open = false;
102
+ } else if (a === "--help" || a === "-h") {
103
+ help = true;
104
+ }
105
+ }
106
+ if (port !== void 0 && (!Number.isFinite(port) || port < 0 || port > 65535)) port = void 0;
107
+ return { port, open, help };
108
+ }
109
+ var SERVE_HELP = `tokmon serve - Launch the tokmon web dashboard (local, loopback only)
110
+
111
+ Usage: tokmon serve [options]
112
+
113
+ Options:
114
+ -p, --port <n> Port to listen on (default: 4317, auto-falls back if taken)
115
+ --no-open Don't open the browser automatically
116
+ -h, --help Show this help
117
+ `;
118
+ async function runDaemon(args, opts) {
119
+ const { port, open, help } = parseDaemonArgs(args);
120
+ if (help && opts.foreground) {
121
+ process.stdout.write(SERVE_HELP);
122
+ return;
123
+ }
124
+ if (opts.foreground && port === void 0) {
125
+ const lock = readLock();
126
+ if (lock && lock.version === appVersion() && isAlive(lock.pid) && await probeHealth(lock.url)) {
127
+ process.stdout.write(`
128
+ \u25C6 tokmon web already running \u2192 ${lock.url}
129
+ `);
130
+ process.stdout.write(` reusing the live dashboard (started by another tokmon)
131
+
132
+ `);
133
+ if (open) {
134
+ openBrowser(lock.url);
135
+ process.stdout.write(` opening browser\u2026
136
+ `);
137
+ }
138
+ return;
139
+ }
140
+ }
141
+ const config = await loadConfig();
142
+ let controller;
143
+ try {
144
+ controller = await startWebServer({ config, port, log: opts.foreground });
145
+ } catch (err) {
146
+ const msg = `tokmon: failed to start web server: ${err.message}`;
147
+ process.stderr.write(msg + "\n");
148
+ process.exitCode = 1;
149
+ return;
150
+ }
151
+ const version = appVersion();
152
+ if (opts.foreground) {
153
+ writeLock({
154
+ pid: process.pid,
155
+ port: controller.port,
156
+ url: controller.url,
157
+ wsToken: controller.wsToken,
158
+ version,
159
+ startedAt: Date.now()
160
+ });
161
+ }
162
+ let shuttingDown = false;
163
+ const shutdown = async (exitCode = 0) => {
164
+ if (shuttingDown) return;
165
+ shuttingDown = true;
166
+ if (opts.foreground) {
167
+ process.stdout.write("\n stopping tokmon web\u2026\n");
168
+ unlinkLock();
169
+ }
170
+ try {
171
+ await controller.stop();
172
+ } catch {
173
+ }
174
+ await flushDisk();
175
+ process.exit(exitCode);
176
+ };
177
+ if (opts.foreground) process.once("exit", () => {
178
+ unlinkLock();
179
+ });
180
+ process.on("SIGINT", () => {
181
+ void shutdown(0);
182
+ });
183
+ process.on("SIGTERM", () => {
184
+ void shutdown(0);
185
+ });
186
+ if (opts.foreground) {
187
+ process.stdout.write(`
188
+ \u25C6 tokmon web \u2192 ${controller.url}
189
+ `);
190
+ process.stdout.write(` live dashboard \xB7 Ctrl-C to stop
191
+
192
+ `);
193
+ if (open) {
194
+ openBrowser(controller.url);
195
+ process.stdout.write(` opening browser\u2026
196
+ `);
197
+ }
198
+ } else {
199
+ const selfExit = () => {
200
+ void shutdown(0);
201
+ };
202
+ process.stdin.on("end", selfExit);
203
+ process.stdin.on("close", selfExit);
204
+ process.stdin.on("error", selfExit);
205
+ process.stdin.resume();
206
+ process.stdout.write(JSON.stringify({ ready: 1, url: controller.url, port: controller.port, wsToken: controller.wsToken, version }) + "\n");
207
+ }
208
+ await new Promise(() => {
209
+ });
210
+ }
211
+ export {
212
+ runDaemon
213
+ };
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/client/daemon-handle.ts
4
+ import { spawn } from "child_process";
5
+ import { extname } from "path";
6
+ var HANDSHAKE_TIMEOUT_MS = 3e3;
7
+ function runtimeExecArgv(entry, override) {
8
+ if (override) return override;
9
+ const ext = extname(entry).toLowerCase();
10
+ if (ext !== ".ts" && ext !== ".tsx" && ext !== ".mts" && ext !== ".cts") return [];
11
+ const keepFlags = ["--require", "--import", "--loader"];
12
+ const out = [];
13
+ const src = process.execArgv;
14
+ for (let i = 0; i < src.length; i++) {
15
+ const a = src[i];
16
+ if (a.startsWith("--experimental-")) {
17
+ out.push(a);
18
+ continue;
19
+ }
20
+ const matched = keepFlags.find((f) => a === f || a.startsWith(f + "="));
21
+ if (!matched) continue;
22
+ out.push(a);
23
+ if (a === matched && i + 1 < src.length) out.push(src[++i]);
24
+ }
25
+ return out;
26
+ }
27
+ function parseHandshake(line) {
28
+ try {
29
+ const o = JSON.parse(line);
30
+ if (o && o.ready === 1 && typeof o.url === "string" && typeof o.wsToken === "string") return o;
31
+ return null;
32
+ } catch {
33
+ return null;
34
+ }
35
+ }
36
+ function attachOrSpawn(opts = {}) {
37
+ const entry = opts.entry ?? process.argv[1];
38
+ const execPath = opts.execPath ?? process.execPath;
39
+ const timeoutMs = opts.timeoutMs ?? HANDSHAKE_TIMEOUT_MS;
40
+ if (!entry) return Promise.resolve(degraded());
41
+ return new Promise((resolve) => {
42
+ const args = ["__daemon", "--port", "0", "--no-open"];
43
+ const execArgv = runtimeExecArgv(entry, opts.execArgv);
44
+ let child;
45
+ try {
46
+ child = spawn(execPath, [...execArgv, entry, ...args], {
47
+ stdio: ["pipe", "pipe", "ignore"],
48
+ detached: false
49
+ });
50
+ } catch {
51
+ resolve(degraded());
52
+ return;
53
+ }
54
+ let settled = false;
55
+ let stdoutBuf = "";
56
+ let stopped = false;
57
+ const onExit = () => {
58
+ try {
59
+ if (!stopped) child.kill("SIGTERM");
60
+ } catch {
61
+ }
62
+ };
63
+ const onSignal = () => {
64
+ onExit();
65
+ };
66
+ process.once("exit", onExit);
67
+ process.once("SIGINT", onSignal);
68
+ process.once("SIGTERM", onSignal);
69
+ const removeHooks = () => {
70
+ process.removeListener("exit", onExit);
71
+ process.removeListener("SIGINT", onSignal);
72
+ process.removeListener("SIGTERM", onSignal);
73
+ };
74
+ const stop = () => {
75
+ if (stopped) return;
76
+ stopped = true;
77
+ removeHooks();
78
+ try {
79
+ child.kill("SIGTERM");
80
+ } catch {
81
+ }
82
+ };
83
+ const timer = setTimeout(() => {
84
+ if (settled) return;
85
+ settled = true;
86
+ try {
87
+ child.kill("SIGTERM");
88
+ } catch {
89
+ }
90
+ removeHooks();
91
+ resolve(degraded());
92
+ }, timeoutMs);
93
+ timer.unref?.();
94
+ const finishSpawned = (url, wsToken) => {
95
+ if (settled) return;
96
+ settled = true;
97
+ clearTimeout(timer);
98
+ child.stdout?.resume();
99
+ resolve({ kind: "spawned", baseUrl: url, wsToken, stop });
100
+ };
101
+ const finishDegraded = () => {
102
+ if (settled) return;
103
+ settled = true;
104
+ clearTimeout(timer);
105
+ try {
106
+ child.kill("SIGTERM");
107
+ } catch {
108
+ }
109
+ removeHooks();
110
+ resolve(degraded());
111
+ };
112
+ child.stdout?.setEncoding("utf-8");
113
+ child.stdout?.on("data", (chunk) => {
114
+ if (settled) return;
115
+ stdoutBuf += chunk;
116
+ let nl;
117
+ while ((nl = stdoutBuf.indexOf("\n")) !== -1) {
118
+ const line = stdoutBuf.slice(0, nl).trim();
119
+ stdoutBuf = stdoutBuf.slice(nl + 1);
120
+ if (!line) continue;
121
+ const hs = parseHandshake(line);
122
+ if (hs) {
123
+ finishSpawned(hs.url, hs.wsToken);
124
+ return;
125
+ }
126
+ finishDegraded();
127
+ return;
128
+ }
129
+ });
130
+ child.once("error", finishDegraded);
131
+ child.once("exit", () => {
132
+ if (!settled) finishDegraded();
133
+ });
134
+ });
135
+ }
136
+ function degraded() {
137
+ return { kind: "degraded", baseUrl: null, wsToken: null, stop: () => {
138
+ } };
139
+ }
140
+ export {
141
+ attachOrSpawn
142
+ };
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ GLYPHS_ASCII,
4
+ GLYPHS_UNICODE,
5
+ detectUnicode,
6
+ glyphs,
7
+ resolveGlyphs,
8
+ setGlyphs
9
+ } from "./chunk-RF4GGQGM.js";
10
+ export {
11
+ GLYPHS_ASCII,
12
+ GLYPHS_UNICODE,
13
+ detectUnicode,
14
+ glyphs,
15
+ resolveGlyphs,
16
+ setGlyphs
17
+ };
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ startWebServer
4
+ } from "./chunk-A6RQRHRO.js";
5
+ import "./chunk-MB6LRSEZ.js";
6
+ import "./chunk-MVMPQJ5S.js";
7
+ export {
8
+ startWebServer
9
+ };
@@ -1,4 +1,4 @@
1
- import{R as h,g as Qe,r as J,j as u,P as fe,E as pe,a as Ye,s as ee,b as G,c as z,d as Je,T as re}from"./index-mgYwFiX4.js";import{c as I,a as k,y as et,z as xt,B as tt,F as At,i as C,H as Pe,I as T,L as _,J as nt,K as Oe,M as rt,D as kt,C as Pt,e as W,j as F,S as Ot,A as jt,N as _t,b as De,d as wt,l as M,g as je,u as St,G as Tt,O as ae,f as Et,P as _e,Q as Rt,U as ie,V as Be,o as it,W as we,X as Se,Y as Te,p as It,Z as Nt,q as Ee,_ as at,r as Re,R as Ie,s as ot,t as st,v as se,T as ct,x as Ne}from"./chart-C6EyXc8D.js";var Lt=["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 $t(n,e){if(n==null)return{};var r=Ct(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Ct(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 Ke(n){return Ft(n)||Kt(n)||Bt(n)||Dt()}function Dt(){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 Bt(n,e){if(n){if(typeof n=="string")return be(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 be(n,e)}}function Kt(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Ft(n){if(Array.isArray(n))return be(n)}function be(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 Fe=function(e){return e&&e.x===+e.x&&e.y===+e.y},Mt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return e.forEach(function(t){Fe(t)?r[r.length-1].push(t):r[r.length-1].length>0&&r.push([])}),Fe(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=Mt(e);r&&(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},Vt=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))},qt=function(e){var r=e.points,t=e.className,i=e.baseLinePoints,a=e.connectNulls,o=$t(e,Lt);if(!r||!r.length)return null;var c=I("recharts-polygon",t);if(i&&i.length){var f=o.stroke&&o.stroke!=="none",s=Vt(r,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(r,a)})):null,f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(i,a)})):null)}var p=Q(r,a);return h.createElement("path",V({},k(o,!0),{fill:p.slice(-1)==="Z"?o.fill:"none",className:c,d:p}))},ye,Me;function zt(){if(Me)return ye;Me=1;var n=et(),e=xt(),r=tt();function t(i,a){return i&&i.length?n(i,r(a,2),e):void 0}return ye=t,ye}var Wt=zt();const Gt=Qe(Wt);var ge,Ve;function Ht(){if(Ve)return ge;Ve=1;var n=et(),e=tt(),r=At();function t(i,a){return i&&i.length?n(i,e(a,2),r):void 0}return ge=t,ge}var Zt=Ht();const Ut=Qe(Zt);var Xt=["cx","cy","angle","ticks","axisLine"],Qt=["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){de(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 ze(n,e){if(n==null)return{};var r=Yt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Yt(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 Jt(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function We(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,ut(t.key),t)}}function en(n,e,r){return e&&We(n.prototype,e),r&&We(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function tn(n,e,r){return e=ce(e),nn(n,lt()?Reflect.construct(e,r||[],ce(n).constructor):e.apply(n,r))}function nn(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 rn(n)}function rn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function lt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lt=function(){return!!n})()}function ce(n){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ce(n)}function an(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&&xe(n,e)}function xe(n,e){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},xe(n,e)}function de(n,e,r){return e=ut(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function ut(n){var e=on(n,"string");return H(e)=="symbol"?e:e+""}function on(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(e==="string"?String:Number)(n)}var me=(function(n){function e(){return Jt(this,e),tn(this,e,arguments)}return an(e,n),en(e,[{key:"getTickValueCoord",value:function(t){var i=t.coordinate,a=this.props,o=a.angle,c=a.cx,f=a.cy;return T(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=Gt(c,function(p){return p.coordinate||0}),s=Ut(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,Xt),p=c.reduce(function(m,l){return[Math.min(m[0],l.coordinate),Math.max(m[1],l.coordinate)]},[1/0,-1/0]),d=T(i,a,p[0],o),v=T(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,Qt),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",nt(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(),rt.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 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 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 Ge(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?Ge(Object(r),!0).forEach(function(t){ve(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ge(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function sn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function He(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,pt(t.key),t)}}function cn(n,e,r){return e&&He(n.prototype,e),r&&He(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function ln(n,e,r){return e=le(e),un(n,ft()?Reflect.construct(e,r||[],le(n).constructor):e.apply(n,r))}function un(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 fn(n)}function fn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function ft(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ft=function(){return!!n})()}function le(n){return le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},le(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&&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 ve(n,e,r){return e=pt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function pt(n){var e=dn(n,"string");return Z(e)=="symbol"?e:e+""}function dn(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(e==="string"?String:Number)(n)}var mn=Math.PI/180,Ze=1e-5,he=(function(n){function e(){return sn(this,e),ln(this,e,arguments)}return pn(e,n),cn(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=T(a,o,c,t.coordinate),v=T(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*mn),o;return a>Ze?o=i==="outer"?"start":"end":a<-Ze?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(kt,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 T(i,a,o,v.coordinate)});return h.createElement(qt,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",nt(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 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 q(){return q=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},q.apply(this,arguments)}function Ue(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?Ue(Object(r),!0).forEach(function(t){O(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ue(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function vn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Xe(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,mt(t.key),t)}}function hn(n,e,r){return e&&Xe(n.prototype,e),r&&Xe(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function yn(n,e,r){return e=ue(e),gn(n,dt()?Reflect.construct(e,r||[],ue(n).constructor):e.apply(n,r))}function gn(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 bn(n)}function bn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function dt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dt=function(){return!!n})()}function ue(n){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(n)}function xn(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 O(n,e,r){return e=mt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function mt(n){var e=An(n,"string");return U(e)=="symbol"?e:e+""}function An(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 E=(function(n){function e(r){var t;return vn(this,e),t=yn(this,e,[r]),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:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},t}return xn(e,n),hn(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=T(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:[T(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(Ot,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(jt,{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?_t(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,S=j.startAngle,te=De(0,K-S),ne=te(l),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(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||!wt(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),rt.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(Pt,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:!Tt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});O(E,"parseDeltaAngle",function(n,e){var r=ae(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=Et(r,_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(n,e){var r=e.top,t=e.left,i=e.width,a=e.height,o=Rt(i,a),c=t+ie(n.cx,i,i/2),f=r+ie(n.cy,a,a/2),s=ie(n.innerRadius,o,0),p=ie(n.outerRadius,o,o*.8),d=n.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:c,cy:f,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=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,r),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,
1
+ import{R as h,g as Qe,r as J,j as u,P as fe,E as pe,a as Ye,s as ee,b as G,c as z,d as Je,e as xt,T as re}from"./index-vqWRGYnh.js";import{c as I,a as k,z as et,B as At,F as tt,H as kt,i as C,I as Pe,J as S,L as _,K as nt,M as Oe,N as rt,D as Pt,C as Ot,e as W,j as F,S as jt,A as _t,O as wt,b as De,d as Tt,l as M,g as je,u as St,G as Et,P as ae,f as Rt,Q as _e,U as It,V as ie,W as Be,o as it,Z as we,X as Te,Y as Se,p as Nt,_ as Lt,q as Ee,$ as at,r as Re,R as Ie,s as ot,t as st,v as se,T as ct,x as Ne}from"./chart-CFynoGh5.js";var $t=["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 Ct(n,e){if(n==null)return{};var r=Dt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Dt(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 Ke(n){return Mt(n)||Ft(n)||Kt(n)||Bt()}function Bt(){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 Kt(n,e){if(n){if(typeof n=="string")return be(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 be(n,e)}}function Ft(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Mt(n){if(Array.isArray(n))return be(n)}function be(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 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]:[],r=[[]];return e.forEach(function(t){Fe(t)?r[r.length-1].push(t):r[r.length-1].length>0&&r.push([])}),Fe(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=Vt(e);r&&(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,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))},zt=function(e){var r=e.points,t=e.className,i=e.baseLinePoints,a=e.connectNulls,o=Ct(e,$t);if(!r||!r.length)return null;var c=I("recharts-polygon",t);if(i&&i.length){var f=o.stroke&&o.stroke!=="none",s=qt(r,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(r,a)})):null,f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(i,a)})):null)}var p=Q(r,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 n=et(),e=At(),r=tt();function t(i,a){return i&&i.length?n(i,r(a,2),e):void 0}return ye=t,ye}var Gt=Wt();const Ht=Qe(Gt);var ge,Ve;function Zt(){if(Ve)return ge;Ve=1;var n=et(),e=tt(),r=kt();function t(i,a){return i&&i.length?n(i,e(a,2),r):void 0}return ge=t,ge}var Ut=Zt();const Xt=Qe(Ut);var Qt=["cx","cy","angle","ticks","axisLine"],Yt=["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){de(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 ze(n,e){if(n==null)return{};var r=Jt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Jt(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 en(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function We(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,ut(t.key),t)}}function tn(n,e,r){return e&&We(n.prototype,e),r&&We(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function nn(n,e,r){return e=ce(e),rn(n,lt()?Reflect.construct(e,r||[],ce(n).constructor):e.apply(n,r))}function rn(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 an(n)}function an(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function lt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lt=function(){return!!n})()}function ce(n){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ce(n)}function on(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&&xe(n,e)}function xe(n,e){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},xe(n,e)}function de(n,e,r){return e=ut(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function ut(n){var e=sn(n,"string");return H(e)=="symbol"?e:e+""}function sn(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(e==="string"?String:Number)(n)}var me=(function(n){function e(){return en(this,e),nn(this,e,arguments)}return on(e,n),tn(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",nt(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(),rt.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 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 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 Ge(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?Ge(Object(r),!0).forEach(function(t){ve(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ge(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function cn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function He(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,pt(t.key),t)}}function ln(n,e,r){return e&&He(n.prototype,e),r&&He(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function un(n,e,r){return e=le(e),fn(n,ft()?Reflect.construct(e,r||[],le(n).constructor):e.apply(n,r))}function fn(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 pn(n)}function pn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function ft(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ft=function(){return!!n})()}function le(n){return le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},le(n)}function dn(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 ve(n,e,r){return e=pt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function pt(n){var e=mn(n,"string");return Z(e)=="symbol"?e:e+""}function mn(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(e==="string"?String:Number)(n)}var vn=Math.PI/180,Ze=1e-5,he=(function(n){function e(){return cn(this,e),un(this,e,arguments)}return dn(e,n),ln(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*vn),o;return a>Ze?o=i==="outer"?"start":"end":a<-Ze?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",nt(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 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 q(){return q=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},q.apply(this,arguments)}function Ue(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?Ue(Object(r),!0).forEach(function(t){O(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ue(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function hn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Xe(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,mt(t.key),t)}}function yn(n,e,r){return e&&Xe(n.prototype,e),r&&Xe(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function gn(n,e,r){return e=ue(e),bn(n,dt()?Reflect.construct(e,r||[],ue(n).constructor):e.apply(n,r))}function bn(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 xn(n)}function xn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function dt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dt=function(){return!!n})()}function ue(n){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(n)}function An(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 O(n,e,r){return e=mt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function mt(n){var e=kn(n,"string");return U(e)=="symbol"?e:e+""}function kn(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 E=(function(n){function e(r){var t;return hn(this,e),t=gn(this,e,[r]),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:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},t}return An(e,n),yn(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),ne=te(l),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(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),rt.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(n,e){var r=ae(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=Rt(r,_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(n,e){var r=e.top,t=e.left,i=e.width,a=e.height,o=It(i,a),c=t+ie(n.cx,i,i/2),f=r+ie(n.cy,a,a/2),s=ie(n.innerRadius,o,0),p=ie(n.outerRadius,o,o*.8),d=n.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:c,cy:f,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=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,r),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
- 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 S=F(K,b,0);return P+(M(S)?S:0)},0),N;if(w>0){var X;N=i.map(function(P,K){var S=F(P,b,0),te=F(P,p,K),ne=(M(S)?S:0)/w,R;K?R=X.endAngle+ae(l)*f*(S!==0?1:0):R=o;var Le=R+ae(l)*((S!==0?A:0)+ne*B),$e=(R+Le)/2,Ce=(m.innerRadius+m.outerRadius)/2,gt=[{name:te,value:S,payload:P,dataKey:b,type:v}],bt=T(m.cx,m.cy,Ce,$e);return X=y(y(y({percent:ne,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:we,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Se},{axisType:"yAxis",AxisComp:Te}],formatAxisMap:It}),kn=it({chartName:"PieChart",GraphicalChild:E,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:he},{axisType:"radiusAxis",AxisComp:me}],formatAxisMap:Nt,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)"},Pn=Ne(n=>{var e,r;return[{label:"cost",value:G(((e=n[0])==null?void 0:e.value)??0),color:(r=n[0])==null?void 0:r.color}]},{title:n=>ee(n)}),On=Ne(n=>{var e,r;return[{label:"tokens",value:z(((e=n[0])==null?void 0:e.value)??0),color:(r=n[0])==null?void 0:r.color}]},{title:n=>ee(n)}),jn=Ne(n=>{var e,r;return[{label:"saved",value:G(((e=n[0])==null?void 0:e.value)??0),color:(r=n[0])==null?void 0:r.color}]},{title:n=>ee(n)});function Sn({derived:n,height:e=280,limit:r=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=[...n.byModel].sort((d,v)=>s?v.tokens-d.tokens:v.cost-d.cost).slice(0,r);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(Se,{type:"number",...se,tickFormatter:s?z:Ye}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:c,tickFormatter:ee}),u.jsx(ct,{content:s?On:Pn,cursor:ht}),u.jsxs(we,{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 Tn({derived:n,height:e=240,limit:r=12,periodLabel:t}){const i=Ee(),a=at("(min-width: 768px)"),o=a?124:92,c=a?60:44,f=[...n.byModel].filter(s=>s.cacheSavings>0).sort((s,p)=>p.cacheSavings-s.cacheSavings).slice(0,r);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(Se,{type:"number",...se,tickFormatter:Ye}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:o,tickFormatter:ee}),u.jsx(ct,{content:jn,cursor:ht}),u.jsx(we,{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 En({derived:n,height:e=280,periodLabel:r}){const t=Ee(),i=n.byProvider,a=n.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:r,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(kn,{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 Rn({derived:n,periodLabel:e}){const r=n.tokenComposition,t=r.input+r.output+r.cacheCreate+r.cacheRead,i=[{key:"cacheRead",label:"cache read",value:r.cacheRead,color:re.cacheRead},{key:"input",label:"input",value:r.input,color:re.input},{key:"output",label:"output",value:r.output,color:re.output},{key:"cacheCreate",label:"cache write",value:r.cacheCreate,color:re.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{Tn as CacheByModel,Sn as CostByModel,En as ProviderDonut,Rn as TokenComposition};
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),ne=(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)+ne*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:ne,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:we,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Te},{axisType:"yAxis",AxisComp:Se}],formatAxisMap:Nt}),Pn=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)"},On=Ne("cost",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),jn=Ne("tokens",z,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),_n=Ne("saved",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)});function Sn({derived:n,height:e=280,limit:r=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=[...n.byModel].sort((d,v)=>s?v.tokens-d.tokens:v.cost-d.cost).slice(0,r);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(Te,{type:"number",...se,tickFormatter:s?z:Ye}),u.jsx(Se,{type:"category",dataKey:"model",...se,width:c,tickFormatter:ee}),u.jsx(ct,{content:s?jn:On,cursor:ht}),u.jsxs(we,{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 En({derived:n,height:e=240,limit:r=12,periodLabel:t}){const i=Ee(),a=at("(min-width: 768px)"),o=a?124:92,c=a?60:44,f=[...n.byModel].filter(s=>s.cacheSavings>0).sort((s,p)=>p.cacheSavings-s.cacheSavings).slice(0,r);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(Te,{type:"number",...se,tickFormatter:Ye}),u.jsx(Se,{type:"category",dataKey:"model",...se,width:o,tickFormatter:ee}),u.jsx(ct,{content:_n,cursor:ht}),u.jsx(we,{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 Rn({derived:n,height:e=280,periodLabel:r}){const t=Ee(),i=n.byProvider,a=n.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:r,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(Pn,{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 In({derived:n,periodLabel:e}){const r=n.tokenComposition,t=xt(r),i=[{key:"cacheRead",label:"cache read",value:r.cacheRead,color:re.cacheRead},{key:"input",label:"input",value:r.input,color:re.input},{key:"output",label:"output",value:r.output,color:re.output},{key:"cacheCreate",label:"cache write",value:r.cacheCreate,color:re.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{En as CacheByModel,Sn as CostByModel,Rn as ProviderDonut,In as TokenComposition};