tokmon 0.28.2 → 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-IMT3S5HU.js → bootstrap-ink-WG4WG3R2.js} +1579 -1136
- package/dist/chunk-7CH6S7BR.js +447 -0
- package/dist/{chunk-LCAHTRGP.js → chunk-CFKUZCMB.js} +56 -29
- package/dist/chunk-HNWEJ6MS.js +1094 -0
- package/dist/{chunk-WUK3MQUB.js → chunk-JZSZEHVD.js} +167 -10
- package/dist/{chunk-6ZEW2M6P.js → chunk-P57DVFNH.js} +125 -25
- package/dist/{chunk-LKYOWBD4.js → chunk-P5JN5DDX.js} +21 -42
- package/dist/chunk-TN6V7XSL.js +512 -0
- package/dist/{chunk-J3JW3RFP.js → chunk-USKOQIE3.js} +95 -13
- package/dist/chunk-UYPDMVW5.js +21 -0
- package/dist/{cli-command-DCENRCO3.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-44ZSQEOS.js +0 -299
- package/dist/chunk-HP5UZCXP.js +0 -436
- package/dist/chunk-M7XMV36F.js +0 -275
- package/dist/daemon-6Y4O7NXS.js +0 -241
- package/dist/daemon-handle-GVCYVDPO.js +0 -10
- package/dist/server-GXXOWUVZ.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
package/dist/daemon-6Y4O7NXS.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
acquireLock,
|
|
4
|
-
isAlive,
|
|
5
|
-
readLock,
|
|
6
|
-
reclaimAbandonedLock,
|
|
7
|
-
reclaimDeadLock,
|
|
8
|
-
unlinkLock,
|
|
9
|
-
verifyLock,
|
|
10
|
-
writeLock
|
|
11
|
-
} from "./chunk-J3JW3RFP.js";
|
|
12
|
-
import {
|
|
13
|
-
appVersion,
|
|
14
|
-
startWebServer
|
|
15
|
-
} from "./chunk-6ZEW2M6P.js";
|
|
16
|
-
import "./chunk-44ZSQEOS.js";
|
|
17
|
-
import {
|
|
18
|
-
flushDisk
|
|
19
|
-
} from "./chunk-LCAHTRGP.js";
|
|
20
|
-
import {
|
|
21
|
-
TOKMON_CAPABILITIES,
|
|
22
|
-
TOKMON_PROTOCOL_VERSION
|
|
23
|
-
} from "./chunk-WUK3MQUB.js";
|
|
24
|
-
import {
|
|
25
|
-
loadConfig
|
|
26
|
-
} from "./chunk-HP5UZCXP.js";
|
|
27
|
-
|
|
28
|
-
// src/web/daemon.ts
|
|
29
|
-
import { randomBytes } from "crypto";
|
|
30
|
-
|
|
31
|
-
// src/web/open.ts
|
|
32
|
-
import { spawn } from "child_process";
|
|
33
|
-
import { appendFileSync } from "fs";
|
|
34
|
-
function openBrowser(url) {
|
|
35
|
-
const target = url;
|
|
36
|
-
if (process.env.TOKMON_OPENLOG) {
|
|
37
|
-
try {
|
|
38
|
-
appendFileSync(process.env.TOKMON_OPENLOG, target + "\n");
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
if (process.platform === "darwin") {
|
|
45
|
-
spawn("open", [target], { stdio: "ignore", detached: true }).unref();
|
|
46
|
-
} else if (process.platform === "win32") {
|
|
47
|
-
spawn("cmd", ["/c", "start", "", target], { stdio: "ignore", detached: true }).unref();
|
|
48
|
-
} else {
|
|
49
|
-
spawn("xdg-open", [target], { stdio: "ignore", detached: true }).unref();
|
|
50
|
-
}
|
|
51
|
-
} catch {
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// src/web/daemon.ts
|
|
56
|
-
function parseDaemonArgs(args) {
|
|
57
|
-
let port;
|
|
58
|
-
let open = true;
|
|
59
|
-
let help = false;
|
|
60
|
-
for (let i = 0; i < args.length; i++) {
|
|
61
|
-
const arg = args[i];
|
|
62
|
-
if ((arg === "--port" || arg === "-p") && args[i + 1]) port = Number(args[++i]);
|
|
63
|
-
else if (arg.startsWith("--port=")) port = Number(arg.slice("--port=".length));
|
|
64
|
-
else if (arg === "--no-open") open = false;
|
|
65
|
-
else if (arg === "--help" || arg === "-h") help = true;
|
|
66
|
-
}
|
|
67
|
-
if (port !== void 0 && (!Number.isInteger(port) || port < 0 || port > 65535)) port = void 0;
|
|
68
|
-
return { port, open, help };
|
|
69
|
-
}
|
|
70
|
-
var SERVE_HELP = `tokmon serve - Launch the tokmon web dashboard
|
|
71
|
-
|
|
72
|
-
Usage: tokmon serve [options]
|
|
73
|
-
|
|
74
|
-
Options:
|
|
75
|
-
-p, --port <n> Port to listen on (default: 4317, auto-falls back if taken)
|
|
76
|
-
--no-open Don't open the browser automatically
|
|
77
|
-
-h, --help Show this help
|
|
78
|
-
`;
|
|
79
|
-
function handshake(lock) {
|
|
80
|
-
process.stdout.write(JSON.stringify({
|
|
81
|
-
ready: 1,
|
|
82
|
-
url: lock.url,
|
|
83
|
-
port: lock.port,
|
|
84
|
-
wsToken: lock.wsToken,
|
|
85
|
-
version: lock.version,
|
|
86
|
-
protocolVersion: lock.protocolVersion,
|
|
87
|
-
capabilities: lock.capabilities,
|
|
88
|
-
ownerKind: lock.ownerKind
|
|
89
|
-
}) + "\n");
|
|
90
|
-
}
|
|
91
|
-
function describeExisting(lock, open) {
|
|
92
|
-
process.stdout.write(`
|
|
93
|
-
\u25C6 tokmon web \u2192 ${lock.url}
|
|
94
|
-
`);
|
|
95
|
-
process.stdout.write(" reusing the live singleton daemon\n\n");
|
|
96
|
-
if (open) {
|
|
97
|
-
openBrowser(lock.url);
|
|
98
|
-
process.stdout.write(" opening browser\u2026\n");
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function runDaemon(args, opts) {
|
|
102
|
-
const { port, open, help } = parseDaemonArgs(args);
|
|
103
|
-
if (help && opts.foreground) {
|
|
104
|
-
process.stdout.write(SERVE_HELP);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const version = appVersion();
|
|
108
|
-
let current = readLock();
|
|
109
|
-
if (!current && reclaimAbandonedLock()) current = readLock();
|
|
110
|
-
const live = await verifyLock(current, TOKMON_PROTOCOL_VERSION);
|
|
111
|
-
if (live) {
|
|
112
|
-
if (opts.foreground) describeExisting(live, open);
|
|
113
|
-
else handshake(live);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (current?.state === "starting" && current.protocolVersion === TOKMON_PROTOCOL_VERSION && isAlive(current.pid)) {
|
|
117
|
-
for (let attempt = 0; attempt < 60; attempt++) {
|
|
118
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
119
|
-
const winner = await verifyLock(readLock(), TOKMON_PROTOCOL_VERSION, 250);
|
|
120
|
-
if (winner) {
|
|
121
|
-
if (opts.foreground) describeExisting(winner, open);
|
|
122
|
-
else handshake(winner);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (current && isAlive(current.pid)) {
|
|
128
|
-
const message = "tokmon: another daemon owns the lock but could not be verified (version/token mismatch)";
|
|
129
|
-
if (opts.foreground) {
|
|
130
|
-
process.stderr.write(message + "\n");
|
|
131
|
-
process.exitCode = 1;
|
|
132
|
-
}
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (current) reclaimDeadLock();
|
|
136
|
-
const ownerId = randomBytes(32).toString("base64url");
|
|
137
|
-
const token = randomBytes(32).toString("base64url");
|
|
138
|
-
const reservation = {
|
|
139
|
-
pid: process.pid,
|
|
140
|
-
port: 0,
|
|
141
|
-
url: "",
|
|
142
|
-
wsToken: token,
|
|
143
|
-
version,
|
|
144
|
-
protocolVersion: TOKMON_PROTOCOL_VERSION,
|
|
145
|
-
capabilities: [...TOKMON_CAPABILITIES],
|
|
146
|
-
ownerKind: "cli",
|
|
147
|
-
startedAt: Date.now(),
|
|
148
|
-
ownerId,
|
|
149
|
-
state: "starting"
|
|
150
|
-
};
|
|
151
|
-
if (!acquireLock(reservation)) {
|
|
152
|
-
for (let attempt = 0; attempt < 60; attempt++) {
|
|
153
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
154
|
-
const winner = await verifyLock(readLock(), TOKMON_PROTOCOL_VERSION, 250);
|
|
155
|
-
if (winner) {
|
|
156
|
-
if (opts.foreground) describeExisting(winner, open);
|
|
157
|
-
else handshake(winner);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (opts.foreground) {
|
|
162
|
-
process.stderr.write("tokmon: daemon startup is already in progress\n");
|
|
163
|
-
process.exitCode = 1;
|
|
164
|
-
}
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
let controller = null;
|
|
168
|
-
try {
|
|
169
|
-
const config = await loadConfig();
|
|
170
|
-
controller = await startWebServer({
|
|
171
|
-
config,
|
|
172
|
-
port,
|
|
173
|
-
log: opts.foreground,
|
|
174
|
-
wsToken: token,
|
|
175
|
-
ownerKind: reservation.ownerKind,
|
|
176
|
-
protocolVersion: reservation.protocolVersion,
|
|
177
|
-
capabilities: reservation.capabilities
|
|
178
|
-
});
|
|
179
|
-
const ready = {
|
|
180
|
-
...reservation,
|
|
181
|
-
port: controller.port,
|
|
182
|
-
url: controller.url,
|
|
183
|
-
state: "ready"
|
|
184
|
-
};
|
|
185
|
-
if (!writeLock(ready)) throw new Error("lost daemon lock ownership during startup");
|
|
186
|
-
let shuttingDown = false;
|
|
187
|
-
const shutdown = async (exitCode = 0) => {
|
|
188
|
-
if (shuttingDown) return;
|
|
189
|
-
shuttingDown = true;
|
|
190
|
-
if (opts.foreground) process.stdout.write("\n stopping tokmon web\u2026\n");
|
|
191
|
-
try {
|
|
192
|
-
await controller?.stop();
|
|
193
|
-
} catch {
|
|
194
|
-
}
|
|
195
|
-
await flushDisk().catch(() => {
|
|
196
|
-
});
|
|
197
|
-
unlinkLock(ownerId);
|
|
198
|
-
process.exit(exitCode);
|
|
199
|
-
};
|
|
200
|
-
process.once("exit", () => {
|
|
201
|
-
unlinkLock(ownerId);
|
|
202
|
-
});
|
|
203
|
-
process.once("SIGINT", () => {
|
|
204
|
-
void shutdown(0);
|
|
205
|
-
});
|
|
206
|
-
process.once("SIGTERM", () => {
|
|
207
|
-
void shutdown(0);
|
|
208
|
-
});
|
|
209
|
-
if (opts.foreground) {
|
|
210
|
-
process.stdout.write(`
|
|
211
|
-
\u25C6 tokmon web \u2192 ${controller.url}
|
|
212
|
-
`);
|
|
213
|
-
process.stdout.write(" live dashboard \xB7 Ctrl-C to stop\n\n");
|
|
214
|
-
if (config.allowNetworkAccess) {
|
|
215
|
-
process.stdout.write(" \u26A0 unsafe network access enabled \u2014 dashboard is reachable from your LAN\n\n");
|
|
216
|
-
}
|
|
217
|
-
if (open) {
|
|
218
|
-
openBrowser(controller.url);
|
|
219
|
-
process.stdout.write(" opening browser\u2026\n");
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
handshake(ready);
|
|
223
|
-
}
|
|
224
|
-
await new Promise(() => {
|
|
225
|
-
});
|
|
226
|
-
} catch (error) {
|
|
227
|
-
try {
|
|
228
|
-
await controller?.stop();
|
|
229
|
-
} catch {
|
|
230
|
-
}
|
|
231
|
-
unlinkLock(ownerId);
|
|
232
|
-
const message = `tokmon: failed to start web server: ${error.message}`;
|
|
233
|
-
if (opts.foreground) {
|
|
234
|
-
process.stderr.write(message + "\n");
|
|
235
|
-
process.exitCode = 1;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export {
|
|
240
|
-
runDaemon
|
|
241
|
-
};
|
package/dist/server-GXXOWUVZ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./breakdown-kOSSJ3mI.js","./index-DH3dOnbg.js","./index-BErCXT7f.css","./chart-cZoLgpmG.js","./panel-DTQBwExW.js","./primitives-C36qJlA2.js","./timeline-B4uG-Emo.js","./Area-CMXvOw33.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{h as D,i as j,k as A,D as k,M as z,r as x,j as e,e as T,f as C,a as E,b as I,m as $,s as B,_ as M}from"./index-DH3dOnbg.js";import{P as F}from"./panel-DTQBwExW.js";import{a as w}from"./primitives-C36qJlA2.js";const R=[0,.32,.55,.78,1],S=t=>t===0?"var(--color-bg-2)":`color-mix(in oklab, var(--color-cost) ${R[t]*100}%, var(--color-bg-2))`,L=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function O(t,n){const i=t,c=i.filter(l=>n(l)>0);if(c.length===0)return null;const h=i.reduce((l,a)=>l+n(a),0),d=c.reduce((l,a)=>n(a)>n(l)?a:l),p=new Array(7).fill(0);for(const l of i)p[D(j(l.date))]+=n(l);const m=p.indexOf(Math.max(...p)),f=new Set(c.map(l=>l.date));let v=0;for(let l=j(c[c.length-1].date);f.has(A(l));l-=k)v++;return{active:c.length,total:h,top:d,avg:h/c.length,busiest:m,streak:v,costed:t.some(l=>l.cost>0)}}function V(t,n,i){const c=new Map(t.map(s=>[s.date,i(s)]));if(t.length===0)return null;const h=t[t.length-1].date,d=t[0].date;let p=j(h),m=j(d);(p-m)/(k*7)>n&&(m=p-n*7*k),m-=D(m)*k;const f=Math.max(...t.map(i),0),v=s=>{if(s<=0||f<=0)return 0;const r=s/f;return r>.66?4:r>.4?3:r>.15?2:1},l=[];let a=new Array(7).fill(null);const u=[];let b=-1,N=0;for(let s=m;s<=p;s+=k){const r=A(s),o=D(s);o===0&&a.some(Boolean)&&(l.push(a),a=new Array(7).fill(null),N++);const g=new Date(s).getUTCMonth();g!==b&&o===0&&(u.push({col:N,text:z[g]}),b=g);const y=s>=j(d);a[o]=y?{date:r,cost:c.get(r)??0,level:v(c.get(r)??0)}:null}return a.some(Boolean)&&l.push(a),{weeks:l,monthLabels:u}}function H({derived:t,maxWeeks:n=26,periodLabel:i}){const[c,h]=x.useState(null),[d,p]=x.useState(null),m=c??d,f=x.useMemo(()=>new Map(t.calendar.map(s=>[s.date,s])),[t.calendar]),v=x.useMemo(()=>t.calendar.some(s=>s.cost>0),[t.calendar]),l=s=>v?s.cost:s.tokens,a=x.useMemo(()=>O(t.calendar,l),[t,v]),u=x.useMemo(()=>V(t.calendar,n,l),[t,n]),b=u?`repeat(${u.weeks.length}, minmax(0,1fr))`:void 0,N=u?u.weeks.length*25:void 0;return e.jsx(e.Fragment,{children:e.jsx(F,{title:"daily spend",titleTag:i,captureName:"calendar",children:!u||!a?e.jsx("div",{className:"py-6 text-center text-xs text-fg-faint",children:"no usage yet"}):e.jsxs("div",{className:"grid gap-x-8 gap-y-5 pt-1 md:grid-cols-[minmax(0,1fr)_210px] md:items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("div",{className:"pl-6",children:e.jsx("div",{className:"grid gap-[3px] text-[9px] text-fg-faint",style:{gridTemplateColumns:b,maxWidth:N},children:u.weeks.map((s,r)=>{const o=u.monthLabels.find(g=>g.col===r);return e.jsx("div",{className:"truncate",children:(o==null?void 0:o.text)??""},r)})})}),e.jsxs("div",{className:"flex gap-[3px]",children:[e.jsx("div",{className:"flex w-5 shrink-0 flex-col gap-[3px] text-[9px] text-fg-faint",children:["M","","W","","F","",""].map((s,r)=>e.jsx("div",{className:"flex flex-1 items-center",children:s},r))}),e.jsx("div",{className:"grid min-w-0 flex-1 gap-[3px]",style:{gridTemplateColumns:b,maxWidth:N},onMouseLeave:()=>h(null),children:u.weeks.map((s,r)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:s.map((o,g)=>o===null?e.jsx("div",{className:"aspect-square"},g):e.jsx("button",{type:"button","aria-label":`${T(o.date)} — click to pin`,"aria-pressed":(d==null?void 0:d.date)===o.date,className:`aspect-square block rounded-[3px] p-0 transition duration-150 hover:scale-[1.18] hover:ring-1 hover:ring-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent ${(d==null?void 0:d.date)===o.date?"ring-1 ring-fg-bright":""}`,style:{background:S(o.level)},onMouseEnter:()=>h(f.get(o.date)??null),onFocus:()=>h(f.get(o.date)??null),onClick:()=>p(y=>(y==null?void 0:y.date)===o.date?null:f.get(o.date)??null)},g))},r))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 pl-6 pt-1 text-[9px] text-fg-faint",children:["less",[0,1,2,3,4].map(s=>e.jsx("span",{className:"size-[11px] rounded-[2px]",style:{background:S(s)}},s)),"more"]})]}),e.jsxs("div",{className:"relative border-line-faint md:border-l md:pl-6",children:[e.jsxs("div",{className:`grid grid-cols-2 gap-x-6 gap-y-4 transition-opacity duration-200 md:grid-cols-1 ${m?"opacity-0":"opacity-100"}`,children:[e.jsx(w,{label:"busiest day",value:a.costed?C(a.top.cost):E(a.top.tokens),sub:T(a.top.date),valueClass:"text-cost"}),e.jsx(w,{label:"daily average",value:a.costed?C(a.avg):E(a.avg),sub:`across ${a.active} active days`}),e.jsx(w,{label:"top weekday",value:L[a.busiest],valueClass:"text-fg-bright"}),e.jsx(w,{label:"latest streak",value:`${a.streak}d`,sub:a.streak>0?"in a row":"idle today",valueClass:"text-positive"})]}),m&&e.jsx("div",{className:"dialog-fade absolute inset-0 md:pl-6",children:e.jsx(W,{day:m,pinned:!c&&m===d})})]})]})})})}function W({day:t,pinned:n=!1}){return e.jsxs("div",{className:"font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 border-b border-line-faint pb-2",children:[e.jsxs("span",{className:"text-fg-dim",children:[L[D(j(t.date))]," · ",T(t.date),n&&e.jsx("span",{className:"ml-1.5 text-[9px] uppercase tracking-wide text-accent",children:"pinned"})]}),e.jsx("span",{className:"tnum text-cost",children:t.cost>0?C(t.cost):"—"})]}),t.cost>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 py-2 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"calls"}),e.jsx("div",{className:"tnum text-fg",children:I(t.calls)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"tokens"}),e.jsx("div",{className:"tnum text-fg",children:E(t.tokens)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"saved"}),e.jsx("div",{className:"tnum text-positive",children:C(t.cacheSavings)})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 border-t border-line-faint pt-2",children:[t.models.slice(0,5).map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{background:$(i.name)}}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-fg-dim",children:B(i.name)}),e.jsx("span",{className:"tnum w-16 shrink-0 text-right text-fg",children:C(i.cost)})]},i.name)),t.models.length>5&&e.jsxs("div",{className:"pt-0.5 text-fg-faint",children:["+",t.models.length-5," more"]})]})]}):e.jsx("div",{className:"pt-2 text-fg-faint",children:"no spend this day"})]})}const Y=x.lazy(()=>M(()=>import("./breakdown-kOSSJ3mI.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.CostByModel}))),q=x.lazy(()=>M(()=>import("./breakdown-kOSSJ3mI.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.ProviderDonut}))),P=x.lazy(()=>M(()=>import("./breakdown-kOSSJ3mI.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(t=>({default:t.TokenComposition}))),G=x.lazy(()=>M(()=>import("./timeline-B4uG-Emo.js"),__vite__mapDeps([6,1,2,3,4,5,7]),import.meta.url).then(t=>({default:t.CacheSavings}))),K=x.lazy(()=>M(()=>import("./timeline-B4uG-Emo.js"),__vite__mapDeps([6,1,2,3,4,5,7]),import.meta.url).then(t=>({default:t.CumulativeSpend})));function _({children:t}){return e.jsx(x.Suspense,{fallback:e.jsx("div",{className:"min-h-64",role:"status","aria-label":"Loading chart"}),children:t})}function X({derived:t,scopeLabel:n}){const i=t.byProvider.length>1;return e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx(H,{derived:t,periodLabel:n})}),e.jsx(_,{children:e.jsx(Y,{derived:t,periodLabel:n})}),e.jsx(_,{children:i?e.jsx(q,{derived:t,periodLabel:n}):e.jsx(P,{derived:t,periodLabel:n})}),i?e.jsx(_,{children:e.jsx(P,{derived:t,periodLabel:n})}):null,e.jsx("div",{className:i?void 0:"md:col-span-2",children:e.jsx(_,{children:e.jsx(G,{derived:t,periodLabel:n})})}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(_,{children:e.jsx(K,{derived:t,height:300,periodLabel:n})})})]})}export{X as AnalyticsTab};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{R as h,l as Qe,r as J,j as u,g as Ye,s as ee,f as G,a as z,n as Je,o as xt,T as ne}from"./index-DH3dOnbg.js";import{c as I,d as k,r as et,e as At,h as tt,i as kt,j as C,k as Pe,p as S,L as _,l as rt,n as Oe,o as nt,D as Pt,q as Ot,t as W,v as F,S as jt,w as _t,x as wt,y as De,z as Tt,B as M,E as je,F as St,H as Et,I as ae,J as Rt,K as _e,M as It,N as ie,O as Be,g as it,X as we,Y as Te,P as Se,f as Nt,Q as Lt,u as Ee,U as at,C as Re,R as Ie,a as ot,G as st,A as se,T as ct,s as Ne}from"./chart-cZoLgpmG.js";import{P as fe}from"./panel-DTQBwExW.js";import{E as pe}from"./primitives-C36qJlA2.js";var $t=["points","className","baseLinePoints","connectNulls"];function V(){return V=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},V.apply(this,arguments)}function Ct(r,e){if(r==null)return{};var n=Dt(r,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}function Dt(r,e){if(r==null)return{};var n={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(e.indexOf(t)>=0)continue;n[t]=r[t]}return n}function Ke(r){return Mt(r)||Ft(r)||Kt(r)||Bt()}function Bt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kt(r,e){if(r){if(typeof r=="string")return be(r,e);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor&&(n=r.constructor.name),n==="Map"||n==="Set")return Array.from(r);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return be(r,e)}}function Ft(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Mt(r){if(Array.isArray(r))return be(r)}function be(r,e){(e==null||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}var Fe=function(e){return e&&e.x===+e.x&&e.y===+e.y},Vt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=[[]];return e.forEach(function(t){Fe(t)?n[n.length-1].push(t):n[n.length-1].length>0&&n.push([])}),Fe(e[0])&&n[n.length-1].push(e[0]),n[n.length-1].length<=0&&(n=n.slice(0,-1)),n},Q=function(e,n){var t=Vt(e);n&&(t=[t.reduce(function(a,o){return[].concat(Ke(a),Ke(o))},[])]);var i=t.map(function(a){return a.reduce(function(o,c,f){return"".concat(o).concat(f===0?"M":"L").concat(c.x,",").concat(c.y)},"")}).join("");return t.length===1?"".concat(i,"Z"):i},qt=function(e,n,t){var i=Q(e,t);return"".concat(i.slice(-1)==="Z"?i.slice(0,-1):i,"L").concat(Q(n.reverse(),t).slice(1))},zt=function(e){var n=e.points,t=e.className,i=e.baseLinePoints,a=e.connectNulls,o=Ct(e,$t);if(!n||!n.length)return null;var c=I("recharts-polygon",t);if(i&&i.length){var f=o.stroke&&o.stroke!=="none",s=qt(n,i,a);return h.createElement("g",{className:c},h.createElement("path",V({},k(o,!0),{fill:s.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:s})),f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(n,a)})):null,f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(i,a)})):null)}var p=Q(n,a);return h.createElement("path",V({},k(o,!0),{fill:p.slice(-1)==="Z"?o.fill:"none",className:c,d:p}))},ye,Me;function Wt(){if(Me)return ye;Me=1;var r=et(),e=At(),n=tt();function t(i,a){return i&&i.length?r(i,n(a,2),e):void 0}return ye=t,ye}var Gt=Wt();const Ht=Qe(Gt);var ge,Ve;function Ut(){if(Ve)return ge;Ve=1;var r=et(),e=tt(),n=kt();function t(i,a){return i&&i.length?r(i,e(a,2),n):void 0}return ge=t,ge}var Zt=Ut();const Xt=Qe(Zt);var Qt=["cx","cy","angle","ticks","axisLine"],Yt=["ticks","tick","angle","tickFormatter","stroke"];function H(r){"@babel/helpers - typeof";return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},H(r)}function Y(){return Y=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},Y.apply(this,arguments)}function qe(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),n.push.apply(n,t)}return n}function L(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qe(Object(n),!0).forEach(function(t){de(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):qe(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function ze(r,e){if(r==null)return{};var n=Jt(r,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}function Jt(r,e){if(r==null)return{};var n={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if(e.indexOf(t)>=0)continue;n[t]=r[t]}return n}function er(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function We(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,ut(t.key),t)}}function tr(r,e,n){return e&&We(r.prototype,e),n&&We(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function rr(r,e,n){return e=ce(e),nr(r,lt()?Reflect.construct(e,n||[],ce(r).constructor):e.apply(r,n))}function nr(r,e){if(e&&(H(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ir(r)}function ir(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function lt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lt=function(){return!!r})()}function ce(r){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ce(r)}function ar(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&xe(r,e)}function xe(r,e){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},xe(r,e)}function de(r,e,n){return e=ut(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function ut(r){var e=or(r,"string");return H(e)=="symbol"?e:e+""}function or(r,e){if(H(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(H(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var me=(function(r){function e(){return er(this,e),rr(this,e,arguments)}return ar(e,r),tr(e,[{key:"getTickValueCoord",value:function(t){var i=t.coordinate,a=this.props,o=a.angle,c=a.cx,f=a.cy;return S(c,f,i,o)}},{key:"getTickTextAnchor",value:function(){var t=this.props.orientation,i;switch(t){case"left":i="end";break;case"right":i="start";break;default:i="middle";break}return i}},{key:"getViewBox",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=Ht(c,function(p){return p.coordinate||0}),s=Xt(c,function(p){return p.coordinate||0});return{cx:i,cy:a,startAngle:o,endAngle:o,innerRadius:s.coordinate||0,outerRadius:f.coordinate||0}}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=t.axisLine,s=ze(t,Qt),p=c.reduce(function(m,l){return[Math.min(m[0],l.coordinate),Math.max(m[1],l.coordinate)]},[1/0,-1/0]),d=S(i,a,p[0],o),v=S(i,a,p[1],o),A=L(L(L({},k(s,!1)),{},{fill:"none"},k(f,!1)),{},{x1:d.x,y1:d.y,x2:v.x,y2:v.y});return h.createElement("line",Y({className:"recharts-polar-radius-axis-line"},A))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.angle,f=i.tickFormatter,s=i.stroke,p=ze(i,Yt),d=this.getTickTextAnchor(),v=k(p,!1),A=k(o,!1),m=a.map(function(l,g){var b=t.getTickValueCoord(l),x=L(L(L(L({textAnchor:d,transform:"rotate(".concat(90-c,", ").concat(b.x,", ").concat(b.y,")")},v),{},{stroke:"none",fill:s},A),{},{index:g},b),{},{payload:l});return h.createElement(_,Y({className:I("recharts-polar-radius-axis-tick",rt(o)),key:"tick-".concat(l.coordinate)},Oe(t.props,l,g)),e.renderTickItem(o,x,f?f(l.value,g):l.value))});return h.createElement(_,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.axisLine,o=t.tick;return!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-radius-axis",this.props.className)},a&&this.renderAxisLine(),o&&this.renderTicks(),nt.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Pe,Y({},i,{className:"recharts-polar-radius-axis-tick-value"}),a),o}}])})(J.PureComponent);de(me,"displayName","PolarRadiusAxis");de(me,"axisType","radiusAxis");de(me,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function U(r){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(r)}function D(){return D=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},D.apply(this,arguments)}function Ge(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),n.push.apply(n,t)}return n}function $(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ge(Object(n),!0).forEach(function(t){ve(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ge(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function sr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function He(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,pt(t.key),t)}}function cr(r,e,n){return e&&He(r.prototype,e),n&&He(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function lr(r,e,n){return e=le(e),ur(r,ft()?Reflect.construct(e,n||[],le(r).constructor):e.apply(r,n))}function ur(r,e){if(e&&(U(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fr(r)}function fr(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function ft(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ft=function(){return!!r})()}function le(r){return le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},le(r)}function pr(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&Ae(r,e)}function Ae(r,e){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},Ae(r,e)}function ve(r,e,n){return e=pt(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function pt(r){var e=dr(r,"string");return U(e)=="symbol"?e:e+""}function dr(r,e){if(U(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(U(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var mr=Math.PI/180,Ue=1e-5,he=(function(r){function e(){return sr(this,e),lr(this,e,arguments)}return pr(e,r),cr(e,[{key:"getTickLineCoord",value:function(t){var i=this.props,a=i.cx,o=i.cy,c=i.radius,f=i.orientation,s=i.tickSize,p=s||8,d=S(a,o,c,t.coordinate),v=S(a,o,c+(f==="inner"?-1:1)*p,t.coordinate);return{x1:d.x,y1:d.y,x2:v.x,y2:v.y}}},{key:"getTickTextAnchor",value:function(t){var i=this.props.orientation,a=Math.cos(-t.coordinate*mr),o;return a>Ue?o=i==="outer"?"start":"end":a<-Ue?o=i==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.radius,c=t.axisLine,f=t.axisLineType,s=$($({},k(this.props,!1)),{},{fill:"none"},k(c,!1));if(f==="circle")return h.createElement(Pt,D({className:"recharts-polar-angle-axis-line"},s,{cx:i,cy:a,r:o}));var p=this.props.ticks,d=p.map(function(v){return S(i,a,o,v.coordinate)});return h.createElement(zt,D({className:"recharts-polar-angle-axis-line"},s,{points:d}))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.tickLine,f=i.tickFormatter,s=i.stroke,p=k(this.props,!1),d=k(o,!1),v=$($({},p),{},{fill:"none"},k(c,!1)),A=a.map(function(m,l){var g=t.getTickLineCoord(m),b=t.getTickTextAnchor(m),x=$($($({textAnchor:b},p),{},{stroke:"none",fill:s},d),{},{index:l,payload:m,x:g.x2,y:g.y2});return h.createElement(_,D({className:I("recharts-polar-angle-axis-tick",rt(o)),key:"tick-".concat(m.coordinate)},Oe(t.props,m,l)),c&&h.createElement("line",D({className:"recharts-polar-angle-axis-tick-line"},v,g)),o&&e.renderTickItem(o,x,f?f(m.value,l):m.value))});return h.createElement(_,{className:"recharts-polar-angle-axis-ticks"},A)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.radius,o=t.axisLine;return a<=0||!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Pe,D({},i,{className:"recharts-polar-angle-axis-tick-value"}),a),o}}])})(J.PureComponent);ve(he,"displayName","PolarAngleAxis");ve(he,"axisType","angleAxis");ve(he,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var oe;function Z(r){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Z(r)}function q(){return q=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},q.apply(this,arguments)}function Ze(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),n.push.apply(n,t)}return n}function y(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ze(Object(n),!0).forEach(function(t){O(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function vr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Xe(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,mt(t.key),t)}}function hr(r,e,n){return e&&Xe(r.prototype,e),n&&Xe(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function yr(r,e,n){return e=ue(e),gr(r,dt()?Reflect.construct(e,n||[],ue(r).constructor):e.apply(r,n))}function gr(r,e){if(e&&(Z(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return br(r)}function br(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function dt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dt=function(){return!!r})()}function ue(r){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ue(r)}function xr(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&ke(r,e)}function ke(r,e){return ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},ke(r,e)}function O(r,e,n){return e=mt(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function mt(r){var e=Ar(r,"string");return Z(e)=="symbol"?e:e+""}function Ar(r,e){if(Z(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e);if(Z(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var E=(function(r){function e(n){var t;return vr(this,e),t=yr(this,e,[n]),O(t,"pieRef",null),O(t,"sectorRefs",[]),O(t,"id",St("recharts-pie-")),O(t,"handleAnimationEnd",function(){var i=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),C(i)&&i()}),O(t,"handleAnimationStart",function(){var i=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),C(i)&&i()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return xr(e,r),hr(e,[{key:"isActiveIndex",value:function(t){var i=this.props.activeIndex;return Array.isArray(i)?i.indexOf(t)!==-1:t===i}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.label,c=a.labelLine,f=a.dataKey,s=a.valueKey,p=k(this.props,!1),d=k(o,!1),v=k(c,!1),A=o&&o.offsetRadius||20,m=t.map(function(l,g){var b=(l.startAngle+l.endAngle)/2,x=S(l.cx,l.cy,l.outerRadius+A,b),j=y(y(y(y({},p),l),{},{stroke:"none"},d),{},{index:g,textAnchor:e.getTextAnchor(x.x,l.cx)},x),B=y(y(y(y({},p),l),{},{fill:"none",stroke:l.fill},v),{},{index:g,points:[S(l.cx,l.cy,l.outerRadius,b),x]}),w=f;return W(f)&&W(s)?w="value":W(f)&&(w=s),h.createElement(_,{key:"label-".concat(l.startAngle,"-").concat(l.endAngle,"-").concat(l.midAngle,"-").concat(g)},c&&e.renderLabelLineItem(c,B,"line"),e.renderLabelItem(o,j,F(l,w)))});return h.createElement(_,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(t){var i=this,a=this.props,o=a.activeShape,c=a.blendStroke,f=a.inactiveShape;return t.map(function(s,p){if((s==null?void 0:s.startAngle)===0&&(s==null?void 0:s.endAngle)===0&&t.length!==1)return null;var d=i.isActiveIndex(p),v=f&&i.hasActiveIndex()?f:null,A=d?o:v,m=y(y({},s),{},{stroke:c?s.fill:s.stroke,tabIndex:-1});return h.createElement(_,q({ref:function(g){g&&!i.sectorRefs.includes(g)&&i.sectorRefs.push(g)},tabIndex:-1,className:"recharts-pie-sector"},Oe(i.props,s,p),{key:"sector-".concat(s==null?void 0:s.startAngle,"-").concat(s==null?void 0:s.endAngle,"-").concat(s.midAngle,"-").concat(p)}),h.createElement(jt,q({option:A,isActive:d,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,i=this.props,a=i.sectors,o=i.isAnimationActive,c=i.animationBegin,f=i.animationDuration,s=i.animationEasing,p=i.animationId,d=this.state,v=d.prevSectors,A=d.prevIsAnimationActive;return h.createElement(_t,{begin:c,duration:f,isActive:o,easing:s,from:{t:0},to:{t:1},key:"pie-".concat(p,"-").concat(A),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var l=m.t,g=[],b=a&&a[0],x=b.startAngle;return a.forEach(function(j,B){var w=v&&v[B],N=B>0?wt(j,"paddingAngle",0):0;if(w){var X=De(w.endAngle-w.startAngle,j.endAngle-j.startAngle),P=y(y({},j),{},{startAngle:x+N,endAngle:x+X(l)+N});g.push(P),x=P.endAngle}else{var K=j.endAngle,T=j.startAngle,te=De(0,K-T),re=te(l),R=y(y({},j),{},{startAngle:x+N,endAngle:x+re+N});g.push(R),x=R.endAngle}}),h.createElement(_,null,t.renderSectorsStatically(g))})}},{key:"attachKeyboardHandlers",value:function(t){var i=this;t.onkeydown=function(a){if(!a.altKey)switch(a.key){case"ArrowLeft":{var o=++i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[o].focus(),i.setState({sectorToFocus:o});break}case"ArrowRight":{var c=--i.state.sectorToFocus<0?i.sectorRefs.length-1:i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[c].focus(),i.setState({sectorToFocus:c});break}case"Escape":{i.sectorRefs[i.state.sectorToFocus].blur(),i.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,i=t.sectors,a=t.isAnimationActive,o=this.state.prevSectors;return a&&i&&i.length&&(!o||!Tt(o,i))?this.renderSectorsWithAnimation():this.renderSectorsStatically(i)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,i=this.props,a=i.hide,o=i.sectors,c=i.className,f=i.label,s=i.cx,p=i.cy,d=i.innerRadius,v=i.outerRadius,A=i.isAnimationActive,m=this.state.isAnimationFinished;if(a||!o||!o.length||!M(s)||!M(p)||!M(d)||!M(v))return null;var l=I("recharts-pie",c);return h.createElement(_,{tabIndex:this.props.rootTabIndex,className:l,ref:function(b){t.pieRef=b}},this.renderSectors(),f&&this.renderLabels(o),nt.renderCallByParent(this.props,null,!1),(!A||m)&&je.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,i){return i.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==i.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:i.curSectors,isAnimationFinished:!0}:t.sectors!==i.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,i){return t>i?"start":t<i?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);if(C(t))return t(i);var o=I("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return h.createElement(Ot,q({},i,{key:a,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);var o=a;if(C(t)&&(o=t(i),h.isValidElement(o)))return o;var c=I("recharts-pie-label-text",typeof t!="boolean"&&!C(t)?t.className:"");return h.createElement(Pe,q({},i,{alignmentBaseline:"middle",className:c}),o)}}])})(J.PureComponent);oe=E;O(E,"displayName","Pie");O(E,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Et.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});O(E,"parseDeltaAngle",function(r,e){var n=ae(e-r),t=Math.min(Math.abs(e-r),360);return n*t});O(E,"getRealPieData",function(r){var e=r.data,n=r.children,t=k(r,!1),i=Rt(n,_e);return e&&e.length?e.map(function(a,o){return y(y(y({payload:a},t),a),i&&i[o]&&i[o].props)}):i&&i.length?i.map(function(a){return y(y({},t),a.props)}):[]});O(E,"parseCoordinateOfPie",function(r,e){var n=e.top,t=e.left,i=e.width,a=e.height,o=It(i,a),c=t+ie(r.cx,i,i/2),f=n+ie(r.cy,a,a/2),s=ie(r.innerRadius,o,0),p=ie(r.outerRadius,o,o*.8),d=r.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:c,cy:f,innerRadius:s,outerRadius:p,maxRadius:d}});O(E,"getComposedData",function(r){var e=r.item,n=r.offset,t=e.type.defaultProps!==void 0?y(y({},e.type.defaultProps),e.props):e.props,i=oe.getRealPieData(t);if(!i||!i.length)return null;var a=t.cornerRadius,o=t.startAngle,c=t.endAngle,f=t.paddingAngle,s=t.dataKey,p=t.nameKey,d=t.valueKey,v=t.tooltipType,A=Math.abs(t.minAngle),m=oe.parseCoordinateOfPie(t,n),l=oe.parseDeltaAngle(o,c),g=Math.abs(l),b=s;W(s)&&W(d)?(Be(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
-
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 T=F(K,b,0);return P+(M(T)?T:0)},0),N;if(w>0){var X;N=i.map(function(P,K){var T=F(P,b,0),te=F(P,p,K),re=(M(T)?T:0)/w,R;K?R=X.endAngle+ae(l)*f*(T!==0?1:0):R=o;var Le=R+ae(l)*((T!==0?A:0)+re*B),$e=(R+Le)/2,Ce=(m.innerRadius+m.outerRadius)/2,gt=[{name:te,value:T,payload:P,dataKey:b,type:v}],bt=S(m.cx,m.cy,Ce,$e);return X=y(y(y({percent:re,cornerRadius:a,name:te,tooltipPayload:gt,midAngle:$e,middleRadius:Ce,tooltipPosition:bt},P),m),{},{value:F(P,b),startAngle:R,endAngle:Le,payload:P,paddingAngle:ae(l)*f}),X})}return y(y({},m),{},{sectors:N,data:i})});var vt=it({chartName:"BarChart",GraphicalChild:Se,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:we},{axisType:"yAxis",AxisComp:Te}],formatAxisMap:Nt}),kr=it({chartName:"PieChart",GraphicalChild:E,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:he},{axisType:"radiusAxis",AxisComp:me}],formatAxisMap:Lt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const ht={fill:"var(--color-bg-2)"},yt={fill:"var(--color-fg-dim)",fontSize:10,fontFamily:"var(--font-mono)"},Pr=Ne("cost",G,r=>{var e;return(e=r[0])==null?void 0:e.color},{title:r=>ee(r)}),Or=Ne("tokens",z,r=>{var e;return(e=r[0])==null?void 0:e.color},{title:r=>ee(r)}),jr=Ne("saved",G,r=>{var e;return(e=r[0])==null?void 0:e.color},{title:r=>ee(r)});function Er({derived:r,height:e=280,limit:n=10,metric:t="cost",periodLabel:i}){const a=Ee(),o=at("(min-width: 768px)"),c=o?124:92,f=o?60:44,s=t==="tokens",p=[...r.byModel].sort((d,v)=>s?v.tokens-d.tokens:v.cost-d.cost).slice(0,n);return u.jsx(fe,{title:s?"tokens by model":"cost by model",titleTag:i,captureName:s?"tokens-by-model":"cost-by-model",children:p.length===0?u.jsx(pe,{children:"no models in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:p,layout:"vertical",margin:{top:4,right:f,left:4,bottom:0},children:[u.jsx(ot,{...st,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:s?z:Ye}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:c,tickFormatter:ee}),u.jsx(ct,{content:s?Or:Pr,cursor:ht}),u.jsxs(Se,{dataKey:s?"tokens":"cost",radius:[0,3,3,0],isAnimationActive:a,animationDuration:350,children:[p.map(d=>u.jsx(_e,{fill:d.color},d.model)),u.jsx(je,{dataKey:s?"tokens":"cost",position:"right",offset:6,...yt,formatter:d=>s?z(d):G(d)})]})]})})})})}function Rr({derived:r,height:e=240,limit:n=12,periodLabel:t}){const i=Ee(),a=at("(min-width: 768px)"),o=a?124:92,c=a?60:44,f=[...r.byModel].filter(s=>s.cacheSavings>0).sort((s,p)=>p.cacheSavings-s.cacheSavings).slice(0,n);return u.jsx(fe,{title:"cache savings by model",titleTag:t,captureName:"cache-savings-by-model",children:f.length===0?u.jsx(pe,{children:"no cache savings in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:f,layout:"vertical",margin:{top:4,right:c,left:4,bottom:0},children:[u.jsx(ot,{...st,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:Ye}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:o,tickFormatter:ee}),u.jsx(ct,{content:jr,cursor:ht}),u.jsx(Se,{dataKey:"cacheSavings",radius:[0,3,3,0],fill:"var(--color-positive)",isAnimationActive:i,animationDuration:350,children:u.jsx(je,{dataKey:"cacheSavings",position:"right",offset:6,...yt,formatter:s=>G(s)})})]})})})})}function Ir({derived:r,height:e=280,periodLabel:n}){const t=Ee(),i=r.byProvider,a=r.totals.cost,[o,c]=J.useState(null),[f,s]=J.useState(null),p=f?i.findIndex(m=>m.id===f):-1,d=o??(p>=0?p:null),v=d!=null?i[d]:null,A=v&&a>0?v.cost/a:0;return u.jsx(fe,{title:"provider split",titleTag:n,captureName:"provider-split",children:i.length===0?u.jsx(pe,{children:"no spend in period"}):u.jsxs("div",{className:"relative",onMouseLeave:()=>c(null),children:[u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsx(kr,{children:u.jsx(E,{data:i,dataKey:"cost",nameKey:"name",innerRadius:"60%",outerRadius:"88%",paddingAngle:i.length>1?2:0,stroke:"var(--color-bg-1)",strokeWidth:2,isAnimationActive:t,animationDuration:350,style:{cursor:"pointer"},onMouseEnter:(m,l)=>c(l),onClick:(m,l)=>s(g=>{var b,x;return g===((b=i[l])==null?void 0:b.id)?null:((x=i[l])==null?void 0:x.id)??null}),children:i.map((m,l)=>u.jsx(_e,{fill:m.color,"aria-label":`${m.name}: ${G(m.cost)}`,fillOpacity:d==null||d===l?1:.32,style:{transition:"fill-opacity 150ms ease"}},m.id))})})})}),u.jsxs("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"tnum text-xl",style:{color:v?v.color:"var(--color-fg-bright)"},children:G(v?v.cost:a)}),u.jsxs("div",{className:"font-display text-[10px] uppercase tracking-wide text-fg-faint",children:[v?`${v.name} · ${Je(A,A>0&&A<.01?1:0)}`:"total",v&&o==null&&p>=0&&u.jsx("span",{className:"text-accent",children:" · pinned"})]})]})]})})}function Nr({derived:r,periodLabel:e}){const n=r.tokenComposition,t=xt(n),i=[{key:"cacheRead",label:"cache read",value:n.cacheRead,color:ne.cacheRead},{key:"input",label:"input",value:n.input,color:ne.input},{key:"output",label:"output",value:n.output,color:ne.output},{key:"cacheCreate",label:"cache write",value:n.cacheCreate,color:ne.cacheCreate}];return u.jsx(fe,{title:"token composition",titleTag:e,captureName:"token-composition",right:u.jsx("span",{className:"tnum text-xs text-fg-dim",children:z(t)}),children:t===0?u.jsx(pe,{children:"no tokens in period"}):u.jsxs("div",{className:"flex flex-col gap-4 pt-1",children:[u.jsx("div",{className:"flex h-3 w-full overflow-hidden rounded-full bg-bg-3",children:i.map(a=>a.value>0&&u.jsx("div",{style:{width:`${a.value/t*100}%`,minWidth:"2px",background:a.color},title:`${a.label}: ${z(a.value)}`},a.key))}),u.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2.5",children:i.map(a=>{const o=t>0?a.value/t:0;return u.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[u.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim",children:[u.jsx("span",{className:"inline-block size-2 rounded-[2px]",style:{background:a.color}}),a.label]}),u.jsxs("span",{className:"text-fg",children:[u.jsx("span",{className:"tnum text-fg-bright",children:z(a.value)}),u.jsx("span",{className:"ml-1.5 text-fg-faint",children:Je(o,o>0&&o<.01?1:0)})]})]},a.key)})})]})})}export{Rr as CacheByModel,Er as CostByModel,Ir as ProviderDonut,Nr as TokenComposition};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{q as ne,t as me,u as Pe,w as Ee,o as L,v as De,r as $,j as h,m as Ge,s as oe,a as J,f as z,b as ze,x as Se,e as he,y as He,S as Ae,z as Le,c as je,A as Ne,X as Oe}from"./index-DH3dOnbg.js";import{P as ke}from"./panel-DTQBwExW.js";function Be(e){return e.reduce((n,t)=>(n.input+=t.input,n.output+=t.output,n.cacheCreate+=t.cacheCreate,n.cacheRead+=t.cacheRead,n.cacheSavings+=t.cacheSavings,n.cost+=t.cost,n.count+=t.count,n),{input:0,output:0,cacheCreate:0,cacheRead:0,cacheSavings:0,cost:0,count:0})}function Te(e,n,t){var d;if(!e)return[];const o=ne(e,n),i=me(o),r=Pe(n.period,t,i,e.tz),s=r?t==="monthly"?r.slice(0,7):t==="weekly"?Ee(r):r:null,u=n.models.length?new Set(n.models):null,g=new Map;for(const f of o)for(const m of((d=f.table)==null?void 0:d[t])??[]){if(s&&m.label<s)continue;const a=u?m.breakdown.filter(p=>u.has(p.name)):m.breakdown;if(u&&a.length===0)continue;const l=g.get(m.label),c=Be(a);if(!l)g.set(m.label,{label:m.label,models:a.map(p=>p.name).sort(),...c,total:L(c),breakdown:a.map(p=>({...p}))});else{l.input+=c.input,l.output+=c.output,l.cacheCreate+=c.cacheCreate,l.cacheRead+=c.cacheRead,l.cacheSavings+=c.cacheSavings,l.total+=L(c),l.cost+=c.cost,l.count+=c.count;const p=new Map(l.breakdown.map(S=>[S.name,S]));for(const S of a){const C=p.get(S.name);C?(C.input+=S.input,C.output+=S.output,C.cacheCreate+=S.cacheCreate,C.cacheRead+=S.cacheRead,C.cacheSavings+=S.cacheSavings,C.cost+=S.cost,C.count+=S.count):p.set(S.name,{...S})}l.breakdown=[...p.values()].sort((S,C)=>C.cost-S.cost),l.models=l.breakdown.map(S=>S.name)}}return[...g.values()]}function de(){return{input:0,output:0,cacheCreate:0,cacheRead:0,cost:0,count:0}}function ce(e,n){e.input+=n.input,e.output+=n.output,e.cacheCreate+=n.cacheCreate,e.cacheRead+=n.cacheRead,e.cost+=n.cost,e.count+=n.count}function qe(e,n,t){var m;if(!e)return null;const o=ne(e,n),i=me(o),r=De(n.period,i,e.tz),s=a=>!r||a>=r,u=new Map(e.providers.map(a=>[a.id,a.name])),g=de(),d=new Map,f=[];for(const a of o){const l=de();for(const p of((m=a.table)==null?void 0:m.daily)??[]){if(!s(p.label))continue;const S=p.breakdown.find(x=>x.name===t);if(!S)continue;const C=L(S);ce(g,S),ce(l,S);const R=d.get(p.label)??{day:p.label,cost:0,tokens:0};R.cost+=S.cost,R.tokens+=C,d.set(p.label,R)}const c=L(l);(c>0||l.cost>0||l.count>0)&&f.push({name:a.name,color:a.color,provider:u.get(a.providerId)??a.providerId,providerId:a.providerId,tokens:c,cost:l.cost})}return{accounts:f.sort((a,l)=>l.cost-a.cost||l.tokens-a.tokens||a.name.localeCompare(l.name)),totals:g,daily:[...d.values()].sort((a,l)=>a.day.localeCompare(l.day))}}/**
|
|
2
|
-
* table-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/function Ue(){return{accessor:(e,n)=>typeof e=="function"?{...n,accessorFn:e}:{...n,accessorKey:e},display:e=>e,group:e=>e}}function P(e,n){return typeof e=="function"?e(n):e}function y(e,n){return t=>{n.setState(o=>({...o,[e]:P(t,o[e])}))}}function k(e){return e instanceof Function}function be(e){return Array.isArray(e)&&e.every(n=>typeof n=="number")}function Xe(e,n){const t=[],o=i=>{i.forEach(r=>{t.push(r);const s=n(r);s!=null&&s.length&&o(s)})};return o(e),t}function w(e,n,t){let o=[],i;return r=>{let s;t.key&&t.debug&&(s=Date.now());const u=e(r);if(!(u.length!==o.length||u.some((f,m)=>o[m]!==f)))return i;o=u;let d;if(t.key&&t.debug&&(d=Date.now()),i=n(...u),t==null||t.onChange==null||t.onChange(i),t.key&&t.debug&&t!=null&&t.debug()){const f=Math.round((Date.now()-s)*100)/100,m=Math.round((Date.now()-d)*100)/100,a=m/16,l=(c,p)=>{for(c=String(c);c.length<p;)c=" "+c;return c};console.info(`%c⏱ ${l(m,5)} /${l(f,5)} ms`,`
|
|
11
|
-
font-size: .6rem;
|
|
12
|
-
font-weight: bold;
|
|
13
|
-
color: hsl(${Math.max(0,Math.min(120-120*a,120))}deg 100% 31%);`,t==null?void 0:t.key)}return i}}function v(e,n,t,o){return{debug:()=>{var i;return(i=e==null?void 0:e.debugAll)!=null?i:e[n]},key:!1,onChange:o}}function Ke(e,n,t,o){const i=()=>{var s;return(s=r.getValue())!=null?s:e.options.renderFallbackValue},r={id:`${n.id}_${t.id}`,row:n,column:t,getValue:()=>n.getValue(o),renderValue:i,getContext:w(()=>[e,t,n,r],(s,u,g,d)=>({table:s,column:u,row:g,cell:d,getValue:d.getValue,renderValue:d.renderValue}),v(e.options,"debugCells"))};return e._features.forEach(s=>{s.createCell==null||s.createCell(r,t,n,e)},{}),r}function Qe(e,n,t,o){var i,r;const u={...e._getDefaultColumnDef(),...n},g=u.accessorKey;let d=(i=(r=u.id)!=null?r:g?typeof String.prototype.replaceAll=="function"?g.replaceAll(".","_"):g.replace(/\./g,"_"):void 0)!=null?i:typeof u.header=="string"?u.header:void 0,f;if(u.accessorFn?f=u.accessorFn:g&&(g.includes(".")?f=a=>{let l=a;for(const p of g.split(".")){var c;l=(c=l)==null?void 0:c[p]}return l}:f=a=>a[u.accessorKey]),!d)throw new Error;let m={id:`${String(d)}`,accessorFn:f,parent:o,depth:t,columnDef:u,columns:[],getFlatColumns:w(()=>[!0],()=>{var a;return[m,...(a=m.columns)==null?void 0:a.flatMap(l=>l.getFlatColumns())]},v(e.options,"debugColumns")),getLeafColumns:w(()=>[e._getOrderColumnsFn()],a=>{var l;if((l=m.columns)!=null&&l.length){let c=m.columns.flatMap(p=>p.getLeafColumns());return a(c)}return[m]},v(e.options,"debugColumns"))};for(const a of e._features)a.createColumn==null||a.createColumn(m,e);return m}const _="debugHeaders";function fe(e,n,t){var o;let r={id:(o=t.id)!=null?o:n.id,column:n,index:t.index,isPlaceholder:!!t.isPlaceholder,placeholderId:t.placeholderId,depth:t.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const s=[],u=g=>{g.subHeaders&&g.subHeaders.length&&g.subHeaders.map(u),s.push(g)};return u(r),s},getContext:()=>({table:e,header:r,column:n})};return e._features.forEach(s=>{s.createHeader==null||s.createHeader(r,e)}),r}const Je={createTable:e=>{e.getHeaderGroups=w(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,t,o,i)=>{var r,s;const u=(r=o==null?void 0:o.map(m=>t.find(a=>a.id===m)).filter(Boolean))!=null?r:[],g=(s=i==null?void 0:i.map(m=>t.find(a=>a.id===m)).filter(Boolean))!=null?s:[],d=t.filter(m=>!(o!=null&&o.includes(m.id))&&!(i!=null&&i.includes(m.id)));return j(n,[...u,...d,...g],e)},v(e.options,_)),e.getCenterHeaderGroups=w(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,t,o,i)=>(t=t.filter(r=>!(o!=null&&o.includes(r.id))&&!(i!=null&&i.includes(r.id))),j(n,t,e,"center")),v(e.options,_)),e.getLeftHeaderGroups=w(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(n,t,o)=>{var i;const r=(i=o==null?void 0:o.map(s=>t.find(u=>u.id===s)).filter(Boolean))!=null?i:[];return j(n,r,e,"left")},v(e.options,_)),e.getRightHeaderGroups=w(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(n,t,o)=>{var i;const r=(i=o==null?void 0:o.map(s=>t.find(u=>u.id===s)).filter(Boolean))!=null?i:[];return j(n,r,e,"right")},v(e.options,_)),e.getFooterGroups=w(()=>[e.getHeaderGroups()],n=>[...n].reverse(),v(e.options,_)),e.getLeftFooterGroups=w(()=>[e.getLeftHeaderGroups()],n=>[...n].reverse(),v(e.options,_)),e.getCenterFooterGroups=w(()=>[e.getCenterHeaderGroups()],n=>[...n].reverse(),v(e.options,_)),e.getRightFooterGroups=w(()=>[e.getRightHeaderGroups()],n=>[...n].reverse(),v(e.options,_)),e.getFlatHeaders=w(()=>[e.getHeaderGroups()],n=>n.map(t=>t.headers).flat(),v(e.options,_)),e.getLeftFlatHeaders=w(()=>[e.getLeftHeaderGroups()],n=>n.map(t=>t.headers).flat(),v(e.options,_)),e.getCenterFlatHeaders=w(()=>[e.getCenterHeaderGroups()],n=>n.map(t=>t.headers).flat(),v(e.options,_)),e.getRightFlatHeaders=w(()=>[e.getRightHeaderGroups()],n=>n.map(t=>t.headers).flat(),v(e.options,_)),e.getCenterLeafHeaders=w(()=>[e.getCenterFlatHeaders()],n=>n.filter(t=>{var o;return!((o=t.subHeaders)!=null&&o.length)}),v(e.options,_)),e.getLeftLeafHeaders=w(()=>[e.getLeftFlatHeaders()],n=>n.filter(t=>{var o;return!((o=t.subHeaders)!=null&&o.length)}),v(e.options,_)),e.getRightLeafHeaders=w(()=>[e.getRightFlatHeaders()],n=>n.filter(t=>{var o;return!((o=t.subHeaders)!=null&&o.length)}),v(e.options,_)),e.getLeafHeaders=w(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(n,t,o)=>{var i,r,s,u,g,d;return[...(i=(r=n[0])==null?void 0:r.headers)!=null?i:[],...(s=(u=t[0])==null?void 0:u.headers)!=null?s:[],...(g=(d=o[0])==null?void 0:d.headers)!=null?g:[]].map(f=>f.getLeafHeaders()).flat()},v(e.options,_))}};function j(e,n,t,o){var i,r;let s=0;const u=function(a,l){l===void 0&&(l=1),s=Math.max(s,l),a.filter(c=>c.getIsVisible()).forEach(c=>{var p;(p=c.columns)!=null&&p.length&&u(c.columns,l+1)},0)};u(e);let g=[];const d=(a,l)=>{const c={depth:l,id:[o,`${l}`].filter(Boolean).join("_"),headers:[]},p=[];a.forEach(S=>{const C=[...p].reverse()[0],R=S.column.depth===c.depth;let x,V=!1;if(R&&S.column.parent?x=S.column.parent:(x=S.column,V=!0),C&&(C==null?void 0:C.column)===x)C.subHeaders.push(S);else{const F=fe(t,x,{id:[o,l,x.id,S==null?void 0:S.id].filter(Boolean).join("_"),isPlaceholder:V,placeholderId:V?`${p.filter(D=>D.column===x).length}`:void 0,depth:l,index:p.length});F.subHeaders.push(S),p.push(F)}c.headers.push(S),S.headerGroup=c}),g.push(c),l>0&&d(p,l-1)},f=n.map((a,l)=>fe(t,a,{depth:s,index:l}));d(f,s-1),g.reverse();const m=a=>a.filter(c=>c.column.getIsVisible()).map(c=>{let p=0,S=0,C=[0];c.subHeaders&&c.subHeaders.length?(C=[],m(c.subHeaders).forEach(x=>{let{colSpan:V,rowSpan:F}=x;p+=V,C.push(F)})):p=1;const R=Math.min(...C);return S=S+R,c.colSpan=p,c.rowSpan=S,{colSpan:p,rowSpan:S}});return m((i=(r=g[0])==null?void 0:r.headers)!=null?i:[]),g}const ie=(e,n,t,o,i,r,s)=>{let u={id:n,index:o,original:t,depth:i,parentId:s,_valuesCache:{},_uniqueValuesCache:{},getValue:g=>{if(u._valuesCache.hasOwnProperty(g))return u._valuesCache[g];const d=e.getColumn(g);if(d!=null&&d.accessorFn)return u._valuesCache[g]=d.accessorFn(u.original,o),u._valuesCache[g]},getUniqueValues:g=>{if(u._uniqueValuesCache.hasOwnProperty(g))return u._uniqueValuesCache[g];const d=e.getColumn(g);if(d!=null&&d.accessorFn)return d.columnDef.getUniqueValues?(u._uniqueValuesCache[g]=d.columnDef.getUniqueValues(u.original,o),u._uniqueValuesCache[g]):(u._uniqueValuesCache[g]=[u.getValue(g)],u._uniqueValuesCache[g])},renderValue:g=>{var d;return(d=u.getValue(g))!=null?d:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>Xe(u.subRows,g=>g.subRows),getParentRow:()=>u.parentId?e.getRow(u.parentId,!0):void 0,getParentRows:()=>{let g=[],d=u;for(;;){const f=d.getParentRow();if(!f)break;g.push(f),d=f}return g.reverse()},getAllCells:w(()=>[e.getAllLeafColumns()],g=>g.map(d=>Ke(e,u,d,d.id)),v(e.options,"debugRows")),_getAllCellsByColumnId:w(()=>[u.getAllCells()],g=>g.reduce((d,f)=>(d[f.column.id]=f,d),{}),v(e.options,"debugRows"))};for(let g=0;g<e._features.length;g++){const d=e._features[g];d==null||d.createRow==null||d.createRow(u,e)}return u},We={createColumn:(e,n)=>{e._getFacetedRowModel=n.options.getFacetedRowModel&&n.options.getFacetedRowModel(n,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():n.getPreFilteredRowModel(),e._getFacetedUniqueValues=n.options.getFacetedUniqueValues&&n.options.getFacetedUniqueValues(n,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=n.options.getFacetedMinMaxValues&&n.options.getFacetedMinMaxValues(n,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},Ce=(e,n,t)=>{var o,i;const r=t==null||(o=t.toString())==null?void 0:o.toLowerCase();return!!(!((i=e.getValue(n))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(r))};Ce.autoRemove=e=>M(e);const we=(e,n,t)=>{var o;return!!(!((o=e.getValue(n))==null||(o=o.toString())==null)&&o.includes(t))};we.autoRemove=e=>M(e);const ve=(e,n,t)=>{var o;return((o=e.getValue(n))==null||(o=o.toString())==null?void 0:o.toLowerCase())===(t==null?void 0:t.toLowerCase())};ve.autoRemove=e=>M(e);const Re=(e,n,t)=>{var o;return(o=e.getValue(n))==null?void 0:o.includes(t)};Re.autoRemove=e=>M(e);const xe=(e,n,t)=>!t.some(o=>{var i;return!((i=e.getValue(n))!=null&&i.includes(o))});xe.autoRemove=e=>M(e)||!(e!=null&&e.length);const _e=(e,n,t)=>t.some(o=>{var i;return(i=e.getValue(n))==null?void 0:i.includes(o)});_e.autoRemove=e=>M(e)||!(e!=null&&e.length);const Fe=(e,n,t)=>e.getValue(n)===t;Fe.autoRemove=e=>M(e);const $e=(e,n,t)=>e.getValue(n)==t;$e.autoRemove=e=>M(e);const re=(e,n,t)=>{let[o,i]=t;const r=e.getValue(n);return r>=o&&r<=i};re.resolveFilterValue=e=>{let[n,t]=e,o=typeof n!="number"?parseFloat(n):n,i=typeof t!="number"?parseFloat(t):t,r=n===null||Number.isNaN(o)?-1/0:o,s=t===null||Number.isNaN(i)?1/0:i;if(r>s){const u=r;r=s,s=u}return[r,s]};re.autoRemove=e=>M(e)||M(e[0])&&M(e[1]);const I={includesString:Ce,includesStringSensitive:we,equalsString:ve,arrIncludes:Re,arrIncludesAll:xe,arrIncludesSome:_e,equals:Fe,weakEquals:$e,inNumberRange:re};function M(e){return e==null||e===""}const Ye={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:y("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,n)=>{e.getAutoFilterFn=()=>{const t=n.getCoreRowModel().flatRows[0],o=t==null?void 0:t.getValue(e.id);return typeof o=="string"?I.includesString:typeof o=="number"?I.inNumberRange:typeof o=="boolean"||o!==null&&typeof o=="object"?I.equals:Array.isArray(o)?I.arrIncludes:I.weakEquals},e.getFilterFn=()=>{var t,o;return k(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(t=(o=n.options.filterFns)==null?void 0:o[e.columnDef.filterFn])!=null?t:I[e.columnDef.filterFn]},e.getCanFilter=()=>{var t,o,i;return((t=e.columnDef.enableColumnFilter)!=null?t:!0)&&((o=n.options.enableColumnFilters)!=null?o:!0)&&((i=n.options.enableFilters)!=null?i:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var t;return(t=n.getState().columnFilters)==null||(t=t.find(o=>o.id===e.id))==null?void 0:t.value},e.getFilterIndex=()=>{var t,o;return(t=(o=n.getState().columnFilters)==null?void 0:o.findIndex(i=>i.id===e.id))!=null?t:-1},e.setFilterValue=t=>{n.setColumnFilters(o=>{const i=e.getFilterFn(),r=o==null?void 0:o.find(f=>f.id===e.id),s=P(t,r?r.value:void 0);if(pe(i,s,e)){var u;return(u=o==null?void 0:o.filter(f=>f.id!==e.id))!=null?u:[]}const g={id:e.id,value:s};if(r){var d;return(d=o==null?void 0:o.map(f=>f.id===e.id?g:f))!=null?d:[]}return o!=null&&o.length?[...o,g]:[g]})}},createRow:(e,n)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=n=>{const t=e.getAllLeafColumns(),o=i=>{var r;return(r=P(n,i))==null?void 0:r.filter(s=>{const u=t.find(g=>g.id===s.id);if(u){const g=u.getFilterFn();if(pe(g,s.value,u))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(o)},e.resetColumnFilters=n=>{var t,o;e.setColumnFilters(n?[]:(t=(o=e.initialState)==null?void 0:o.columnFilters)!=null?t:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function pe(e,n,t){return(e&&e.autoRemove?e.autoRemove(n,t):!1)||typeof n>"u"||typeof n=="string"&&!n}const Ze=(e,n,t)=>t.reduce((o,i)=>{const r=i.getValue(e);return o+(typeof r=="number"?r:0)},0),et=(e,n,t)=>{let o;return t.forEach(i=>{const r=i.getValue(e);r!=null&&(o>r||o===void 0&&r>=r)&&(o=r)}),o},tt=(e,n,t)=>{let o;return t.forEach(i=>{const r=i.getValue(e);r!=null&&(o<r||o===void 0&&r>=r)&&(o=r)}),o},nt=(e,n,t)=>{let o,i;return t.forEach(r=>{const s=r.getValue(e);s!=null&&(o===void 0?s>=s&&(o=i=s):(o>s&&(o=s),i<s&&(i=s)))}),[o,i]},ot=(e,n)=>{let t=0,o=0;if(n.forEach(i=>{let r=i.getValue(e);r!=null&&(r=+r)>=r&&(++t,o+=r)}),t)return o/t},it=(e,n)=>{if(!n.length)return;const t=n.map(r=>r.getValue(e));if(!be(t))return;if(t.length===1)return t[0];const o=Math.floor(t.length/2),i=t.sort((r,s)=>r-s);return t.length%2!==0?i[o]:(i[o-1]+i[o])/2},rt=(e,n)=>Array.from(new Set(n.map(t=>t.getValue(e))).values()),lt=(e,n)=>new Set(n.map(t=>t.getValue(e))).size,st=(e,n)=>n.length,B={sum:Ze,min:et,max:tt,extent:nt,mean:ot,median:it,unique:rt,uniqueCount:lt,count:st},ut={getDefaultColumnDef:()=>({aggregatedCell:e=>{var n,t;return(n=(t=e.getValue())==null||t.toString==null?void 0:t.toString())!=null?n:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:y("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,n)=>{e.toggleGrouping=()=>{n.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(o=>o!==e.id):[...t??[],e.id])},e.getCanGroup=()=>{var t,o;return((t=e.columnDef.enableGrouping)!=null?t:!0)&&((o=n.options.enableGrouping)!=null?o:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var t;return(t=n.getState().grouping)==null?void 0:t.includes(e.id)},e.getGroupedIndex=()=>{var t;return(t=n.getState().grouping)==null?void 0:t.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const t=n.getCoreRowModel().flatRows[0],o=t==null?void 0:t.getValue(e.id);if(typeof o=="number")return B.sum;if(Object.prototype.toString.call(o)==="[object Date]")return B.extent},e.getAggregationFn=()=>{var t,o;if(!e)throw new Error;return k(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(t=(o=n.options.aggregationFns)==null?void 0:o[e.columnDef.aggregationFn])!=null?t:B[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=n=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(n),e.resetGrouping=n=>{var t,o;e.setGrouping(n?[]:(t=(o=e.initialState)==null?void 0:o.grouping)!=null?t:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,n)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=t=>{if(e._groupingValuesCache.hasOwnProperty(t))return e._groupingValuesCache[t];const o=n.getColumn(t);return o!=null&&o.columnDef.getGroupingValue?(e._groupingValuesCache[t]=o.columnDef.getGroupingValue(e.original),e._groupingValuesCache[t]):e.getValue(t)},e._groupingValuesCache={}},createCell:(e,n,t,o)=>{e.getIsGrouped=()=>n.getIsGrouped()&&n.id===t.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&n.getIsGrouped(),e.getIsAggregated=()=>{var i;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((i=t.subRows)!=null&&i.length)}}};function at(e,n,t){if(!(n!=null&&n.length)||!t)return e;const o=e.filter(r=>!n.includes(r.id));return t==="remove"?o:[...n.map(r=>e.find(s=>s.id===r)).filter(Boolean),...o]}const gt={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:y("columnOrder",e)}),createColumn:(e,n)=>{e.getIndex=w(t=>[A(n,t)],t=>t.findIndex(o=>o.id===e.id),v(n.options,"debugColumns")),e.getIsFirstColumn=t=>{var o;return((o=A(n,t)[0])==null?void 0:o.id)===e.id},e.getIsLastColumn=t=>{var o;const i=A(n,t);return((o=i[i.length-1])==null?void 0:o.id)===e.id}},createTable:e=>{e.setColumnOrder=n=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(n),e.resetColumnOrder=n=>{var t;e.setColumnOrder(n?[]:(t=e.initialState.columnOrder)!=null?t:[])},e._getOrderColumnsFn=w(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(n,t,o)=>i=>{let r=[];if(!(n!=null&&n.length))r=i;else{const s=[...n],u=[...i];for(;u.length&&s.length;){const g=s.shift(),d=u.findIndex(f=>f.id===g);d>-1&&r.push(u.splice(d,1)[0])}r=[...r,...u]}return at(r,t,o)},v(e.options,"debugTable"))}},T=()=>({left:[],right:[]}),dt={getInitialState:e=>({columnPinning:T(),...e}),getDefaultOptions:e=>({onColumnPinningChange:y("columnPinning",e)}),createColumn:(e,n)=>{e.pin=t=>{const o=e.getLeafColumns().map(i=>i.id).filter(Boolean);n.setColumnPinning(i=>{var r,s;if(t==="right"){var u,g;return{left:((u=i==null?void 0:i.left)!=null?u:[]).filter(m=>!(o!=null&&o.includes(m))),right:[...((g=i==null?void 0:i.right)!=null?g:[]).filter(m=>!(o!=null&&o.includes(m))),...o]}}if(t==="left"){var d,f;return{left:[...((d=i==null?void 0:i.left)!=null?d:[]).filter(m=>!(o!=null&&o.includes(m))),...o],right:((f=i==null?void 0:i.right)!=null?f:[]).filter(m=>!(o!=null&&o.includes(m)))}}return{left:((r=i==null?void 0:i.left)!=null?r:[]).filter(m=>!(o!=null&&o.includes(m))),right:((s=i==null?void 0:i.right)!=null?s:[]).filter(m=>!(o!=null&&o.includes(m)))}})},e.getCanPin=()=>e.getLeafColumns().some(o=>{var i,r,s;return((i=o.columnDef.enablePinning)!=null?i:!0)&&((r=(s=n.options.enableColumnPinning)!=null?s:n.options.enablePinning)!=null?r:!0)}),e.getIsPinned=()=>{const t=e.getLeafColumns().map(u=>u.id),{left:o,right:i}=n.getState().columnPinning,r=t.some(u=>o==null?void 0:o.includes(u)),s=t.some(u=>i==null?void 0:i.includes(u));return r?"left":s?"right":!1},e.getPinnedIndex=()=>{var t,o;const i=e.getIsPinned();return i?(t=(o=n.getState().columnPinning)==null||(o=o[i])==null?void 0:o.indexOf(e.id))!=null?t:-1:0}},createRow:(e,n)=>{e.getCenterVisibleCells=w(()=>[e._getAllVisibleCells(),n.getState().columnPinning.left,n.getState().columnPinning.right],(t,o,i)=>{const r=[...o??[],...i??[]];return t.filter(s=>!r.includes(s.column.id))},v(n.options,"debugRows")),e.getLeftVisibleCells=w(()=>[e._getAllVisibleCells(),n.getState().columnPinning.left],(t,o)=>(o??[]).map(r=>t.find(s=>s.column.id===r)).filter(Boolean).map(r=>({...r,position:"left"})),v(n.options,"debugRows")),e.getRightVisibleCells=w(()=>[e._getAllVisibleCells(),n.getState().columnPinning.right],(t,o)=>(o??[]).map(r=>t.find(s=>s.column.id===r)).filter(Boolean).map(r=>({...r,position:"right"})),v(n.options,"debugRows"))},createTable:e=>{e.setColumnPinning=n=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(n),e.resetColumnPinning=n=>{var t,o;return e.setColumnPinning(n?T():(t=(o=e.initialState)==null?void 0:o.columnPinning)!=null?t:T())},e.getIsSomeColumnsPinned=n=>{var t;const o=e.getState().columnPinning;if(!n){var i,r;return!!((i=o.left)!=null&&i.length||(r=o.right)!=null&&r.length)}return!!((t=o[n])!=null&&t.length)},e.getLeftLeafColumns=w(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(n,t)=>(t??[]).map(o=>n.find(i=>i.id===o)).filter(Boolean),v(e.options,"debugColumns")),e.getRightLeafColumns=w(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(n,t)=>(t??[]).map(o=>n.find(i=>i.id===o)).filter(Boolean),v(e.options,"debugColumns")),e.getCenterLeafColumns=w(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,t,o)=>{const i=[...t??[],...o??[]];return n.filter(r=>!i.includes(r.id))},v(e.options,"debugColumns"))}};function ct(e){return e||(typeof document<"u"?document:null)}const N={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},q=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),ft={getDefaultColumnDef:()=>N,getInitialState:e=>({columnSizing:{},columnSizingInfo:q(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:y("columnSizing",e),onColumnSizingInfoChange:y("columnSizingInfo",e)}),createColumn:(e,n)=>{e.getSize=()=>{var t,o,i;const r=n.getState().columnSizing[e.id];return Math.min(Math.max((t=e.columnDef.minSize)!=null?t:N.minSize,(o=r??e.columnDef.size)!=null?o:N.size),(i=e.columnDef.maxSize)!=null?i:N.maxSize)},e.getStart=w(t=>[t,A(n,t),n.getState().columnSizing],(t,o)=>o.slice(0,e.getIndex(t)).reduce((i,r)=>i+r.getSize(),0),v(n.options,"debugColumns")),e.getAfter=w(t=>[t,A(n,t),n.getState().columnSizing],(t,o)=>o.slice(e.getIndex(t)+1).reduce((i,r)=>i+r.getSize(),0),v(n.options,"debugColumns")),e.resetSize=()=>{n.setColumnSizing(t=>{let{[e.id]:o,...i}=t;return i})},e.getCanResize=()=>{var t,o;return((t=e.columnDef.enableResizing)!=null?t:!0)&&((o=n.options.enableColumnResizing)!=null?o:!0)},e.getIsResizing=()=>n.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,n)=>{e.getSize=()=>{let t=0;const o=i=>{if(i.subHeaders.length)i.subHeaders.forEach(o);else{var r;t+=(r=i.column.getSize())!=null?r:0}};return o(e),t},e.getStart=()=>{if(e.index>0){const t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=t=>{const o=n.getColumn(e.column.id),i=o==null?void 0:o.getCanResize();return r=>{if(!o||!i||(r.persist==null||r.persist(),U(r)&&r.touches&&r.touches.length>1))return;const s=e.getSize(),u=e?e.getLeafHeaders().map(C=>[C.column.id,C.column.getSize()]):[[o.id,o.getSize()]],g=U(r)?Math.round(r.touches[0].clientX):r.clientX,d={},f=(C,R)=>{typeof R=="number"&&(n.setColumnSizingInfo(x=>{var V,F;const D=n.options.columnResizeDirection==="rtl"?-1:1,ue=(R-((V=x==null?void 0:x.startOffset)!=null?V:0))*D,ae=Math.max(ue/((F=x==null?void 0:x.startSize)!=null?F:0),-.999999);return x.columnSizingStart.forEach(Ve=>{let[Ie,ge]=Ve;d[Ie]=Math.round(Math.max(ge+ge*ae,0)*100)/100}),{...x,deltaOffset:ue,deltaPercentage:ae}}),(n.options.columnResizeMode==="onChange"||C==="end")&&n.setColumnSizing(x=>({...x,...d})))},m=C=>f("move",C),a=C=>{f("end",C),n.setColumnSizingInfo(R=>({...R,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},l=ct(t),c={moveHandler:C=>m(C.clientX),upHandler:C=>{l==null||l.removeEventListener("mousemove",c.moveHandler),l==null||l.removeEventListener("mouseup",c.upHandler),a(C.clientX)}},p={moveHandler:C=>(C.cancelable&&(C.preventDefault(),C.stopPropagation()),m(C.touches[0].clientX),!1),upHandler:C=>{var R;l==null||l.removeEventListener("touchmove",p.moveHandler),l==null||l.removeEventListener("touchend",p.upHandler),C.cancelable&&(C.preventDefault(),C.stopPropagation()),a((R=C.touches[0])==null?void 0:R.clientX)}},S=pt()?{passive:!1}:!1;U(r)?(l==null||l.addEventListener("touchmove",p.moveHandler,S),l==null||l.addEventListener("touchend",p.upHandler,S)):(l==null||l.addEventListener("mousemove",c.moveHandler,S),l==null||l.addEventListener("mouseup",c.upHandler,S)),n.setColumnSizingInfo(C=>({...C,startOffset:g,startSize:s,deltaOffset:0,deltaPercentage:0,columnSizingStart:u,isResizingColumn:o.id}))}}},createTable:e=>{e.setColumnSizing=n=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(n),e.setColumnSizingInfo=n=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(n),e.resetColumnSizing=n=>{var t;e.setColumnSizing(n?{}:(t=e.initialState.columnSizing)!=null?t:{})},e.resetHeaderSizeInfo=n=>{var t;e.setColumnSizingInfo(n?q():(t=e.initialState.columnSizingInfo)!=null?t:q())},e.getTotalSize=()=>{var n,t;return(n=(t=e.getHeaderGroups()[0])==null?void 0:t.headers.reduce((o,i)=>o+i.getSize(),0))!=null?n:0},e.getLeftTotalSize=()=>{var n,t;return(n=(t=e.getLeftHeaderGroups()[0])==null?void 0:t.headers.reduce((o,i)=>o+i.getSize(),0))!=null?n:0},e.getCenterTotalSize=()=>{var n,t;return(n=(t=e.getCenterHeaderGroups()[0])==null?void 0:t.headers.reduce((o,i)=>o+i.getSize(),0))!=null?n:0},e.getRightTotalSize=()=>{var n,t;return(n=(t=e.getRightHeaderGroups()[0])==null?void 0:t.headers.reduce((o,i)=>o+i.getSize(),0))!=null?n:0}}};let O=null;function pt(){if(typeof O=="boolean")return O;let e=!1;try{const n={get passive(){return e=!0,!1}},t=()=>{};window.addEventListener("test",t,n),window.removeEventListener("test",t)}catch{e=!1}return O=e,O}function U(e){return e.type==="touchstart"}const mt={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:y("columnVisibility",e)}),createColumn:(e,n)=>{e.toggleVisibility=t=>{e.getCanHide()&&n.setColumnVisibility(o=>({...o,[e.id]:t??!e.getIsVisible()}))},e.getIsVisible=()=>{var t,o;const i=e.columns;return(t=i.length?i.some(r=>r.getIsVisible()):(o=n.getState().columnVisibility)==null?void 0:o[e.id])!=null?t:!0},e.getCanHide=()=>{var t,o;return((t=e.columnDef.enableHiding)!=null?t:!0)&&((o=n.options.enableHiding)!=null?o:!0)},e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,n)=>{e._getAllVisibleCells=w(()=>[e.getAllCells(),n.getState().columnVisibility],t=>t.filter(o=>o.column.getIsVisible()),v(n.options,"debugRows")),e.getVisibleCells=w(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(t,o,i)=>[...t,...o,...i],v(n.options,"debugRows"))},createTable:e=>{const n=(t,o)=>w(()=>[o(),o().filter(i=>i.getIsVisible()).map(i=>i.id).join("_")],i=>i.filter(r=>r.getIsVisible==null?void 0:r.getIsVisible()),v(e.options,"debugColumns"));e.getVisibleFlatColumns=n("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=n("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=n("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=n("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=n("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{var o;e.setColumnVisibility(t?{}:(o=e.initialState.columnVisibility)!=null?o:{})},e.toggleAllColumnsVisible=t=>{var o;t=(o=t)!=null?o:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((i,r)=>({...i,[r.id]:t||!(r.getCanHide!=null&&r.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(t=>!(t.getIsVisible!=null&&t.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(t=>t.getIsVisible==null?void 0:t.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{var o;e.toggleAllColumnsVisible((o=t.target)==null?void 0:o.checked)}}};function A(e,n){return n?n==="center"?e.getCenterVisibleLeafColumns():n==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const St={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},ht={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:y("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:n=>{var t;const o=(t=e.getCoreRowModel().flatRows[0])==null||(t=t._getAllCellsByColumnId()[n.id])==null?void 0:t.getValue();return typeof o=="string"||typeof o=="number"}}),createColumn:(e,n)=>{e.getCanGlobalFilter=()=>{var t,o,i,r;return((t=e.columnDef.enableGlobalFilter)!=null?t:!0)&&((o=n.options.enableGlobalFilter)!=null?o:!0)&&((i=n.options.enableFilters)!=null?i:!0)&&((r=n.options.getColumnCanGlobalFilter==null?void 0:n.options.getColumnCanGlobalFilter(e))!=null?r:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>I.includesString,e.getGlobalFilterFn=()=>{var n,t;const{globalFilterFn:o}=e.options;return k(o)?o:o==="auto"?e.getGlobalAutoFilterFn():(n=(t=e.options.filterFns)==null?void 0:t[o])!=null?n:I[o]},e.setGlobalFilter=n=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(n)},e.resetGlobalFilter=n=>{e.setGlobalFilter(n?void 0:e.initialState.globalFilter)}}},Ct={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:y("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let n=!1,t=!1;e._autoResetExpanded=()=>{var o,i;if(!n){e._queue(()=>{n=!0});return}if((o=(i=e.options.autoResetAll)!=null?i:e.options.autoResetExpanded)!=null?o:!e.options.manualExpanding){if(t)return;t=!0,e._queue(()=>{e.resetExpanded(),t=!1})}},e.setExpanded=o=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(o),e.toggleAllRowsExpanded=o=>{o??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=o=>{var i,r;e.setExpanded(o?{}:(i=(r=e.initialState)==null?void 0:r.expanded)!=null?i:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(o=>o.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>o=>{o.persist==null||o.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const o=e.getState().expanded;return o===!0||Object.values(o).some(Boolean)},e.getIsAllRowsExpanded=()=>{const o=e.getState().expanded;return typeof o=="boolean"?o===!0:!(!Object.keys(o).length||e.getRowModel().flatRows.some(i=>!i.getIsExpanded()))},e.getExpandedDepth=()=>{let o=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(r=>{const s=r.split(".");o=Math.max(o,s.length)}),o},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,n)=>{e.toggleExpanded=t=>{n.setExpanded(o=>{var i;const r=o===!0?!0:!!(o!=null&&o[e.id]);let s={};if(o===!0?Object.keys(n.getRowModel().rowsById).forEach(u=>{s[u]=!0}):s=o,t=(i=t)!=null?i:!r,!r&&t)return{...s,[e.id]:!0};if(r&&!t){const{[e.id]:u,...g}=s;return g}return o})},e.getIsExpanded=()=>{var t;const o=n.getState().expanded;return!!((t=n.options.getIsRowExpanded==null?void 0:n.options.getIsRowExpanded(e))!=null?t:o===!0||o!=null&&o[e.id])},e.getCanExpand=()=>{var t,o,i;return(t=n.options.getRowCanExpand==null?void 0:n.options.getRowCanExpand(e))!=null?t:((o=n.options.enableExpanding)!=null?o:!0)&&!!((i=e.subRows)!=null&&i.length)},e.getIsAllParentsExpanded=()=>{let t=!0,o=e;for(;t&&o.parentId;)o=n.getRow(o.parentId,!0),t=o.getIsExpanded();return t},e.getToggleExpandedHandler=()=>{const t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},W=0,Y=10,b=()=>({pageIndex:W,pageSize:Y}),wt={getInitialState:e=>({...e,pagination:{...b(),...e==null?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:y("pagination",e)}),createTable:e=>{let n=!1,t=!1;e._autoResetPageIndex=()=>{var o,i;if(!n){e._queue(()=>{n=!0});return}if((o=(i=e.options.autoResetAll)!=null?i:e.options.autoResetPageIndex)!=null?o:!e.options.manualPagination){if(t)return;t=!0,e._queue(()=>{e.resetPageIndex(),t=!1})}},e.setPagination=o=>{const i=r=>P(o,r);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(i)},e.resetPagination=o=>{var i;e.setPagination(o?b():(i=e.initialState.pagination)!=null?i:b())},e.setPageIndex=o=>{e.setPagination(i=>{let r=P(o,i.pageIndex);const s=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return r=Math.max(0,Math.min(r,s)),{...i,pageIndex:r}})},e.resetPageIndex=o=>{var i,r;e.setPageIndex(o?W:(i=(r=e.initialState)==null||(r=r.pagination)==null?void 0:r.pageIndex)!=null?i:W)},e.resetPageSize=o=>{var i,r;e.setPageSize(o?Y:(i=(r=e.initialState)==null||(r=r.pagination)==null?void 0:r.pageSize)!=null?i:Y)},e.setPageSize=o=>{e.setPagination(i=>{const r=Math.max(1,P(o,i.pageSize)),s=i.pageSize*i.pageIndex,u=Math.floor(s/r);return{...i,pageIndex:u,pageSize:r}})},e.setPageCount=o=>e.setPagination(i=>{var r;let s=P(o,(r=e.options.pageCount)!=null?r:-1);return typeof s=="number"&&(s=Math.max(-1,s)),{...i,pageCount:s}}),e.getPageOptions=w(()=>[e.getPageCount()],o=>{let i=[];return o&&o>0&&(i=[...new Array(o)].fill(null).map((r,s)=>s)),i},v(e.options,"debugTable")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:o}=e.getState().pagination,i=e.getPageCount();return i===-1?!0:i===0?!1:o<i-1},e.previousPage=()=>e.setPageIndex(o=>o-1),e.nextPage=()=>e.setPageIndex(o=>o+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var o;return(o=e.options.pageCount)!=null?o:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var o;return(o=e.options.rowCount)!=null?o:e.getPrePaginationRowModel().rows.length}}},X=()=>({top:[],bottom:[]}),vt={getInitialState:e=>({rowPinning:X(),...e}),getDefaultOptions:e=>({onRowPinningChange:y("rowPinning",e)}),createRow:(e,n)=>{e.pin=(t,o,i)=>{const r=o?e.getLeafRows().map(g=>{let{id:d}=g;return d}):[],s=i?e.getParentRows().map(g=>{let{id:d}=g;return d}):[],u=new Set([...s,e.id,...r]);n.setRowPinning(g=>{var d,f;if(t==="bottom"){var m,a;return{top:((m=g==null?void 0:g.top)!=null?m:[]).filter(p=>!(u!=null&&u.has(p))),bottom:[...((a=g==null?void 0:g.bottom)!=null?a:[]).filter(p=>!(u!=null&&u.has(p))),...Array.from(u)]}}if(t==="top"){var l,c;return{top:[...((l=g==null?void 0:g.top)!=null?l:[]).filter(p=>!(u!=null&&u.has(p))),...Array.from(u)],bottom:((c=g==null?void 0:g.bottom)!=null?c:[]).filter(p=>!(u!=null&&u.has(p)))}}return{top:((d=g==null?void 0:g.top)!=null?d:[]).filter(p=>!(u!=null&&u.has(p))),bottom:((f=g==null?void 0:g.bottom)!=null?f:[]).filter(p=>!(u!=null&&u.has(p)))}})},e.getCanPin=()=>{var t;const{enableRowPinning:o,enablePinning:i}=n.options;return typeof o=="function"?o(e):(t=o??i)!=null?t:!0},e.getIsPinned=()=>{const t=[e.id],{top:o,bottom:i}=n.getState().rowPinning,r=t.some(u=>o==null?void 0:o.includes(u)),s=t.some(u=>i==null?void 0:i.includes(u));return r?"top":s?"bottom":!1},e.getPinnedIndex=()=>{var t,o;const i=e.getIsPinned();if(!i)return-1;const r=(t=i==="top"?n.getTopRows():n.getBottomRows())==null?void 0:t.map(s=>{let{id:u}=s;return u});return(o=r==null?void 0:r.indexOf(e.id))!=null?o:-1}},createTable:e=>{e.setRowPinning=n=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(n),e.resetRowPinning=n=>{var t,o;return e.setRowPinning(n?X():(t=(o=e.initialState)==null?void 0:o.rowPinning)!=null?t:X())},e.getIsSomeRowsPinned=n=>{var t;const o=e.getState().rowPinning;if(!n){var i,r;return!!((i=o.top)!=null&&i.length||(r=o.bottom)!=null&&r.length)}return!!((t=o[n])!=null&&t.length)},e._getPinnedRows=(n,t,o)=>{var i;return((i=e.options.keepPinnedRows)==null||i?(t??[]).map(s=>{const u=e.getRow(s,!0);return u.getIsAllParentsExpanded()?u:null}):(t??[]).map(s=>n.find(u=>u.id===s))).filter(Boolean).map(s=>({...s,position:o}))},e.getTopRows=w(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(n,t)=>e._getPinnedRows(n,t,"top"),v(e.options,"debugRows")),e.getBottomRows=w(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(n,t)=>e._getPinnedRows(n,t,"bottom"),v(e.options,"debugRows")),e.getCenterRows=w(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(n,t,o)=>{const i=new Set([...t??[],...o??[]]);return n.filter(r=>!i.has(r.id))},v(e.options,"debugRows"))}},Rt={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:y("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=n=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(n),e.resetRowSelection=n=>{var t;return e.setRowSelection(n?{}:(t=e.initialState.rowSelection)!=null?t:{})},e.toggleAllRowsSelected=n=>{e.setRowSelection(t=>{n=typeof n<"u"?n:!e.getIsAllRowsSelected();const o={...t},i=e.getPreGroupedRowModel().flatRows;return n?i.forEach(r=>{r.getCanSelect()&&(o[r.id]=!0)}):i.forEach(r=>{delete o[r.id]}),o})},e.toggleAllPageRowsSelected=n=>e.setRowSelection(t=>{const o=typeof n<"u"?n:!e.getIsAllPageRowsSelected(),i={...t};return e.getRowModel().rows.forEach(r=>{Z(i,r.id,o,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=w(()=>[e.getState().rowSelection,e.getCoreRowModel()],(n,t)=>Object.keys(n).length?K(e,t):{rows:[],flatRows:[],rowsById:{}},v(e.options,"debugTable")),e.getFilteredSelectedRowModel=w(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(n,t)=>Object.keys(n).length?K(e,t):{rows:[],flatRows:[],rowsById:{}},v(e.options,"debugTable")),e.getGroupedSelectedRowModel=w(()=>[e.getState().rowSelection,e.getSortedRowModel()],(n,t)=>Object.keys(n).length?K(e,t):{rows:[],flatRows:[],rowsById:{}},v(e.options,"debugTable")),e.getIsAllRowsSelected=()=>{const n=e.getFilteredRowModel().flatRows,{rowSelection:t}=e.getState();let o=!!(n.length&&Object.keys(t).length);return o&&n.some(i=>i.getCanSelect()&&!t[i.id])&&(o=!1),o},e.getIsAllPageRowsSelected=()=>{const n=e.getPaginationRowModel().flatRows.filter(i=>i.getCanSelect()),{rowSelection:t}=e.getState();let o=!!n.length;return o&&n.some(i=>!t[i.id])&&(o=!1),o},e.getIsSomeRowsSelected=()=>{var n;const t=Object.keys((n=e.getState().rowSelection)!=null?n:{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const n=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:n.filter(t=>t.getCanSelect()).some(t=>t.getIsSelected()||t.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>n=>{e.toggleAllRowsSelected(n.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>n=>{e.toggleAllPageRowsSelected(n.target.checked)}},createRow:(e,n)=>{e.toggleSelected=(t,o)=>{const i=e.getIsSelected();n.setRowSelection(r=>{var s;if(t=typeof t<"u"?t:!i,e.getCanSelect()&&i===t)return r;const u={...r};return Z(u,e.id,t,(s=o==null?void 0:o.selectChildren)!=null?s:!0,n),u})},e.getIsSelected=()=>{const{rowSelection:t}=n.getState();return le(e,t)},e.getIsSomeSelected=()=>{const{rowSelection:t}=n.getState();return ee(e,t)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:t}=n.getState();return ee(e,t)==="all"},e.getCanSelect=()=>{var t;return typeof n.options.enableRowSelection=="function"?n.options.enableRowSelection(e):(t=n.options.enableRowSelection)!=null?t:!0},e.getCanSelectSubRows=()=>{var t;return typeof n.options.enableSubRowSelection=="function"?n.options.enableSubRowSelection(e):(t=n.options.enableSubRowSelection)!=null?t:!0},e.getCanMultiSelect=()=>{var t;return typeof n.options.enableMultiRowSelection=="function"?n.options.enableMultiRowSelection(e):(t=n.options.enableMultiRowSelection)!=null?t:!0},e.getToggleSelectedHandler=()=>{const t=e.getCanSelect();return o=>{var i;t&&e.toggleSelected((i=o.target)==null?void 0:i.checked)}}}},Z=(e,n,t,o,i)=>{var r;const s=i.getRow(n,!0);t?(s.getCanMultiSelect()||Object.keys(e).forEach(u=>delete e[u]),s.getCanSelect()&&(e[n]=!0)):delete e[n],o&&(r=s.subRows)!=null&&r.length&&s.getCanSelectSubRows()&&s.subRows.forEach(u=>Z(e,u.id,t,o,i))};function K(e,n){const t=e.getState().rowSelection,o=[],i={},r=function(s,u){return s.map(g=>{var d;const f=le(g,t);if(f&&(o.push(g),i[g.id]=g),(d=g.subRows)!=null&&d.length&&(g={...g,subRows:r(g.subRows)}),f)return g}).filter(Boolean)};return{rows:r(n.rows),flatRows:o,rowsById:i}}function le(e,n){var t;return(t=n[e.id])!=null?t:!1}function ee(e,n,t){var o;if(!((o=e.subRows)!=null&&o.length))return!1;let i=!0,r=!1;return e.subRows.forEach(s=>{if(!(r&&!i)&&(s.getCanSelect()&&(le(s,n)?r=!0:i=!1),s.subRows&&s.subRows.length)){const u=ee(s,n);u==="all"?r=!0:(u==="some"&&(r=!0),i=!1)}}),i?"all":r?"some":!1}const te=/([0-9]+)/gm,xt=(e,n,t)=>ye(E(e.getValue(t)).toLowerCase(),E(n.getValue(t)).toLowerCase()),_t=(e,n,t)=>ye(E(e.getValue(t)),E(n.getValue(t))),Ft=(e,n,t)=>se(E(e.getValue(t)).toLowerCase(),E(n.getValue(t)).toLowerCase()),$t=(e,n,t)=>se(E(e.getValue(t)),E(n.getValue(t))),yt=(e,n,t)=>{const o=e.getValue(t),i=n.getValue(t);return o>i?1:o<i?-1:0},Mt=(e,n,t)=>se(e.getValue(t),n.getValue(t));function se(e,n){return e===n?0:e>n?1:-1}function E(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function ye(e,n){const t=e.split(te).filter(Boolean),o=n.split(te).filter(Boolean);for(;t.length&&o.length;){const i=t.shift(),r=o.shift(),s=parseInt(i,10),u=parseInt(r,10),g=[s,u].sort();if(isNaN(g[0])){if(i>r)return 1;if(r>i)return-1;continue}if(isNaN(g[1]))return isNaN(s)?-1:1;if(s>u)return 1;if(u>s)return-1}return t.length-o.length}const H={alphanumeric:xt,alphanumericCaseSensitive:_t,text:Ft,textCaseSensitive:$t,datetime:yt,basic:Mt},Vt={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:y("sorting",e),isMultiSortEvent:n=>n.shiftKey}),createColumn:(e,n)=>{e.getAutoSortingFn=()=>{const t=n.getFilteredRowModel().flatRows.slice(10);let o=!1;for(const i of t){const r=i==null?void 0:i.getValue(e.id);if(Object.prototype.toString.call(r)==="[object Date]")return H.datetime;if(typeof r=="string"&&(o=!0,r.split(te).length>1))return H.alphanumeric}return o?H.text:H.basic},e.getAutoSortDir=()=>{const t=n.getFilteredRowModel().flatRows[0];return typeof(t==null?void 0:t.getValue(e.id))=="string"?"asc":"desc"},e.getSortingFn=()=>{var t,o;if(!e)throw new Error;return k(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(t=(o=n.options.sortingFns)==null?void 0:o[e.columnDef.sortingFn])!=null?t:H[e.columnDef.sortingFn]},e.toggleSorting=(t,o)=>{const i=e.getNextSortingOrder(),r=typeof t<"u"&&t!==null;n.setSorting(s=>{const u=s==null?void 0:s.find(l=>l.id===e.id),g=s==null?void 0:s.findIndex(l=>l.id===e.id);let d=[],f,m=r?t:i==="desc";if(s!=null&&s.length&&e.getCanMultiSort()&&o?u?f="toggle":f="add":s!=null&&s.length&&g!==s.length-1?f="replace":u?f="toggle":f="replace",f==="toggle"&&(r||i||(f="remove")),f==="add"){var a;d=[...s,{id:e.id,desc:m}],d.splice(0,d.length-((a=n.options.maxMultiSortColCount)!=null?a:Number.MAX_SAFE_INTEGER))}else f==="toggle"?d=s.map(l=>l.id===e.id?{...l,desc:m}:l):f==="remove"?d=s.filter(l=>l.id!==e.id):d=[{id:e.id,desc:m}];return d})},e.getFirstSortDir=()=>{var t,o;return((t=(o=e.columnDef.sortDescFirst)!=null?o:n.options.sortDescFirst)!=null?t:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=t=>{var o,i;const r=e.getFirstSortDir(),s=e.getIsSorted();return s?s!==r&&((o=n.options.enableSortingRemoval)==null||o)&&(!(t&&(i=n.options.enableMultiRemove)!=null)||i)?!1:s==="desc"?"asc":"desc":r},e.getCanSort=()=>{var t,o;return((t=e.columnDef.enableSorting)!=null?t:!0)&&((o=n.options.enableSorting)!=null?o:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var t,o;return(t=(o=e.columnDef.enableMultiSort)!=null?o:n.options.enableMultiSort)!=null?t:!!e.accessorFn},e.getIsSorted=()=>{var t;const o=(t=n.getState().sorting)==null?void 0:t.find(i=>i.id===e.id);return o?o.desc?"desc":"asc":!1},e.getSortIndex=()=>{var t,o;return(t=(o=n.getState().sorting)==null?void 0:o.findIndex(i=>i.id===e.id))!=null?t:-1},e.clearSorting=()=>{n.setSorting(t=>t!=null&&t.length?t.filter(o=>o.id!==e.id):[])},e.getToggleSortingHandler=()=>{const t=e.getCanSort();return o=>{t&&(o.persist==null||o.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?n.options.isMultiSortEvent==null?void 0:n.options.isMultiSortEvent(o):!1))}}},createTable:e=>{e.setSorting=n=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(n),e.resetSorting=n=>{var t,o;e.setSorting(n?[]:(t=(o=e.initialState)==null?void 0:o.sorting)!=null?t:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},It=[Je,mt,gt,dt,We,Ye,St,ht,Vt,ut,Ct,wt,vt,Rt,ft];function Pt(e){var n,t;const o=[...It,...(n=e._features)!=null?n:[]];let i={_features:o};const r=i._features.reduce((a,l)=>Object.assign(a,l.getDefaultOptions==null?void 0:l.getDefaultOptions(i)),{}),s=a=>i.options.mergeOptions?i.options.mergeOptions(r,a):{...r,...a};let g={...{},...(t=e.initialState)!=null?t:{}};i._features.forEach(a=>{var l;g=(l=a.getInitialState==null?void 0:a.getInitialState(g))!=null?l:g});const d=[];let f=!1;const m={_features:o,options:{...r,...e},initialState:g,_queue:a=>{d.push(a),f||(f=!0,Promise.resolve().then(()=>{for(;d.length;)d.shift()();f=!1}).catch(l=>setTimeout(()=>{throw l})))},reset:()=>{i.setState(i.initialState)},setOptions:a=>{const l=P(a,i.options);i.options=s(l)},getState:()=>i.options.state,setState:a=>{i.options.onStateChange==null||i.options.onStateChange(a)},_getRowId:(a,l,c)=>{var p;return(p=i.options.getRowId==null?void 0:i.options.getRowId(a,l,c))!=null?p:`${c?[c.id,l].join("."):l}`},getCoreRowModel:()=>(i._getCoreRowModel||(i._getCoreRowModel=i.options.getCoreRowModel(i)),i._getCoreRowModel()),getRowModel:()=>i.getPaginationRowModel(),getRow:(a,l)=>{let c=(l?i.getPrePaginationRowModel():i.getRowModel()).rowsById[a];if(!c&&(c=i.getCoreRowModel().rowsById[a],!c))throw new Error;return c},_getDefaultColumnDef:w(()=>[i.options.defaultColumn],a=>{var l;return a=(l=a)!=null?l:{},{header:c=>{const p=c.header.column.columnDef;return p.accessorKey?p.accessorKey:p.accessorFn?p.id:null},cell:c=>{var p,S;return(p=(S=c.renderValue())==null||S.toString==null?void 0:S.toString())!=null?p:null},...i._features.reduce((c,p)=>Object.assign(c,p.getDefaultColumnDef==null?void 0:p.getDefaultColumnDef()),{}),...a}},v(e,"debugColumns")),_getColumnDefs:()=>i.options.columns,getAllColumns:w(()=>[i._getColumnDefs()],a=>{const l=function(c,p,S){return S===void 0&&(S=0),c.map(C=>{const R=Qe(i,C,S,p),x=C;return R.columns=x.columns?l(x.columns,R,S+1):[],R})};return l(a)},v(e,"debugColumns")),getAllFlatColumns:w(()=>[i.getAllColumns()],a=>a.flatMap(l=>l.getFlatColumns()),v(e,"debugColumns")),_getAllFlatColumnsById:w(()=>[i.getAllFlatColumns()],a=>a.reduce((l,c)=>(l[c.id]=c,l),{}),v(e,"debugColumns")),getAllLeafColumns:w(()=>[i.getAllColumns(),i._getOrderColumnsFn()],(a,l)=>{let c=a.flatMap(p=>p.getLeafColumns());return l(c)},v(e,"debugColumns")),getColumn:a=>i._getAllFlatColumnsById()[a]};Object.assign(i,m);for(let a=0;a<i._features.length;a++){const l=i._features[a];l==null||l.createTable==null||l.createTable(i)}return i}function Et(){return e=>w(()=>[e.options.data],n=>{const t={rows:[],flatRows:[],rowsById:{}},o=function(i,r,s){r===void 0&&(r=0);const u=[];for(let d=0;d<i.length;d++){const f=ie(e,e._getRowId(i[d],d,s),i[d],d,r,void 0,s==null?void 0:s.id);if(t.flatRows.push(f),t.rowsById[f.id]=f,u.push(f),e.options.getSubRows){var g;f.originalSubRows=e.options.getSubRows(i[d],d),(g=f.originalSubRows)!=null&&g.length&&(f.subRows=o(f.originalSubRows,r+1,f))}}return u};return t.rows=o(n),t},v(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Dt(){return e=>w(()=>[e.getState().expanded,e.getPreExpandedRowModel(),e.options.paginateExpandedRows],(n,t,o)=>!t.rows.length||n!==!0&&!Object.keys(n??{}).length||!o?t:Gt(t),v(e.options,"debugTable"))}function Gt(e){const n=[],t=o=>{var i;n.push(o),(i=o.subRows)!=null&&i.length&&o.getIsExpanded()&&o.subRows.forEach(t)};return e.rows.forEach(t),{rows:n,flatRows:e.flatRows,rowsById:e.rowsById}}function zt(e,n,t){return t.options.filterFromLeafRows?Ht(e,n,t):At(e,n,t)}function Ht(e,n,t){var o;const i=[],r={},s=(o=t.options.maxLeafRowFilterDepth)!=null?o:100,u=function(g,d){d===void 0&&(d=0);const f=[];for(let a=0;a<g.length;a++){var m;let l=g[a];const c=ie(t,l.id,l.original,l.index,l.depth,void 0,l.parentId);if(c.columnFilters=l.columnFilters,(m=l.subRows)!=null&&m.length&&d<s){if(c.subRows=u(l.subRows,d+1),l=c,n(l)&&!c.subRows.length){f.push(l),r[l.id]=l,i.push(l);continue}if(n(l)||c.subRows.length){f.push(l),r[l.id]=l,i.push(l);continue}}else l=c,n(l)&&(f.push(l),r[l.id]=l,i.push(l))}return f};return{rows:u(e),flatRows:i,rowsById:r}}function At(e,n,t){var o;const i=[],r={},s=(o=t.options.maxLeafRowFilterDepth)!=null?o:100,u=function(g,d){d===void 0&&(d=0);const f=[];for(let a=0;a<g.length;a++){let l=g[a];if(n(l)){var m;if((m=l.subRows)!=null&&m.length&&d<s){const p=ie(t,l.id,l.original,l.index,l.depth,void 0,l.parentId);p.subRows=u(l.subRows,d+1),l=p}f.push(l),i.push(l),r[l.id]=l}}return f};return{rows:u(e),flatRows:i,rowsById:r}}function Lt(){return e=>w(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(n,t,o)=>{if(!n.rows.length||!(t!=null&&t.length)&&!o){for(let a=0;a<n.flatRows.length;a++)n.flatRows[a].columnFilters={},n.flatRows[a].columnFiltersMeta={};return n}const i=[],r=[];(t??[]).forEach(a=>{var l;const c=e.getColumn(a.id);if(!c)return;const p=c.getFilterFn();p&&i.push({id:a.id,filterFn:p,resolvedValue:(l=p.resolveFilterValue==null?void 0:p.resolveFilterValue(a.value))!=null?l:a.value})});const s=(t??[]).map(a=>a.id),u=e.getGlobalFilterFn(),g=e.getAllLeafColumns().filter(a=>a.getCanGlobalFilter());o&&u&&g.length&&(s.push("__global__"),g.forEach(a=>{var l;r.push({id:a.id,filterFn:u,resolvedValue:(l=u.resolveFilterValue==null?void 0:u.resolveFilterValue(o))!=null?l:o})}));let d,f;for(let a=0;a<n.flatRows.length;a++){const l=n.flatRows[a];if(l.columnFilters={},i.length)for(let c=0;c<i.length;c++){d=i[c];const p=d.id;l.columnFilters[p]=d.filterFn(l,p,d.resolvedValue,S=>{l.columnFiltersMeta[p]=S})}if(r.length){for(let c=0;c<r.length;c++){f=r[c];const p=f.id;if(f.filterFn(l,p,f.resolvedValue,S=>{l.columnFiltersMeta[p]=S})){l.columnFilters.__global__=!0;break}}l.columnFilters.__global__!==!0&&(l.columnFilters.__global__=!1)}}const m=a=>{for(let l=0;l<s.length;l++)if(a.columnFilters[s[l]]===!1)return!1;return!0};return zt(n.rows,m,e)},v(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function jt(){return e=>w(()=>[e.getState().sorting,e.getPreSortedRowModel()],(n,t)=>{if(!t.rows.length||!(n!=null&&n.length))return t;const o=e.getState().sorting,i=[],r=o.filter(g=>{var d;return(d=e.getColumn(g.id))==null?void 0:d.getCanSort()}),s={};r.forEach(g=>{const d=e.getColumn(g.id);d&&(s[g.id]={sortUndefined:d.columnDef.sortUndefined,invertSorting:d.columnDef.invertSorting,sortingFn:d.getSortingFn()})});const u=g=>{const d=g.map(f=>({...f}));return d.sort((f,m)=>{for(let l=0;l<r.length;l+=1){var a;const c=r[l],p=s[c.id],S=p.sortUndefined,C=(a=c==null?void 0:c.desc)!=null?a:!1;let R=0;if(S){const x=f.getValue(c.id),V=m.getValue(c.id),F=x===void 0,D=V===void 0;if(F||D){if(S==="first")return F?-1:1;if(S==="last")return F?1:-1;R=F&&D?0:F?S:-S}}if(R===0&&(R=p.sortingFn(f,m,c.id)),R!==0)return C&&(R*=-1),p.invertSorting&&(R*=-1),R}return f.index-m.index}),d.forEach(f=>{var m;i.push(f),(m=f.subRows)!=null&&m.length&&(f.subRows=u(f.subRows))}),d};return{rows:u(t.rows),flatRows:i,rowsById:t.rowsById}},v(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}/**
|
|
14
|
-
* react-table
|
|
15
|
-
*
|
|
16
|
-
* Copyright (c) TanStack
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the MIT license found in the
|
|
19
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
20
|
-
*
|
|
21
|
-
* @license MIT
|
|
22
|
-
*/function Q(e,n){return e?Nt(e)?$.createElement(e,n):e:null}function Nt(e){return Ot(e)||typeof e=="function"||kt(e)}function Ot(e){return typeof e=="function"&&(()=>{const n=Object.getPrototypeOf(e);return n.prototype&&n.prototype.isReactComponent})()}function kt(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function Bt(e){const n={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[t]=$.useState(()=>({current:Pt(n)})),[o,i]=$.useState(()=>t.current.initialState);return t.current.setOptions(r=>({...r,...e,state:{...o,...e.state},onStateChange:s=>{i(s),e.onStateChange==null||e.onStateChange(s)}})),t.current}const G=Ue(),Me=h.jsx("span",{className:"text-fg-faint",children:"—"}),Tt=e=>`${he(e.label)} ${e.label} ${e.models.map(oe).join(" ")} ${e.models.join(" ")}`.toLowerCase();function qt(e){return $.useMemo(()=>[G.accessor("label",{header:e,cell:n=>h.jsxs("button",{type:"button","aria-expanded":n.row.getIsExpanded(),onClick:t=>{t.stopPropagation(),n.row.toggleExpanded()},className:"flex items-center gap-1 rounded text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent",children:[h.jsx("span",{"aria-hidden":!0,className:n.row.getIsExpanded()?"text-accent":"text-fg-faint",children:n.row.getIsExpanded()?"▾":"▸"}),h.jsx("span",{className:"text-fg",children:he(n.getValue())})]})}),G.display({id:"models",header:"models",cell:n=>h.jsx("span",{className:"line-clamp-1 text-fg-dim",children:n.row.original.models.map(oe).join(", ")})}),G.accessor("total",{header:"tokens",meta:{align:"right"},cell:n=>n.getValue()>0?h.jsx("span",{className:"text-fg",children:J(n.getValue())}):Me}),G.accessor("cacheSavings",{header:"saved",meta:{align:"right",hiddenSm:!0},cell:n=>h.jsx("span",{className:"text-positive",children:z(n.getValue())})}),G.accessor("count",{header:"calls",meta:{align:"right",hiddenSm:!0},cell:n=>h.jsx("span",{className:"text-fg-dim",children:Se(n.getValue())})}),G.accessor("cost",{header:"cost",meta:{align:"right"},cell:n=>h.jsx("span",{className:"text-cost",children:z(n.getValue())})})],[e])}const Ut=e=>`py-2 pr-3${(e==null?void 0:e.align)==="right"?" text-right":""}${e!=null&&e.hiddenSm?" hidden sm:table-cell":""}`;function bt({rows:e,granLabel:n,q:t}){const[o,i]=$.useState([{id:"label",desc:!0}]),[r,s]=$.useState({}),g=qt(n==="monthly"?"month":n==="weekly"?"week":"date"),d=Bt({data:e,columns:g,state:{sorting:o,expanded:r,globalFilter:t},onSortingChange:i,onExpandedChange:s,getRowCanExpand:()=>!0,globalFilterFn:(a,l,c)=>!String(c).trim()||Tt(a.original).includes(String(c).trim().toLowerCase()),getCoreRowModel:Et(),getSortedRowModel:jt(),getFilteredRowModel:Lt(),getExpandedRowModel:Dt()}),f=d.getRowModel().rows,m=$.useMemo(()=>f.reduce((a,l)=>({total:a.total+l.original.total,cost:a.cost+l.original.cost,cacheSavings:a.cacheSavings+l.original.cacheSavings,count:a.count+l.original.count}),{total:0,cost:0,cacheSavings:0,count:0}),[f]);return h.jsx(ke,{title:`explore · ${n}`,captureName:"explore",children:h.jsx("div",{className:"max-h-[calc(100vh-240px)] overflow-auto",children:h.jsxs("table",{className:"w-full border-collapse text-xs",children:[h.jsxs("caption",{className:"sr-only",children:["Usage by ",n,", including tokens, cache savings, calls, and cost"]}),h.jsxs("colgroup",{children:[h.jsx("col",{}),h.jsx("col",{style:{width:"34%"}}),h.jsx("col",{style:{width:"13%"}}),h.jsx("col",{style:{width:"12%"}}),h.jsx("col",{style:{width:"11%"}}),h.jsx("col",{style:{width:"13%"}})]}),h.jsx("thead",{children:h.jsx("tr",{className:"sticky top-0 z-10 bg-bg-1 text-[11px] shadow-[inset_0_-1px_0_var(--color-line)]",children:d.getHeaderGroups()[0].headers.map(a=>{const l=a.column.columnDef.meta,c=a.column.getIsSorted();return h.jsx("th",{scope:"col","aria-sort":c?c==="asc"?"ascending":"descending":void 0,className:`py-2 pr-3 font-normal ${(l==null?void 0:l.align)==="right"?"text-right":"text-left"}${l!=null&&l.hiddenSm?" hidden sm:table-cell":""}`,children:a.column.getCanSort()?h.jsxs("button",{type:"button",onClick:a.column.getToggleSortingHandler(),className:`flex w-full items-center gap-1 rounded text-fg-faint transition hover:text-fg focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent ${(l==null?void 0:l.align)==="right"?"justify-end":""}`,children:[Q(a.column.columnDef.header,a.getContext()),c&&h.jsx("span",{className:"text-accent",children:c==="asc"?"▲":"▼"})]}):h.jsx("span",{className:"text-fg-faint",children:Q(a.column.columnDef.header,a.getContext())})},a.id)})})}),h.jsxs("tbody",{children:[f.length===0&&h.jsx("tr",{children:h.jsx("td",{colSpan:6,className:"py-8 text-center text-fg-faint",children:t.trim()?`no rows match “${t.trim()}”`:"no usage in this range"})}),f.map(a=>h.jsxs($.Fragment,{children:[h.jsx("tr",{className:"usage-row border-b border-line-faint transition hover:bg-bg-2/60",children:a.getVisibleCells().map(l=>h.jsx("td",{className:`${Ut(l.column.columnDef.meta)}${l.column.id==="label"?" whitespace-nowrap":""} tnum`,children:Q(l.column.columnDef.cell,l.getContext())},l.id))}),a.getIsExpanded()&&a.original.breakdown.map(l=>{const c=L(l);return h.jsxs("tr",{className:"usage-row border-b border-line-faint bg-bg-0/40 text-[11px]",children:[h.jsxs("td",{className:"py-1.5 pr-3 pl-5 text-fg-dim",colSpan:2,children:[h.jsx("span",{className:"mr-1.5 inline-block size-1.5 rounded-full align-middle",style:{background:Ge(l.name)},"aria-hidden":!0}),oe(l.name)]}),h.jsx("td",{className:"tnum py-1.5 pr-3 text-right text-fg-dim",children:c>0?J(c):Me}),h.jsx("td",{className:"tnum hidden py-1.5 pr-3 text-right text-positive/80 sm:table-cell",children:z(l.cacheSavings)}),h.jsx("td",{className:"tnum hidden py-1.5 pr-3 text-right text-fg-faint sm:table-cell",children:ze(l.count)}),h.jsx("td",{className:"tnum py-1.5 text-right text-cost/90",children:z(l.cost)})]},l.name)})]},a.id))]}),f.length>0&&h.jsx("tfoot",{children:h.jsxs("tr",{className:"sticky bottom-0 z-10 bg-bg-1 text-fg shadow-[inset_0_1px_0_var(--color-line)]",children:[h.jsxs("td",{className:"py-2 pr-3 font-display text-[11px] uppercase text-fg-dim",colSpan:2,children:["total · ",f.length]}),h.jsx("td",{className:"tnum py-2 pr-3 text-right",children:J(m.total)}),h.jsx("td",{className:"tnum hidden py-2 pr-3 text-right text-positive sm:table-cell",children:z(m.cacheSavings)}),h.jsx("td",{className:"tnum hidden py-2 pr-3 text-right sm:table-cell",children:Se(m.count)}),h.jsx("td",{className:"tnum py-2 text-right text-cost",children:z(m.cost)})]})})]})})})}const Xt=[{value:"daily",label:"daily"},{value:"weekly",label:"weekly"},{value:"monthly",label:"monthly"}];function Jt({snapshot:e,filters:n,periodLabel:t,privacyMode:o}){const[i,r]=$.useState(""),[s,u]=$.useState("daily"),g=He(),d=n.models.length===1?n.models[0]:null,f=$.useMemo(()=>Te(e,n,s),[e,n,s]),m=$.useMemo(()=>d?qe(e,n,d):null,[e,n,d]),a=$.useMemo(()=>(e?ne(e,n):[]).some(c=>c.tableState!=="ready"),[e,n]),l=s==="daily"?`scoped to ${t}`:`showing up to ${s==="monthly"?"12 months":"12 weeks"}`;return h.jsxs("div",{className:"flex flex-col gap-3",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-fg-faint",children:"granularity:"}),h.jsx(Ae,{options:[...Xt],value:s,onChange:u,size:"sm",ariaLabel:"Row granularity",btnClassName:"px-3 py-1 text-xs capitalize transition"})]}),h.jsx("span",{className:"text-xs text-fg-faint",children:l}),a?h.jsxs("span",{className:"text-xs text-fg-faint",role:"status","aria-live":"polite",children:["loading history",h.jsx("span",{className:"cursor-blink text-accent","aria-hidden":!0,children:"▋"})]}):null,d&&m?h.jsxs("button",{type:"button",onClick:()=>g({kind:"model",model:d,periodLabel:t,tz:(e==null?void 0:e.tz)??"",version:(e==null?void 0:e.version)??"",...m,accounts:m.accounts.map(c=>({...c,name:je(c.name,o)}))}),className:"flex items-center gap-1.5 rounded border border-line bg-bg-1 px-2.5 py-1 text-xs text-fg-dim transition hover:border-accent/60 hover:text-accent active:scale-[0.97] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent max-sm:py-2",title:"Create a shareable model image",children:[h.jsx(Le,{className:"size-3.5"}),h.jsx("span",{children:"share model"})]}):null,h.jsxs("div",{className:"ml-auto flex items-center gap-1.5 rounded border border-line bg-bg-1 px-2 py-1 text-xs focus-within:border-line-2 focus-within:ring-1 focus-within:ring-accent",children:[h.jsx(Ne,{className:"size-3 text-fg-faint"}),h.jsx("input",{type:"search",name:"usage-filter",value:i,onChange:c=>r(c.target.value),onKeyDown:c=>{c.key==="Escape"&&r("")},placeholder:"filter rows…","aria-label":"Filter rows by date or model",autoComplete:"off",spellCheck:!1,className:"w-32 bg-transparent text-fg outline-none placeholder:text-fg-faint [&::-webkit-search-cancel-button]:appearance-none"}),i?h.jsx("button",{type:"button",onClick:()=>r(""),"aria-label":"Clear row filter",className:"rounded focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent",children:h.jsx(Oe,{className:"size-3 text-fg-faint hover:text-fg"})}):null]})]}),h.jsx(bt,{rows:f,granLabel:s,q:i})]})}export{Jt as ExploreTab};
|