gitlytics 0.1.1__py3-none-any.whl
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.
- github_traffic/__init__.py +4 -0
- github_traffic/api.py +76 -0
- github_traffic/automation.py +122 -0
- github_traffic/cli.py +154 -0
- github_traffic/core.py +147 -0
- github_traffic/frontend/dist/assets/axios-BATw4G7Y.js +9 -0
- github_traffic/frontend/dist/assets/index-BJy89P_N.js +44 -0
- github_traffic/frontend/dist/assets/index-DHekp9vT.css +1 -0
- github_traffic/frontend/dist/favicon.svg +1 -0
- github_traffic/frontend/dist/icons.svg +24 -0
- github_traffic/frontend/dist/index.html +14 -0
- github_traffic/frontend/node_modules/flatted/python/flatted.py +144 -0
- github_traffic/process.py +43 -0
- gitlytics-0.1.1.dist-info/METADATA +201 -0
- gitlytics-0.1.1.dist-info/RECORD +19 -0
- gitlytics-0.1.1.dist-info/WHEEL +5 -0
- gitlytics-0.1.1.dist-info/entry_points.txt +2 -0
- gitlytics-0.1.1.dist-info/licenses/LICENSE +201 -0
- gitlytics-0.1.1.dist-info/top_level.txt +1 -0
github_traffic/api.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
api.py
|
|
3
|
+
This file powers the FastAPI backend, serving our data and React dashboard to the browser!
|
|
4
|
+
"""
|
|
5
|
+
import os
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from fastapi import FastAPI, HTTPException, Header, Body, File, UploadFile
|
|
8
|
+
from fastapi.staticfiles import StaticFiles
|
|
9
|
+
from fastapi.responses import FileResponse, JSONResponse
|
|
10
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
11
|
+
import pandas as pd
|
|
12
|
+
|
|
13
|
+
from github_traffic.core import validate_token, fetch_all_traffic
|
|
14
|
+
from github_traffic.process import process_uploaded_csv
|
|
15
|
+
|
|
16
|
+
app = FastAPI(title="GitHub Traffic API")
|
|
17
|
+
|
|
18
|
+
# Allow CORS for local development (Vite runs on 5173 usually)
|
|
19
|
+
app.add_middleware(
|
|
20
|
+
CORSMiddleware,
|
|
21
|
+
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173"],
|
|
22
|
+
allow_credentials=True,
|
|
23
|
+
allow_methods=["*"],
|
|
24
|
+
allow_headers=["*"],
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
@app.post("/api/auth")
|
|
28
|
+
def auth(token: str = Body(..., embed=True)):
|
|
29
|
+
ok, username, avatar_url, name = validate_token(token)
|
|
30
|
+
if not ok:
|
|
31
|
+
raise HTTPException(status_code=401, detail=username) # validate_token returns error msg in username slot
|
|
32
|
+
return {
|
|
33
|
+
"authenticated": True,
|
|
34
|
+
"username": username,
|
|
35
|
+
"name": name or username,
|
|
36
|
+
"avatar_url": avatar_url
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@app.post("/api/traffic")
|
|
40
|
+
def get_traffic(token: str = Body(..., embed=True)):
|
|
41
|
+
ok, _, _, _ = validate_token(token)
|
|
42
|
+
if not ok:
|
|
43
|
+
raise HTTPException(status_code=401, detail="Invalid token")
|
|
44
|
+
|
|
45
|
+
df = fetch_all_traffic(token)
|
|
46
|
+
# Convert dataframe to JSON response
|
|
47
|
+
# Replacing NaN/Inf with None so it serializes correctly to JSON
|
|
48
|
+
df = df.replace([float('inf'), float('-inf')], None).where(pd.notnull(df), None)
|
|
49
|
+
return df.to_dict(orient="records")
|
|
50
|
+
|
|
51
|
+
@app.post("/api/upload-csv")
|
|
52
|
+
def upload_csv(file: UploadFile = File(...)):
|
|
53
|
+
try:
|
|
54
|
+
df = process_uploaded_csv(file.file)
|
|
55
|
+
df = df.replace([float('inf'), float('-inf')], None).where(pd.notnull(df), None)
|
|
56
|
+
return df.to_dict(orient="records")
|
|
57
|
+
except Exception as e:
|
|
58
|
+
raise HTTPException(status_code=400, detail=str(e))
|
|
59
|
+
|
|
60
|
+
# Mount the React frontend assets (if built)
|
|
61
|
+
frontend_dist = Path(__file__).parent / "frontend" / "dist"
|
|
62
|
+
|
|
63
|
+
@app.get("/")
|
|
64
|
+
def serve_index():
|
|
65
|
+
index_file = frontend_dist / "index.html"
|
|
66
|
+
if index_file.exists():
|
|
67
|
+
return FileResponse(index_file)
|
|
68
|
+
return JSONResponse(
|
|
69
|
+
status_code=404,
|
|
70
|
+
content={"error": "Frontend not built. Run 'npm run build' in the frontend directory."}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# Mount all other static files
|
|
74
|
+
if frontend_dist.exists():
|
|
75
|
+
app.mount("/", StaticFiles(directory=frontend_dist), name="static")
|
|
76
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""
|
|
2
|
+
automation.py
|
|
3
|
+
This file silently backs up your traffic data in the background so you never lose it!
|
|
4
|
+
"""
|
|
5
|
+
import os
|
|
6
|
+
import json
|
|
7
|
+
import csv
|
|
8
|
+
from datetime import datetime, timezone
|
|
9
|
+
from collections import defaultdict
|
|
10
|
+
|
|
11
|
+
# Import from the new package core
|
|
12
|
+
from github_traffic.core import fetch_all_traffic
|
|
13
|
+
|
|
14
|
+
# This runs the background script that safely appends today's data to the monthly CSVs.
|
|
15
|
+
|
|
16
|
+
def get_csv_path(data_dir, month):
|
|
17
|
+
return os.path.join(data_dir, f"traffic_{month}.csv")
|
|
18
|
+
|
|
19
|
+
def sync_monthly_traffic(token: str, data_dir: str = "data"):
|
|
20
|
+
if not token:
|
|
21
|
+
print("Error: GitHub token not provided.")
|
|
22
|
+
return
|
|
23
|
+
|
|
24
|
+
print("Fetching traffic data...")
|
|
25
|
+
df = fetch_all_traffic(token)
|
|
26
|
+
if df.empty:
|
|
27
|
+
print("No data fetched.")
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
os.makedirs(data_dir, exist_ok=True)
|
|
31
|
+
monthly_data = defaultdict(dict)
|
|
32
|
+
|
|
33
|
+
# 2. Process fetched data
|
|
34
|
+
new_records_added = 0
|
|
35
|
+
|
|
36
|
+
for _, row in df.iterrows():
|
|
37
|
+
repo = row["Repository"]
|
|
38
|
+
stars = row.get("Stars", 0)
|
|
39
|
+
forks = row.get("Forks", 0)
|
|
40
|
+
|
|
41
|
+
daily_views = row.get("_daily_views", [])
|
|
42
|
+
if not isinstance(daily_views, list): daily_views = []
|
|
43
|
+
|
|
44
|
+
daily_clones = row.get("_daily_clones", [])
|
|
45
|
+
if not isinstance(daily_clones, list): daily_clones = []
|
|
46
|
+
|
|
47
|
+
# Merge views
|
|
48
|
+
for v in daily_views:
|
|
49
|
+
date = str(v.get("timestamp", ""))[:10]
|
|
50
|
+
if not date: continue
|
|
51
|
+
|
|
52
|
+
month = date[:7]
|
|
53
|
+
key = (repo, date)
|
|
54
|
+
|
|
55
|
+
# Load CSV if not already in memory
|
|
56
|
+
csv_path = get_csv_path(data_dir, month)
|
|
57
|
+
if month not in monthly_data and os.path.exists(csv_path):
|
|
58
|
+
with open(csv_path, "r", encoding="utf-8") as f:
|
|
59
|
+
reader = csv.DictReader(f)
|
|
60
|
+
for r in reader:
|
|
61
|
+
monthly_data[month][(r["repo_name"], r["date"])] = r
|
|
62
|
+
|
|
63
|
+
if key not in monthly_data[month]:
|
|
64
|
+
monthly_data[month][key] = {
|
|
65
|
+
"date": date, "repo_name": repo,
|
|
66
|
+
"views": 0, "unique_visitors": 0,
|
|
67
|
+
"clones": 0, "unique_cloners": 0,
|
|
68
|
+
"stars": stars, "forks": forks
|
|
69
|
+
}
|
|
70
|
+
new_records_added += 1
|
|
71
|
+
|
|
72
|
+
monthly_data[month][key]["views"] = int(v.get("count", 0))
|
|
73
|
+
monthly_data[month][key]["unique_visitors"] = int(v.get("uniques", 0))
|
|
74
|
+
monthly_data[month][key]["stars"] = stars
|
|
75
|
+
monthly_data[month][key]["forks"] = forks
|
|
76
|
+
|
|
77
|
+
# Merge clones
|
|
78
|
+
for c in daily_clones:
|
|
79
|
+
date = str(c.get("timestamp", ""))[:10]
|
|
80
|
+
if not date: continue
|
|
81
|
+
|
|
82
|
+
month = date[:7]
|
|
83
|
+
key = (repo, date)
|
|
84
|
+
|
|
85
|
+
csv_path = get_csv_path(data_dir, month)
|
|
86
|
+
if month not in monthly_data and os.path.exists(csv_path):
|
|
87
|
+
with open(csv_path, "r", encoding="utf-8") as f:
|
|
88
|
+
reader = csv.DictReader(f)
|
|
89
|
+
for r in reader:
|
|
90
|
+
monthly_data[month][(r["repo_name"], r["date"])] = r
|
|
91
|
+
|
|
92
|
+
if key not in monthly_data[month]:
|
|
93
|
+
monthly_data[month][key] = {
|
|
94
|
+
"date": date, "repo_name": repo,
|
|
95
|
+
"views": 0, "unique_visitors": 0,
|
|
96
|
+
"clones": 0, "unique_cloners": 0,
|
|
97
|
+
"stars": stars, "forks": forks
|
|
98
|
+
}
|
|
99
|
+
new_records_added += 1
|
|
100
|
+
|
|
101
|
+
monthly_data[month][key]["clones"] = int(c.get("count", 0))
|
|
102
|
+
monthly_data[month][key]["unique_cloners"] = int(c.get("uniques", 0))
|
|
103
|
+
monthly_data[month][key]["stars"] = stars
|
|
104
|
+
monthly_data[month][key]["forks"] = forks
|
|
105
|
+
|
|
106
|
+
# 3. Save all months to CSV
|
|
107
|
+
fields = ["date", "repo_name", "views", "unique_visitors", "clones", "unique_cloners", "stars", "forks"]
|
|
108
|
+
|
|
109
|
+
for month, data_dict in monthly_data.items():
|
|
110
|
+
# Convert to list and sort by date then repo
|
|
111
|
+
month_list = list(data_dict.values())
|
|
112
|
+
month_list.sort(key=lambda x: (x.get("date", ""), x.get("repo_name", "")))
|
|
113
|
+
|
|
114
|
+
csv_path = get_csv_path(data_dir, month)
|
|
115
|
+
with open(csv_path, "w", newline="", encoding="utf-8") as f:
|
|
116
|
+
writer = csv.DictWriter(f, fieldnames=fields, extrasaction='ignore')
|
|
117
|
+
writer.writeheader()
|
|
118
|
+
writer.writerows(month_list)
|
|
119
|
+
|
|
120
|
+
print(f"Saved {len(month_list)} records to {csv_path}")
|
|
121
|
+
|
|
122
|
+
print(f"Successfully processed traffic data. Added {new_records_added} new daily records.")
|
github_traffic/cli.py
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"""
|
|
2
|
+
cli.py
|
|
3
|
+
This is the main brain of your app where all terminal commands come to life!
|
|
4
|
+
"""
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
import os
|
|
8
|
+
import csv
|
|
9
|
+
|
|
10
|
+
from github_traffic.core import (
|
|
11
|
+
validate_token,
|
|
12
|
+
get_all_repos,
|
|
13
|
+
get_repo_traffic,
|
|
14
|
+
build_row,
|
|
15
|
+
DEFAULT_CSV
|
|
16
|
+
)
|
|
17
|
+
from github_traffic.automation import sync_monthly_traffic
|
|
18
|
+
|
|
19
|
+
# This routes terminal commands to the correct package functions.
|
|
20
|
+
|
|
21
|
+
def _sep(char="─", width=90):
|
|
22
|
+
print(char * width)
|
|
23
|
+
|
|
24
|
+
def _row(cols, widths):
|
|
25
|
+
print(" ".join(str(c).ljust(w) for c, w in zip(cols, widths)))
|
|
26
|
+
|
|
27
|
+
def print_repo(repo: dict, traffic: dict):
|
|
28
|
+
# Pretty-print one repo to terminal
|
|
29
|
+
views = traffic["views"]
|
|
30
|
+
clones = traffic["clones"]
|
|
31
|
+
refs = traffic["referrers"]
|
|
32
|
+
paths = traffic["paths"]
|
|
33
|
+
|
|
34
|
+
lock = "🔒" if repo.get("private") else "🌐"
|
|
35
|
+
_sep("═")
|
|
36
|
+
print(f" {lock} {repo['full_name']}")
|
|
37
|
+
_sep("═")
|
|
38
|
+
|
|
39
|
+
print("\n 📊 SUMMARY (last 14 days)")
|
|
40
|
+
_sep()
|
|
41
|
+
_row(["Metric", "Total", "Unique"], [35, 15, 15])
|
|
42
|
+
_sep()
|
|
43
|
+
_row(["👁️ Views", views.get("count", 0), views.get("uniques", 0)], [35, 15, 15])
|
|
44
|
+
_row(["📥 Clones", clones.get("count", 0), clones.get("uniques", 0)], [35, 15, 15])
|
|
45
|
+
|
|
46
|
+
if refs:
|
|
47
|
+
print("\n 🔗 TOP REFERRERS")
|
|
48
|
+
_sep()
|
|
49
|
+
_row(["Referrer", "Views", "Unique"], [40, 10, 10])
|
|
50
|
+
_sep()
|
|
51
|
+
for r in refs[:5]:
|
|
52
|
+
_row([r.get("referrer", ""), r.get("count", 0), r.get("uniques", 0)], [40, 10, 10])
|
|
53
|
+
|
|
54
|
+
if paths:
|
|
55
|
+
print("\n 📄 POPULAR PATHS")
|
|
56
|
+
_sep()
|
|
57
|
+
_row(["Path", "Views", "Unique"], [50, 10, 10])
|
|
58
|
+
_sep()
|
|
59
|
+
for p in paths[:5]:
|
|
60
|
+
_row([p.get("path", ""), p.get("count", 0), p.get("uniques", 0)], [50, 10, 10])
|
|
61
|
+
|
|
62
|
+
daily = views.get("views", [])
|
|
63
|
+
if daily:
|
|
64
|
+
print("\n 📅 DAILY VIEWS")
|
|
65
|
+
_sep()
|
|
66
|
+
_row(["Date", "Views", "Unique"], [20, 10, 10])
|
|
67
|
+
_sep()
|
|
68
|
+
for d in daily:
|
|
69
|
+
_row([d.get("timestamp", "")[:10], d.get("count", 0), d.get("uniques", 0)], [20, 10, 10])
|
|
70
|
+
|
|
71
|
+
print()
|
|
72
|
+
|
|
73
|
+
def main():
|
|
74
|
+
parser = argparse.ArgumentParser(description="GitHub Traffic Monitor CLI")
|
|
75
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
76
|
+
|
|
77
|
+
fetch_parser = subparsers.add_parser("fetch", help="Fetch traffic and save to a CSV")
|
|
78
|
+
fetch_parser.add_argument("-t", "--token", help="GitHub PAT")
|
|
79
|
+
fetch_parser.add_argument("-o", "--output", help="Output CSV filename")
|
|
80
|
+
|
|
81
|
+
sync_parser = subparsers.add_parser("sync", help="Append today's traffic to monthly CSVs")
|
|
82
|
+
sync_parser.add_argument("-t", "--token", help="GitHub PAT")
|
|
83
|
+
sync_parser.add_argument("--dir", help="Directory containing monthly CSVs", default="data")
|
|
84
|
+
|
|
85
|
+
dashboard_parser = subparsers.add_parser("dashboard", help="Launch the React Dashboard")
|
|
86
|
+
|
|
87
|
+
args = parser.parse_args()
|
|
88
|
+
|
|
89
|
+
if not args.command:
|
|
90
|
+
parser.print_help()
|
|
91
|
+
sys.exit(1)
|
|
92
|
+
|
|
93
|
+
if args.command == "dashboard":
|
|
94
|
+
print("\n🚀 Starting Gitlytics Local Web Dashboard...")
|
|
95
|
+
print("🌐 You can view your dashboard at: http://127.0.0.1:8000")
|
|
96
|
+
print("Press CTRL+C to quit.\n")
|
|
97
|
+
try:
|
|
98
|
+
import uvicorn
|
|
99
|
+
from github_traffic.api import app
|
|
100
|
+
except ImportError:
|
|
101
|
+
print(" ❌ Dashboard dependencies not installed.")
|
|
102
|
+
print(" Install them with: pip install \"gitlytics[dashboard]\"")
|
|
103
|
+
sys.exit(1)
|
|
104
|
+
|
|
105
|
+
uvicorn.run(app, host="127.0.0.1", port=8000, log_level="warning")
|
|
106
|
+
return
|
|
107
|
+
|
|
108
|
+
# Both fetch and sync need token
|
|
109
|
+
token = args.token or os.environ.get("GITHUB_TOKEN")
|
|
110
|
+
if not token:
|
|
111
|
+
print(" ❌ No token found.")
|
|
112
|
+
print(" Use --token or set GITHUB_TOKEN environment variable")
|
|
113
|
+
sys.exit(1)
|
|
114
|
+
|
|
115
|
+
if args.command == "sync":
|
|
116
|
+
sync_monthly_traffic(token, data_dir=args.dir)
|
|
117
|
+
return
|
|
118
|
+
|
|
119
|
+
if args.command == "fetch":
|
|
120
|
+
# Validate before doing any real work
|
|
121
|
+
ok, info, _, _ = validate_token(token)
|
|
122
|
+
if not ok:
|
|
123
|
+
print(f" ❌ {info}")
|
|
124
|
+
sys.exit(1)
|
|
125
|
+
print(f"\n ✅ Logged in as: {info}")
|
|
126
|
+
|
|
127
|
+
# Fetch and print each repo
|
|
128
|
+
print("\n🚀 Fetching all repositories…\n")
|
|
129
|
+
repos = get_all_repos(token)
|
|
130
|
+
print(f" Found {len(repos)} repositories.\n")
|
|
131
|
+
|
|
132
|
+
all_rows = []
|
|
133
|
+
for repo in repos:
|
|
134
|
+
traffic = get_repo_traffic(token, repo["full_name"])
|
|
135
|
+
print_repo(repo, traffic)
|
|
136
|
+
all_rows.append(build_row(repo, traffic))
|
|
137
|
+
|
|
138
|
+
# Save results to CSV
|
|
139
|
+
if all_rows:
|
|
140
|
+
out = args.output or DEFAULT_CSV
|
|
141
|
+
path = os.path.join(os.getcwd(), out)
|
|
142
|
+
with open(path, "w", newline="", encoding="utf-8") as f:
|
|
143
|
+
cols = [c for c in all_rows[0].keys() if not c.startswith("_")]
|
|
144
|
+
writer = csv.DictWriter(f, fieldnames=cols, extrasaction="ignore")
|
|
145
|
+
writer.writeheader()
|
|
146
|
+
writer.writerows(all_rows)
|
|
147
|
+
_sep("═")
|
|
148
|
+
print(f"\n ✅ Saved → {path}")
|
|
149
|
+
print(f" 📦 {len(all_rows)} repos exported.\n")
|
|
150
|
+
else:
|
|
151
|
+
print(" ⚠️ No data to save.")
|
|
152
|
+
|
|
153
|
+
if __name__ == "__main__":
|
|
154
|
+
main()
|
github_traffic/core.py
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""
|
|
2
|
+
github_traffic_fetch.py -> core.py
|
|
3
|
+
All GitHub API logic lives here.
|
|
4
|
+
"""
|
|
5
|
+
# This handles fetching all the raw traffic data directly from the GitHub API.
|
|
6
|
+
|
|
7
|
+
import io
|
|
8
|
+
import csv
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
import requests
|
|
12
|
+
import pandas as pd
|
|
13
|
+
from datetime import datetime, timezone
|
|
14
|
+
|
|
15
|
+
# GitHub API base URL
|
|
16
|
+
BASE = "https://api.github.com"
|
|
17
|
+
|
|
18
|
+
# Today's date for default CSV name
|
|
19
|
+
DEFAULT_CSV = f"github_traffic_{datetime.now(timezone.utc).strftime('%Y-%m-%d')}.csv"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# ── Auth ──────────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
def make_headers(token: str) -> dict:
|
|
25
|
+
# Standard GitHub API headers
|
|
26
|
+
return {
|
|
27
|
+
"Authorization": f"Bearer {token}",
|
|
28
|
+
"Accept": "application/vnd.github+json",
|
|
29
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def validate_token(token: str) -> tuple[bool, str, str, str]:
|
|
34
|
+
# Check token and return user info
|
|
35
|
+
try:
|
|
36
|
+
r = requests.get(f"{BASE}/user", headers=make_headers(token), timeout=10)
|
|
37
|
+
except requests.exceptions.ConnectionError:
|
|
38
|
+
return False, "No internet connection.", "", ""
|
|
39
|
+
except Exception as e:
|
|
40
|
+
return False, str(e), "", ""
|
|
41
|
+
|
|
42
|
+
if r.status_code == 200:
|
|
43
|
+
data = r.json()
|
|
44
|
+
return True, data.get("login", ""), data.get("avatar_url", ""), data.get("name", "")
|
|
45
|
+
if r.status_code == 401:
|
|
46
|
+
return False, "Invalid token — authentication failed.", "", ""
|
|
47
|
+
if r.status_code == 403:
|
|
48
|
+
return False, "Token has insufficient permissions.", "", ""
|
|
49
|
+
return False, f"GitHub returned HTTP {r.status_code}.", "", ""
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# ── Fetching repos ────────────────────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
def _safe_get(url: str, headers: dict, params: dict = None):
|
|
55
|
+
# Fetch JSON, return empty on error
|
|
56
|
+
try:
|
|
57
|
+
r = requests.get(url, headers=headers, params=params, timeout=10)
|
|
58
|
+
return r.json() if r.status_code == 200 else {}
|
|
59
|
+
except Exception:
|
|
60
|
+
return {}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def get_all_repos(token: str) -> list[dict]:
|
|
64
|
+
# Page through all user repos
|
|
65
|
+
headers = make_headers(token)
|
|
66
|
+
repos, page = [], 1
|
|
67
|
+
while True:
|
|
68
|
+
data = _safe_get(f"{BASE}/user/repos", headers, {"per_page": 100, "page": page, "type": "all"})
|
|
69
|
+
if not data or not isinstance(data, list):
|
|
70
|
+
break
|
|
71
|
+
repos.extend(data)
|
|
72
|
+
if len(data) < 100:
|
|
73
|
+
break
|
|
74
|
+
page += 1
|
|
75
|
+
return repos
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def get_repo_traffic(token: str, full_name: str) -> dict:
|
|
79
|
+
# Grab views, clones, referrers, paths
|
|
80
|
+
h = make_headers(token)
|
|
81
|
+
views = _safe_get(f"{BASE}/repos/{full_name}/traffic/views", h)
|
|
82
|
+
clones = _safe_get(f"{BASE}/repos/{full_name}/traffic/clones", h)
|
|
83
|
+
refs = _safe_get(f"{BASE}/repos/{full_name}/traffic/popular/referrers", h)
|
|
84
|
+
paths = _safe_get(f"{BASE}/repos/{full_name}/traffic/popular/paths", h)
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
"views": views if isinstance(views, dict) else {},
|
|
88
|
+
"clones": clones if isinstance(clones, dict) else {},
|
|
89
|
+
"referrers": refs if isinstance(refs, list) else [],
|
|
90
|
+
"paths": paths if isinstance(paths, list) else [],
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# ── Building the data row ──────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
def build_row(repo: dict, traffic: dict) -> dict:
|
|
97
|
+
# Flatten repo + traffic into one row
|
|
98
|
+
views = traffic["views"]
|
|
99
|
+
clones = traffic["clones"]
|
|
100
|
+
refs = traffic["referrers"]
|
|
101
|
+
paths = traffic["paths"]
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
"Repository": repo["full_name"],
|
|
105
|
+
"Private": repo.get("private", False),
|
|
106
|
+
"Stars": repo.get("stargazers_count", 0),
|
|
107
|
+
"Forks": repo.get("forks_count", 0),
|
|
108
|
+
"Total Views": views.get("count", 0),
|
|
109
|
+
"Unique Visitors": views.get("uniques", 0),
|
|
110
|
+
"Total Clones": clones.get("count", 0),
|
|
111
|
+
"Unique Cloners": clones.get("uniques", 0),
|
|
112
|
+
"Top Referrer": refs[0].get("referrer", "") if refs else "",
|
|
113
|
+
"Top Referrer Views": refs[0].get("count", 0) if refs else 0,
|
|
114
|
+
"Top Path": paths[0].get("path", "") if paths else "",
|
|
115
|
+
"Top Path Views": paths[0].get("count", 0) if paths else 0,
|
|
116
|
+
"Fetched At": datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC"),
|
|
117
|
+
# Raw lists kept for UI charts
|
|
118
|
+
"_daily_views": views.get("views", []),
|
|
119
|
+
"_daily_clones": clones.get("clones", []),
|
|
120
|
+
"_referrers": refs,
|
|
121
|
+
"_paths": paths,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# ── High-level fetch (used by both CLI and Streamlit) ─────────────────────────
|
|
126
|
+
|
|
127
|
+
def fetch_all_traffic(token: str, progress_cb=None) -> pd.DataFrame:
|
|
128
|
+
# Fetch every repo's traffic, return DataFrame
|
|
129
|
+
repos = get_all_repos(token)
|
|
130
|
+
rows = []
|
|
131
|
+
total = max(len(repos), 1)
|
|
132
|
+
|
|
133
|
+
for i, repo in enumerate(repos):
|
|
134
|
+
traffic = get_repo_traffic(token, repo["full_name"])
|
|
135
|
+
rows.append(build_row(repo, traffic))
|
|
136
|
+
if progress_cb:
|
|
137
|
+
progress_cb((i + 1) / total)
|
|
138
|
+
|
|
139
|
+
return pd.DataFrame(rows) if rows else pd.DataFrame()
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def to_csv_bytes(df: pd.DataFrame) -> bytes:
|
|
143
|
+
# Export display columns to CSV bytes
|
|
144
|
+
cols = [c for c in df.columns if not c.startswith("_")]
|
|
145
|
+
buf = io.StringIO()
|
|
146
|
+
df[cols].to_csv(buf, index=False)
|
|
147
|
+
return buf.getvalue().encode("utf-8")
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{t as e}from"./index-BJy89P_N.js";function t(e,t){return function(){return e.apply(t,arguments)}}var{toString:n}=Object.prototype,{getPrototypeOf:r}=Object,{iterator:i,toStringTag:a}=Symbol,o=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),s=(e,t)=>{let n=e,i=[];for(;n!=null&&n!==Object.prototype;){if(i.indexOf(n)!==-1)return!1;if(i.push(n),o(n,t))return!0;n=r(n)}return!1},c=(e,t)=>e!=null&&s(e,t)?e[t]:void 0,l=(e=>t=>{let r=n.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),u=e=>(e=e.toLowerCase(),t=>l(t)===e),d=e=>t=>typeof t===e,{isArray:f}=Array,p=d(`undefined`);function m(e){return e!==null&&!p(e)&&e.constructor!==null&&!p(e.constructor)&&v(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var h=u(`ArrayBuffer`);function g(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer),t}var _=d(`string`),v=d(`function`),y=d(`number`),b=e=>typeof e==`object`&&!!e,x=e=>e===!0||e===!1,S=e=>{if(!b(e))return!1;let t=r(e);return(t===null||t===Object.prototype||r(t)===null)&&!s(e,a)&&!s(e,i)},ee=e=>{if(!b(e)||m(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},C=u(`Date`),w=u(`File`),T=e=>!!(e&&e.uri!==void 0),E=e=>e&&e.getParts!==void 0,te=u(`Blob`),ne=u(`FileList`),D=e=>b(e)&&v(e.pipe);function O(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var k=O(),A=k.FormData===void 0?void 0:k.FormData,j=e=>{if(!e)return!1;if(A&&e instanceof A)return!0;let t=r(e);if(!t||t===Object.prototype||!v(e.append))return!1;let n=l(e);return n===`formdata`||n===`object`&&v(e.toString)&&e.toString()===`[object FormData]`},re=u(`URLSearchParams`),[ie,ae,M,oe]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(u),N=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function P(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),f(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(m(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function se(e,t){if(m(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var F=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,ce=e=>!p(e)&&e!==F;function le(...e){let{caseless:t,skipUndefined:n}=ce(this)&&this||{},r={},i=(e,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=t&&typeof i==`string`&&se(r,i)||i,s=o(r,a)?r[a]:void 0;S(s)&&S(e)?r[a]=le(s,e):S(e)?r[a]=le({},e):f(e)?r[a]=e.slice():(!n||!p(e))&&(r[a]=e)};for(let t=0,n=e.length;t<n;t++){let n=e[t];if(!n||m(n)||(P(n,i),typeof n!=`object`||f(n)))continue;let r=Object.getOwnPropertySymbols(n);for(let e=0;e<r.length;e++){let t=r[e];xe.call(n,t)&&i(n[t],t)}}return r}var ue=(e,n,r,{allOwnKeys:i}={})=>(P(n,(n,i)=>{r&&v(n)?Object.defineProperty(e,i,{__proto__:null,value:t(n,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:n,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),e),de=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),fe=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},pe=(e,t,n,i)=>{let a,o,s,c={};if(t||={},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),o=a.length;o-- >0;)s=a[o],(!i||i(s,e,t))&&!c[s]&&(t[s]=e[s],c[s]=!0);e=n!==!1&&r(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},me=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},he=e=>{if(!e)return null;if(f(e))return e;let t=e.length;if(!y(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},ge=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&r(Uint8Array)),_e=(e,t)=>{let n=(e&&e[i]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},ve=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ye=u(`HTMLFormElement`),be=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),{propertyIsEnumerable:xe}=Object.prototype,Se=u(`RegExp`),Ce=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};P(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},we=e=>{Ce(e,(t,n)=>{if(v(e)&&[`arguments`,`caller`,`callee`].includes(n))return!1;let r=e[n];if(v(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Te=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return f(e)?r(e):r(String(e).split(t)),n},Ee=()=>{},De=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Oe(e){return!!(e&&v(e.append)&&e[a]===`FormData`&&e[i])}var ke=e=>{let t=new WeakSet,n=e=>{if(b(e)){if(t.has(e))return;if(m(e))return e;if(!(`toJSON`in e)){t.add(e);let r=f(e)?[]:{};return P(e,(e,t)=>{let i=n(e);!p(i)&&(r[t]=i)}),t.delete(e),r}}return e};return n(e)},Ae=u(`AsyncFunction`),je=e=>e&&(b(e)||v(e))&&v(e.then)&&v(e.catch),Me=((e,t)=>e?setImmediate:t?((e,t)=>(F.addEventListener(`message`,({source:n,data:r})=>{n===F&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),F.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,v(F.postMessage)),Ne=typeof queueMicrotask<`u`?queueMicrotask.bind(F):typeof process<`u`&&process.nextTick||Me,Pe=e=>e!=null&&v(e[i]),I={isArray:f,isArrayBuffer:h,isBuffer:m,isFormData:j,isArrayBufferView:g,isString:_,isNumber:y,isBoolean:x,isObject:b,isPlainObject:S,isEmptyObject:ee,isReadableStream:ie,isRequest:ae,isResponse:M,isHeaders:oe,isUndefined:p,isDate:C,isFile:w,isReactNativeBlob:T,isReactNative:E,isBlob:te,isRegExp:Se,isFunction:v,isStream:D,isURLSearchParams:re,isTypedArray:ge,isFileList:ne,forEach:P,merge:le,extend:ue,trim:N,stripBOM:de,inherits:fe,toFlatObject:pe,kindOf:l,kindOfTest:u,endsWith:me,toArray:he,forEachEntry:_e,matchAll:ve,isHTMLForm:ye,hasOwnProperty:o,hasOwnProp:o,hasOwnInPrototypeChain:s,getSafeProp:c,reduceDescriptors:Ce,freezeMethods:we,toObjectSet:Te,toCamelCase:be,noop:Ee,toFiniteNumber:De,findKey:se,global:F,isContextDefined:ce,isSpecCompliantForm:Oe,toJSONObject:ke,isAsyncFn:Ae,isThenable:je,setImmediate:Me,asap:Ne,isIterable:Pe,isSafeIterable:e=>e!=null&&s(e,i)&&Pe(e)},Fe=I.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),Ie=e=>{let t={},n,r,i;return e&&e.split(`
|
|
2
|
+
`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&Fe[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t};function Le(e){let t=0,n=e.length;for(;t<n;){let n=e.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==9&&t!==32)break;--n}return t===0&&n===e.length?e:e.slice(t,n)}var Re=RegExp(`[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+`,`g`),ze=RegExp(`[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+`,`g`);function Be(e,t){return I.isArray(e)?e.map(e=>Be(e,t)):Le(String(e).replace(t,``))}var Ve=e=>Be(e,Re),He=e=>Be(e,ze);function Ue(e){let t=Object.create(null);return I.forEach(e.toJSON(),(e,n)=>{t[n]=He(e)}),t}var We=Symbol(`internals`);function L(e){return e&&String(e).trim().toLowerCase()}function Ge(e){return e===!1||e==null?e:I.isArray(e)?e.map(Ge):Ve(String(e))}function Ke(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var qe=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Je(e,t,n,r,i){if(I.isFunction(r))return r.call(this,t,n);if(i&&(t=n),I.isString(t)){if(I.isString(r))return t.indexOf(r)!==-1;if(I.isRegExp(r))return r.test(t)}}function Ye(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function Xe(e,t){let n=I.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var R=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=L(t);if(!i)return;let a=I.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=Ge(e))}let a=(e,t)=>I.forEach(e,(e,n)=>i(e,n,t));if(I.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(I.isString(e)&&(e=e.trim())&&!qe(e))a(Ie(e),t);else if(I.isObject(e)&&I.isSafeIterable(e)){let n=Object.create(null),r,i;for(let t of e){if(!I.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);i=t[0],I.hasOwnProp(n,i)?(r=n[i],n[i]=I.isArray(r)?[...r,t[1]]:[r,t[1]]):n[i]=t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=L(e),e){let n=I.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return Ke(e);if(I.isFunction(t))return t.call(this,e,n);if(I.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=L(e),e){let n=I.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Je(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=L(e),e){let i=I.findKey(n,e);i&&(!t||Je(n,n[i],i,t))&&(delete n[i],r=!0)}}return I.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||Je(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return I.forEach(this,(r,i)=>{let a=I.findKey(n,i);if(a){t[a]=Ge(r),delete t[i];return}let o=e?Ye(i):String(i).trim();o!==i&&delete t[i],t[o]=Ge(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return I.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&I.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[We]=this[We]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=L(e);t[r]||(Xe(n,e),t[r]=!0)}return I.isArray(e)?e.forEach(r):r(e),this}};R.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),I.reduceDescriptors(R.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),I.freezeMethods(R);var Ze=`[REDACTED ****]`;function Qe(e){if(I.hasOwnProp(e,`toJSON`))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(I.hasOwnProp(t,`toJSON`))return!0;t=Object.getPrototypeOf(t)}return!1}function $e(e,t){let n=new Set(t.map(e=>String(e).toLowerCase())),r=[],i=e=>{if(typeof e!=`object`||!e||I.isBuffer(e))return e;if(r.indexOf(e)!==-1)return;e instanceof R&&(e=e.toJSON()),r.push(e);let t;if(I.isArray(e))t=[],e.forEach((e,n)=>{let r=i(e);I.isUndefined(r)||(t[n]=r)});else{if(!I.isPlainObject(e)&&Qe(e))return r.pop(),e;t=Object.create(null);for(let[r,a]of Object.entries(e)){let e=n.has(r.toLowerCase())?Ze:i(a);I.isUndefined(e)||(t[r]=e)}}return r.pop(),t};return i(e)}var z=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){let e=this.config,t=e&&I.hasOwnProp(e,`redact`)?e.redact:void 0,n=I.isArray(t)&&t.length>0?$e(e,t):I.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}};z.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,z.ERR_BAD_OPTION=`ERR_BAD_OPTION`,z.ECONNABORTED=`ECONNABORTED`,z.ETIMEDOUT=`ETIMEDOUT`,z.ECONNREFUSED=`ECONNREFUSED`,z.ERR_NETWORK=`ERR_NETWORK`,z.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,z.ERR_DEPRECATED=`ERR_DEPRECATED`,z.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,z.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,z.ERR_CANCELED=`ERR_CANCELED`,z.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,z.ERR_INVALID_URL=`ERR_INVALID_URL`,z.ERR_FORM_DATA_DEPTH_EXCEEDED=`ERR_FORM_DATA_DEPTH_EXCEEDED`;function et(e){return I.isPlainObject(e)||I.isArray(e)}function tt(e){return I.endsWith(e,`[]`)?e.slice(0,-2):e}function nt(e,t,n){return e?e.concat(t).map(function(e,t){return e=tt(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function rt(e){return I.isArray(e)&&!e.some(et)}var it=I.toFlatObject(I,{},null,function(e){return/^is[A-Z]/.test(e)});function B(e,t,n){if(!I.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=I.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!I.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||m,a=n.dots,o=n.indexes,s=n.Blob||typeof Blob<`u`&&Blob,c=n.maxDepth===void 0?100:n.maxDepth,l=s&&I.isSpecCompliantForm(t),u=[];if(!I.isFunction(i))throw TypeError(`visitor must be a function`);function d(e){if(e===null)return``;if(I.isDate(e))return e.toISOString();if(I.isBoolean(e))return e.toString();if(!l&&I.isBlob(e))throw new z(`Blob is not supported. Use a Buffer instead.`);return I.isArrayBuffer(e)||I.isTypedArray(e)?l&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function f(e){if(e>c)throw new z(`Object is too deeply nested (`+e+` levels). Max depth: `+c,z.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(e,t){if(c===1/0)return JSON.stringify(e);let n=[];return JSON.stringify(e,function(e,r){if(!I.isObject(r))return r;for(;n.length&&n[n.length-1]!==this;)n.pop();return n.push(r),f(t+n.length-1),r})}function m(e,n,i){let s=e;if(I.isReactNative(t)&&I.isReactNativeBlob(e))return t.append(nt(i,n,a),d(e)),!1;if(e&&!i&&typeof e==`object`){if(I.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=p(e,1);else if(I.isArray(e)&&rt(e)||(I.isFileList(e)||I.endsWith(n,`[]`))&&(s=I.toArray(e)))return n=tt(n),s.forEach(function(e,r){!(I.isUndefined(e)||e===null)&&t.append(o===!0?nt([n],r,a):o===null?n:n+`[]`,d(e))}),!1}return et(e)?!0:(t.append(nt(i,n,a),d(e)),!1)}let h=Object.assign(it,{defaultVisitor:m,convertValue:d,isVisitable:et});function g(e,n,r=0){if(!I.isUndefined(e)){if(f(r),u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),I.forEach(e,function(e,a){(!(I.isUndefined(e)||e===null)&&i.call(t,e,I.isString(a)?a.trim():a,n,h))===!0&&g(e,n?n.concat(a):[a],r+1)}),u.pop()}}if(!I.isObject(e))throw TypeError(`data must be an object`);return g(e),t}function at(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function ot(e,t){this._pairs=[],e&&B(e,this,t)}var st=ot.prototype;st.append=function(e,t){this._pairs.push([e,t])},st.toString=function(e){let t=e?function(t){return e.call(this,t,at)}:at;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function ct(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function lt(e,t,n){if(!t)return e;let r=I.isFunction(n)?{serialize:n}:n,i=I.getSafeProp(r,`encode`)||ct,a=I.getSafeProp(r,`serialize`),o;if(o=a?a(t,r):I.isURLSearchParams(t)?t.toString():new ot(t,r).toString(i),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var ut=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){I.forEach(this.handlers,function(t){t!==null&&e(t)})}},dt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},ft={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:ot,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},pt=e({hasBrowserEnv:()=>mt,hasStandardBrowserEnv:()=>gt,hasStandardBrowserWebWorkerEnv:()=>_t,navigator:()=>ht,origin:()=>vt}),mt=typeof window<`u`&&typeof document<`u`,ht=typeof navigator==`object`&&navigator||void 0,gt=mt&&(!ht||[`ReactNative`,`NativeScript`,`NS`].indexOf(ht.product)<0),_t=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,vt=mt&&window.location.href||`http://localhost`,V={...pt,...ft};function yt(e,t){return B(e,new V.classes.URLSearchParams,{visitor:function(e,t,n,r){return V.isNode&&I.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}var bt=100;function xt(e){if(e>bt)throw new z(`FormData field is too deeply nested (`+e+` levels). Max depth: `+bt,z.ERR_FORM_DATA_DEPTH_EXCEEDED)}function St(e){let t=[],n=/\w+|\[(\w*)]/g,r;for(;(r=n.exec(e))!==null;)xt(t.length),t.push(r[0]===`[]`?``:r[1]||r[0]);return t}function Ct(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function wt(e){function t(e,n,r,i){xt(i);let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&I.isArray(r)?r.length:a,s?(I.hasOwnProp(r,a)?r[a]=I.isArray(r[a])?r[a].concat(n):[r[a],n]:r[a]=n,!o):((!I.hasOwnProp(r,a)||!I.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&I.isArray(r[a])&&(r[a]=Ct(r[a])),!o)}if(I.isFormData(e)&&I.isFunction(e.entries)){let n={};return I.forEachEntry(e,(e,r)=>{t(St(e),r,n,0)}),n}return null}var H=(e,t)=>e!=null&&I.hasOwnProp(e,t)?e[t]:void 0;function Tt(e,t,n){if(I.isString(e))try{return(t||JSON.parse)(e),I.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var U={transitional:dt,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=I.isObject(e);if(i&&I.isHTMLForm(e)&&(e=new FormData(e)),I.isFormData(e))return r?JSON.stringify(wt(e)):e;if(I.isArrayBuffer(e)||I.isBuffer(e)||I.isStream(e)||I.isFile(e)||I.isBlob(e)||I.isReadableStream(e))return e;if(I.isArrayBufferView(e))return e.buffer;if(I.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){let t=H(this,`formSerializer`);if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return yt(e,t).toString();if((a=I.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let n=H(this,`env`),r=n&&n.FormData;return B(a?{"files[]":e}:e,r&&new r,t)}}return i||r?(t.setContentType(`application/json`,!1),Tt(e)):e}],transformResponse:[function(e){let t=H(this,`transitional`)||U.transitional,n=t&&t.forcedJSONParsing,r=H(this,`responseType`),i=r===`json`;if(I.isResponse(e)||I.isReadableStream(e))return e;if(e&&I.isString(e)&&(n&&!r||i)){let n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,H(this,`parseReviver`))}catch(e){if(n)throw e.name===`SyntaxError`?z.from(e,z.ERR_BAD_RESPONSE,this,null,H(this,`response`)):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:V.classes.FormData,Blob:V.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};I.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`],e=>{U.headers[e]={}});function Et(e,t){let n=this||U,r=t||n,i=R.from(r.headers),a=r.data;return I.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function Dt(e){return!!(e&&e.__CANCEL__)}var W=class extends z{constructor(e,t,n){super(e??`canceled`,z.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function Ot(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new z(`Request failed with status code `+n.status,n.status>=400&&n.status<500?z.ERR_BAD_REQUEST:z.ERR_BAD_RESPONSE,n.config,n.request,n))}function kt(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||``}function At(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function jt(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var G=(e,t,n=3)=>{let r=0,i=At(50,250);return jt(n=>{if(!n||typeof n.loaded!=`number`)return;let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=o==null?a:Math.min(a,o),c=Math.max(0,s-r),l=i(c);r=Math.max(r,s),e({loaded:s,total:o,progress:o?s/o:void 0,bytes:c,rate:l||void 0,estimated:l&&o?(o-s)/l:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},Mt=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Nt=e=>(...t)=>I.asap(()=>e(...t)),Pt=V.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,V.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(V.origin),V.navigator&&/(msie|trident)/i.test(V.navigator.userAgent)):()=>!0,Ft=V.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];I.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),I.isString(r)&&s.push(`path=${r}`),I.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),I.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.split(`;`);for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,``),i=r.indexOf(`=`);if(i!==-1&&r.slice(0,i)===e)return decodeURIComponent(r.slice(i+1))}return null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function It(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function Lt(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}var Rt=/^https?:(?!\/\/)/i,zt=/[\t\n\r]/g;function Bt(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}function Vt(e){return Bt(e).replace(zt,``)}function Ht(e,t){if(typeof e==`string`&&Rt.test(Vt(e)))throw new z(`Invalid URL: missing "//" after protocol`,z.ERR_INVALID_URL,t)}function Ut(e,t,n,r){Ht(t,r);let i=!It(t);return e&&(i||n===!1)?(Ht(e,r),Lt(e,t)):t}var Wt=e=>e instanceof R?{...e}:e;function K(e,t){t||={};let n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(e,t,n,r){return I.isPlainObject(e)&&I.isPlainObject(t)?I.merge.call({caseless:r},e,t):I.isPlainObject(t)?I.merge({},t):I.isArray(t)?t.slice():t}function i(e,t,n,i){if(!I.isUndefined(t))return r(e,t,n,i);if(!I.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!I.isUndefined(t))return r(void 0,t)}function o(e,t){if(!I.isUndefined(t))return r(void 0,t);if(!I.isUndefined(e))return r(void 0,e)}function s(n){let r=I.hasOwnProp(t,`transitional`)?t.transitional:void 0;if(!I.isUndefined(r))if(I.isPlainObject(r)){if(I.hasOwnProp(r,n))return r[n]}else return;let i=I.hasOwnProp(e,`transitional`)?e.transitional:void 0;if(I.isPlainObject(i)&&I.hasOwnProp(i,n))return i[n]}function c(n,i,a){if(I.hasOwnProp(t,a))return r(n,i);if(I.hasOwnProp(e,a))return r(void 0,n)}let l={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,allowedSocketPaths:o,responseEncoding:o,validateStatus:c,headers:(e,t,n)=>i(Wt(e),Wt(t),n,!0)};return I.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=I.hasOwnProp(l,r)?l[r]:i,o=a(I.hasOwnProp(e,r)?e[r]:void 0,I.hasOwnProp(t,r)?t[r]:void 0,r);I.isUndefined(o)&&a!==c||(n[r]=o)}),I.hasOwnProp(t,`validateStatus`)&&I.isUndefined(t.validateStatus)&&s(`validateStatusUndefinedResolves`)===!1&&(I.hasOwnProp(e,`validateStatus`)?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}var Gt=[`content-type`,`content-length`];function Kt(e,t,n){if(n!==`content-only`){e.set(t);return}Object.entries(t).forEach(([t,n])=>{Gt.includes(t.toLowerCase())&&e.set(t,n)})}var qt=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16)));function Jt(e){let t=K({},e),n=e=>I.hasOwnProp(t,e)?t[e]:void 0,r=n(`data`),i=n(`withXSRFToken`),a=n(`xsrfHeaderName`),o=n(`xsrfCookieName`),s=n(`headers`),c=n(`auth`),l=n(`baseURL`),u=n(`allowAbsoluteUrls`),d=n(`url`);if(t.headers=s=R.from(s),t.url=lt(Ut(l,d,u,t),n(`params`),n(`paramsSerializer`)),c){let e=I.getSafeProp(c,`username`)||``,t=I.getSafeProp(c,`password`)||``;s.set(`Authorization`,`Basic `+btoa(e+`:`+(t?qt(t):``)))}if(I.isFormData(r)&&(V.hasStandardBrowserEnv||V.hasStandardBrowserWebWorkerEnv||I.isReactNative(r)?s.setContentType(void 0):I.isFunction(r.getHeaders)&&Kt(s,r.getHeaders(),n(`formDataHeaderPolicy`))),V.hasStandardBrowserEnv&&(I.isFunction(i)&&(i=i(t)),i===!0||i==null&&Pt(t.url))){let e=a&&o&&Ft.read(o);e&&s.set(a,e)}return t}var Yt=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=Jt(e),i=r.data,a=R.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=R.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());Ot(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith(`file:`))||setTimeout(g)},h.onabort=function(){h&&=(n(new z(`Request aborted`,z.ECONNABORTED,e,h)),m(),null)},h.onerror=function(t){let r=new z(t&&t.message?t.message:`Network Error`,z.ERR_NETWORK,e,h);r.event=t||null,n(r),m(),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||dt;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new z(t,i.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,e,h)),m(),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&I.forEach(Ue(a),function(e,t){h.setRequestHeader(t,e)}),I.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=G(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=G(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new W(null,e,h):t),h.abort(),m(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=kt(r.url);if(_&&!V.protocols.includes(_)){n(new z(`Unsupported protocol `+_+`:`,z.ERR_BAD_REQUEST,e));return}h.send(i||null)})},Xt=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof z?t:new W(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new z(`timeout of ${t}ms exceeded`,z.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>I.asap(o),s},Zt=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},Qt=async function*(e,t){for await(let n of $t(e))yield*Zt(n,t)},$t=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},en=(e,t,n,r)=>{let i=Qt(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},q=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,tn=(e,t,n)=>t+2<n&&q(e.charCodeAt(t+1))&&q(e.charCodeAt(t+2));function nn(e){if(!e||typeof e!=`string`||!e.startsWith(`data:`))return 0;let t=e.indexOf(`,`);if(t<0)return 0;let n=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(n)){let e=r.length,t=r.length;for(let n=0;n<t;n++)if(r.charCodeAt(n)===37&&n+2<t){let t=r.charCodeAt(n+1),i=r.charCodeAt(n+2);q(t)&&q(i)&&(e-=2,n+=2)}let n=0,i=t-1,a=e=>e>=2&&r.charCodeAt(e-2)===37&&r.charCodeAt(e-1)===51&&(r.charCodeAt(e)===68||r.charCodeAt(e)===100);i>=0&&(r.charCodeAt(i)===61?(n++,i--):a(i)&&(n++,i-=3)),n===1&&i>=0&&(r.charCodeAt(i)===61||a(i))&&n++;let o=Math.floor(e/4)*3-(n||0);return o>0?o:0}let i=0;for(let e=0,t=r.length;e<t;e++){let n=r.charCodeAt(e);if(n===37&&tn(r,e,t))i+=1,e+=2;else if(n<128)i+=1;else if(n<2048)i+=2;else if(n>=55296&&n<=56319&&e+1<t){let t=r.charCodeAt(e+1);t>=56320&&t<=57343?(i+=4,e++):i+=3}else i+=3}return i}var rn=`1.18.0`,an=64*1024,{isFunction:J}=I,on=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))),sn=e=>{if(!I.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},cn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ln=e=>{let t=e.indexOf(`://`),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes(`@`)||n.includes(`:`)},un=e=>{let t=I.global!==void 0&&I.global!==null?I.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=I.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:i,Request:a,Response:o}=e,s=i?J(i):typeof fetch==`function`,c=J(a),l=J(o);if(!s)return!1;let u=s&&J(n),d=s&&(typeof r==`function`?(e=>t=>e.encode(t))(new r):async e=>new Uint8Array(await new a(e).arrayBuffer())),f=c&&u&&cn(()=>{let e=!1,t=new a(V.origin,{body:new n,method:`POST`,get duplex(){return e=!0,`half`}}),r=t.headers.has(`Content-Type`);return t.body!=null&&t.body.cancel(),e&&!r}),p=l&&u&&cn(()=>I.isReadableStream(new o(``).body)),m={stream:p&&(e=>e.body)};s&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!m[e]&&(m[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new z(`Response type '${e}' is not supported`,z.ERR_NOT_SUPPORT,n)})});let h=async e=>{if(e==null)return 0;if(I.isBlob(e))return e.size;if(I.isSpecCompliantForm(e))return(await new a(V.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(I.isArrayBufferView(e)||I.isArrayBuffer(e))return e.byteLength;if(I.isURLSearchParams(e)&&(e+=``),I.isString(e))return(await d(e)).byteLength},g=async(e,t)=>I.toFiniteNumber(e.getContentLength())??h(t);return async e=>{let{url:t,method:n,data:s,signal:l,cancelToken:d,timeout:_,onDownloadProgress:v,onUploadProgress:y,responseType:b,headers:x,withCredentials:S=`same-origin`,fetchOptions:ee,maxContentLength:C,maxBodyLength:w}=Jt(e),T=I.isNumber(C)&&C>-1,E=I.isNumber(w)&&w>-1,te=t=>I.hasOwnProp(e,t)?e[t]:void 0,ne=i||fetch;b=b?(b+``).toLowerCase():`text`;let D=Xt([l,d&&d.toAbortSignal()],_),O=null,k=D&&D.unsubscribe&&(()=>{D.unsubscribe()}),A,j=null,re=()=>new z(`Request body larger than maxBodyLength limit`,z.ERR_BAD_REQUEST,e,O);try{let i,l=te(`auth`);if(l&&(i={username:I.getSafeProp(l,`username`)||``,password:I.getSafeProp(l,`password`)||``}),ln(t)){let e=new URL(t,V.origin);!i&&(e.username||e.password)&&(i={username:sn(e.username),password:sn(e.password)}),(e.username||e.password)&&(e.username=``,e.password=``,t=e.href)}if(i&&(x.delete(`authorization`),x.set(`Authorization`,`Basic `+btoa(on((i.username||``)+`:`+(i.password||``))))),T&&typeof t==`string`&&t.startsWith(`data:`)&&nn(t)>C)throw new z(`maxContentLength size of `+C+` exceeded`,z.ERR_BAD_RESPONSE,e,O);if(E&&n!==`get`&&n!==`head`){let e=await h(s);if(typeof e==`number`&&isFinite(e)&&(A=e,e>w))throw re()}let d=E&&(I.isReadableStream(s)||I.isStream(s)),_=(e,t,n)=>en(e,an,e=>{if(E&&e>w)throw j=re();t&&t(e)},n);if(f&&n!==`get`&&n!==`head`&&(y||d)){if(A??=await g(x,s),A!==0||d){let e=new a(t,{method:`POST`,body:s,duplex:`half`}),n;if(I.isFormData(s)&&(n=e.headers.get(`content-type`))&&x.setContentType(n),e.body){let[t,n]=y&&Mt(A,G(Nt(y)))||[];s=_(e.body,t,n)}}}else if(d&&!c&&u&&n!==`get`&&n!==`head`)s=_(s);else if(d&&c&&!f&&n!==`get`&&n!==`head`)throw new z(`Stream request bodies are not supported by the current fetch implementation`,z.ERR_NOT_SUPPORT,e,O);I.isString(S)||(S=S?`include`:`omit`);let ie=c&&`credentials`in a.prototype;if(I.isFormData(s)){let e=x.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&x.delete(`content-type`)}x.set(`User-Agent`,`axios/`+rn,!1);let ae={...ee,signal:D,method:n.toUpperCase(),headers:Ue(x.normalize()),body:s,duplex:`half`,credentials:ie?S:void 0};O=c&&new a(t,ae);let M=await(c?ne(O,ee):ne(t,ae)),oe=R.from(M.headers);if(T){let t=I.toFiniteNumber(oe.getContentLength());if(t!=null&&t>C)throw new z(`maxContentLength size of `+C+` exceeded`,z.ERR_BAD_RESPONSE,e,O)}let N=p&&(b===`stream`||b===`response`);if(p&&M.body&&(v||T||N&&k)){let t={};[`status`,`statusText`,`headers`].forEach(e=>{t[e]=M[e]});let n=I.toFiniteNumber(oe.getContentLength()),[r,i]=v&&Mt(n,G(Nt(v),!0))||[],a=0;M=new o(en(M.body,an,t=>{if(T&&(a=t,a>C))throw new z(`maxContentLength size of `+C+` exceeded`,z.ERR_BAD_RESPONSE,e,O);r&&r(t)},()=>{i&&i(),k&&k()}),t)}b||=`text`;let P=await m[I.findKey(m,b)||`text`](M,e);if(T&&!p&&!N){let t;if(P!=null&&(typeof P.byteLength==`number`?t=P.byteLength:typeof P.size==`number`?t=P.size:typeof P==`string`&&(t=typeof r==`function`?new r().encode(P).byteLength:P.length)),typeof t==`number`&&t>C)throw new z(`maxContentLength size of `+C+` exceeded`,z.ERR_BAD_RESPONSE,e,O)}return!N&&k&&k(),await new Promise((t,n)=>{Ot(t,n,{data:P,headers:R.from(M.headers),status:M.status,statusText:M.statusText,config:e,request:O})})}catch(t){if(k&&k(),D&&D.aborted&&D.reason instanceof z){let n=D.reason;throw n.config=e,O&&(n.request=O),t!==n&&(n.cause=t),n}throw j?(O&&!j.request&&(j.request=O),j):t instanceof z?(O&&!t.request&&(t.request=O),t):t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new z(`Network Error`,z.ERR_NETWORK,e,O,t&&t.response),{cause:t.cause||t}):z.from(t,t&&t.code,e,O,t&&t.response)}}},dn=new Map,fn=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=dn;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:un(t)),l=c;return c};fn();var pn={http:null,xhr:Yt,fetch:{get:fn}};I.forEach(pn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});var mn=e=>`- ${e}`,hn=e=>I.isFunction(e)||e===null||e===!1;function gn(e,t){e=I.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!hn(r)&&(i=pn[(n=String(r)).toLowerCase()],i===void 0))throw new z(`Unknown adapter '${n}'`);if(i&&(I.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new z(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
|
|
4
|
+
`+e.map(mn).join(`
|
|
5
|
+
`):` `+mn(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i}var _n={getAdapter:gn,adapters:pn};function vn(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new W(null,e)}function yn(e){return vn(e),e.headers=R.from(e.headers),e.data=Et.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),_n.getAdapter(e.adapter||U.adapter,e)(e).then(function(t){vn(e),e.response=t;try{t.data=Et.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=R.from(t.headers),t},function(t){if(!Dt(t)&&(vn(e),t&&t.response)){e.response=t.response;try{t.response.data=Et.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=R.from(t.response.headers)}return Promise.reject(t)})}var Y={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{Y[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var bn={};Y.transitional=function(e,t,n){function r(e,t){return`[Axios v`+rn+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new z(r(i,` has been removed`+(t?` in `+t:``)),z.ERR_DEPRECATED);return t&&!bn[i]&&(bn[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},Y.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function xn(e,t,n){if(typeof e!=`object`)throw new z(`options must be an object`,z.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new z(`option `+a+` must be `+n,z.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new z(`Unknown option `+a,z.ERR_BAD_OPTION)}}var X={assertOptions:xn,validators:Y},Z=X.validators,Q=class{constructor(e){this.defaults=e||{},this.interceptors={request:new ut,response:new ut}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=(()=>{if(!t.stack)return``;let e=t.stack.indexOf(`
|
|
6
|
+
`);return e===-1?``:t.stack.slice(e+1)})();try{if(!e.stack)e.stack=n;else if(n){let t=n.indexOf(`
|
|
7
|
+
`),r=t===-1?-1:n.indexOf(`
|
|
8
|
+
`,t+1),i=r===-1?``:n.slice(r+1);String(e.stack).endsWith(i)||(e.stack+=`
|
|
9
|
+
`+n)}}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=K(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&X.assertOptions(n,{silentJSONParsing:Z.transitional(Z.boolean),forcedJSONParsing:Z.transitional(Z.boolean),clarifyTimeoutError:Z.transitional(Z.boolean),legacyInterceptorReqResOrdering:Z.transitional(Z.boolean),advertiseZstdAcceptEncoding:Z.transitional(Z.boolean),validateStatusUndefinedResolves:Z.transitional(Z.boolean)},!1),r!=null&&(I.isFunction(r)?t.paramsSerializer={serialize:r}:X.assertOptions(r,{encode:Z.function,serialize:Z.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),X.assertOptions(t,{baseUrl:Z.spelling(`baseURL`),withXsrfToken:Z.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&I.merge(i.common,i[t.method]);i&&I.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`,`common`],e=>{delete i[e]}),t.headers=R.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||dt;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[yn.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=yn.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=K(this.defaults,e),lt(Ut(e.baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}};I.forEach([`delete`,`get`,`head`,`options`],function(e){Q.prototype[e]=function(t,n){return this.request(K(n||{},{method:e,url:t,data:n&&I.hasOwnProp(n,`data`)?n.data:void 0}))}}),I.forEach([`post`,`put`,`patch`,`query`],function(e){function t(t){return function(n,r,i){return this.request(K(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}Q.prototype[e]=t(),e!==`query`&&(Q.prototype[e+`Form`]=t(!0))});var Sn=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new W(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function Cn(e){return function(t){return e.apply(null,t)}}function wn(e){return I.isObject(e)&&e.isAxiosError===!0}var Tn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Tn).forEach(([e,t])=>{Tn[t]=e});function En(e){let n=new Q(e),r=t(Q.prototype.request,n);return I.extend(r,Q.prototype,n,{allOwnKeys:!0}),I.extend(r,n,null,{allOwnKeys:!0}),r.create=function(t){return En(K(e,t))},r}var $=En(U);$.Axios=Q,$.CanceledError=W,$.CancelToken=Sn,$.isCancel=Dt,$.VERSION=rn,$.toFormData=B,$.AxiosError=z,$.Cancel=$.CanceledError,$.all=function(e){return Promise.all(e)},$.spread=Cn,$.isAxiosError=wn,$.mergeConfig=K,$.AxiosHeaders=R,$.formToJSON=e=>wt(I.isHTMLForm(e)?new FormData(e):e),$.getAdapter=_n.getAdapter,$.HttpStatusCode=Tn,$.default=$;var{Axios:Dn,AxiosError:On,CanceledError:kn,isCancel:An,CancelToken:jn,VERSION:Mn,all:Nn,Cancel:Pn,isAxiosError:Fn,spread:In,toFormData:Ln,AxiosHeaders:Rn,HttpStatusCode:zn,formToJSON:Bn,getAdapter:Vn,mergeConfig:Hn,create:Un}=$;export{$ as default};
|