aicodeswitch 1.6.1 → 1.6.2
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 +1 -1
- package/dist/ui/assets/{index-dcQX0zYo.css → index-Bfc2kKan.css} +1 -1
- package/dist/ui/assets/{index-i28c5f0H.js → index-BwrBKpaK.js} +2 -2
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/public/donate-to-me.png +0 -0
- package/public/vendors-recommand.md +14 -0
- /package/{donate-to-me.png → dist/ui/donate-to-me.png} +0 -0
- /package/{docs → dist/ui}/vendors-recommand.md +0 -0
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.app{display:flex;width:100%;height:100%}.sidebar{width:260px;background:var(--bg-sidebar);color:var(--text-primary);display:flex;flex-direction:column;padding:0 0 80px;border-radius:20px;box-shadow:0 8px 32px var(--shadow-primary),0 0 20px #0478574d;margin:16px;position:relative;z-index:1;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1)}.logo{padding:28px 20px;border-bottom:2px solid rgba(255,255,255,.2);text-align:center;position:relative;overflow:hidden}.logo:before{content:"✨";position:absolute;top:12px;left:12px;font-size:16px;opacity:.7;transition:all .3s ease}.logo:after{content:"🌟";position:absolute;top:12px;right:12px;font-size:16px;opacity:.7;transition:all .3s ease}.logo:hover:before,.logo:focus:before{animation:sparkle 3s ease-in-out infinite}.logo:hover:after,.logo:focus:after{animation:sparkle 3s ease-in-out infinite 1.5s}@keyframes sparkle{0%,to{transform:scale(1) rotate(0);opacity:.7}50%{transform:scale(1.2) rotate(180deg);opacity:1}}.logo h2{font-size:22px;font-weight:800;background:linear-gradient(135deg,#fff,#f8f8ff,#e6e6fa);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;text-shadow:0 2px 4px rgba(0,0,0,.1),0 0 20px rgba(4,120,87,.3);position:relative;z-index:1;letter-spacing:1px;text-transform:uppercase;transition:all .3s ease}.logo:hover h2,.logo:focus h2{animation:logoGlow 4s ease-in-out infinite}@keyframes logoGlow{0%,to{text-shadow:0 2px 4px rgba(0,0,0,.1),0 0 20px rgba(4,120,87,.3)}50%{text-shadow:0 2px 4px rgba(0,0,0,.1),0 0 30px rgba(4,120,87,.5),0 0 40px rgba(4,120,87,.3)}}.nav-menu{list-style:none;padding:16px 0;margin:0}.nav-menu li{margin:8px 12px}.nav-menu a{display:block;padding:14px 20px;color:var(--text-sidebar);text-decoration:none;border-radius:12px;transition:all .3s ease-out;font-weight:500;position:relative;overflow:hidden}.nav-menu a:before{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.15),transparent);transition:left .5s ease-out}.nav-menu a:hover:before{left:100%}.nav-menu a:hover{background-color:#ffffff1a;transform:translate(4px);box-shadow:0 4px 12px #0f172a33}.nav-menu a.active{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));box-shadow:0 4px 16px var(--shadow-primary)}.main-content{flex:1;padding:24px;overflow-y:auto;background:var(--bg-primary);position:relative;z-index:1;margin:16px 16px 16px 0;border-radius:20px}.main-content:before{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background-image:radial-gradient(circle at 20% 80%,rgba(255,206,92,.1) 0%,transparent 50%),radial-gradient(circle at 80% 20%,rgba(134,204,202,.1) 0%,transparent 50%),radial-gradient(circle at 40% 40%,rgba(255,113,206,.05) 0%,transparent 50%);pointer-events:none}.page-header{margin-bottom:24px;position:relative;z-index:1}.page-header h1{font-family:Fredoka,sans-serif;font-size:28px;font-weight:700;color:var(--accent-primary);margin-bottom:8px;text-shadow:0 2px 4px var(--shadow-primary)}.page-header p{color:var(--text-muted);font-size:16px;font-weight:400}.card{background:var(--bg-card);border-radius:20px;padding:24px;box-shadow:0 8px 32px var(--shadow-secondary),0 0 16px #0478571a;margin-bottom:24px;border:1px solid var(--border-primary);position:relative;overflow:hidden;transition:all .3s ease-out;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.card:before{content:"";position:absolute;top:0;left:0;right:0;height:4px;background:linear-gradient(90deg,var(--accent-primary),var(--accent-secondary),var(--accent-primary));border-radius:20px 20px 0 0;background-size:200% 100%;transition:all .3s ease}.card:hover:before{animation:gradientShift 3s ease-in-out infinite}@keyframes gradientShift{0%,to{background-position:0% 50%}50%{background-position:100% 50%}}.card:hover{transform:translateY(-2px);box-shadow:0 12px 40px #6a7bb433,0 8px 24px #ff71ce26}.btn{padding:10px 20px;border:none;border-radius:12px;cursor:pointer;font-size:14px;font-weight:600;transition:all .3s ease-out;position:relative;overflow:hidden;box-shadow:0 2px 8px #0000001a;white-space:nowrap}.btn:before{content:"";position:absolute;top:50%;left:50%;width:0;height:0;background:#ffffff4d;border-radius:50%;transform:translate(-50%,-50%);transition:width .6s,height .6s}.btn:hover:before{width:300px;height:300px}.btn:hover{transform:translateY(-1px);box-shadow:0 4px 16px #00000026}.btn:active{transform:translateY(0)}.btn:disabled{opacity:.4;cursor:not-allowed}.btn-primary{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));color:#fff;position:relative;overflow:hidden}.btn-primary:before{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.3),transparent);transition:left .5s ease}.btn-primary:hover:before{left:100%}.btn-primary:hover{transform:translateY(-2px);box-shadow:0 8px 25px #04785766}.btn-danger{background:var(--accent-danger);color:#fff}.btn-danger:hover{background:#ea580c}.btn-success{background:var(--accent-success);color:#fff}.btn-success:hover{background:#059669}.btn-secondary{background:var(--accent-secondary);color:#fff}.btn-secondary:hover{background:var(--accent-primary)}.btn-sm{padding:4px 8px}table{width:100%;border-collapse:collapse;margin-top:16px;border-radius:12px;overflow:hidden;box-shadow:0 4px 16px #6a7bb41a}table th,table td{padding:16px;text-align:left;border-bottom:1px solid var(--border-secondary);color:var(--text-primary)}table th{background:var(--bg-table-header);font-weight:700;color:var(--text-secondary);font-family:Fredoka,sans-serif;font-size:14px}.form-group{margin-bottom:20px}.form-group label{display:block;margin-bottom:8px;color:var(--text-primary);font-size:14px;font-weight:600;font-family:Nunito,sans-serif}.form-group input,.form-group select,.form-group textarea{width:100%;padding:12px 16px;border:2px solid var(--border-primary);border-radius:12px;font-size:14px;font-family:Nunito,sans-serif;background:var(--bg-secondary);color:var(--text-primary);transition:all .3s ease-out}.form-group input:focus,.form-group select:focus,.form-group textarea:focus{outline:none;border-color:var(--accent-primary);box-shadow:0 0 0 3px var(--shadow-secondary);background:var(--bg-secondary)}.modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:#000000b3;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);display:flex;justify-content:center;align-items:center;z-index:1000;animation:modalFadeIn .3s ease-out}@keyframes modalFadeIn{0%{opacity:0}to{opacity:1}}.modal{background:var(--bg-secondary);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);border-radius:24px;padding:32px;min-width:500px;max-width:90%;max-height:90%;overflow-y:auto;box-shadow:0 20px 60px var(--shadow-primary),0 8px 32px var(--shadow-secondary);border:1px solid var(--border-secondary);animation:modalSlideIn .4s ease-out}@keyframes modalSlideIn{0%{opacity:0;transform:translateY(-20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.modal-header h2{font-size:20px;color:var(--text-primary)}.modal-footer{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}.action-buttons{display:flex;gap:8px}.badge{display:inline-block;padding:6px 12px;border-radius:20px;font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.5px;box-shadow:0 2px 8px #0000001a;margin-top:-40px;margin-right:-24px}.badge-success{background:var(--accent-success);color:#fff}.badge-warning{background:var(--accent-warning);color:#fff}.badge-danger{background:var(--accent-danger);color:#fff}.empty-state{text-align:center;padding:60px 20px;color:var(--text-muted);font-family:Nunito,sans-serif}.empty-state p{margin-bottom:20px;font-size:16px;font-weight:500}.toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}.theme-toggle{position:absolute;bottom:20px;left:20px;right:20px;display:flex;align-items:center;justify-content:center;gap:12px;padding:12px;background:#ffffff14;border-radius:12px;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);transition:all .3s ease-out}.theme-toggle:hover{background:#ffffff1f}.theme-toggle button{background:none;border:none;color:var(--text-sidebar);cursor:pointer;padding:8px;border-radius:8px;transition:all .3s ease-out;display:flex;align-items:center;justify-content:center}.theme-toggle button:hover{background:#ffffff26}.theme-toggle button.active{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));color:#fff;box-shadow:0 2px 8px var(--shadow-primary),0 0 8px #04785780;animation:pulse 2s ease-in-out infinite}@keyframes pulse{0%,to{transform:scale(1)}50%{transform:scale(1.05)}}.update-notification{position:absolute;bottom:80px;left:20px;right:20px;background:linear-gradient(135deg,#10b98126,#05966926);border:1px solid rgba(16,185,129,.4);border-radius:12px;padding:12px;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);animation:slideUp .3s ease-out;box-shadow:0 4px 12px #10b98133;margin-bottom:12px}@keyframes slideUp{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.update-notification-content{display:flex;align-items:center;gap:10px;margin-bottom:8px}.update-icon{font-size:18px;animation:bounce 1s ease-in-out infinite}@keyframes bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-3px)}}.update-text{flex:1}.update-title{font-size:13px;font-weight:600;color:var(--text-sidebar);margin-bottom:2px}.update-versions{font-size:11px;color:#ffffffb3;font-family:Monaco,Menlo,monospace}.update-message{font-size:10px;color:var(--text-sidebar);margin-bottom:2px}.update-message code{background:#ffffff1a;padding:2px 4px;border-radius:4px;font-family:Monaco,Menlo,monospace;margin-top:2px;display:inline-block}.update-link{display:block;text-align:center;padding:6px 12px;background:linear-gradient(135deg,var(--accent-success),#059669);color:#fff;text-decoration:none;border-radius:8px;font-size:12px;font-weight:600;transition:all .3s ease-out}.update-link:hover{transform:translateY(-1px);box-shadow:0 4px 12px #10b98166}@media (prefers-reduced-motion: reduce){.nav-menu a,.card,.btn,.form-group input,.form-group select,.form-group textarea,.modal-overlay,.modal,table tr{transition:none;animation:none}.nav-menu a:hover,.card:hover,.btn:hover,table tr:hover{transform:none}.btn:before{display:none}}.markdown-content{line-height:1.7;color:var(--text-primary);max-width:100%;overflow-x:auto}.markdown-content h1{font-size:2em;font-weight:700;margin-top:0;margin-bottom:.8em;color:var(--text-primary);border-bottom:2px solid var(--border-color);padding-bottom:.3em}.markdown-content h2{font-size:1.6em;font-weight:600;margin-top:1.5em;margin-bottom:.6em;color:var(--text-primary);border-bottom:1px solid var(--border-color);padding-bottom:.25em}.markdown-content h3{font-size:1.3em;font-weight:600;margin-top:1.2em;margin-bottom:.5em;color:var(--text-primary)}.markdown-content h4{font-size:1.1em;font-weight:600;margin-top:1em;margin-bottom:.4em;color:var(--text-primary)}.markdown-content p{margin-bottom:1em;line-height:1.8}.markdown-content ul,.markdown-content ol{margin-bottom:1em;padding-left:2em}.markdown-content li{margin-bottom:.5em;line-height:1.7}.markdown-content code{background:var(--bg-secondary);padding:.2em .4em;border-radius:4px;font-size:.9em;font-family:Monaco,Menlo,Ubuntu Mono,Consolas,monospace;color:var(--accent-secondary);border:1px solid var(--border-color)}.markdown-content pre{background:var(--bg-secondary);padding:1em;border-radius:8px;overflow-x:auto;margin-bottom:1em;border:1px solid var(--border-color)}.markdown-content pre code{background:none;padding:0;border:none;color:var(--text-primary);font-size:.95em}.markdown-content blockquote{border-left:4px solid var(--accent-primary);padding-left:1em;margin-left:0;margin-bottom:1em;color:var(--text-secondary);font-style:italic}.markdown-content a{color:var(--accent-primary);text-decoration:none;border-bottom:1px solid transparent;transition:all .2s ease}.markdown-content a:hover{color:var(--accent-secondary);border-bottom-color:var(--accent-secondary)}.markdown-content table{width:100%;border-collapse:collapse;margin-bottom:1em}.markdown-content table th,.markdown-content table td{padding:.75em;text-align:left;border:1px solid var(--border-color)}.markdown-content table th{background:var(--bg-secondary);font-weight:600}.markdown-content hr{border:none;border-top:2px solid var(--border-color);margin:2em 0}.markdown-content strong{font-weight:600;color:var(--text-primary)}.markdown-content em{font-style:italic}.markdown-content img{max-width:100%;height:auto;border-radius:8px;margin:1em 0}*{margin:0;padding:0;box-sizing:border-box}:root{--bg-primary: linear-gradient(135deg, #F7FEE7 0%, #F0FDF4 100%);--bg-secondary: rgba(255, 255, 255, .95);--bg-sidebar: linear-gradient(135deg, #0F5132 0%, #065F46 100%);--bg-card: rgba(255, 255, 255, .98);--bg-code: #f4fff7;--bg-table-header: linear-gradient(135deg, #A7F3D0 0%, #6EE7B7 100%);--text-primary: #14532D;--text-secondary: #064E3B;--text-muted: #065F46;--text-sidebar: #FFFFFF;--text-on-dark: #FFFFFF;--border-primary: rgba(15, 81, 50, .2);--border-secondary: rgba(6, 95, 70, .2);--accent-primary: #0F5132;--accent-secondary: #047857;--accent-light: #a1e9c7;--accent-success: #047857;--accent-warning: #D97706;--accent-danger: #DC2626;--shadow-primary: rgba(15, 81, 50, .3);--shadow-secondary: rgba(15, 81, 50, .15);--bg-route-item: rgba(248, 249, 250, .9);--bg-route-item-hover: rgba(230, 244, 234, .95);--bg-route-item-selected: rgba(161, 233, 199, .25);--text-route-muted: #6c757d;--text-info: #2faeee}[data-theme=dark]{--bg-primary: linear-gradient(135deg, #0A1A0F 0%, #0F2415 100%);--bg-secondary: rgba(15, 36, 21, .9);--bg-sidebar: linear-gradient(135deg, #0F5132 0%, #065F46 100%);--bg-card: rgba(25, 51, 31, .95);--bg-code: #0f172a;--bg-table-header: linear-gradient(135deg, #0F5132 0%, #047857 100%);--text-primary: #ECFEF5;--text-secondary: #A7F3D0;--text-muted: #6EE7B7;--text-sidebar: #FFFFFF;--text-on-dark: #ECFEF5;--border-primary: rgba(15, 81, 50, .5);--border-secondary: rgba(6, 95, 70, .5);--accent-primary: #0F5132;--accent-secondary: #047857;--accent-light: #002d18;--accent-success: #10B981;--accent-warning: #F59E0B;--accent-danger: #EF4444;--shadow-primary: rgba(15, 81, 50, .4);--shadow-secondary: rgba(6, 95, 70, .3);--bg-route-item: rgba(20, 46, 28, .7);--bg-route-item-hover: rgba(30, 60, 38, .85);--bg-route-item-selected: rgba(16, 185, 129, .15);--text-route-muted: #A7F3D0}body{font-family:Nunito,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:var(--bg-primary);color:var(--text-primary);transition:all .3s ease;min-height:100vh}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}#root{width:100vw;height:100vh;overflow:hidden}::-webkit-scrollbar{width:12px;height:12px}::-webkit-scrollbar-track{background:var(--bg-secondary);border-radius:8px}::-webkit-scrollbar-thumb{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));border-radius:8px;border:2px solid var(--bg-secondary);box-shadow:0 2px 4px #0000001a;transition:all .3s ease}::-webkit-scrollbar-thumb:hover{background:linear-gradient(135deg,var(--accent-secondary),var(--accent-primary));box-shadow:0 4px 8px #0003;transform:scale(1.1)}::-webkit-scrollbar-thumb:active{background:var(--accent-primary);box-shadow:0 6px 12px #0000004d}::-webkit-scrollbar-corner{background:var(--bg-secondary)}*{scrollbar-width:thin;scrollbar-color:var(--accent-primary) var(--bg-secondary)}::-webkit-scrollbar-button{display:none}html{scroll-behavior:smooth}
|
|
1
|
+
.app{display:flex;width:100%;height:100%}.sidebar{width:260px;background:var(--bg-sidebar);color:var(--text-primary);display:flex;flex-direction:column;padding:0 0 80px;border-radius:20px;box-shadow:0 8px 32px var(--shadow-primary),0 0 20px #0478574d;margin:16px;position:relative;z-index:1;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1)}.logo{padding:28px 20px;border-bottom:2px solid rgba(255,255,255,.2);text-align:center;position:relative;overflow:hidden}.logo:before{content:"✨";position:absolute;top:12px;left:12px;font-size:16px;opacity:.7;transition:all .3s ease}.logo:after{content:"🌟";position:absolute;top:12px;right:12px;font-size:16px;opacity:.7;transition:all .3s ease}.logo:hover:before,.logo:focus:before{animation:sparkle 3s ease-in-out infinite}.logo:hover:after,.logo:focus:after{animation:sparkle 3s ease-in-out infinite 1.5s}@keyframes sparkle{0%,to{transform:scale(1) rotate(0);opacity:.7}50%{transform:scale(1.2) rotate(180deg);opacity:1}}.logo h2{font-size:22px;font-weight:800;background:linear-gradient(135deg,#fff,#f8f8ff,#e6e6fa);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;text-shadow:0 2px 4px rgba(0,0,0,.1),0 0 20px rgba(4,120,87,.3);position:relative;z-index:1;letter-spacing:1px;text-transform:uppercase;transition:all .3s ease}.logo:hover h2,.logo:focus h2{animation:logoGlow 4s ease-in-out infinite}@keyframes logoGlow{0%,to{text-shadow:0 2px 4px rgba(0,0,0,.1),0 0 20px rgba(4,120,87,.3)}50%{text-shadow:0 2px 4px rgba(0,0,0,.1),0 0 30px rgba(4,120,87,.5),0 0 40px rgba(4,120,87,.3)}}.nav-menu{list-style:none;padding:16px 0;margin:0}.nav-menu li{margin:8px 12px}.nav-menu a{display:block;padding:14px 20px;color:var(--text-sidebar);text-decoration:none;border-radius:12px;transition:all .3s ease-out;font-weight:500;position:relative;overflow:hidden}.nav-menu a:before{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.15),transparent);transition:left .5s ease-out}.nav-menu a:hover:before{left:100%}.nav-menu a:hover{background-color:#ffffff1a;transform:translate(4px);box-shadow:0 4px 12px #0f172a33}.nav-menu a.active{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));box-shadow:0 4px 16px var(--shadow-primary)}.main-content{flex:1;padding:24px;overflow-y:auto;background:var(--bg-primary);position:relative;z-index:1;margin:16px 16px 16px 0;border-radius:20px}.main-content:before{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background-image:radial-gradient(circle at 20% 80%,rgba(255,206,92,.1) 0%,transparent 50%),radial-gradient(circle at 80% 20%,rgba(134,204,202,.1) 0%,transparent 50%),radial-gradient(circle at 40% 40%,rgba(255,113,206,.05) 0%,transparent 50%);pointer-events:none}.page-header{margin-bottom:24px;position:relative;z-index:1}.page-header h1{font-family:Fredoka,sans-serif;font-size:28px;font-weight:700;color:var(--accent-primary);margin-bottom:8px;text-shadow:0 2px 4px var(--shadow-primary)}.page-header p{color:var(--text-muted);font-size:16px;font-weight:400}.card{background:var(--bg-card);border-radius:20px;padding:24px;box-shadow:0 8px 32px var(--shadow-secondary),0 0 16px #0478571a;margin-bottom:24px;border:1px solid var(--border-primary);position:relative;overflow:hidden;transition:all .3s ease-out;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.card:before{content:"";position:absolute;top:0;left:0;right:0;height:4px;background:linear-gradient(90deg,var(--accent-primary),var(--accent-secondary),var(--accent-primary));border-radius:20px 20px 0 0;background-size:200% 100%;transition:all .3s ease}.card:hover:before{animation:gradientShift 3s ease-in-out infinite}@keyframes gradientShift{0%,to{background-position:0% 50%}50%{background-position:100% 50%}}.card:hover{transform:translateY(-2px);box-shadow:0 12px 40px #6a7bb433,0 8px 24px #ff71ce26}.btn{padding:10px 20px;border:none;border-radius:12px;cursor:pointer;font-size:14px;font-weight:600;transition:all .3s ease-out;position:relative;overflow:hidden;box-shadow:0 2px 8px #0000001a;white-space:nowrap}.btn:before{content:"";position:absolute;top:50%;left:50%;width:0;height:0;background:#ffffff4d;border-radius:50%;transform:translate(-50%,-50%);transition:width .6s,height .6s}.btn:hover:before{width:300px;height:300px}.btn:hover{transform:translateY(-1px);box-shadow:0 4px 16px #00000026}.btn:active{transform:translateY(0)}.btn:disabled{opacity:.4;cursor:not-allowed}.btn-primary{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));color:#fff;position:relative;overflow:hidden}.btn-primary:before{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.3),transparent);transition:left .5s ease}.btn-primary:hover:before{left:100%}.btn-primary:hover{transform:translateY(-2px);box-shadow:0 8px 25px #04785766}.btn-danger{background:var(--accent-danger);color:#fff}.btn-danger:hover{background:#ea580c}.btn-success{background:var(--accent-success);color:#fff}.btn-success:hover{background:#059669}.btn-secondary{background:var(--accent-secondary);color:#fff}.btn-secondary:hover{background:var(--accent-primary)}.btn-sm{padding:4px 8px}table{width:100%;border-collapse:collapse;margin-top:16px;border-radius:12px;overflow:hidden;box-shadow:0 4px 16px #6a7bb41a}table th,table td{padding:16px;text-align:left;border-bottom:1px solid var(--border-secondary);color:var(--text-primary)}table th{background:var(--bg-table-header);font-weight:700;color:var(--text-secondary);font-family:Fredoka,sans-serif;font-size:14px}.form-group{margin-bottom:20px}.form-group label{display:block;margin-bottom:8px;color:var(--text-primary);font-size:14px;font-weight:600;font-family:Nunito,sans-serif}.form-group input,.form-group select,.form-group textarea{width:100%;padding:12px 16px;border:2px solid var(--border-primary);border-radius:12px;font-size:14px;font-family:Nunito,sans-serif;background:var(--bg-secondary);color:var(--text-primary);transition:all .3s ease-out}.form-group input:focus,.form-group select:focus,.form-group textarea:focus{outline:none;border-color:var(--accent-primary);box-shadow:0 0 0 3px var(--shadow-secondary);background:var(--bg-secondary)}.modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:#000000b3;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);display:flex;justify-content:center;align-items:center;z-index:1000;animation:modalFadeIn .3s ease-out}@keyframes modalFadeIn{0%{opacity:0}to{opacity:1}}.modal{background:var(--bg-secondary);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);border-radius:24px;padding:32px;min-width:500px;max-width:90%;max-height:90%;overflow-y:auto;box-shadow:0 20px 60px var(--shadow-primary),0 8px 32px var(--shadow-secondary);border:1px solid var(--border-secondary);animation:modalSlideIn .4s ease-out}@keyframes modalSlideIn{0%{opacity:0;transform:translateY(-20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.modal-header h2{font-size:20px;color:var(--text-primary)}.modal-footer{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}.action-buttons{display:flex;gap:8px}.badge{display:inline-block;padding:6px 12px;border-radius:20px;font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.5px;box-shadow:0 2px 8px #0000001a;margin-top:-40px;margin-right:-24px}.badge-success{background:var(--accent-success);color:#fff}.badge-warning{background:var(--accent-warning);color:#fff}.badge-danger{background:var(--accent-danger);color:#fff}.empty-state{text-align:center;padding:60px 20px;color:var(--text-muted);font-family:Nunito,sans-serif}.empty-state p{margin-bottom:20px;font-size:16px;font-weight:500}.toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}.theme-toggle{position:absolute;bottom:20px;left:20px;right:20px;display:flex;align-items:center;justify-content:center;gap:12px;padding:12px;background:#ffffff14;border-radius:12px;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);transition:all .3s ease-out}.theme-toggle:hover{background:#ffffff1f}.theme-toggle button{background:none;border:none;color:var(--text-sidebar);cursor:pointer;padding:8px;border-radius:8px;transition:all .3s ease-out;display:flex;align-items:center;justify-content:center}.theme-toggle button:hover{background:#ffffff26}.theme-toggle button.active{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));color:#fff;box-shadow:0 2px 8px var(--shadow-primary),0 0 8px #04785780;animation:pulse 2s ease-in-out infinite}@keyframes pulse{0%,to{transform:scale(1)}50%{transform:scale(1.05)}}.update-notification{position:absolute;bottom:80px;left:20px;right:20px;background:linear-gradient(135deg,#10b98126,#05966926);border:1px solid rgba(16,185,129,.4);border-radius:12px;padding:12px;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);animation:slideUp .3s ease-out;box-shadow:0 4px 12px #10b98133;margin-bottom:12px}@keyframes slideUp{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.update-notification-content{display:flex;align-items:center;gap:10px;margin-bottom:8px}.update-icon{font-size:18px;animation:bounce 1s ease-in-out infinite}@keyframes bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-3px)}}.update-text{flex:1}.update-title{font-size:13px;font-weight:600;color:var(--text-sidebar);margin-bottom:2px}.update-versions{font-size:11px;color:#ffffffb3;font-family:Monaco,Menlo,monospace}.update-message{font-size:10px;color:var(--text-sidebar);margin-bottom:2px}.update-message code{background:#ffffff1a;padding:2px 4px;border-radius:4px;font-family:Monaco,Menlo,monospace;margin-top:2px;display:inline-block}.update-link{display:block;text-align:center;padding:6px 12px;background:linear-gradient(135deg,var(--accent-success),#059669);color:#fff;text-decoration:none;border-radius:8px;font-size:12px;font-weight:600;transition:all .3s ease-out}.update-link:hover{transform:translateY(-1px);box-shadow:0 4px 12px #10b98166}@media (prefers-reduced-motion: reduce){.nav-menu a,.card,.btn,.form-group input,.form-group select,.form-group textarea,.modal-overlay,.modal,table tr{transition:none;animation:none}.nav-menu a:hover,.card:hover,.btn:hover,table tr:hover{transform:none}.btn:before{display:none}}.markdown-content{line-height:1.7;color:var(--text-primary);max-width:100%;overflow-x:auto}.markdown-content h1{font-size:2em;font-weight:700;margin-top:0;margin-bottom:.8em;color:var(--text-primary);border-bottom:2px solid var(--border-color);padding-bottom:.3em}.markdown-content h2{font-size:1.6em;font-weight:600;margin-top:1.5em;margin-bottom:.6em;color:var(--text-primary);border-bottom:1px solid var(--border-color);padding-bottom:.25em}.markdown-content h3{font-size:1.3em;font-weight:600;margin-top:1.2em;margin-bottom:.5em;color:var(--text-primary)}.markdown-content h4{font-size:1.1em;font-weight:600;margin-top:1em;margin-bottom:.4em;color:var(--text-primary)}.markdown-content p{margin-bottom:1em;line-height:1.8}.markdown-content ul,.markdown-content ol{margin-bottom:1em;padding-left:2em}.markdown-content li{margin-bottom:.5em;line-height:1.7}.markdown-content code{background:var(--bg-secondary);padding:.2em .4em;border-radius:4px;font-size:.9em;font-family:Monaco,Menlo,Ubuntu Mono,Consolas,monospace;color:var(--accent-secondary);border:1px solid var(--border-color)}.markdown-content pre{background:var(--bg-secondary);padding:1em;border-radius:8px;overflow-x:auto;margin-bottom:1em;border:1px solid var(--border-color)}.markdown-content pre code{background:none;padding:0;border:none;color:var(--text-primary);font-size:.95em}.markdown-content blockquote{border-left:4px solid var(--accent-primary);padding-left:1em;margin-left:0;margin-bottom:1em;color:var(--text-secondary);font-style:italic}.markdown-content a{color:var(--accent-primary);text-decoration:none;border-bottom:1px solid var(--accent-secondary);transition:all .2s ease}.markdown-content a:hover{color:var(--accent-secondary)}.markdown-content table{width:100%;border-collapse:collapse;margin-bottom:1em}.markdown-content table th,.markdown-content table td{padding:.75em;text-align:left;border:1px solid var(--border-color)}.markdown-content table th{background:var(--bg-secondary);font-weight:600}.markdown-content hr{border:none;border-top:2px solid var(--border-color);margin:2em 0}.markdown-content strong{font-weight:600;color:var(--text-primary)}.markdown-content em{font-style:italic}.markdown-content img{max-width:100%;height:auto;border-radius:8px;margin:1em 0}*{margin:0;padding:0;box-sizing:border-box}:root{--bg-primary: linear-gradient(135deg, #F7FEE7 0%, #F0FDF4 100%);--bg-secondary: rgba(255, 255, 255, .95);--bg-sidebar: linear-gradient(135deg, #0F5132 0%, #065F46 100%);--bg-card: rgba(255, 255, 255, .98);--bg-code: #f4fff7;--bg-table-header: linear-gradient(135deg, #A7F3D0 0%, #6EE7B7 100%);--text-primary: #14532D;--text-secondary: #064E3B;--text-muted: #065F46;--text-sidebar: #FFFFFF;--text-on-dark: #FFFFFF;--border-primary: rgba(15, 81, 50, .2);--border-secondary: rgba(6, 95, 70, .2);--accent-primary: #0F5132;--accent-secondary: #047857;--accent-light: #a1e9c7;--accent-success: #047857;--accent-warning: #D97706;--accent-danger: #DC2626;--shadow-primary: rgba(15, 81, 50, .3);--shadow-secondary: rgba(15, 81, 50, .15);--bg-route-item: rgba(248, 249, 250, .9);--bg-route-item-hover: rgba(230, 244, 234, .95);--bg-route-item-selected: rgba(161, 233, 199, .25);--text-route-muted: #6c757d;--text-info: #2faeee}[data-theme=dark]{--bg-primary: linear-gradient(135deg, #0A1A0F 0%, #0F2415 100%);--bg-secondary: rgba(15, 36, 21, .9);--bg-sidebar: linear-gradient(135deg, #0F5132 0%, #065F46 100%);--bg-card: rgba(25, 51, 31, .95);--bg-code: #0f172a;--bg-table-header: linear-gradient(135deg, #0F5132 0%, #047857 100%);--text-primary: #ECFEF5;--text-secondary: #A7F3D0;--text-muted: #6EE7B7;--text-sidebar: #FFFFFF;--text-on-dark: #ECFEF5;--border-primary: rgba(15, 81, 50, .5);--border-secondary: rgba(6, 95, 70, .5);--accent-primary: #0F5132;--accent-secondary: #047857;--accent-light: #002d18;--accent-success: #10B981;--accent-warning: #F59E0B;--accent-danger: #EF4444;--shadow-primary: rgba(15, 81, 50, .4);--shadow-secondary: rgba(6, 95, 70, .3);--bg-route-item: rgba(20, 46, 28, .7);--bg-route-item-hover: rgba(30, 60, 38, .85);--bg-route-item-selected: rgba(16, 185, 129, .15);--text-route-muted: #A7F3D0}body{font-family:Nunito,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:var(--bg-primary);color:var(--text-primary);transition:all .3s ease;min-height:100vh}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}#root{width:100vw;height:100vh;overflow:hidden}::-webkit-scrollbar{width:12px;height:12px}::-webkit-scrollbar-track{background:var(--bg-secondary);border-radius:8px}::-webkit-scrollbar-thumb{background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary));border-radius:8px;border:2px solid var(--bg-secondary);box-shadow:0 2px 4px #0000001a;transition:all .3s ease}::-webkit-scrollbar-thumb:hover{background:linear-gradient(135deg,var(--accent-secondary),var(--accent-primary));box-shadow:0 4px 8px #0003;transform:scale(1.1)}::-webkit-scrollbar-thumb:active{background:var(--accent-primary);box-shadow:0 6px 12px #0000004d}::-webkit-scrollbar-corner{background:var(--bg-secondary)}*{scrollbar-width:thin;scrollbar-color:var(--accent-primary) var(--bg-secondary)}::-webkit-scrollbar-button{display:none}html{scroll-behavior:smooth}
|
|
@@ -294,7 +294,7 @@ PORT=4567
|
|
|
294
294
|
|
|
295
295
|
## 支持我
|
|
296
296
|
|
|
297
|
-

|
|
297
|
+

|
|
298
298
|
|
|
299
299
|
你的支持是我前进的动力!
|
|
300
300
|
|
|
@@ -307,7 +307,7 @@ PORT=4567
|
|
|
307
307
|
|
|
308
308
|
## 技术支持
|
|
309
309
|
|
|
310
|
-
如有问题或建议,请访问项目 [GitHub 仓库](https://github.com/tangshuang/aicodeswitch/issues)提交 Issue。`;function cj(e,t){let n,r;return function(){const[i,a]=m.useState(e);return m.useEffect(()=>{if(r){a(r);return}const o=l=>{l&&(r=l,a(l))};n?n.then(o).catch(()=>{}):n=t().then(o).catch(()=>{})},[]),i}}const w3=cj(x3,oe.getRecommendVendorsMarkdown),S3=cj(b3,oe.getReadmeMarkdown);function P3({value:e=[],onChange:t,placeholder:n,inputValue:r,onInputChange:i}){const a=l=>{if(l.key==="Enter"||l.key===","){l.preventDefault();const u=r.trim();u&&!e.includes(u)&&(t([...e,u]),i(""))}else l.key==="Backspace"&&!r&&e.length>0&&t(e.slice(0,-1))},o=l=>{t(e.filter((u,s)=>s!==l))};return h.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"4px",padding:"8px",minHeight:"40px",background:"var(--bg-secondary)"},children:h.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",alignItems:"center"},children:[e.map((l,u)=>h.jsxs("span",{style:{backgroundColor:"var(--accent-light)",color:"var(--text-primary)",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[l,h.jsx("button",{type:"button",onClick:()=>o(u),style:{background:"none",border:"none",color:"var(--text-primary)",cursor:"pointer",fontSize:"16px",lineHeight:"1",padding:"0",marginLeft:"4px"},onMouseOver:s=>s.currentTarget.style.color="var(--accent-danger)",onMouseOut:s=>s.currentTarget.style.color="var(--text-primary)",children:"×"})]},u)),h.jsx("input",{type:"text",value:r,onChange:l=>i(l.target.value),onKeyDown:a,placeholder:n,style:{border:"none",outline:"none",flex:"1",minWidth:"120px",fontSize:"14px"}})]})})}const lw={"openai-chat":"OpenAI Chat","openai-code":"OpenAI Code","openai-responses":"OpenAI Responses","claude-chat":"Claude Chat","claude-code":"Claude Code","deepseek-chat":"DeepSeek Chat"};function k3(){var ue;const[e,t]=m.useState([]),[n,r]=m.useState([]),[i,a]=m.useState(null),[o,l]=m.useState(!1),[u,s]=m.useState(!1),[c,f]=m.useState(!1),[d,p]=m.useState(!1),[v,y]=m.useState(null),[x,g]=m.useState(null),[b,w]=m.useState([]),[P,k]=m.useState(""),[S,E]=m.useState(""),[C,N]=m.useState([]),[T,_]=m.useState(""),A=w3();m.useEffect(()=>{V()},[]),m.useEffect(()=>{i&&$(i.id)},[i]);const V=async()=>{const I=await oe.getVendors();t(I),I.length>0&&!i&&a(I[0])},$=async I=>{const J=await oe.getAPIServices(I);r(J)},L=()=>{y(null),l(!0)},B=()=>{f(!0)},F=I=>{y(I),l(!0)},M=async I=>{confirm("确定要删除此供应商吗")&&(await oe.deleteVendor(I),V(),i&&i.id===I&&(a(null),r([])))},R=async I=>{I.preventDefault();const J=new FormData(I.currentTarget),z={name:J.get("name"),description:J.get("description")};v?await oe.updateVendor(v.id,z):await oe.createVendor(z),l(!1),V()},O=()=>{g(null),w([]),k(""),s(!0)},q=I=>{g(I),w(I.supportedModels||[]),k(""),s(!0)},Q=async I=>{confirm("确定要删除此API服务吗")&&(await oe.deleteAPIService(I),i&&$(i.id))},j=async I=>{I.preventDefault();let J=[...b];if(P.trim()){const re=P.split(",").map(K=>K.trim()).filter(K=>K&&!J.includes(K));J=[...J,...re]}const z=new FormData(I.currentTarget),X={vendorId:i.id,name:z.get("name"),apiUrl:z.get("apiUrl"),apiKey:z.get("apiKey"),timeout:parseInt(z.get("timeout"))||3e4,sourceType:z.get("sourceType"),supportedModels:J.length>0?J:void 0};x?await oe.updateAPIService(x.id,X):await oe.createAPIService(X),s(!1),w([]),k(""),i&&$(i.id)},ie=I=>{if(I){E(I);const J=Ia[I];J&&J.services.length>0&&N(J.services.map(z=>z.sourceType))}else E(""),N([]);_(""),p(!0)},he=async I=>{I.preventDefault();const J=new FormData(I.currentTarget),z=J.get("vendorKey"),X=J.get("apiKey");if(!z||!X){alert("请填写完整信息");return}if(C.length===0){alert("请至少选择一个源类型");return}const re=Ia[z];if(!re){alert("未找到对应的供应商配置");return}try{const K=await oe.createVendor({name:re.name,description:re.description}),U=C.map(async ae=>{const me=re.services.find(ve=>ve.sourceType===ae);return me?oe.createAPIService({vendorId:K.id,name:me.name,apiUrl:me.apiUrl,apiKey:X,timeout:3e4,sourceType:ae,supportedModels:me.models?me.models.split(",").map(ve=>ve.trim()):void 0}):(console.warn(`未找到源类型 ${ae} 的配置`),null)});await Promise.all(U),await V(),p(!1),alert(`配置成功! 已创建 ${C.length} 个API服务`)}catch(K){console.error("一键配置失败:",K),alert("配置失败,请检查输入信息")}};return h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"供应商管理"}),h.jsx("p",{children:"管理API供应商和服务配置"})]}),h.jsxs("div",{style:{display:"flex",gap:"20px"},children:[h.jsxs("div",{className:"card",style:{flex:"0 0 33%"},children:[h.jsxs("div",{className:"toolbar",children:[h.jsx("h3",{children:"供应商列表"}),h.jsxs("div",{style:{display:"flex",gap:"10px"},children:[h.jsx("button",{className:"btn btn-secondary",style:{background:"linear-gradient(135deg, #2563EB 0%, #F97316 100%)",color:"#FFFFFF",boxShadow:"0 4px 12px rgba(37, 99, 235, 0.3)",border:"none",transition:"all 0.3s ease",cursor:"pointer",fontWeight:"600",letterSpacing:"0.5px"},onClick:B,onMouseEnter:I=>{I.currentTarget.style.transform="translateY(-2px)",I.currentTarget.style.boxShadow="0 8px 20px rgba(37, 99, 235, 0.4)"},onMouseLeave:I=>{I.currentTarget.style.transform="translateY(0)",I.currentTarget.style.boxShadow="0 4px 12px rgba(37, 99, 235, 0.3)"},onFocus:I=>{I.currentTarget.style.outline="2px solid #2563EB",I.currentTarget.style.outlineOffset="2px"},onBlur:I=>{I.currentTarget.style.outline="none"},children:"推荐"}),h.jsx("button",{className:"btn btn-primary",onClick:()=>ie(),children:"一键配置"}),h.jsx("button",{className:"btn btn-primary",onClick:L,children:"新增"})]})]}),e.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无供应商"})}):h.jsx("div",{style:{marginTop:"10px"},children:e.map(I=>h.jsx("div",{onClick:()=>a(I),style:{padding:"12px",marginBottom:"8px",backgroundColor:i&&i.id===I.id?"var(--accent-light)":"var(--bg-secondary)",borderRadius:"4px",cursor:"pointer",border:"1px solid var(--border-secondary)",color:"var(--text-primary)"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:I.name}),I.description&&h.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"4px"},children:I.description})]}),h.jsxs("div",{className:"action-buttons",children:[h.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:J=>{J.stopPropagation(),F(I)},children:"编辑"}),h.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:J=>{J.stopPropagation(),M(I.id)},children:"删除"})]})]})},I.id))})]}),h.jsxs("div",{className:"card",style:{flex:1},children:[h.jsxs("div",{className:"toolbar",children:[h.jsxs("h3",{children:["供应商API服务",i&&` - ${i.name}`]}),i&&h.jsx("button",{className:"btn btn-primary",onClick:O,children:"新增服务"})]}),i?n.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无API服务"})}):h.jsxs("table",{style:{fontSize:"smaller"},children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{style:{whiteSpace:"nowrap"},children:"服务名称"}),h.jsx("th",{children:"源类型"}),h.jsx("th",{children:"API地址"}),h.jsx("th",{children:"模型列表"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:n.map(I=>{var J;return h.jsxs("tr",{children:[h.jsx("td",{children:I.name}),h.jsx("td",{children:I.sourceType?lw[I.sourceType]:"-"}),h.jsx("td",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:I.apiUrl,children:I.apiUrl}),h.jsx("td",{children:((J=I.supportedModels)==null?void 0:J.join(", "))||"*"}),h.jsx("td",{children:h.jsxs("div",{className:"action-buttons",children:[h.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>q(I),children:"编辑"}),h.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>Q(I.id),children:"删除"})]})})]},I.id)})})]}):h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"请先选择一个供应商"})})]})]}),o&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:v?"编辑供应商":"新增供应商"})}),h.jsxs("form",{onSubmit:R,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商名称"}),h.jsx("input",{type:"text",name:"name",defaultValue:v?v.name:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"描述"}),h.jsx("textarea",{name:"description",rows:3,defaultValue:v?v.description:""})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>l(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})}),u&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:x?"编辑供应商API服务":"新增供应商API服务"})}),h.jsxs("form",{onSubmit:j,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"服务名称"}),h.jsx("input",{type:"text",name:"name",defaultValue:x?x.name:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["源类型 ",h.jsx("small",{children:"供应商接口返回的数据格式标准类型"})]}),h.jsxs("select",{name:"sourceType",defaultValue:x&&x.sourceType||"",required:!0,children:[h.jsx("option",{value:"",children:"请选择源类型"}),h.jsx("option",{value:"openai-chat",children:"OpenAI Chat"}),h.jsx("option",{value:"openai-code",children:"OpenAI Code"}),h.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),h.jsx("option",{value:"claude-chat",children:"Claude Chat"}),h.jsx("option",{value:"claude-code",children:"Claude Code"}),h.jsx("option",{value:"deepseek-chat",children:"DeepSeek Chat"})]})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商API地址"}),h.jsx("input",{type:"url",name:"apiUrl",defaultValue:x?x.apiUrl:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商API密钥"}),h.jsx("input",{type:"password",name:"apiKey",defaultValue:x?x.apiKey:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"超时时间(ms)"}),h.jsx("input",{type:"number",name:"timeout",defaultValue:x?x.timeout:3e4})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"支持的模型列表"}),h.jsx(P3,{value:b,onChange:w,inputValue:P,onInputChange:k,placeholder:"输入模型名,按Enter或逗号添加"},(x==null?void 0:x.id)||"new"),h.jsx("div",{style:{display:"block",width:"100%"},children:h.jsx("small",{style:{fontSize:"10px"},children:"留空表示支持所有模型,路由配置中,可直接将模型透传给该供应商服务接口。"})})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>s(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})}),c&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",style:{maxWidth:"800px"},onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"供应商推荐"})}),h.jsx("div",{className:"modal-body",children:h.jsx("div",{className:"markdown-content",children:h.jsx(sj,{components:{a:({href:I,children:J,title:z})=>z&&Ia[z]?h.jsx("a",{href:"#",style:{color:"#2563EB",borderBottom:"solid 1px #2563EB",cursor:"pointer"},onClick:X=>{X.preventDefault(),f(!1),ie(z)},children:J}):h.jsx("a",{href:I,style:{color:"#2563EB",borderBottom:"solid 1px #2563EB"},target:"_blank",rel:"noopener noreferrer",children:J})},children:A})})}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>f(!1),children:"关闭"})})]})}),d&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"一键配置供应商"})}),h.jsxs("form",{onSubmit:he,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商"}),h.jsxs("select",{name:"vendorKey",value:S,onChange:I=>{const J=I.target.value;if(E(J),J){const z=Ia[J];z&&z.services.length>0&&N(z.services.map(X=>X.sourceType))}else N([])},required:!0,children:[h.jsx("option",{value:"",children:"请选择供应商"}),Object.entries(Ia).map(([I,J])=>h.jsx("option",{value:I,children:J.name},I))]})]}),h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["源类型 ",h.jsx("small",{style:{color:"var(--text-muted)",fontWeight:"normal"},children:"可选择多个"})]}),h.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"16px",background:"var(--bg-secondary)",minHeight:"100px",display:"flex",flexDirection:"column",gap:"8px"},children:S?(ue=Ia[S])==null?void 0:ue.services.map((I,J)=>{const z=C.includes(I.sourceType);return h.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer",padding:"10px 14px",borderRadius:"6px",background:z?"var(--accent-light)":"transparent",border:`2px solid ${z?"var(--accent-primary)":"transparent"}`,transition:"all 0.2s ease",position:"relative",overflow:"hidden"},onMouseEnter:X=>{z||(X.currentTarget.style.background="var(--bg-hover)",X.currentTarget.style.borderColor="var(--border-secondary)")},onMouseLeave:X=>{z||(X.currentTarget.style.background="transparent",X.currentTarget.style.borderColor="transparent")},children:[h.jsx("input",{type:"checkbox",checked:z,onChange:X=>{const re=I.sourceType;X.target.checked?N([...C,re]):N(C.filter(K=>K!==re))},style:{width:"18px",height:"18px",marginRight:"12px",cursor:"pointer",accentColor:"var(--accent-primary)"}}),h.jsx("span",{style:{fontSize:"14px",fontWeight:z?"600":"400",color:z?"var(--accent-primary)":"var(--text-primary)",transition:"all 0.2s ease"},children:lw[I.sourceType]}),z&&h.jsx("span",{style:{marginLeft:"auto",fontSize:"16px",color:"var(--accent-primary)"},children:"✓"})]},J)}):h.jsx("div",{style:{color:"var(--text-muted)",textAlign:"center",padding:"30px 20px",fontSize:"14px"},children:"请先选择供应商"})})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"API Key"}),h.jsx("input",{type:"password",name:"apiKey",value:T,onChange:I=>_(I.target.value),placeholder:"请输入API密钥",required:!0})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>p(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"确认配置"})]})]})]})})]})}const uw=[{value:"default",label:"默认"},{value:"background",label:"后台"},{value:"thinking",label:"思考"},{value:"long-context",label:"长上下文"},{value:"image-understanding",label:"图像理解"},{value:"model-mapping",label:"模型顶替"}],Xp=[{value:"claude-code",label:"Claude Code"},{value:"codex",label:"Codex"}];function O3(){var re,K;const[e,t]=m.useState([]),[n,r]=m.useState([]),[i,a]=m.useState([]),[o,l]=m.useState([]),[u,s]=m.useState([]),[c,f]=m.useState(null),[d,p]=m.useState(!1),[v,y]=m.useState(!1),[x,g]=m.useState(null),[b,w]=m.useState(null),[P,k]=m.useState(""),[S,E]=m.useState(""),[C,N]=m.useState(""),[T,_]=m.useState(""),[A,V]=m.useState(0),[$,L]=m.useState((b==null?void 0:b.contentType)||""),[B,F]=m.useState(null);m.useEffect(()=>{M(),O(),q()},[]),m.useEffect(()=>{c&&R(c.id)},[c]),m.useEffect(()=>{s(P?o.filter(U=>U.vendorId===P):[]),E(""),N("")},[P,o]);const M=async()=>{const U=await oe.getRoutes();t(U),U.length>0&&!c&&f(U[0])},R=async U=>{const ae=await oe.getRules(U);r(ae)},O=async()=>{const U=await oe.getVendors();a(U)},q=async()=>{const U=await oe.getAPIServices();l(U)},Q=async U=>{await oe.activateRoute(U),M()},j=async U=>{await oe.deactivateRoute(U),M()},ie=async U=>{U.preventDefault();const ae=new FormData(U.currentTarget),me={name:ae.get("name"),description:ae.get("description"),targetType:ae.get("targetType"),isActive:!1};x?await oe.updateRoute(x.id,me):await oe.createRoute(me),p(!1),M()},he=async U=>{confirm("确定要删除此路由吗")&&(await oe.deleteRoute(U),M(),c&&c.id===U&&(f(null),r([])))},ue=async U=>{U.preventDefault();const ae=new FormData(U.currentTarget),me={routeId:c.id,contentType:ae.get("contentType"),targetServiceId:S,targetModel:C||void 0,replacedModel:T||void 0,sortOrder:A};b?await oe.updateRule(b.id,me):await oe.createRule(me),y(!1),c&&R(c.id)},I=async U=>{confirm("确定要删除此路由吗")&&(await oe.deleteRule(U),c&&R(c.id))},J=()=>uw,z=U=>{w(U),L(U.contentType);const ae=o.find(me=>me.id===U.targetServiceId);ae&&(k(ae.vendorId),s(o.filter(me=>me.vendorId===ae.vendorId)),setTimeout(()=>{E(ae.id),N(U.targetModel||""),_(U.replacedModel||""),V(U.sortOrder||0)},0)),y(!0)},X=()=>{w(null),L(""),k(""),E(""),N(""),_(""),V(0),y(!0)};return h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"路由管理"}),h.jsx("p",{children:"管理API路由和路由配置"})]}),h.jsxs("div",{style:{display:"flex",gap:"20px"},children:[h.jsxs("div",{className:"card",style:{flex:"0 0 33%"},children:[h.jsxs("div",{className:"toolbar",children:[h.jsx("h3",{children:"路由"}),h.jsx("button",{className:"btn btn-primary",onClick:()=>p(!0),children:"新建"})]}),e.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无路由"})}):h.jsx("div",{style:{marginTop:"10px"},children:e.map(U=>{var ae,me;return h.jsx("div",{onClick:()=>f(U),style:{padding:"12px",marginBottom:"8px",backgroundColor:c&&c.id===U.id?"var(--bg-route-item-selected)":"var(--bg-route-item)",borderRadius:"8px",cursor:"pointer",border:"1px solid var(--border-primary)",transition:"all 0.2s ease"},onMouseEnter:ve=>{(c==null?void 0:c.id)!==U.id&&(ve.currentTarget.style.backgroundColor="var(--bg-route-item-hover)")},onMouseLeave:ve=>{(c==null?void 0:c.id)!==U.id&&(ve.currentTarget.style.backgroundColor="var(--bg-route-item)")},children:h.jsxs("div",{children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx("div",{style:{fontWeight:500},children:U.name}),U.isActive&&h.jsxs("span",{className:"badge badge-success",children:[(ae=Xp.find(ve=>ve.value===U.targetType))==null?void 0:ae.label," 已激活"]})]}),h.jsxs("div",{style:{fontSize:"12px",color:"var(--text-route-muted)",marginTop:"2px"},children:["路由对象: ",(me=Xp.find(ve=>ve.value===U.targetType))==null?void 0:me.label]}),h.jsxs("div",{className:"action-buttons",style:{marginTop:"8px"},children:[U.isActive?h.jsx("button",{className:"btn btn-warning",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),j(U.id)},children:"停用"}):h.jsx("button",{className:"btn btn-success",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),Q(U.id)},children:"激活"}),h.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),g(U),p(!0)},children:"编辑"}),h.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),he(U.id)},disabled:U.isActive,children:"删除"})]})]})},U.id)})})]}),h.jsxs("div",{className:"card",style:{flex:1},children:[h.jsxs("div",{className:"toolbar",children:[h.jsx("h3",{children:"规则列表"}),c&&h.jsx("button",{className:"btn btn-primary",onClick:X,children:"新建规则"})]}),c?n.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无路由"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"优先级"}),h.jsx("th",{children:"请求类型"}),h.jsx("th",{children:"供应商"}),h.jsx("th",{children:"API服务"}),h.jsx("th",{children:"模型"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:n.map(U=>{var nn;const ae=o.find(Qn=>Qn.id===U.targetServiceId),me=i.find(Qn=>Qn.id===(ae==null?void 0:ae.vendorId)),ve=(nn=uw.find(Qn=>Qn.value===U.contentType))==null?void 0:nn.label;return h.jsxs("tr",{children:[h.jsx("td",{children:U.sortOrder||0}),h.jsx("td",{children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[h.jsx("span",{children:ve}),U.contentType==="model-mapping"&&U.replacedModel&&h.jsxs("div",{style:{position:"relative",display:"inline-block"},onMouseEnter:()=>F(U.id),onMouseLeave:()=>F(null),children:[h.jsx("span",{style:{cursor:"help",fontSize:"14px",color:"var(--text-info)",fontWeight:"bold"},children:"ⓘ"}),B===U.id&&h.jsxs("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"calc(100% + 8px)",backgroundColor:"var(--bg-popover, #333)",color:"var(--text-popover, #fff)",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:["被顶替的模型是: ",U.replacedModel,h.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"-4px",width:"0",height:"0",borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid var(--bg-popover, #333)"}})]})]})]})}),h.jsx("td",{children:me?me.name:"Unknown"}),h.jsx("td",{children:ae?ae.name:"Unknown"}),h.jsx("td",{children:U.targetModel||"透传"}),h.jsx("td",{children:h.jsxs("div",{className:"action-buttons",children:[h.jsx("button",{className:"btn btn-secondary",onClick:()=>z(U),children:"编辑"}),h.jsx("button",{className:"btn btn-danger",onClick:()=>I(U.id),children:"删除"})]})})]},U.id)})})]}):h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"请先选择一个路由"})}),c&&n.length>0&&h.jsxs("div",{style:{fontSize:"12px",color:"#666",marginTop:"16px",padding:"12px",backgroundColor:"#f8f9fa",borderRadius:"6px",border:"1px solid #e0e0e0",lineHeight:"1.6"},children:[h.jsx("strong",{children:"💡 智能故障切换机制"}),h.jsxs("div",{style:{marginTop:"6px"},children:["• 当同一请求类型配置多个规则时,系统会按排序优先使用第一个",h.jsx("br",{}),"• 如果某个服务报错(4xx/5xx),将自动切换到下一个可用服务",h.jsx("br",{}),"• 报错的服务会被标记为不可用,有效期10分钟",h.jsx("br",{}),"• 10分钟后自动解除标记,如果再次报错则重新标记",h.jsx("br",{}),"• 确保您的请求始终路由到稳定可用的服务",h.jsx("br",{}),"• 如不需要此功能,可在",h.jsx("strong",{children:"设置"}),'页面关闭"启用智能故障切换"选项']})]})]})]}),d&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:U=>U.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:x?"编辑路由":"新建路由"})}),h.jsxs("form",{onSubmit:ie,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"路由名称"}),h.jsx("input",{type:"text",name:"name",defaultValue:x?x.name:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"描述"}),h.jsx("textarea",{name:"description",rows:3,defaultValue:x?x.description:""})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"路由对象"}),h.jsx("select",{name:"targetType",defaultValue:x?x.targetType:"claude-code",required:!0,children:Xp.map(U=>h.jsx("option",{value:U.value,children:U.label},U.value))})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>p(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})}),v&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:U=>U.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:b?"编辑规则":"新建规则"})}),h.jsxs("form",{onSubmit:ue,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"对象请求类型"}),h.jsxs("select",{name:"contentType",value:$,required:!0,onChange:U=>{L(U.target.value)},children:[h.jsx("option",{value:"",disabled:!0,children:"请选择对象请求类型"}),J().map(U=>h.jsx("option",{value:U.value,children:U.label},U.value))]})]}),$==="model-mapping"&&h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["被顶替模型 ",h.jsx("small",{children:"(可在日志中找出想要顶替的模型名)"})]}),h.jsx("input",{type:"text",value:T,onChange:U=>_(U.target.value),placeholder:"例如:gpt-4"})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"排序(值越大优先级越高)"}),h.jsx("input",{type:"number",value:A,onChange:U=>V(parseInt(U.target.value)||0),min:"0",max:"1000"})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商"}),h.jsxs("select",{value:P,onChange:U=>k(U.target.value),required:!0,children:[h.jsx("option",{value:"",disabled:!0,children:"请选择供应商"}),i.map(U=>h.jsx("option",{value:U.id,children:U.name},U.id))]})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"API服务"}),h.jsxs("select",{value:S,onChange:U=>{E(U.target.value),N("")},required:!0,disabled:!P,children:[h.jsx("option",{value:"",disabled:!0,children:"请选择API服务"}),u.map(U=>h.jsx("option",{value:U.id,children:U.name},U.id))]})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"模型"}),h.jsxs("select",{value:C,onChange:U=>N(U.target.value),disabled:!S,children:[h.jsx("option",{value:"",children:"透传模型名"}),(K=(re=o.find(U=>U.id===S))==null?void 0:re.supportedModels)==null?void 0:K.map(U=>h.jsx("option",{value:U,children:U},U))]})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>y(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]})}var fj={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Dl,function(){var n=1e3,r=6e4,i=36e5,a="millisecond",o="second",l="minute",u="hour",s="day",c="week",f="month",d="quarter",p="year",v="date",y="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,g=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var L=["th","st","nd","rd"],B=$%100;return"["+$+(L[(B-20)%10]||L[B]||L[0])+"]"}},w=function($,L,B){var F=String($);return!F||F.length>=L?$:""+Array(L+1-F.length).join(B)+$},P={s:w,z:function($){var L=-$.utcOffset(),B=Math.abs(L),F=Math.floor(B/60),M=B%60;return(L<=0?"+":"-")+w(F,2,"0")+":"+w(M,2,"0")},m:function $(L,B){if(L.date()<B.date())return-$(B,L);var F=12*(B.year()-L.year())+(B.month()-L.month()),M=L.clone().add(F,f),R=B-M<0,O=L.clone().add(F+(R?-1:1),f);return+(-(F+(B-M)/(R?M-O:O-M))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:f,y:p,w:c,d:s,D:v,h:u,m:l,s:o,ms:a,Q:d}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},k="en",S={};S[k]=b;var E="$isDayjsObject",C=function($){return $ instanceof A||!(!$||!$[E])},N=function $(L,B,F){var M;if(!L)return k;if(typeof L=="string"){var R=L.toLowerCase();S[R]&&(M=R),B&&(S[R]=B,M=R);var O=L.split("-");if(!M&&O.length>1)return $(O[0])}else{var q=L.name;S[q]=L,M=q}return!F&&M&&(k=M),M||!F&&k},T=function($,L){if(C($))return $.clone();var B=typeof L=="object"?L:{};return B.date=$,B.args=arguments,new A(B)},_=P;_.l=N,_.i=C,_.w=function($,L){return T($,{locale:L.$L,utc:L.$u,x:L.$x,$offset:L.$offset})};var A=function(){function $(B){this.$L=N(B.locale,null,!0),this.parse(B),this.$x=this.$x||B.x||{},this[E]=!0}var L=$.prototype;return L.parse=function(B){this.$d=function(F){var M=F.date,R=F.utc;if(M===null)return new Date(NaN);if(_.u(M))return new Date;if(M instanceof Date)return new Date(M);if(typeof M=="string"&&!/Z$/i.test(M)){var O=M.match(x);if(O){var q=O[2]-1||0,Q=(O[7]||"0").substring(0,3);return R?new Date(Date.UTC(O[1],q,O[3]||1,O[4]||0,O[5]||0,O[6]||0,Q)):new Date(O[1],q,O[3]||1,O[4]||0,O[5]||0,O[6]||0,Q)}}return new Date(M)}(B),this.init()},L.init=function(){var B=this.$d;this.$y=B.getFullYear(),this.$M=B.getMonth(),this.$D=B.getDate(),this.$W=B.getDay(),this.$H=B.getHours(),this.$m=B.getMinutes(),this.$s=B.getSeconds(),this.$ms=B.getMilliseconds()},L.$utils=function(){return _},L.isValid=function(){return this.$d.toString()!==y},L.isSame=function(B,F){var M=T(B);return this.startOf(F)<=M&&M<=this.endOf(F)},L.isAfter=function(B,F){return T(B)<this.startOf(F)},L.isBefore=function(B,F){return this.endOf(F)<T(B)},L.$g=function(B,F,M){return _.u(B)?this[F]:this.set(M,B)},L.unix=function(){return Math.floor(this.valueOf()/1e3)},L.valueOf=function(){return this.$d.getTime()},L.startOf=function(B,F){var M=this,R=!!_.u(F)||F,O=_.p(B),q=function(z,X){var re=_.w(M.$u?Date.UTC(M.$y,X,z):new Date(M.$y,X,z),M);return R?re:re.endOf(s)},Q=function(z,X){return _.w(M.toDate()[z].apply(M.toDate("s"),(R?[0,0,0,0]:[23,59,59,999]).slice(X)),M)},j=this.$W,ie=this.$M,he=this.$D,ue="set"+(this.$u?"UTC":"");switch(O){case p:return R?q(1,0):q(31,11);case f:return R?q(1,ie):q(0,ie+1);case c:var I=this.$locale().weekStart||0,J=(j<I?j+7:j)-I;return q(R?he-J:he+(6-J),ie);case s:case v:return Q(ue+"Hours",0);case u:return Q(ue+"Minutes",1);case l:return Q(ue+"Seconds",2);case o:return Q(ue+"Milliseconds",3);default:return this.clone()}},L.endOf=function(B){return this.startOf(B,!1)},L.$set=function(B,F){var M,R=_.p(B),O="set"+(this.$u?"UTC":""),q=(M={},M[s]=O+"Date",M[v]=O+"Date",M[f]=O+"Month",M[p]=O+"FullYear",M[u]=O+"Hours",M[l]=O+"Minutes",M[o]=O+"Seconds",M[a]=O+"Milliseconds",M)[R],Q=R===s?this.$D+(F-this.$W):F;if(R===f||R===p){var j=this.clone().set(v,1);j.$d[q](Q),j.init(),this.$d=j.set(v,Math.min(this.$D,j.daysInMonth())).$d}else q&&this.$d[q](Q);return this.init(),this},L.set=function(B,F){return this.clone().$set(B,F)},L.get=function(B){return this[_.p(B)]()},L.add=function(B,F){var M,R=this;B=Number(B);var O=_.p(F),q=function(ie){var he=T(R);return _.w(he.date(he.date()+Math.round(ie*B)),R)};if(O===f)return this.set(f,this.$M+B);if(O===p)return this.set(p,this.$y+B);if(O===s)return q(1);if(O===c)return q(7);var Q=(M={},M[l]=r,M[u]=i,M[o]=n,M)[O]||1,j=this.$d.getTime()+B*Q;return _.w(j,this)},L.subtract=function(B,F){return this.add(-1*B,F)},L.format=function(B){var F=this,M=this.$locale();if(!this.isValid())return M.invalidDate||y;var R=B||"YYYY-MM-DDTHH:mm:ssZ",O=_.z(this),q=this.$H,Q=this.$m,j=this.$M,ie=M.weekdays,he=M.months,ue=M.meridiem,I=function(X,re,K,U){return X&&(X[re]||X(F,R))||K[re].slice(0,U)},J=function(X){return _.s(q%12||12,X,"0")},z=ue||function(X,re,K){var U=X<12?"AM":"PM";return K?U.toLowerCase():U};return R.replace(g,function(X,re){return re||function(K){switch(K){case"YY":return String(F.$y).slice(-2);case"YYYY":return _.s(F.$y,4,"0");case"M":return j+1;case"MM":return _.s(j+1,2,"0");case"MMM":return I(M.monthsShort,j,he,3);case"MMMM":return I(he,j);case"D":return F.$D;case"DD":return _.s(F.$D,2,"0");case"d":return String(F.$W);case"dd":return I(M.weekdaysMin,F.$W,ie,2);case"ddd":return I(M.weekdaysShort,F.$W,ie,3);case"dddd":return ie[F.$W];case"H":return String(q);case"HH":return _.s(q,2,"0");case"h":return J(1);case"hh":return J(2);case"a":return z(q,Q,!0);case"A":return z(q,Q,!1);case"m":return String(Q);case"mm":return _.s(Q,2,"0");case"s":return String(F.$s);case"ss":return _.s(F.$s,2,"0");case"SSS":return _.s(F.$ms,3,"0");case"Z":return O}return null}(X)||O.replace(":","")})},L.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},L.diff=function(B,F,M){var R,O=this,q=_.p(F),Q=T(B),j=(Q.utcOffset()-this.utcOffset())*r,ie=this-Q,he=function(){return _.m(O,Q)};switch(q){case p:R=he()/12;break;case f:R=he();break;case d:R=he()/3;break;case c:R=(ie-j)/6048e5;break;case s:R=(ie-j)/864e5;break;case u:R=ie/i;break;case l:R=ie/r;break;case o:R=ie/n;break;default:R=ie}return M?R:_.a(R)},L.daysInMonth=function(){return this.endOf(f).$D},L.$locale=function(){return S[this.$L]},L.locale=function(B,F){if(!B)return this.$L;var M=this.clone(),R=N(B,F,!0);return R&&(M.$L=R),M},L.clone=function(){return _.w(this.$d,this)},L.toDate=function(){return new Date(this.valueOf())},L.toJSON=function(){return this.isValid()?this.toISOString():null},L.toISOString=function(){return this.$d.toISOString()},L.toString=function(){return this.$d.toUTCString()},$}(),V=A.prototype;return T.prototype=V,[["$ms",a],["$s",o],["$m",l],["$H",u],["$W",s],["$M",f],["$y",p],["$D",v]].forEach(function($){V[$[1]]=function(L){return this.$g(L,$[0],$[1])}}),T.extend=function($,L){return $.$i||($(L,A,T),$.$i=!0),T},T.locale=N,T.isDayjs=C,T.unix=function($){return T(1e3*$)},T.en=S[k],T.Ls=S,T.p={},T})})(fj);var E3=fj.exports;const kn=In(E3),ei=({data:e,title:t,collapsed:n=!1})=>{const[r,i]=m.useState(!n),[a,o]=m.useState(!1),l=c=>{try{let f;return typeof c=="string"?f=JSON.parse(c):f=c,JSON.stringify(f,null,2)}catch{return typeof c=="string"?c:String(c)}},u=()=>{const c=l(e);navigator.clipboard.writeText(c).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)}).catch(f=>{console.error("Failed to copy JSON:",f)})},s=l(e);return h.jsxs("div",{className:"json-viewer",children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[t&&h.jsx("h4",{style:{margin:0,fontSize:"14px",color:"var(--text-primary)"},children:t}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>i(!r),className:"btn btn-sm btn-secondary",style:{fontSize:"12px",padding:"2px 8px"},children:r?"折叠":"展开"}),h.jsx("button",{onClick:u,className:"btn btn-sm btn-primary",style:{fontSize:"12px",padding:"2px 8px"},children:a?"已复制":"复制"})]})]}),r&&h.jsx("pre",{style:{background:"var(--bg-code)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"12px",overflowX:"auto",fontSize:"12px",lineHeight:"1.4",color:"var(--text-primary)",maxHeight:"400px",overflowY:"auto",margin:0},children:h.jsx("code",{children:s})})]})},Qp={"claude-code":"Claude Code",codex:"Codex"};function j3(){const[e,t]=m.useState("request"),[n,r]=m.useState([]),[i,a]=m.useState([]),[o,l]=m.useState([]),[u,s]=m.useState(null),[c,f]=m.useState(null),[d,p]=m.useState(null),[v,y]=m.useState(!1),x=100,g=0,[b,w]=m.useState([]),[P,k]=m.useState([]),[S,E]=m.useState(""),[C,N]=m.useState(""),[T,_]=m.useState(""),[A,V]=m.useState("");m.useEffect(()=>{$(),L()},[e]);const $=async()=>{if(e==="request"){const I=await oe.getLogs(x,g);r(I)}else if(e==="access"){const I=await oe.getAccessLogs(x,g);a(I)}else if(e==="error"){const I=await oe.getErrorLogs(x,g);l(I)}},L=async()=>{try{const[I,J]=await Promise.all([oe.getVendors(),oe.getAPIServices()]);w(I),k(J)}catch(I){console.error("Failed to load vendors and services:",I)}},B=async()=>{confirm("确定要清空当前类型的所有日志吗?")&&(e==="request"?(await oe.clearLogs(),r([]),s(null)):e==="access"?(await oe.clearAccessLogs(),a([]),f(null)):e==="error"&&(await oe.clearErrorLogs(),l([]),p(null)))},F=I=>I?I>=200&&I<300?"badge-success":I>=400&&I<500?"badge-warning":"badge-danger":"badge-danger",M=I=>{N(I),_(""),V("")},R=I=>{_(I),V("")},O=()=>C?P.filter(I=>I.vendorId===C):[],q=()=>{if(!T)return[];const I=P.find(J=>J.id===T);return(I==null?void 0:I.supportedModels)||[]},j=(I=>I.filter(J=>!(S&&J.targetType!==S||C&&J.vendorId!==C||T&&J.targetServiceId!==T||A&&J.targetModel!==A)))(n),ie=()=>j.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无请求日志"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"时间"}),h.jsx("th",{children:"来源对象类型"}),h.jsx("th",{children:"路径"}),h.jsx("th",{children:"状态"}),h.jsx("th",{children:"响应时间"}),h.jsx("th",{children:"Tokens信息"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:j.map(I=>h.jsxs("tr",{children:[h.jsx("td",{children:kn(I.timestamp).format("YYYY-MM-DD HH:mm:ss")}),h.jsx("td",{children:Qp[I.targetType]?h.jsx("span",{className:"badge badge-info",children:Qp[I.targetType]}):"-"}),h.jsx("td",{children:I.path}),h.jsx("td",{children:h.jsx("span",{className:`badge ${F(I.statusCode)}`,children:I.statusCode||"Error"})}),h.jsx("td",{children:I.responseTime?`${I.responseTime}ms`:"-"}),h.jsx("td",{children:I.usage?h.jsxs("span",{children:[I.usage.totalTokens?I.usage.totalTokens:I.usage.inputTokens+I.usage.outputTokens," tokens"]}):"-"}),h.jsx("td",{children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>s(I),children:"详情"})})]},I.id))})]}),he=()=>i.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无访问日志"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"时间"}),h.jsx("th",{children:"方法"}),h.jsx("th",{children:"路径"}),h.jsx("th",{children:"状态"}),h.jsx("th",{children:"响应时间"}),h.jsx("th",{children:"客户端IP"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:i.map(I=>h.jsxs("tr",{children:[h.jsx("td",{children:kn(I.timestamp).format("YYYY-MM-DD HH:mm:ss")}),h.jsx("td",{children:h.jsx("span",{className:"badge badge-success",children:I.method})}),h.jsx("td",{children:I.path}),h.jsx("td",{children:h.jsx("span",{className:`badge ${F(I.statusCode)}`,children:I.statusCode||"-"})}),h.jsx("td",{children:I.responseTime?`${I.responseTime}ms`:"-"}),h.jsx("td",{style:{fontSize:"12px"},children:I.clientIp||"-"}),h.jsx("td",{children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>f(I),children:"详情"})})]},I.id))})]}),ue=()=>o.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无错误日志"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"时间"}),h.jsx("th",{children:"方法"}),h.jsx("th",{children:"路径"}),h.jsx("th",{children:"状态"}),h.jsx("th",{children:"错误信息"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:o.map(I=>h.jsxs("tr",{children:[h.jsx("td",{children:kn(I.timestamp).format("YYYY-MM-DD HH:mm:ss")}),h.jsx("td",{children:h.jsx("span",{className:"badge badge-danger",children:I.method})}),h.jsx("td",{children:I.path}),h.jsx("td",{children:h.jsx("span",{className:"badge badge-danger",children:I.statusCode||"-"})}),h.jsx("td",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#e74c3c"},children:I.errorMessage}),h.jsx("td",{children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>p(I),children:"详情"})})]},I.id))})]});return h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"请求日志"}),h.jsx("p",{children:"查看所有API请求日志"})]}),h.jsxs("div",{className:"card",children:[h.jsx("div",{style:{borderBottom:"1px solid #ecf0f1",marginBottom:"20px"},children:h.jsxs("div",{style:{display:"flex",gap:"0"},children:[h.jsxs("button",{onClick:()=>t("request"),style:{padding:"12px 24px",border:"none",background:e==="request"?"#3498db":"transparent",color:e==="request"?"white":"#7f8c8d",cursor:"pointer",borderBottom:e==="request"?"2px solid #2980b9":"2px solid transparent",fontWeight:e==="request"?"bold":"normal"},children:["请求日志 (",n.length,")"]}),h.jsxs("button",{onClick:()=>t("access"),style:{padding:"12px 24px",border:"none",background:e==="access"?"#3498db":"transparent",color:e==="access"?"white":"#7f8c8d",cursor:"pointer",borderBottom:e==="access"?"2px solid #2980b9":"2px solid transparent",fontWeight:e==="access"?"bold":"normal"},children:["访问日志 (",i.length,")"]}),h.jsxs("button",{onClick:()=>t("error"),style:{padding:"12px 24px",border:"none",background:e==="error"?"#e74c3c":"transparent",color:e==="error"?"white":"#7f8c8d",cursor:"pointer",borderBottom:e==="error"?"2px solid #c0392b":"2px solid transparent",fontWeight:e==="error"?"bold":"normal"},children:["错误日志 (",o.length,")"]})]})}),h.jsxs("div",{className:"toolbar",children:[h.jsxs("h3",{children:[e==="access"&&"访问日志列表",e==="error"&&"错误日志列表",e==="request"&&"请求日志列表"]}),h.jsxs("div",{style:{display:"flex",gap:"10px"},children:[h.jsx("button",{className:"btn btn-primary",onClick:$,children:"刷新"}),h.jsx("button",{className:"btn btn-danger",onClick:B,children:"清空日志"})]})]}),e==="request"&&h.jsxs("div",{style:{padding:"15px",background:"var(--bg-secondary)",borderRadius:"12px",marginBottom:"20px",display:"flex",gap:"15px",alignItems:"center",flexWrap:"wrap",border:"1px solid var(--border-primary)"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"来源类型:"}),h.jsxs("select",{value:S,onChange:I=>E(I.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)"},children:[h.jsx("option",{value:"",children:"全部"}),h.jsx("option",{value:"claude-code",children:"Claude Code"}),h.jsx("option",{value:"codex",children:"Codex"})]})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"供应商:"}),h.jsxs("select",{value:C,onChange:I=>M(I.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:"var(--bg-card)",color:"var(--text-primary)"},children:[h.jsx("option",{value:"",children:"全部供应商"}),b.map(I=>h.jsx("option",{value:I.id,children:I.name},I.id))]})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"API服务:"}),h.jsxs("select",{value:T,onChange:I=>R(I.target.value),disabled:!C,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:C?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:C?"pointer":"not-allowed",opacity:C?1:.6},children:[h.jsx("option",{value:"",children:"全部服务"}),O().map(I=>h.jsx("option",{value:I.id,children:I.name},I.id))]})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"模型:"}),h.jsxs("select",{value:A,onChange:I=>V(I.target.value),disabled:!T,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:T?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:T?"pointer":"not-allowed",opacity:T?1:.6},children:[h.jsx("option",{value:"",children:"全部模型"}),q().map(I=>h.jsx("option",{value:I,children:I},I))]})]}),(S||C||T||A)&&h.jsx("button",{onClick:()=>{E(""),N(""),_(""),V("")},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--accent-danger)",background:"var(--accent-danger)",color:"white",cursor:"pointer",fontSize:"14px"},children:"清除筛选"}),h.jsxs("div",{style:{marginLeft:"auto",color:"var(--text-muted)",fontSize:"14px"},children:["显示 ",j.length," / ",n.length," 条"]})]}),e==="request"&&ie(),e==="access"&&he(),e==="error"&&ue()]}),u&&h.jsx("div",{className:"modal-overlay",onClick:()=>s(null),children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),style:{width:"800px",maxWidth:"90%",maxHeight:"90vh",overflowY:"auto"},children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"请求详情"})}),h.jsxs("div",{children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"日志ID"}),h.jsx("input",{type:"text",value:u.id,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"时间"}),h.jsx("input",{type:"text",value:kn(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),u.targetType&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"来源对象类型"}),h.jsx("input",{type:"text",value:Qp[u.targetType]||"-",readOnly:!0})]}),u.requestModel&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求模型"}),h.jsx("input",{type:"text",value:u.requestModel,readOnly:!0})]}),u.vendorName&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商"}),h.jsx("input",{type:"text",value:u.vendorName,readOnly:!0})]}),u.targetServiceName&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商API服务"}),h.jsx("input",{type:"text",value:u.targetServiceName,readOnly:!0})]}),u.targetModel&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商模型"}),h.jsx("input",{type:"text",value:u.targetModel,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求方法"}),h.jsx("input",{type:"text",value:u.method,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求路径"}),h.jsx("input",{type:"text",value:u.path,readOnly:!0})]}),u.headers&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求头"}),h.jsx(ei,{data:u.headers,collapsed:!0})]}),u.body&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求体"}),h.jsx(ei,{data:u.body})]}),u.upstreamRequest&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"实际转发信息"}),h.jsx(ei,{data:u.upstreamRequest})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"状态码"}),h.jsx("input",{type:"text",value:u.statusCode||"Error",readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"响应时间"}),h.jsx("input",{type:"text",value:u.responseTime?`${u.responseTime}ms`:"-",readOnly:!0})]}),u.responseHeaders&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"响应头"}),h.jsx(ei,{data:u.responseHeaders,collapsed:!0})]}),u.responseBody&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"响应体"}),h.jsx(ei,{data:u.responseBody})]}),u.streamChunks&&u.streamChunks.length>0&&h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["Stream Chunks (",u.streamChunks.length,"个)",h.jsx("button",{onClick:()=>y(!v),style:{marginLeft:"10px",padding:"2px 8px",fontSize:"12px"},className:"btn btn-sm btn-primary",children:v?"折叠":"展开"})]}),v&&h.jsx("div",{style:{maxHeight:"400px",overflowY:"auto",border:"1px solid #ddd",padding:"10px",borderRadius:"4px"},children:u.streamChunks.map((I,J)=>h.jsxs("div",{style:{marginBottom:"10px"},children:[h.jsxs("div",{style:{fontWeight:"bold",fontSize:"12px",color:"#7f8c8d",marginBottom:"4px"},children:["Chunk #",J+1]}),h.jsx(ei,{data:I,collapsed:!0})]},J))})]}),u.usage&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"Token 使用"}),h.jsx("textarea",{rows:4,value:`输入: ${u.usage.inputTokens}
|
|
310
|
+
如有问题或建议,请访问项目 [GitHub 仓库](https://github.com/tangshuang/aicodeswitch/issues)提交 Issue。`;function cj(e,t){let n,r;const i=a=>a.replace(/!\[.*?\]\(.*?\)/g,o=>{var u;const l=(u=o.match(/\((.*?)\)/))==null?void 0:u[1];if((l==null?void 0:l.indexOf("public/"))===0){const s=l.replace("public/","/");return o.replace(l,s)}else return o});return function(){const[a,o]=m.useState(i(e));return m.useEffect(()=>{if(r){o(i(r));return}const l=u=>{u&&(r=u,o(i(u)))};n?n.then(l).catch(()=>{}):n=t().then(l).catch(()=>{})},[]),a}}const w3=cj(x3,oe.getRecommendVendorsMarkdown),S3=cj(b3,oe.getReadmeMarkdown);function P3({value:e=[],onChange:t,placeholder:n,inputValue:r,onInputChange:i}){const a=l=>{if(l.key==="Enter"||l.key===","){l.preventDefault();const u=r.trim();u&&!e.includes(u)&&(t([...e,u]),i(""))}else l.key==="Backspace"&&!r&&e.length>0&&t(e.slice(0,-1))},o=l=>{t(e.filter((u,s)=>s!==l))};return h.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"4px",padding:"8px",minHeight:"40px",background:"var(--bg-secondary)"},children:h.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",alignItems:"center"},children:[e.map((l,u)=>h.jsxs("span",{style:{backgroundColor:"var(--accent-light)",color:"var(--text-primary)",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[l,h.jsx("button",{type:"button",onClick:()=>o(u),style:{background:"none",border:"none",color:"var(--text-primary)",cursor:"pointer",fontSize:"16px",lineHeight:"1",padding:"0",marginLeft:"4px"},onMouseOver:s=>s.currentTarget.style.color="var(--accent-danger)",onMouseOut:s=>s.currentTarget.style.color="var(--text-primary)",children:"×"})]},u)),h.jsx("input",{type:"text",value:r,onChange:l=>i(l.target.value),onKeyDown:a,placeholder:n,style:{border:"none",outline:"none",flex:"1",minWidth:"120px",fontSize:"14px"}})]})})}const lw={"openai-chat":"OpenAI Chat","openai-code":"OpenAI Code","openai-responses":"OpenAI Responses","claude-chat":"Claude Chat","claude-code":"Claude Code","deepseek-chat":"DeepSeek Chat"};function k3(){var ue;const[e,t]=m.useState([]),[n,r]=m.useState([]),[i,a]=m.useState(null),[o,l]=m.useState(!1),[u,s]=m.useState(!1),[c,f]=m.useState(!1),[d,p]=m.useState(!1),[v,y]=m.useState(null),[x,g]=m.useState(null),[b,w]=m.useState([]),[P,k]=m.useState(""),[S,E]=m.useState(""),[C,N]=m.useState([]),[T,_]=m.useState(""),A=w3();m.useEffect(()=>{V()},[]),m.useEffect(()=>{i&&$(i.id)},[i]);const V=async()=>{const I=await oe.getVendors();t(I),I.length>0&&!i&&a(I[0])},$=async I=>{const J=await oe.getAPIServices(I);r(J)},L=()=>{y(null),l(!0)},B=()=>{f(!0)},F=I=>{y(I),l(!0)},M=async I=>{confirm("确定要删除此供应商吗")&&(await oe.deleteVendor(I),V(),i&&i.id===I&&(a(null),r([])))},R=async I=>{I.preventDefault();const J=new FormData(I.currentTarget),z={name:J.get("name"),description:J.get("description")};v?await oe.updateVendor(v.id,z):await oe.createVendor(z),l(!1),V()},O=()=>{g(null),w([]),k(""),s(!0)},q=I=>{g(I),w(I.supportedModels||[]),k(""),s(!0)},Q=async I=>{confirm("确定要删除此API服务吗")&&(await oe.deleteAPIService(I),i&&$(i.id))},j=async I=>{I.preventDefault();let J=[...b];if(P.trim()){const re=P.split(",").map(K=>K.trim()).filter(K=>K&&!J.includes(K));J=[...J,...re]}const z=new FormData(I.currentTarget),X={vendorId:i.id,name:z.get("name"),apiUrl:z.get("apiUrl"),apiKey:z.get("apiKey"),timeout:parseInt(z.get("timeout"))||3e4,sourceType:z.get("sourceType"),supportedModels:J.length>0?J:void 0};x?await oe.updateAPIService(x.id,X):await oe.createAPIService(X),s(!1),w([]),k(""),i&&$(i.id)},ie=I=>{if(I){E(I);const J=Ia[I];J&&J.services.length>0&&N(J.services.map(z=>z.sourceType))}else E(""),N([]);_(""),p(!0)},he=async I=>{I.preventDefault();const J=new FormData(I.currentTarget),z=J.get("vendorKey"),X=J.get("apiKey");if(!z||!X){alert("请填写完整信息");return}if(C.length===0){alert("请至少选择一个源类型");return}const re=Ia[z];if(!re){alert("未找到对应的供应商配置");return}try{const K=await oe.createVendor({name:re.name,description:re.description}),U=C.map(async ae=>{const me=re.services.find(ve=>ve.sourceType===ae);return me?oe.createAPIService({vendorId:K.id,name:me.name,apiUrl:me.apiUrl,apiKey:X,timeout:3e4,sourceType:ae,supportedModels:me.models?me.models.split(",").map(ve=>ve.trim()):void 0}):(console.warn(`未找到源类型 ${ae} 的配置`),null)});await Promise.all(U),await V(),p(!1),alert(`配置成功! 已创建 ${C.length} 个API服务`)}catch(K){console.error("一键配置失败:",K),alert("配置失败,请检查输入信息")}};return h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"供应商管理"}),h.jsx("p",{children:"管理API供应商和服务配置"})]}),h.jsxs("div",{style:{display:"flex",gap:"20px"},children:[h.jsxs("div",{className:"card",style:{flex:"0 0 33%"},children:[h.jsxs("div",{className:"toolbar",children:[h.jsx("h3",{children:"供应商列表"}),h.jsxs("div",{style:{display:"flex",gap:"10px"},children:[h.jsx("button",{className:"btn btn-secondary",style:{background:"linear-gradient(135deg, #2563EB 0%, #F97316 100%)",color:"#FFFFFF",boxShadow:"0 4px 12px rgba(37, 99, 235, 0.3)",border:"none",transition:"all 0.3s ease",cursor:"pointer",fontWeight:"600",letterSpacing:"0.5px"},onClick:B,onMouseEnter:I=>{I.currentTarget.style.transform="translateY(-2px)",I.currentTarget.style.boxShadow="0 8px 20px rgba(37, 99, 235, 0.4)"},onMouseLeave:I=>{I.currentTarget.style.transform="translateY(0)",I.currentTarget.style.boxShadow="0 4px 12px rgba(37, 99, 235, 0.3)"},onFocus:I=>{I.currentTarget.style.outline="2px solid #2563EB",I.currentTarget.style.outlineOffset="2px"},onBlur:I=>{I.currentTarget.style.outline="none"},children:"推荐"}),h.jsx("button",{className:"btn btn-primary",onClick:()=>ie(),children:"一键配置"}),h.jsx("button",{className:"btn btn-primary",onClick:L,children:"新增"})]})]}),e.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无供应商"})}):h.jsx("div",{style:{marginTop:"10px"},children:e.map(I=>h.jsx("div",{onClick:()=>a(I),style:{padding:"12px",marginBottom:"8px",backgroundColor:i&&i.id===I.id?"var(--accent-light)":"var(--bg-secondary)",borderRadius:"4px",cursor:"pointer",border:"1px solid var(--border-secondary)",color:"var(--text-primary)"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:I.name}),I.description&&h.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"4px"},children:I.description})]}),h.jsxs("div",{className:"action-buttons",children:[h.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:J=>{J.stopPropagation(),F(I)},children:"编辑"}),h.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:J=>{J.stopPropagation(),M(I.id)},children:"删除"})]})]})},I.id))})]}),h.jsxs("div",{className:"card",style:{flex:1},children:[h.jsxs("div",{className:"toolbar",children:[h.jsxs("h3",{children:["供应商API服务",i&&` - ${i.name}`]}),i&&h.jsx("button",{className:"btn btn-primary",onClick:O,children:"新增服务"})]}),i?n.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无API服务"})}):h.jsxs("table",{style:{fontSize:"smaller"},children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{style:{whiteSpace:"nowrap"},children:"服务名称"}),h.jsx("th",{children:"源类型"}),h.jsx("th",{children:"API地址"}),h.jsx("th",{children:"模型列表"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:n.map(I=>{var J;return h.jsxs("tr",{children:[h.jsx("td",{children:I.name}),h.jsx("td",{children:I.sourceType?lw[I.sourceType]:"-"}),h.jsx("td",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:I.apiUrl,children:I.apiUrl}),h.jsx("td",{children:((J=I.supportedModels)==null?void 0:J.join(", "))||"*"}),h.jsx("td",{children:h.jsxs("div",{className:"action-buttons",children:[h.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>q(I),children:"编辑"}),h.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>Q(I.id),children:"删除"})]})})]},I.id)})})]}):h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"请先选择一个供应商"})})]})]}),o&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:v?"编辑供应商":"新增供应商"})}),h.jsxs("form",{onSubmit:R,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商名称"}),h.jsx("input",{type:"text",name:"name",defaultValue:v?v.name:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"描述"}),h.jsx("textarea",{name:"description",rows:3,defaultValue:v?v.description:""})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>l(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})}),u&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:x?"编辑供应商API服务":"新增供应商API服务"})}),h.jsxs("form",{onSubmit:j,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"服务名称"}),h.jsx("input",{type:"text",name:"name",defaultValue:x?x.name:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["源类型 ",h.jsx("small",{children:"供应商接口返回的数据格式标准类型"})]}),h.jsxs("select",{name:"sourceType",defaultValue:x&&x.sourceType||"",required:!0,children:[h.jsx("option",{value:"",children:"请选择源类型"}),h.jsx("option",{value:"openai-chat",children:"OpenAI Chat"}),h.jsx("option",{value:"openai-code",children:"OpenAI Code"}),h.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),h.jsx("option",{value:"claude-chat",children:"Claude Chat"}),h.jsx("option",{value:"claude-code",children:"Claude Code"}),h.jsx("option",{value:"deepseek-chat",children:"DeepSeek Chat"})]})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商API地址"}),h.jsx("input",{type:"url",name:"apiUrl",defaultValue:x?x.apiUrl:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商API密钥"}),h.jsx("input",{type:"password",name:"apiKey",defaultValue:x?x.apiKey:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"超时时间(ms)"}),h.jsx("input",{type:"number",name:"timeout",defaultValue:x?x.timeout:3e4})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"支持的模型列表"}),h.jsx(P3,{value:b,onChange:w,inputValue:P,onInputChange:k,placeholder:"输入模型名,按Enter或逗号添加"},(x==null?void 0:x.id)||"new"),h.jsx("div",{style:{display:"block",width:"100%"},children:h.jsx("small",{style:{fontSize:"10px"},children:"留空表示支持所有模型,路由配置中,可直接将模型透传给该供应商服务接口。"})})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>s(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})}),c&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",style:{maxWidth:"800px"},onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"供应商推荐"})}),h.jsx("div",{className:"modal-body",children:h.jsx("div",{className:"markdown-content",children:h.jsx(sj,{components:{a:({href:I,children:J,title:z})=>z&&Ia[z]?h.jsx("a",{href:"#",style:{color:"#2563EB",borderBottom:"solid 1px #2563EB",cursor:"pointer"},onClick:X=>{X.preventDefault(),f(!1),ie(z)},children:J}):h.jsx("a",{href:I,style:{color:"#2563EB",borderBottom:"solid 1px #2563EB"},target:"_blank",rel:"noopener noreferrer",children:J})},children:A})})}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>f(!1),children:"关闭"})})]})}),d&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"一键配置供应商"})}),h.jsxs("form",{onSubmit:he,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商"}),h.jsxs("select",{name:"vendorKey",value:S,onChange:I=>{const J=I.target.value;if(E(J),J){const z=Ia[J];z&&z.services.length>0&&N(z.services.map(X=>X.sourceType))}else N([])},required:!0,children:[h.jsx("option",{value:"",children:"请选择供应商"}),Object.entries(Ia).map(([I,J])=>h.jsx("option",{value:I,children:J.name},I))]})]}),h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["源类型 ",h.jsx("small",{style:{color:"var(--text-muted)",fontWeight:"normal"},children:"可选择多个"})]}),h.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"16px",background:"var(--bg-secondary)",minHeight:"100px",display:"flex",flexDirection:"column",gap:"8px"},children:S?(ue=Ia[S])==null?void 0:ue.services.map((I,J)=>{const z=C.includes(I.sourceType);return h.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer",padding:"10px 14px",borderRadius:"6px",background:z?"var(--accent-light)":"transparent",border:`2px solid ${z?"var(--accent-primary)":"transparent"}`,transition:"all 0.2s ease",position:"relative",overflow:"hidden"},onMouseEnter:X=>{z||(X.currentTarget.style.background="var(--bg-hover)",X.currentTarget.style.borderColor="var(--border-secondary)")},onMouseLeave:X=>{z||(X.currentTarget.style.background="transparent",X.currentTarget.style.borderColor="transparent")},children:[h.jsx("input",{type:"checkbox",checked:z,onChange:X=>{const re=I.sourceType;X.target.checked?N([...C,re]):N(C.filter(K=>K!==re))},style:{width:"18px",height:"18px",marginRight:"12px",cursor:"pointer",accentColor:"var(--accent-primary)"}}),h.jsx("span",{style:{fontSize:"14px",fontWeight:z?"600":"400",color:z?"var(--accent-primary)":"var(--text-primary)",transition:"all 0.2s ease"},children:lw[I.sourceType]}),z&&h.jsx("span",{style:{marginLeft:"auto",fontSize:"16px",color:"var(--accent-primary)"},children:"✓"})]},J)}):h.jsx("div",{style:{color:"var(--text-muted)",textAlign:"center",padding:"30px 20px",fontSize:"14px"},children:"请先选择供应商"})})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"API Key"}),h.jsx("input",{type:"password",name:"apiKey",value:T,onChange:I=>_(I.target.value),placeholder:"请输入API密钥",required:!0})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>p(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"确认配置"})]})]})]})})]})}const uw=[{value:"default",label:"默认"},{value:"background",label:"后台"},{value:"thinking",label:"思考"},{value:"long-context",label:"长上下文"},{value:"image-understanding",label:"图像理解"},{value:"model-mapping",label:"模型顶替"}],Xp=[{value:"claude-code",label:"Claude Code"},{value:"codex",label:"Codex"}];function O3(){var re,K;const[e,t]=m.useState([]),[n,r]=m.useState([]),[i,a]=m.useState([]),[o,l]=m.useState([]),[u,s]=m.useState([]),[c,f]=m.useState(null),[d,p]=m.useState(!1),[v,y]=m.useState(!1),[x,g]=m.useState(null),[b,w]=m.useState(null),[P,k]=m.useState(""),[S,E]=m.useState(""),[C,N]=m.useState(""),[T,_]=m.useState(""),[A,V]=m.useState(0),[$,L]=m.useState((b==null?void 0:b.contentType)||""),[B,F]=m.useState(null);m.useEffect(()=>{M(),O(),q()},[]),m.useEffect(()=>{c&&R(c.id)},[c]),m.useEffect(()=>{s(P?o.filter(U=>U.vendorId===P):[]),E(""),N("")},[P,o]);const M=async()=>{const U=await oe.getRoutes();t(U),U.length>0&&!c&&f(U[0])},R=async U=>{const ae=await oe.getRules(U);r(ae)},O=async()=>{const U=await oe.getVendors();a(U)},q=async()=>{const U=await oe.getAPIServices();l(U)},Q=async U=>{await oe.activateRoute(U),M()},j=async U=>{await oe.deactivateRoute(U),M()},ie=async U=>{U.preventDefault();const ae=new FormData(U.currentTarget),me={name:ae.get("name"),description:ae.get("description"),targetType:ae.get("targetType"),isActive:!1};x?await oe.updateRoute(x.id,me):await oe.createRoute(me),p(!1),M()},he=async U=>{confirm("确定要删除此路由吗")&&(await oe.deleteRoute(U),M(),c&&c.id===U&&(f(null),r([])))},ue=async U=>{U.preventDefault();const ae=new FormData(U.currentTarget),me={routeId:c.id,contentType:ae.get("contentType"),targetServiceId:S,targetModel:C||void 0,replacedModel:T||void 0,sortOrder:A};b?await oe.updateRule(b.id,me):await oe.createRule(me),y(!1),c&&R(c.id)},I=async U=>{confirm("确定要删除此路由吗")&&(await oe.deleteRule(U),c&&R(c.id))},J=()=>uw,z=U=>{w(U),L(U.contentType);const ae=o.find(me=>me.id===U.targetServiceId);ae&&(k(ae.vendorId),s(o.filter(me=>me.vendorId===ae.vendorId)),setTimeout(()=>{E(ae.id),N(U.targetModel||""),_(U.replacedModel||""),V(U.sortOrder||0)},0)),y(!0)},X=()=>{w(null),L(""),k(""),E(""),N(""),_(""),V(0),y(!0)};return h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"路由管理"}),h.jsx("p",{children:"管理API路由和路由配置"})]}),h.jsxs("div",{style:{display:"flex",gap:"20px"},children:[h.jsxs("div",{className:"card",style:{flex:"0 0 33%"},children:[h.jsxs("div",{className:"toolbar",children:[h.jsx("h3",{children:"路由"}),h.jsx("button",{className:"btn btn-primary",onClick:()=>p(!0),children:"新建"})]}),e.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无路由"})}):h.jsx("div",{style:{marginTop:"10px"},children:e.map(U=>{var ae,me;return h.jsx("div",{onClick:()=>f(U),style:{padding:"12px",marginBottom:"8px",backgroundColor:c&&c.id===U.id?"var(--bg-route-item-selected)":"var(--bg-route-item)",borderRadius:"8px",cursor:"pointer",border:"1px solid var(--border-primary)",transition:"all 0.2s ease"},onMouseEnter:ve=>{(c==null?void 0:c.id)!==U.id&&(ve.currentTarget.style.backgroundColor="var(--bg-route-item-hover)")},onMouseLeave:ve=>{(c==null?void 0:c.id)!==U.id&&(ve.currentTarget.style.backgroundColor="var(--bg-route-item)")},children:h.jsxs("div",{children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx("div",{style:{fontWeight:500},children:U.name}),U.isActive&&h.jsxs("span",{className:"badge badge-success",children:[(ae=Xp.find(ve=>ve.value===U.targetType))==null?void 0:ae.label," 已激活"]})]}),h.jsxs("div",{style:{fontSize:"12px",color:"var(--text-route-muted)",marginTop:"2px"},children:["路由对象: ",(me=Xp.find(ve=>ve.value===U.targetType))==null?void 0:me.label]}),h.jsxs("div",{className:"action-buttons",style:{marginTop:"8px"},children:[U.isActive?h.jsx("button",{className:"btn btn-warning",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),j(U.id)},children:"停用"}):h.jsx("button",{className:"btn btn-success",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),Q(U.id)},children:"激活"}),h.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),g(U),p(!0)},children:"编辑"}),h.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:ve=>{ve.stopPropagation(),he(U.id)},disabled:U.isActive,children:"删除"})]})]})},U.id)})})]}),h.jsxs("div",{className:"card",style:{flex:1},children:[h.jsxs("div",{className:"toolbar",children:[h.jsx("h3",{children:"规则列表"}),c&&h.jsx("button",{className:"btn btn-primary",onClick:X,children:"新建规则"})]}),c?n.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无路由"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"优先级"}),h.jsx("th",{children:"请求类型"}),h.jsx("th",{children:"供应商"}),h.jsx("th",{children:"API服务"}),h.jsx("th",{children:"模型"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:n.map(U=>{var nn;const ae=o.find(Qn=>Qn.id===U.targetServiceId),me=i.find(Qn=>Qn.id===(ae==null?void 0:ae.vendorId)),ve=(nn=uw.find(Qn=>Qn.value===U.contentType))==null?void 0:nn.label;return h.jsxs("tr",{children:[h.jsx("td",{children:U.sortOrder||0}),h.jsx("td",{children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[h.jsx("span",{children:ve}),U.contentType==="model-mapping"&&U.replacedModel&&h.jsxs("div",{style:{position:"relative",display:"inline-block"},onMouseEnter:()=>F(U.id),onMouseLeave:()=>F(null),children:[h.jsx("span",{style:{cursor:"help",fontSize:"14px",color:"var(--text-info)",fontWeight:"bold"},children:"ⓘ"}),B===U.id&&h.jsxs("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"calc(100% + 8px)",backgroundColor:"var(--bg-popover, #333)",color:"var(--text-popover, #fff)",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:["被顶替的模型是: ",U.replacedModel,h.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"-4px",width:"0",height:"0",borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid var(--bg-popover, #333)"}})]})]})]})}),h.jsx("td",{children:me?me.name:"Unknown"}),h.jsx("td",{children:ae?ae.name:"Unknown"}),h.jsx("td",{children:U.targetModel||"透传"}),h.jsx("td",{children:h.jsxs("div",{className:"action-buttons",children:[h.jsx("button",{className:"btn btn-secondary",onClick:()=>z(U),children:"编辑"}),h.jsx("button",{className:"btn btn-danger",onClick:()=>I(U.id),children:"删除"})]})})]},U.id)})})]}):h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"请先选择一个路由"})}),c&&n.length>0&&h.jsxs("div",{style:{fontSize:"12px",color:"#666",marginTop:"16px",padding:"12px",backgroundColor:"#f8f9fa",borderRadius:"6px",border:"1px solid #e0e0e0",lineHeight:"1.6"},children:[h.jsx("strong",{children:"💡 智能故障切换机制"}),h.jsxs("div",{style:{marginTop:"6px"},children:["• 当同一请求类型配置多个规则时,系统会按排序优先使用第一个",h.jsx("br",{}),"• 如果某个服务报错(4xx/5xx),将自动切换到下一个可用服务",h.jsx("br",{}),"• 报错的服务会被标记为不可用,有效期10分钟",h.jsx("br",{}),"• 10分钟后自动解除标记,如果再次报错则重新标记",h.jsx("br",{}),"• 确保您的请求始终路由到稳定可用的服务",h.jsx("br",{}),"• 如不需要此功能,可在",h.jsx("strong",{children:"设置"}),'页面关闭"启用智能故障切换"选项']})]})]})]}),d&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:U=>U.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:x?"编辑路由":"新建路由"})}),h.jsxs("form",{onSubmit:ie,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"路由名称"}),h.jsx("input",{type:"text",name:"name",defaultValue:x?x.name:"",required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"描述"}),h.jsx("textarea",{name:"description",rows:3,defaultValue:x?x.description:""})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"路由对象"}),h.jsx("select",{name:"targetType",defaultValue:x?x.targetType:"claude-code",required:!0,children:Xp.map(U=>h.jsx("option",{value:U.value,children:U.label},U.value))})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>p(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})}),v&&h.jsx("div",{className:"modal-overlay",children:h.jsxs("div",{className:"modal",onClick:U=>U.stopPropagation(),children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:b?"编辑规则":"新建规则"})}),h.jsxs("form",{onSubmit:ue,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"对象请求类型"}),h.jsxs("select",{name:"contentType",value:$,required:!0,onChange:U=>{L(U.target.value)},children:[h.jsx("option",{value:"",disabled:!0,children:"请选择对象请求类型"}),J().map(U=>h.jsx("option",{value:U.value,children:U.label},U.value))]})]}),$==="model-mapping"&&h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["被顶替模型 ",h.jsx("small",{children:"(可在日志中找出想要顶替的模型名)"})]}),h.jsx("input",{type:"text",value:T,onChange:U=>_(U.target.value),placeholder:"例如:gpt-4"})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"排序(值越大优先级越高)"}),h.jsx("input",{type:"number",value:A,onChange:U=>V(parseInt(U.target.value)||0),min:"0",max:"1000"})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商"}),h.jsxs("select",{value:P,onChange:U=>k(U.target.value),required:!0,children:[h.jsx("option",{value:"",disabled:!0,children:"请选择供应商"}),i.map(U=>h.jsx("option",{value:U.id,children:U.name},U.id))]})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"API服务"}),h.jsxs("select",{value:S,onChange:U=>{E(U.target.value),N("")},required:!0,disabled:!P,children:[h.jsx("option",{value:"",disabled:!0,children:"请选择API服务"}),u.map(U=>h.jsx("option",{value:U.id,children:U.name},U.id))]})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"模型"}),h.jsxs("select",{value:C,onChange:U=>N(U.target.value),disabled:!S,children:[h.jsx("option",{value:"",children:"透传模型名"}),(K=(re=o.find(U=>U.id===S))==null?void 0:re.supportedModels)==null?void 0:K.map(U=>h.jsx("option",{value:U,children:U},U))]})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>y(!1),children:"取消"}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]})}var fj={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Dl,function(){var n=1e3,r=6e4,i=36e5,a="millisecond",o="second",l="minute",u="hour",s="day",c="week",f="month",d="quarter",p="year",v="date",y="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,g=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var L=["th","st","nd","rd"],B=$%100;return"["+$+(L[(B-20)%10]||L[B]||L[0])+"]"}},w=function($,L,B){var F=String($);return!F||F.length>=L?$:""+Array(L+1-F.length).join(B)+$},P={s:w,z:function($){var L=-$.utcOffset(),B=Math.abs(L),F=Math.floor(B/60),M=B%60;return(L<=0?"+":"-")+w(F,2,"0")+":"+w(M,2,"0")},m:function $(L,B){if(L.date()<B.date())return-$(B,L);var F=12*(B.year()-L.year())+(B.month()-L.month()),M=L.clone().add(F,f),R=B-M<0,O=L.clone().add(F+(R?-1:1),f);return+(-(F+(B-M)/(R?M-O:O-M))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:f,y:p,w:c,d:s,D:v,h:u,m:l,s:o,ms:a,Q:d}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},k="en",S={};S[k]=b;var E="$isDayjsObject",C=function($){return $ instanceof A||!(!$||!$[E])},N=function $(L,B,F){var M;if(!L)return k;if(typeof L=="string"){var R=L.toLowerCase();S[R]&&(M=R),B&&(S[R]=B,M=R);var O=L.split("-");if(!M&&O.length>1)return $(O[0])}else{var q=L.name;S[q]=L,M=q}return!F&&M&&(k=M),M||!F&&k},T=function($,L){if(C($))return $.clone();var B=typeof L=="object"?L:{};return B.date=$,B.args=arguments,new A(B)},_=P;_.l=N,_.i=C,_.w=function($,L){return T($,{locale:L.$L,utc:L.$u,x:L.$x,$offset:L.$offset})};var A=function(){function $(B){this.$L=N(B.locale,null,!0),this.parse(B),this.$x=this.$x||B.x||{},this[E]=!0}var L=$.prototype;return L.parse=function(B){this.$d=function(F){var M=F.date,R=F.utc;if(M===null)return new Date(NaN);if(_.u(M))return new Date;if(M instanceof Date)return new Date(M);if(typeof M=="string"&&!/Z$/i.test(M)){var O=M.match(x);if(O){var q=O[2]-1||0,Q=(O[7]||"0").substring(0,3);return R?new Date(Date.UTC(O[1],q,O[3]||1,O[4]||0,O[5]||0,O[6]||0,Q)):new Date(O[1],q,O[3]||1,O[4]||0,O[5]||0,O[6]||0,Q)}}return new Date(M)}(B),this.init()},L.init=function(){var B=this.$d;this.$y=B.getFullYear(),this.$M=B.getMonth(),this.$D=B.getDate(),this.$W=B.getDay(),this.$H=B.getHours(),this.$m=B.getMinutes(),this.$s=B.getSeconds(),this.$ms=B.getMilliseconds()},L.$utils=function(){return _},L.isValid=function(){return this.$d.toString()!==y},L.isSame=function(B,F){var M=T(B);return this.startOf(F)<=M&&M<=this.endOf(F)},L.isAfter=function(B,F){return T(B)<this.startOf(F)},L.isBefore=function(B,F){return this.endOf(F)<T(B)},L.$g=function(B,F,M){return _.u(B)?this[F]:this.set(M,B)},L.unix=function(){return Math.floor(this.valueOf()/1e3)},L.valueOf=function(){return this.$d.getTime()},L.startOf=function(B,F){var M=this,R=!!_.u(F)||F,O=_.p(B),q=function(z,X){var re=_.w(M.$u?Date.UTC(M.$y,X,z):new Date(M.$y,X,z),M);return R?re:re.endOf(s)},Q=function(z,X){return _.w(M.toDate()[z].apply(M.toDate("s"),(R?[0,0,0,0]:[23,59,59,999]).slice(X)),M)},j=this.$W,ie=this.$M,he=this.$D,ue="set"+(this.$u?"UTC":"");switch(O){case p:return R?q(1,0):q(31,11);case f:return R?q(1,ie):q(0,ie+1);case c:var I=this.$locale().weekStart||0,J=(j<I?j+7:j)-I;return q(R?he-J:he+(6-J),ie);case s:case v:return Q(ue+"Hours",0);case u:return Q(ue+"Minutes",1);case l:return Q(ue+"Seconds",2);case o:return Q(ue+"Milliseconds",3);default:return this.clone()}},L.endOf=function(B){return this.startOf(B,!1)},L.$set=function(B,F){var M,R=_.p(B),O="set"+(this.$u?"UTC":""),q=(M={},M[s]=O+"Date",M[v]=O+"Date",M[f]=O+"Month",M[p]=O+"FullYear",M[u]=O+"Hours",M[l]=O+"Minutes",M[o]=O+"Seconds",M[a]=O+"Milliseconds",M)[R],Q=R===s?this.$D+(F-this.$W):F;if(R===f||R===p){var j=this.clone().set(v,1);j.$d[q](Q),j.init(),this.$d=j.set(v,Math.min(this.$D,j.daysInMonth())).$d}else q&&this.$d[q](Q);return this.init(),this},L.set=function(B,F){return this.clone().$set(B,F)},L.get=function(B){return this[_.p(B)]()},L.add=function(B,F){var M,R=this;B=Number(B);var O=_.p(F),q=function(ie){var he=T(R);return _.w(he.date(he.date()+Math.round(ie*B)),R)};if(O===f)return this.set(f,this.$M+B);if(O===p)return this.set(p,this.$y+B);if(O===s)return q(1);if(O===c)return q(7);var Q=(M={},M[l]=r,M[u]=i,M[o]=n,M)[O]||1,j=this.$d.getTime()+B*Q;return _.w(j,this)},L.subtract=function(B,F){return this.add(-1*B,F)},L.format=function(B){var F=this,M=this.$locale();if(!this.isValid())return M.invalidDate||y;var R=B||"YYYY-MM-DDTHH:mm:ssZ",O=_.z(this),q=this.$H,Q=this.$m,j=this.$M,ie=M.weekdays,he=M.months,ue=M.meridiem,I=function(X,re,K,U){return X&&(X[re]||X(F,R))||K[re].slice(0,U)},J=function(X){return _.s(q%12||12,X,"0")},z=ue||function(X,re,K){var U=X<12?"AM":"PM";return K?U.toLowerCase():U};return R.replace(g,function(X,re){return re||function(K){switch(K){case"YY":return String(F.$y).slice(-2);case"YYYY":return _.s(F.$y,4,"0");case"M":return j+1;case"MM":return _.s(j+1,2,"0");case"MMM":return I(M.monthsShort,j,he,3);case"MMMM":return I(he,j);case"D":return F.$D;case"DD":return _.s(F.$D,2,"0");case"d":return String(F.$W);case"dd":return I(M.weekdaysMin,F.$W,ie,2);case"ddd":return I(M.weekdaysShort,F.$W,ie,3);case"dddd":return ie[F.$W];case"H":return String(q);case"HH":return _.s(q,2,"0");case"h":return J(1);case"hh":return J(2);case"a":return z(q,Q,!0);case"A":return z(q,Q,!1);case"m":return String(Q);case"mm":return _.s(Q,2,"0");case"s":return String(F.$s);case"ss":return _.s(F.$s,2,"0");case"SSS":return _.s(F.$ms,3,"0");case"Z":return O}return null}(X)||O.replace(":","")})},L.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},L.diff=function(B,F,M){var R,O=this,q=_.p(F),Q=T(B),j=(Q.utcOffset()-this.utcOffset())*r,ie=this-Q,he=function(){return _.m(O,Q)};switch(q){case p:R=he()/12;break;case f:R=he();break;case d:R=he()/3;break;case c:R=(ie-j)/6048e5;break;case s:R=(ie-j)/864e5;break;case u:R=ie/i;break;case l:R=ie/r;break;case o:R=ie/n;break;default:R=ie}return M?R:_.a(R)},L.daysInMonth=function(){return this.endOf(f).$D},L.$locale=function(){return S[this.$L]},L.locale=function(B,F){if(!B)return this.$L;var M=this.clone(),R=N(B,F,!0);return R&&(M.$L=R),M},L.clone=function(){return _.w(this.$d,this)},L.toDate=function(){return new Date(this.valueOf())},L.toJSON=function(){return this.isValid()?this.toISOString():null},L.toISOString=function(){return this.$d.toISOString()},L.toString=function(){return this.$d.toUTCString()},$}(),V=A.prototype;return T.prototype=V,[["$ms",a],["$s",o],["$m",l],["$H",u],["$W",s],["$M",f],["$y",p],["$D",v]].forEach(function($){V[$[1]]=function(L){return this.$g(L,$[0],$[1])}}),T.extend=function($,L){return $.$i||($(L,A,T),$.$i=!0),T},T.locale=N,T.isDayjs=C,T.unix=function($){return T(1e3*$)},T.en=S[k],T.Ls=S,T.p={},T})})(fj);var E3=fj.exports;const kn=In(E3),ei=({data:e,title:t,collapsed:n=!1})=>{const[r,i]=m.useState(!n),[a,o]=m.useState(!1),l=c=>{try{let f;return typeof c=="string"?f=JSON.parse(c):f=c,JSON.stringify(f,null,2)}catch{return typeof c=="string"?c:String(c)}},u=()=>{const c=l(e);navigator.clipboard.writeText(c).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)}).catch(f=>{console.error("Failed to copy JSON:",f)})},s=l(e);return h.jsxs("div",{className:"json-viewer",children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[t&&h.jsx("h4",{style:{margin:0,fontSize:"14px",color:"var(--text-primary)"},children:t}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>i(!r),className:"btn btn-sm btn-secondary",style:{fontSize:"12px",padding:"2px 8px"},children:r?"折叠":"展开"}),h.jsx("button",{onClick:u,className:"btn btn-sm btn-primary",style:{fontSize:"12px",padding:"2px 8px"},children:a?"已复制":"复制"})]})]}),r&&h.jsx("pre",{style:{background:"var(--bg-code)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"12px",overflowX:"auto",fontSize:"12px",lineHeight:"1.4",color:"var(--text-primary)",maxHeight:"400px",overflowY:"auto",margin:0},children:h.jsx("code",{children:s})})]})},Qp={"claude-code":"Claude Code",codex:"Codex"};function j3(){const[e,t]=m.useState("request"),[n,r]=m.useState([]),[i,a]=m.useState([]),[o,l]=m.useState([]),[u,s]=m.useState(null),[c,f]=m.useState(null),[d,p]=m.useState(null),[v,y]=m.useState(!1),x=100,g=0,[b,w]=m.useState([]),[P,k]=m.useState([]),[S,E]=m.useState(""),[C,N]=m.useState(""),[T,_]=m.useState(""),[A,V]=m.useState("");m.useEffect(()=>{$(),L()},[e]);const $=async()=>{if(e==="request"){const I=await oe.getLogs(x,g);r(I)}else if(e==="access"){const I=await oe.getAccessLogs(x,g);a(I)}else if(e==="error"){const I=await oe.getErrorLogs(x,g);l(I)}},L=async()=>{try{const[I,J]=await Promise.all([oe.getVendors(),oe.getAPIServices()]);w(I),k(J)}catch(I){console.error("Failed to load vendors and services:",I)}},B=async()=>{confirm("确定要清空当前类型的所有日志吗?")&&(e==="request"?(await oe.clearLogs(),r([]),s(null)):e==="access"?(await oe.clearAccessLogs(),a([]),f(null)):e==="error"&&(await oe.clearErrorLogs(),l([]),p(null)))},F=I=>I?I>=200&&I<300?"badge-success":I>=400&&I<500?"badge-warning":"badge-danger":"badge-danger",M=I=>{N(I),_(""),V("")},R=I=>{_(I),V("")},O=()=>C?P.filter(I=>I.vendorId===C):[],q=()=>{if(!T)return[];const I=P.find(J=>J.id===T);return(I==null?void 0:I.supportedModels)||[]},j=(I=>I.filter(J=>!(S&&J.targetType!==S||C&&J.vendorId!==C||T&&J.targetServiceId!==T||A&&J.targetModel!==A)))(n),ie=()=>j.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无请求日志"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"时间"}),h.jsx("th",{children:"来源对象类型"}),h.jsx("th",{children:"路径"}),h.jsx("th",{children:"状态"}),h.jsx("th",{children:"响应时间"}),h.jsx("th",{children:"Tokens信息"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:j.map(I=>h.jsxs("tr",{children:[h.jsx("td",{children:kn(I.timestamp).format("YYYY-MM-DD HH:mm:ss")}),h.jsx("td",{children:Qp[I.targetType]?h.jsx("span",{className:"badge badge-info",children:Qp[I.targetType]}):"-"}),h.jsx("td",{children:I.path}),h.jsx("td",{children:h.jsx("span",{className:`badge ${F(I.statusCode)}`,children:I.statusCode||"Error"})}),h.jsx("td",{children:I.responseTime?`${I.responseTime}ms`:"-"}),h.jsx("td",{children:I.usage?h.jsxs("span",{children:[I.usage.totalTokens?I.usage.totalTokens:I.usage.inputTokens+I.usage.outputTokens," tokens"]}):"-"}),h.jsx("td",{children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>s(I),children:"详情"})})]},I.id))})]}),he=()=>i.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无访问日志"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"时间"}),h.jsx("th",{children:"方法"}),h.jsx("th",{children:"路径"}),h.jsx("th",{children:"状态"}),h.jsx("th",{children:"响应时间"}),h.jsx("th",{children:"客户端IP"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:i.map(I=>h.jsxs("tr",{children:[h.jsx("td",{children:kn(I.timestamp).format("YYYY-MM-DD HH:mm:ss")}),h.jsx("td",{children:h.jsx("span",{className:"badge badge-success",children:I.method})}),h.jsx("td",{children:I.path}),h.jsx("td",{children:h.jsx("span",{className:`badge ${F(I.statusCode)}`,children:I.statusCode||"-"})}),h.jsx("td",{children:I.responseTime?`${I.responseTime}ms`:"-"}),h.jsx("td",{style:{fontSize:"12px"},children:I.clientIp||"-"}),h.jsx("td",{children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>f(I),children:"详情"})})]},I.id))})]}),ue=()=>o.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("p",{children:"暂无错误日志"})}):h.jsxs("table",{children:[h.jsx("thead",{children:h.jsxs("tr",{children:[h.jsx("th",{children:"时间"}),h.jsx("th",{children:"方法"}),h.jsx("th",{children:"路径"}),h.jsx("th",{children:"状态"}),h.jsx("th",{children:"错误信息"}),h.jsx("th",{children:"操作"})]})}),h.jsx("tbody",{children:o.map(I=>h.jsxs("tr",{children:[h.jsx("td",{children:kn(I.timestamp).format("YYYY-MM-DD HH:mm:ss")}),h.jsx("td",{children:h.jsx("span",{className:"badge badge-danger",children:I.method})}),h.jsx("td",{children:I.path}),h.jsx("td",{children:h.jsx("span",{className:"badge badge-danger",children:I.statusCode||"-"})}),h.jsx("td",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#e74c3c"},children:I.errorMessage}),h.jsx("td",{children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>p(I),children:"详情"})})]},I.id))})]});return h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"请求日志"}),h.jsx("p",{children:"查看所有API请求日志"})]}),h.jsxs("div",{className:"card",children:[h.jsx("div",{style:{borderBottom:"1px solid #ecf0f1",marginBottom:"20px"},children:h.jsxs("div",{style:{display:"flex",gap:"0"},children:[h.jsxs("button",{onClick:()=>t("request"),style:{padding:"12px 24px",border:"none",background:e==="request"?"#3498db":"transparent",color:e==="request"?"white":"#7f8c8d",cursor:"pointer",borderBottom:e==="request"?"2px solid #2980b9":"2px solid transparent",fontWeight:e==="request"?"bold":"normal"},children:["请求日志 (",n.length,")"]}),h.jsxs("button",{onClick:()=>t("access"),style:{padding:"12px 24px",border:"none",background:e==="access"?"#3498db":"transparent",color:e==="access"?"white":"#7f8c8d",cursor:"pointer",borderBottom:e==="access"?"2px solid #2980b9":"2px solid transparent",fontWeight:e==="access"?"bold":"normal"},children:["访问日志 (",i.length,")"]}),h.jsxs("button",{onClick:()=>t("error"),style:{padding:"12px 24px",border:"none",background:e==="error"?"#e74c3c":"transparent",color:e==="error"?"white":"#7f8c8d",cursor:"pointer",borderBottom:e==="error"?"2px solid #c0392b":"2px solid transparent",fontWeight:e==="error"?"bold":"normal"},children:["错误日志 (",o.length,")"]})]})}),h.jsxs("div",{className:"toolbar",children:[h.jsxs("h3",{children:[e==="access"&&"访问日志列表",e==="error"&&"错误日志列表",e==="request"&&"请求日志列表"]}),h.jsxs("div",{style:{display:"flex",gap:"10px"},children:[h.jsx("button",{className:"btn btn-primary",onClick:$,children:"刷新"}),h.jsx("button",{className:"btn btn-danger",onClick:B,children:"清空日志"})]})]}),e==="request"&&h.jsxs("div",{style:{padding:"15px",background:"var(--bg-secondary)",borderRadius:"12px",marginBottom:"20px",display:"flex",gap:"15px",alignItems:"center",flexWrap:"wrap",border:"1px solid var(--border-primary)"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"来源类型:"}),h.jsxs("select",{value:S,onChange:I=>E(I.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)"},children:[h.jsx("option",{value:"",children:"全部"}),h.jsx("option",{value:"claude-code",children:"Claude Code"}),h.jsx("option",{value:"codex",children:"Codex"})]})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"供应商:"}),h.jsxs("select",{value:C,onChange:I=>M(I.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:"var(--bg-card)",color:"var(--text-primary)"},children:[h.jsx("option",{value:"",children:"全部供应商"}),b.map(I=>h.jsx("option",{value:I.id,children:I.name},I.id))]})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"API服务:"}),h.jsxs("select",{value:T,onChange:I=>R(I.target.value),disabled:!C,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:C?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:C?"pointer":"not-allowed",opacity:C?1:.6},children:[h.jsx("option",{value:"",children:"全部服务"}),O().map(I=>h.jsx("option",{value:I.id,children:I.name},I.id))]})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"模型:"}),h.jsxs("select",{value:A,onChange:I=>V(I.target.value),disabled:!T,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:T?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:T?"pointer":"not-allowed",opacity:T?1:.6},children:[h.jsx("option",{value:"",children:"全部模型"}),q().map(I=>h.jsx("option",{value:I,children:I},I))]})]}),(S||C||T||A)&&h.jsx("button",{onClick:()=>{E(""),N(""),_(""),V("")},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--accent-danger)",background:"var(--accent-danger)",color:"white",cursor:"pointer",fontSize:"14px"},children:"清除筛选"}),h.jsxs("div",{style:{marginLeft:"auto",color:"var(--text-muted)",fontSize:"14px"},children:["显示 ",j.length," / ",n.length," 条"]})]}),e==="request"&&ie(),e==="access"&&he(),e==="error"&&ue()]}),u&&h.jsx("div",{className:"modal-overlay",onClick:()=>s(null),children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),style:{width:"800px",maxWidth:"90%",maxHeight:"90vh",overflowY:"auto"},children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"请求详情"})}),h.jsxs("div",{children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"日志ID"}),h.jsx("input",{type:"text",value:u.id,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"时间"}),h.jsx("input",{type:"text",value:kn(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),u.targetType&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"来源对象类型"}),h.jsx("input",{type:"text",value:Qp[u.targetType]||"-",readOnly:!0})]}),u.requestModel&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求模型"}),h.jsx("input",{type:"text",value:u.requestModel,readOnly:!0})]}),u.vendorName&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商"}),h.jsx("input",{type:"text",value:u.vendorName,readOnly:!0})]}),u.targetServiceName&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商API服务"}),h.jsx("input",{type:"text",value:u.targetServiceName,readOnly:!0})]}),u.targetModel&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"供应商模型"}),h.jsx("input",{type:"text",value:u.targetModel,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求方法"}),h.jsx("input",{type:"text",value:u.method,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求路径"}),h.jsx("input",{type:"text",value:u.path,readOnly:!0})]}),u.headers&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求头"}),h.jsx(ei,{data:u.headers,collapsed:!0})]}),u.body&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求体"}),h.jsx(ei,{data:u.body})]}),u.upstreamRequest&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"实际转发信息"}),h.jsx(ei,{data:u.upstreamRequest})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"状态码"}),h.jsx("input",{type:"text",value:u.statusCode||"Error",readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"响应时间"}),h.jsx("input",{type:"text",value:u.responseTime?`${u.responseTime}ms`:"-",readOnly:!0})]}),u.responseHeaders&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"响应头"}),h.jsx(ei,{data:u.responseHeaders,collapsed:!0})]}),u.responseBody&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"响应体"}),h.jsx(ei,{data:u.responseBody})]}),u.streamChunks&&u.streamChunks.length>0&&h.jsxs("div",{className:"form-group",children:[h.jsxs("label",{children:["Stream Chunks (",u.streamChunks.length,"个)",h.jsx("button",{onClick:()=>y(!v),style:{marginLeft:"10px",padding:"2px 8px",fontSize:"12px"},className:"btn btn-sm btn-primary",children:v?"折叠":"展开"})]}),v&&h.jsx("div",{style:{maxHeight:"400px",overflowY:"auto",border:"1px solid #ddd",padding:"10px",borderRadius:"4px"},children:u.streamChunks.map((I,J)=>h.jsxs("div",{style:{marginBottom:"10px"},children:[h.jsxs("div",{style:{fontWeight:"bold",fontSize:"12px",color:"#7f8c8d",marginBottom:"4px"},children:["Chunk #",J+1]}),h.jsx(ei,{data:I,collapsed:!0})]},J))})]}),u.usage&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"Token 使用"}),h.jsx("textarea",{rows:4,value:`输入: ${u.usage.inputTokens}
|
|
311
311
|
输出: ${u.usage.outputTokens}
|
|
312
312
|
`+(u.usage.totalTokens!==void 0?`总计: ${u.usage.totalTokens}
|
|
313
313
|
`:"")+(u.usage.cacheReadInputTokens!==void 0?`缓存读取: ${u.usage.cacheReadInputTokens}`:""),readOnly:!0})]}),u.error&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"错误信息"}),h.jsx("textarea",{rows:4,value:u.error,readOnly:!0,style:{color:"red"}})]})]}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>s(null),children:"关闭"})})]})}),c&&h.jsx("div",{className:"modal-overlay",onClick:()=>f(null),children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),style:{minWidth:"600px"},children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"访问日志详情"})}),h.jsxs("div",{children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"时间"}),h.jsx("input",{type:"text",value:kn(c.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求方法"}),h.jsx("input",{type:"text",value:c.method,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求路径"}),h.jsx("input",{type:"text",value:c.path,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"状态码"}),h.jsx("input",{type:"text",value:c.statusCode||"-",readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"响应时间"}),h.jsx("input",{type:"text",value:c.responseTime?`${c.responseTime}ms`:"-",readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"客户端IP"}),h.jsx("input",{type:"text",value:c.clientIp||"-",readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"User Agent"}),h.jsx("textarea",{rows:2,value:c.userAgent||"-",readOnly:!0})]}),c.error&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"错误信息"}),h.jsx("textarea",{rows:6,value:c.error,readOnly:!0,style:{color:"#e74c3c"}})]})]}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>f(null),children:"关闭"})})]})}),d&&h.jsx("div",{className:"modal-overlay",onClick:()=>p(null),children:h.jsxs("div",{className:"modal",onClick:I=>I.stopPropagation(),style:{minWidth:"600px"},children:[h.jsx("div",{className:"modal-header",children:h.jsx("h2",{children:"错误日志详情"})}),h.jsxs("div",{children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"时间"}),h.jsx("input",{type:"text",value:kn(d.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求方法"}),h.jsx("input",{type:"text",value:d.method,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求路径"}),h.jsx("input",{type:"text",value:d.path,readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"状态码"}),h.jsx("input",{type:"text",value:d.statusCode||"-",readOnly:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"错误信息"}),h.jsx("textarea",{rows:4,value:d.errorMessage,readOnly:!0,style:{color:"#e74c3c"}})]}),d.errorStack&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"错误堆栈"}),h.jsx("textarea",{rows:8,value:d.errorStack,readOnly:!0,style:{fontSize:"12px",color:"#7f8c8d"}})]}),d.requestBody&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求体"}),h.jsx(ei,{data:d.requestBody})]}),d.requestHeaders&&h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"请求头"}),h.jsx(ei,{data:d.requestHeaders})]})]}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{className:"btn btn-secondary",onClick:()=>p(null),children:"关闭"})})]})})]})}function C3(){const[e,t]=m.useState(null),[n,r]=m.useState(""),[i,a]=m.useState(""),[o,l]=m.useState("");m.useEffect(()=>{u()},[]);const u=async()=>{const d=await oe.getConfig();t(d)},s=async d=>{d.preventDefault();const p=new FormData(d.currentTarget),v={enableLogging:p.get("enableLogging")==="true",logRetentionDays:parseInt(p.get("logRetentionDays")),maxLogSize:parseInt(p.get("maxLogSize")),apiKey:p.get("apiKey"),enableFailover:p.get("enableFailover")==="true"};await oe.updateConfig(v)?(alert("配置保存成功"),u()):alert("配置保存失败")},c=async()=>{if(!n){alert("请输入密码");return}try{const d=await oe.exportData(n);l(d),alert("导出成功,请复制下方数据")}catch(d){alert("导出失败: "+d.message)}},f=async()=>{if(!n||!i){alert("请输入密码和导入数据");return}try{await oe.importData(i,n)?(alert("导入成功"),a(""),r("")):alert("导入失败,请检查密码是否正确")}catch(d){alert("导入失败: "+d.message)}};return e?h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"设置"}),h.jsx("p",{children:"管理应用配置和数据导入导出"})]}),h.jsxs("div",{className:"card",children:[h.jsx("h3",{children:"应用配置"}),h.jsxs("form",{onSubmit:s,children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"API Key"}),h.jsx("input",{type:"password",name:"apiKey",defaultValue:e.apiKey})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"启用日志"}),h.jsxs("select",{name:"enableLogging",defaultValue:e.enableLogging?"true":"false",children:[h.jsx("option",{value:"true",children:"是"}),h.jsx("option",{value:"false",children:"否"})]})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"启用智能故障切换"}),h.jsxs("select",{name:"enableFailover",defaultValue:e.enableFailover!==!1?"true":"false",children:[h.jsx("option",{value:"true",children:"是"}),h.jsx("option",{value:"false",children:"否"})]}),h.jsx("small",{style:{display:"block",marginTop:"4px",color:"#666",fontSize:"12px"},children:"启用后,当某个服务报错时会自动切换到备用服务,并将报错服务标记为不可用10分钟"})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"日志保留天数"}),h.jsx("input",{type:"number",name:"logRetentionDays",defaultValue:e.logRetentionDays,required:!0})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"最大日志数量"}),h.jsx("input",{type:"number",name:"maxLogSize",defaultValue:e.maxLogSize,required:!0})]}),h.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存配置"})]})]}),h.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[h.jsx("h3",{children:"数据导出"}),h.jsx("p",{style:{color:"#7f8c8d",fontSize:"14px"},children:"导出所有配置数据,包括供应商、API服务、路由等。数据将使用密码加密。"}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"加密密码"}),h.jsx("input",{type:"password",value:n,onChange:d=>r(d.target.value),placeholder:"用于加密导出数据"})]}),h.jsx("button",{className:"btn btn-primary",onClick:c,children:"导出数据"}),o&&h.jsxs("div",{className:"form-group",style:{marginTop:"20px"},children:[h.jsx("label",{children:"导出的数据(请复制保存)"}),h.jsx("textarea",{rows:6,value:o,readOnly:!0,style:{fontFamily:"monospace",fontSize:"12px"}}),h.jsx("button",{className:"btn btn-secondary",style:{marginTop:"10px"},onClick:()=>{navigator.clipboard.writeText(o),alert("已复制到剪贴板")},children:"复制到剪贴板"})]})]}),h.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[h.jsx("h3",{children:"数据导入"}),h.jsx("p",{style:{color:"#e74c3c",fontSize:"14px",fontWeight:500},children:"警告:导入数据将覆盖所有现有配置!请确保已备份重要数据。"}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"解密密码"}),h.jsx("input",{type:"password",value:n,onChange:d=>r(d.target.value),placeholder:"用于解密导入数据"})]}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{children:"导入数据"}),h.jsx("textarea",{rows:6,value:i,onChange:d=>a(d.target.value),placeholder:"粘贴导出的加密数据",style:{fontFamily:"monospace",fontSize:"12px"}})]}),h.jsx("button",{className:"btn btn-danger",onClick:f,children:"导入数据"})]})]}):h.jsx("div",{children:"加载中..."})}function A3(){const[e,t]=m.useState({claude:!1,codex:!1}),[n,r]=m.useState({claude:!1,codex:!1}),[i,a]=m.useState({claude:!1,codex:!1}),[o,l]=m.useState("");m.useEffect(()=>{u()},[]);const u=async()=>{try{const[f,d]=await Promise.all([oe.checkClaudeBackup(),oe.checkCodexBackup()]);a({claude:f.exists,codex:d.exists})}catch(f){console.error("Failed to check backups:",f)}},s=async f=>{t(d=>({...d,[f]:!0})),l("");try{(f==="claude"?await oe.writeClaudeConfig():await oe.writeCodexConfig())?(l(`${f==="claude"?"Claude Code":"Codex"}配置文件写入成功!原始文件已备份为 .bak 文件。`),await u()):l("写入失败: 操作未成功")}catch(d){l(`写入失败: ${d.message}`)}finally{t(d=>({...d,[f]:!1}))}},c=async f=>{r(d=>({...d,[f]:!0})),l("");try{(f==="claude"?await oe.restoreClaudeConfig():await oe.restoreCodexConfig())?(l(`${f==="claude"?"Claude Code":"Codex"}配置文件已从备份恢复!`),await u()):l("恢复失败: 操作未成功")}catch(d){l(`恢复失败: ${d.message}`)}finally{r(d=>({...d,[f]:!1}))}};return h.jsxs("div",{children:[h.jsxs("div",{className:"page-header",children:[h.jsx("h1",{children:"写入配置"}),h.jsx("p",{children:"将Claude Code和Codex的配置文件写入到用户目录"})]}),h.jsxs("div",{className:"card",style:{marginBottom:"20px"},children:[h.jsx("h3",{children:"Claude Code配置"}),h.jsx("p",{style:{color:"#7f8c8d",marginBottom:"15px"},children:"为Claude Code工具写入配置文件。原始文件将被备份为.bak文件。"}),h.jsxs("div",{style:{marginBottom:"15px"},children:[h.jsx("h4",{children:"配置文件:"}),h.jsxs("ul",{style:{color:"#7f8c8d",lineHeight:"1.6"},children:[h.jsxs("li",{children:[h.jsx("code",{children:"~/.claude/settings.json"})," - Claude Code设置"]}),h.jsxs("li",{children:[h.jsx("code",{children:"~/.claude.json"})," - Claude Code初始化设置"]})]})]}),h.jsxs("div",{style:{display:"flex",gap:"10px"},children:[h.jsx("button",{className:"btn btn-primary",onClick:()=>s("claude"),disabled:e.claude||i.claude,children:e.claude?"写入中...":"写入Claude Code配置"}),h.jsx("button",{className:"btn btn-secondary",onClick:()=>c("claude"),disabled:n.claude||!i.claude,children:n.claude?"恢复中...":"恢复Claude Code配置"})]}),!i.claude&&h.jsx("p",{style:{color:"#95a5a6",fontSize:"12px",marginTop:"10px"},children:"没有找到备份文件,恢复功能不可用"}),i.claude&&h.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 备份文件已存在,为避免覆盖原始备份,请先恢复或手动删除备份文件后再写入"})]}),h.jsxs("div",{className:"card",children:[h.jsx("h3",{children:"Codex配置"}),h.jsx("p",{style:{color:"#7f8c8d",marginBottom:"15px"},children:"为Codex工具写入配置文件。原始文件将被备份为.bak文件。"}),h.jsxs("div",{style:{marginBottom:"15px"},children:[h.jsx("h4",{children:"配置文件:"}),h.jsxs("ul",{style:{color:"#7f8c8d",lineHeight:"1.6"},children:[h.jsxs("li",{children:[h.jsx("code",{children:"~/.codex/config.toml"})," - Codex配置"]}),h.jsxs("li",{children:[h.jsx("code",{children:"~/.codex/auth.json"})," - Codex认证信息"]})]})]}),h.jsxs("div",{style:{display:"flex",gap:"10px"},children:[h.jsx("button",{className:"btn btn-primary",onClick:()=>s("codex"),disabled:e.codex||i.codex,children:e.codex?"写入中...":"写入Codex配置"}),h.jsx("button",{className:"btn btn-secondary",onClick:()=>c("codex"),disabled:n.codex||!i.codex,children:n.codex?"恢复中...":"恢复Codex配置"})]}),!i.codex&&h.jsx("p",{style:{color:"#95a5a6",fontSize:"12px",marginTop:"10px"},children:"没有找到备份文件,恢复功能不可用"}),i.codex&&h.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 备份文件已存在,为避免覆盖原始备份,请先恢复或手动删除备份文件后再写入"})]}),o&&h.jsx("div",{style:{marginTop:"20px",padding:"10px",borderRadius:"4px",backgroundColor:o.includes("成功")?"#d4edda":"#f8d7da",color:o.includes("成功")?"#155724":"#721c24",border:`1px solid ${o.includes("成功")?"#c3e6cb":"#f5c6cb"}`},children:o})]})}const _3=()=>{const e=S3();return h.jsx("div",{className:"markdown-content",children:h.jsx(sj,{children:e})})};function dj(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=dj(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function we(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=dj(e))&&(r&&(r+=" "),r+=t);return r}var T3=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function Ug(e){if(typeof e!="string")return!1;var t=T3;return t.includes(e)}var I3=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],N3=new Set(I3);function pj(e){return typeof e!="string"?!1:N3.has(e)}function hj(e){return typeof e=="string"&&e.startsWith("data-")}function Bt(e){if(typeof e!="object"||e===null)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(pj(n)||hj(n))&&(t[n]=e[n]);return t}function pa(e){if(e==null)return null;if(m.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return Bt(t)}return typeof e=="object"&&!Array.isArray(e)?Bt(e):null}function Mt(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(pj(n)||hj(n)||Ug(n))&&(t[n]=e[n]);return t}function M3(e){return e==null?null:m.isValidElement(e)?Mt(e.props):typeof e=="object"&&!Array.isArray(e)?Mt(e):null}var D3=["children","width","height","viewBox","className","style","title","desc"];function Tm(){return Tm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Tm.apply(null,arguments)}function L3(e,t){if(e==null)return{};var n,r,i=R3(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function R3(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Wg=m.forwardRef((e,t)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:u,desc:s}=e,c=L3(e,D3),f=a||{width:r,height:i,x:0,y:0},d=we("recharts-surface",o);return m.createElement("svg",Tm({},Mt(c),{className:d,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:t}),m.createElement("title",null,u),m.createElement("desc",null,s),n)}),z3=["children","className"];function Im(){return Im=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Im.apply(null,arguments)}function $3(e,t){if(e==null)return{};var n,r,i=B3(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function B3(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ze=m.forwardRef((e,t)=>{var{children:n,className:r}=e,i=$3(e,z3),a=we("recharts-layer",r);return m.createElement("g",Im({className:a},Mt(i),{ref:t}),n)}),mj=m.createContext(null),F3=()=>m.useContext(mj);function Ie(e){return function(){return e}}const vj=Math.cos,Ac=Math.sin,Gn=Math.sqrt,_c=Math.PI,Jf=2*_c,Nm=Math.PI,Mm=2*Nm,Vi=1e-6,U3=Mm-Vi;function gj(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function W3(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return gj;const n=10**t;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class K3{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?gj:W3(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,a,o){this._append`C${+t},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(t,n,r,i,a){if(t=+t,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,l=this._y1,u=r-t,s=i-n,c=o-t,f=l-n,d=c*c+f*f;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(d>Vi)if(!(Math.abs(f*u-s*c)>Vi)||!a)this._append`L${this._x1=t},${this._y1=n}`;else{let p=r-o,v=i-l,y=u*u+s*s,x=p*p+v*v,g=Math.sqrt(y),b=Math.sqrt(d),w=a*Math.tan((Nm-Math.acos((y+d-x)/(2*g*b)))/2),P=w/b,k=w/g;Math.abs(P-1)>Vi&&this._append`L${t+P*c},${n+P*f}`,this._append`A${a},${a},0,0,${+(f*p>c*v)},${this._x1=t+k*u},${this._y1=n+k*s}`}}arc(t,n,r,i,a,o){if(t=+t,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),u=r*Math.sin(i),s=t+l,c=n+u,f=1^o,d=o?i-a:a-i;this._x1===null?this._append`M${s},${c}`:(Math.abs(this._x1-s)>Vi||Math.abs(this._y1-c)>Vi)&&this._append`L${s},${c}`,r&&(d<0&&(d=d%Mm+Mm),d>U3?this._append`A${r},${r},0,1,${f},${t-l},${n-u}A${r},${r},0,1,${f},${this._x1=s},${this._y1=c}`:d>Vi&&this._append`A${r},${r},0,${+(d>=Nm)},${f},${this._x1=t+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function Kg(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new K3(t)}function Vg(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function yj(e){this._context=e}yj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ed(e){return new yj(e)}function xj(e){return e[0]}function bj(e){return e[1]}function wj(e,t){var n=Ie(!0),r=null,i=ed,a=null,o=Kg(l);e=typeof e=="function"?e:e===void 0?xj:Ie(e),t=typeof t=="function"?t:t===void 0?bj:Ie(t);function l(u){var s,c=(u=Vg(u)).length,f,d=!1,p;for(r==null&&(a=i(p=o())),s=0;s<=c;++s)!(s<c&&n(f=u[s],s,u))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(f,s,u),+t(f,s,u));if(p)return a=null,p+""||null}return l.x=function(u){return arguments.length?(e=typeof u=="function"?u:Ie(+u),l):e},l.y=function(u){return arguments.length?(t=typeof u=="function"?u:Ie(+u),l):t},l.defined=function(u){return arguments.length?(n=typeof u=="function"?u:Ie(!!u),l):n},l.curve=function(u){return arguments.length?(i=u,r!=null&&(a=i(r)),l):i},l.context=function(u){return arguments.length?(u==null?r=a=null:a=i(r=u),l):r},l}function gs(e,t,n){var r=null,i=Ie(!0),a=null,o=ed,l=null,u=Kg(s);e=typeof e=="function"?e:e===void 0?xj:Ie(+e),t=typeof t=="function"?t:Ie(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?bj:Ie(+n);function s(f){var d,p,v,y=(f=Vg(f)).length,x,g=!1,b,w=new Array(y),P=new Array(y);for(a==null&&(l=o(b=u())),d=0;d<=y;++d){if(!(d<y&&i(x=f[d],d,f))===g)if(g=!g)p=d,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),v=d-1;v>=p;--v)l.point(w[v],P[v]);l.lineEnd(),l.areaEnd()}g&&(w[d]=+e(x,d,f),P[d]=+t(x,d,f),l.point(r?+r(x,d,f):w[d],n?+n(x,d,f):P[d]))}if(b)return l=null,b+""||null}function c(){return wj().defined(i).curve(o).context(a)}return s.x=function(f){return arguments.length?(e=typeof f=="function"?f:Ie(+f),r=null,s):e},s.x0=function(f){return arguments.length?(e=typeof f=="function"?f:Ie(+f),s):e},s.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Ie(+f),s):r},s.y=function(f){return arguments.length?(t=typeof f=="function"?f:Ie(+f),n=null,s):t},s.y0=function(f){return arguments.length?(t=typeof f=="function"?f:Ie(+f),s):t},s.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Ie(+f),s):n},s.lineX0=s.lineY0=function(){return c().x(e).y(t)},s.lineY1=function(){return c().x(e).y(n)},s.lineX1=function(){return c().x(r).y(t)},s.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Ie(!!f),s):i},s.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),s):o},s.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),s):a},s}class Sj{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function V3(e){return new Sj(e,!0)}function H3(e){return new Sj(e,!1)}const Hg={draw(e,t){const n=Gn(t/_c);e.moveTo(n,0),e.arc(0,0,n,0,Jf)}},Y3={draw(e,t){const n=Gn(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},Pj=Gn(1/3),q3=Pj*2,G3={draw(e,t){const n=Gn(t/q3),r=n*Pj;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},X3={draw(e,t){const n=Gn(t),r=-n/2;e.rect(r,r,n,n)}},Q3=.8908130915292852,kj=Ac(_c/10)/Ac(7*_c/10),Z3=Ac(Jf/10)*kj,J3=-vj(Jf/10)*kj,e4={draw(e,t){const n=Gn(t*Q3),r=Z3*n,i=J3*n;e.moveTo(0,-n),e.lineTo(r,i);for(let a=1;a<5;++a){const o=Jf*a/5,l=vj(o),u=Ac(o);e.lineTo(u*n,-l*n),e.lineTo(l*r-u*i,u*r+l*i)}e.closePath()}},Zp=Gn(3),t4={draw(e,t){const n=-Gn(t/(Zp*3));e.moveTo(0,n*2),e.lineTo(-Zp*n,-n),e.lineTo(Zp*n,-n),e.closePath()}},gn=-.5,yn=Gn(3)/2,Dm=1/Gn(12),n4=(Dm/2+1)*3,r4={draw(e,t){const n=Gn(t/n4),r=n/2,i=n*Dm,a=r,o=n*Dm+n,l=-a,u=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(l,u),e.lineTo(gn*r-yn*i,yn*r+gn*i),e.lineTo(gn*a-yn*o,yn*a+gn*o),e.lineTo(gn*l-yn*u,yn*l+gn*u),e.lineTo(gn*r+yn*i,gn*i-yn*r),e.lineTo(gn*a+yn*o,gn*o-yn*a),e.lineTo(gn*l+yn*u,gn*u-yn*l),e.closePath()}};function i4(e,t){let n=null,r=Kg(i);e=typeof e=="function"?e:Ie(e||Hg),t=typeof t=="function"?t:Ie(t===void 0?64:+t);function i(){let a;if(n||(n=a=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(e=typeof a=="function"?a:Ie(a),i):e},i.size=function(a){return arguments.length?(t=typeof a=="function"?a:Ie(+a),i):t},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Tc(){}function Ic(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Oj(e){this._context=e}Oj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Ic(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Ic(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function a4(e){return new Oj(e)}function Ej(e){this._context=e}Ej.prototype={areaStart:Tc,areaEnd:Tc,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Ic(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function o4(e){return new Ej(e)}function jj(e){this._context=e}jj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Ic(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function l4(e){return new jj(e)}function Cj(e){this._context=e}Cj.prototype={areaStart:Tc,areaEnd:Tc,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function u4(e){return new Cj(e)}function sw(e){return e<0?-1:1}function cw(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(sw(a)+sw(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function fw(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Jp(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,l=(a-r)/3;e._context.bezierCurveTo(r+l,i+l*t,a-l,o-l*n,a,o)}function Nc(e){this._context=e}Nc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Jp(this,this._t0,fw(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Jp(this,fw(this,n=cw(this,e,t)),n);break;default:Jp(this,this._t0,n=cw(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function Aj(e){this._context=new _j(e)}(Aj.prototype=Object.create(Nc.prototype)).point=function(e,t){Nc.prototype.point.call(this,t,e)};function _j(e){this._context=e}_j.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function s4(e){return new Nc(e)}function c4(e){return new Aj(e)}function Tj(e){this._context=e}Tj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=dw(e),i=dw(t),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function dw(e){var t,n=e.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,a[t]=4,o[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/a[t-1],a[t]-=r,o[t]-=r*o[t-1];for(i[n-1]=o[n-1]/a[n-1],t=n-2;t>=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)a[t]=2*e[t+1]-i[t+1];return[i,a]}function f4(e){return new Tj(e)}function td(e,t){this._context=e,this._t=t}td.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function d4(e){return new td(e,.5)}function p4(e){return new td(e,0)}function h4(e){return new td(e,1)}function ha(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,l=a.length;n<o;++n)for(i=a,a=e[t[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Lm(e){for(var t=e.length,n=new Array(t);--t>=0;)n[t]=t;return n}function m4(e,t){return e[t]}function v4(e){const t=[];return t.key=e,t}function g4(){var e=Ie([]),t=Lm,n=ha,r=m4;function i(a){var o=Array.from(e.apply(this,arguments),v4),l,u=o.length,s=-1,c;for(const f of a)for(l=0,++s;l<u;++l)(o[l][s]=[0,+r(f,o[l].key,s,a)]).data=f;for(l=0,c=Vg(t(o));l<u;++l)o[c[l]].index=l;return n(o,c),o}return i.keys=function(a){return arguments.length?(e=typeof a=="function"?a:Ie(Array.from(a)),i):e},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Ie(+a),i):r},i.order=function(a){return arguments.length?(t=a==null?Lm:typeof a=="function"?a:Ie(Array.from(a)),i):t},i.offset=function(a){return arguments.length?(n=a??ha,i):n},i}function y4(e,t){if((r=e.length)>0){for(var n,r,i=0,a=e[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=e[n][i][1]||0;if(o)for(n=0;n<r;++n)e[n][i][1]/=o}ha(e,t)}}function x4(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,a=r.length;n<a;++n){for(var o=0,l=0;o<i;++o)l+=e[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}ha(e,t)}}function b4(e,t){if(!(!((o=e.length)>0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,u=0,s=0;l<o;++l){for(var c=e[t[l]],f=c[r][1]||0,d=c[r-1][1]||0,p=(f-d)/2,v=0;v<l;++v){var y=e[t[v]],x=y[r][1]||0,g=y[r-1][1]||0;p+=x-g}u+=f,s+=p*f}i[r-1][1]+=i[r-1][0]=n,u&&(n-=s/u)}i[r-1][1]+=i[r-1][0]=n,ha(e,t)}}var nd={},Ij={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==="__proto__"}e.isUnsafeProperty=t})(Ij);var Yg={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}e.isDeepKey=t})(Yg);var rd={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){var r;return typeof n=="string"||typeof n=="symbol"?n:Object.is((r=n==null?void 0:n.valueOf)==null?void 0:r.call(n),-0)?"-0":String(n)}e.toKey=t})(rd);var id={},Nj={};(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){if(n==null)return"";if(typeof n=="string")return n;if(Array.isArray(n))return n.map(t).join(",");const r=String(n);return r==="0"&&Object.is(Number(n),-0)?"-0":r}e.toString=t})(Nj);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Nj,n=rd;function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=t.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,u="",s="",c=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];s?f==="\\"&&l+1<o?(l++,u+=i[l]):f===s?s="":u+=f:c?f==='"'||f==="'"?s=f:f==="]"?(c=!1,a.push(u),u=""):u+=f:f==="["?(c=!0,u&&(a.push(u),u="")):f==="."?u&&(a.push(u),u=""):u+=f,l++}return u&&a.push(u),a}e.toPath=r})(id);(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Ij,n=Yg,r=rd,i=id;function a(l,u,s){if(l==null)return s;switch(typeof u){case"string":{if(t.isUnsafeProperty(u))return s;const c=l[u];return c===void 0?n.isDeepKey(u)?a(l,i.toPath(u),s):s:c}case"number":case"symbol":{typeof u=="number"&&(u=r.toKey(u));const c=l[u];return c===void 0?s:c}default:{if(Array.isArray(u))return o(l,u,s);if(Object.is(u==null?void 0:u.valueOf(),-0)?u="-0":u=String(u),t.isUnsafeProperty(u))return s;const c=l[u];return c===void 0?s:c}}}function o(l,u,s){if(u.length===0)return s;let c=l;for(let f=0;f<u.length;f++){if(c==null||t.isUnsafeProperty(u[f]))return s;c=c[u[f]]}return c===void 0?s:c}e.get=a})(nd);var w4=nd.get;const ma=In(w4);var S4=4;function di(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:S4,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function qe(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.reduce((i,a,o)=>{var l=n[o-1];return typeof l=="string"?i+l+a:l!==void 0?i+di(l)+a:i+a},"")}var gt=e=>e===0?0:e>0?1:-1,Yn=e=>typeof e=="number"&&e!=+e,va=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,Z=e=>(typeof e=="number"||e instanceof Number)&&!Yn(e),pr=e=>Z(e)||typeof e=="string",P4=0,nu=e=>{var t=++P4;return"".concat(e||"").concat(t)},It=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Z(t)&&typeof t!="string")return r;var a;if(va(t)){if(n==null)return r;var o=t.indexOf("%");a=n*parseFloat(t.slice(0,o))/100}else a=+t;return Yn(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},Mj=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;r<t;r++)if(!n[String(e[r])])n[String(e[r])]=!0;else return!0;return!1};function ke(e,t,n){return Z(e)&&Z(t)?di(e+n*(t-e)):t}function Dj(e,t,n){if(!(!e||!e.length))return e.find(r=>r&&(typeof t=="function"?t(r):ma(r,t))===n)}var Ue=e=>e===null||typeof e>"u",ju=e=>Ue(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function qt(e){return e!=null}function Mi(){}var k4=["type","size","sizeType"];function Rm(){return Rm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Rm.apply(null,arguments)}function pw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function hw(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?pw(Object(n),!0).forEach(function(r){O4(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pw(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function O4(e,t,n){return(t=E4(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E4(e){var t=j4(e,"string");return typeof t=="symbol"?t:t+""}function j4(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function C4(e,t){if(e==null)return{};var n,r,i=A4(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function A4(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Lj={symbolCircle:Hg,symbolCross:Y3,symbolDiamond:G3,symbolSquare:X3,symbolStar:e4,symbolTriangle:t4,symbolWye:r4},_4=Math.PI/180,T4=e=>{var t="symbol".concat(ju(e));return Lj[t]||Hg},I4=(e,t,n)=>{if(t==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var r=18*_4;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},N4=(e,t)=>{Lj["symbol".concat(ju(e))]=t},qg=e=>{var{type:t="circle",size:n=64,sizeType:r="area"}=e,i=C4(e,k4),a=hw(hw({},i),{},{type:t,size:n,sizeType:r}),o="circle";typeof t=="string"&&(o=t);var l=()=>{var d=T4(o),p=i4().type(d).size(I4(n,r,o)),v=p();if(v!==null)return v},{className:u,cx:s,cy:c}=a,f=Mt(a);return Z(s)&&Z(c)&&Z(n)?m.createElement("path",Rm({},f,{className:we("recharts-symbols",u),transform:"translate(".concat(s,", ").concat(c,")"),d:l()})):null};qg.registerSymbol=N4;var Rj=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,Gg=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(m.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{Ug(i)&&(r[i]=a=>n[i](n,a))}),r},M4=(e,t,n)=>r=>(e(t,n,r),null),Cu=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];Ug(i)&&typeof a=="function"&&(r||(r={}),r[i]=M4(a,t,n))}),r};function mw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function D4(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?mw(Object(n),!0).forEach(function(r){L4(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mw(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function L4(e,t,n){return(t=R4(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R4(e){var t=z4(e,"string");return typeof t=="symbol"?t:t+""}function z4(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Je(e,t){var n=D4({},e),r=t,i=Object.keys(t),a=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return a}function Mc(){return Mc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mc.apply(null,arguments)}function vw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $4(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?vw(Object(n),!0).forEach(function(r){B4(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vw(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function B4(e,t,n){return(t=F4(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F4(e){var t=U4(e,"string");return typeof t=="symbol"?t:t+""}function U4(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var bn=32,W4={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function K4(e){var{data:t,iconType:n,inactiveColor:r}=e,i=bn/2,a=bn/6,o=bn/3,l=t.inactive?r:t.color,u=n??t.type;if(u==="none")return null;if(u==="plainline"){var s;return m.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(s=t.payload)===null||s===void 0?void 0:s.strokeDasharray,x1:0,y1:i,x2:bn,y2:i,className:"recharts-legend-icon"})}if(u==="line")return m.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
|
package/dist/ui/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>AI Code Switch</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-BwrBKpaK.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="./assets/index-Bfc2kKan.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicodeswitch",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "A tool to help you manage AI programming tools to access large language models locally. It allows your Claude Code, Codex and other tools to no longer be limited to official models.",
|
|
5
5
|
"author": "tangshuang",
|
|
6
6
|
"license": "GPL-3.0",
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#### 🚀 智谱 GLM Coding Plan
|
|
2
|
+
|
|
3
|
+
> 价格便宜,国内速度快,支持多工具(Claude Code等 20+ 大编程工具),而且其中的GLM-4.7是目前国内最强编程模型。适合对模型有一定要求,同时又无法获取国外模型的朋友入手。
|
|
4
|
+
>
|
|
5
|
+
> 链接:[https://www.bigmodel.cn/glm-coding](https://www.bigmodel.cn/glm-coding?ic=5AH7ATEZSC) | [一键配置](# "glm")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
#### 🗿 AI Code With
|
|
9
|
+
|
|
10
|
+
> 支持Claude、GPT、Gemni三大系列模型,可接入Claude Code、Codex,经实测,非常稳定,速度快,但是没有包月套餐,只能使用tokens流量,适合追求稳定的朋友。
|
|
11
|
+
>
|
|
12
|
+
> 链接:[https://aicodewith.com/](https://aicodewith.com/login?tab=register&invitation=QCA74W) | [一键配置](# "aicodewith")
|
|
13
|
+
|
|
14
|
+
|
|
File without changes
|
|
File without changes
|