@kaitranntt/ccs 7.18.0-dev.3 → 7.18.0-dev.4

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.
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-CBgg0XeO.js";import{r as h}from"./react-vendor-B_CU-WTZ.js";import{aG as Z,aH as ee,af as L,I as w,O as te,Q as se,U as ae,V as oe,W as _,a as $,aI as re,aD as ne,aF as le,i as ce}from"./index-D8K1YCe7.js";import{S as M}from"./switch-CmGBdPfU.js";import{az as B,a0 as R,e as de,n as D,W as ie,V as me,aA as xe}from"./icons-CZDQWWm2.js";import"./tanstack-CxYN0q6L.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function ue(){const{state:s}=Z(),t=ee(),[l,c]=h.useState(null),[u,g]=h.useState(null),[p,i]=h.useState(null),[f,y]=h.useState(null),[j,b]=h.useState(null),v=h.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const n=await L.cliproxyServer.get();t.setProxyConfig(n)}catch(n){t.setProxyError(n.message)}finally{t.setProxyLoading(!1)}},[t]),N=h.useCallback(async n=>{const d=s.proxyConfig;if(!d)return;const m={remote:{...d.remote,...n.remote},fallback:{...d.fallback,...n.fallback},local:{...d.local,...n.local}};t.setProxyConfig(m),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await L.cliproxyServer.update(n);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(d),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),C=h.useCallback(async n=>{const{host:d,port:m,protocol:a,authToken:P}=n;if(!d){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const o=m?parseInt(m,10):void 0,x=await L.cliproxyServer.test({host:d,port:o||void 0,protocol:a,authToken:P||void 0});t.setProxyTestResult(x)}catch(o){t.setProxyError(o.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:l,setEditedHost:c,editedPort:u,setEditedPort:g,editedAuthToken:p,setEditedAuthToken:i,editedManagementKey:f,setEditedManagementKey:y,editedLocalPort:j,setEditedLocalPort:b,fetchConfig:v,saveConfig:N,testConnection:C}}function he({config:s,saving:t,displayLocalPort:l,setEditedLocalPort:c,onSaveLocalPort:u,onSaveConfig:g}){const p=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(w,{type:"number",value:l,onChange:i=>c(i.target.value),onBlur:u,placeholder:"8317",className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(M,{checked:p.auto_start??!0,onCheckedChange:i=>g({local:{...p,auto_start:i}}),disabled:t})]})]})]})}function pe({config:s,saving:t,testing:l,testResult:c,displayHost:u,displayPort:g,displayAuthToken:p,displayManagementKey:i,setEditedHost:f,setEditedPort:y,setEditedAuthToken:j,setEditedManagementKey:b,onSaveHost:v,onSavePort:N,onSaveAuthToken:C,onSaveManagementKey:n,onSaveConfig:d,onTestConnection:m}){const a=s.remote,P=o=>o==="https"?443:8317;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(B,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(w,{value:u,onChange:o=>f(o.target.value),onBlur:v,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",P(s.remote.protocol||"http"),")"]})]}),e.jsx(w,{type:"text",inputMode:"numeric",value:g,onChange:o=>y(o.target.value.replace(/\D/g,"")),onBlur:N,placeholder:`Leave empty for ${P(s.remote.protocol||"http")}`,className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(te,{value:s.remote.protocol||"http",onValueChange:o=>d({remote:{...a,protocol:o}}),disabled:t,children:[e.jsx(se,{children:e.jsx(ae,{})}),e.jsxs(oe,{children:[e.jsx(_,{value:"http",children:"HTTP"}),e.jsx(_,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(w,{type:"password",value:p,onChange:o=>j(o.target.value),onBlur:C,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(w,{type:"password",value:i,onChange:o=>b(o.target.value),onBlur:n,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx($,{onClick:m,disabled:l||!u,variant:"outline",className:"w-full",children:l?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),c&&e.jsx("div",{className:`p-3 rounded-md ${c.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:c.reachable?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",c.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:c.error||"Connection failed"})]})})})]})]})}function Se(){const{config:s,loading:t,saving:l,error:c,success:u,testResult:g,testing:p,editedHost:i,setEditedHost:f,editedPort:y,setEditedPort:j,editedAuthToken:b,setEditedAuthToken:v,editedManagementKey:N,setEditedManagementKey:C,editedLocalPort:n,setEditedLocalPort:d,fetchConfig:m,saveConfig:a,testConnection:P}=ue(),{fetchRawConfig:o}=re();if(h.useEffect(()=>{m(),o()},[m,o]),t||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(R,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const x=s.remote.enabled??!1,k=s.remote,S=s.fallback,U=s.remote.host??"",V=s.remote.port!==void 0?s.remote.port.toString():"",W=s.remote.auth_token??"",z=s.remote.management_key??"",q=(s.local.port??8317).toString(),E=i??U,A=y??V,I=b??W,H=N??z,K=n??q,O=()=>{const r=i??E;r!==s.remote.host&&a({remote:{...k,host:r}}),f(null)},G=()=>{const r=y??A,T=r===""?void 0:parseInt(r,10),F=T&&!isNaN(T)&&T>0?T:void 0;F!==s.remote.port&&a({remote:{...k,port:F}}),j(null)},Q=()=>{const r=b??I;r!==s.remote.auth_token&&a({remote:{...k,auth_token:r}}),v(null)},J=()=>{const r=N??H;r!==s.remote.management_key&&a({remote:{...k,management_key:r||void 0}}),C(null)},X=()=>{const r=parseInt(n??K,10);!isNaN(r)&&r!==s.local.port&&a({local:{...s.local,port:r}}),d(null)},Y=()=>{P({host:E,port:A,protocol:s.remote.protocol||"http",authToken:I})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${c||u?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(ne,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(me,{className:"h-4 w-4"}),e.jsx(le,{children:c})]}),u&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(D,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ce,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure local or remote CLIProxy Plus connection for proxy-based profiles"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>a({remote:{...k,enabled:!1}}),disabled:l,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(xe,{className:`w-5 h-5 ${x?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Run CLIProxy Plus binary on this machine"})]}),e.jsxs("button",{onClick:()=>a({remote:{...k,enabled:!0}}),disabled:l,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(B,{className:`w-5 h-5 ${x?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect to a remote CLIProxy Plus server"})]})]})]}),x&&e.jsx(pe,{config:s,saving:l,testing:p,testResult:g,displayHost:E,displayPort:A,displayAuthToken:I,displayManagementKey:H,setEditedHost:f,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:C,onSaveHost:O,onSavePort:G,onSaveAuthToken:Q,onSaveManagementKey:J,onSaveConfig:a,onTestConnection:Y}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(M,{checked:S.enabled??!0,onCheckedChange:r=>a({fallback:{...S,enabled:r}}),disabled:l||!x})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(M,{checked:S.auto_start??!1,onCheckedChange:r=>a({fallback:{...S,auto_start:r}}),disabled:l||!x||!S.enabled})]})]})]}),!x&&e.jsx(he,{config:s,saving:l,displayLocalPort:K,setEditedLocalPort:d,onSaveLocalPort:X,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs($,{variant:"outline",size:"sm",onClick:()=>{m(),o()},disabled:t||l,className:"w-full",children:[e.jsx(R,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"Refresh"]})})]})}export{Se as default};
1
+ import{j as e}from"./radix-ui-CBgg0XeO.js";import{r as h}from"./react-vendor-B_CU-WTZ.js";import{aG as Z,aH as ee,af as L,I as w,O as te,Q as se,U as ae,V as oe,W as _,a as $,aI as re,aD as ne,aF as le,i as ce}from"./index-B7MyxZLG.js";import{S as M}from"./switch-Kx7oj3ow.js";import{az as B,a0 as R,e as de,n as D,W as ie,V as me,aA as xe}from"./icons-CZDQWWm2.js";import"./tanstack-CxYN0q6L.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function ue(){const{state:s}=Z(),t=ee(),[l,c]=h.useState(null),[u,g]=h.useState(null),[p,i]=h.useState(null),[f,y]=h.useState(null),[j,b]=h.useState(null),v=h.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const n=await L.cliproxyServer.get();t.setProxyConfig(n)}catch(n){t.setProxyError(n.message)}finally{t.setProxyLoading(!1)}},[t]),N=h.useCallback(async n=>{const d=s.proxyConfig;if(!d)return;const m={remote:{...d.remote,...n.remote},fallback:{...d.fallback,...n.fallback},local:{...d.local,...n.local}};t.setProxyConfig(m),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await L.cliproxyServer.update(n);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(d),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),C=h.useCallback(async n=>{const{host:d,port:m,protocol:a,authToken:P}=n;if(!d){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const o=m?parseInt(m,10):void 0,x=await L.cliproxyServer.test({host:d,port:o||void 0,protocol:a,authToken:P||void 0});t.setProxyTestResult(x)}catch(o){t.setProxyError(o.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:l,setEditedHost:c,editedPort:u,setEditedPort:g,editedAuthToken:p,setEditedAuthToken:i,editedManagementKey:f,setEditedManagementKey:y,editedLocalPort:j,setEditedLocalPort:b,fetchConfig:v,saveConfig:N,testConnection:C}}function he({config:s,saving:t,displayLocalPort:l,setEditedLocalPort:c,onSaveLocalPort:u,onSaveConfig:g}){const p=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(w,{type:"number",value:l,onChange:i=>c(i.target.value),onBlur:u,placeholder:"8317",className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(M,{checked:p.auto_start??!0,onCheckedChange:i=>g({local:{...p,auto_start:i}}),disabled:t})]})]})]})}function pe({config:s,saving:t,testing:l,testResult:c,displayHost:u,displayPort:g,displayAuthToken:p,displayManagementKey:i,setEditedHost:f,setEditedPort:y,setEditedAuthToken:j,setEditedManagementKey:b,onSaveHost:v,onSavePort:N,onSaveAuthToken:C,onSaveManagementKey:n,onSaveConfig:d,onTestConnection:m}){const a=s.remote,P=o=>o==="https"?443:8317;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(B,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(w,{value:u,onChange:o=>f(o.target.value),onBlur:v,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",P(s.remote.protocol||"http"),")"]})]}),e.jsx(w,{type:"text",inputMode:"numeric",value:g,onChange:o=>y(o.target.value.replace(/\D/g,"")),onBlur:N,placeholder:`Leave empty for ${P(s.remote.protocol||"http")}`,className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(te,{value:s.remote.protocol||"http",onValueChange:o=>d({remote:{...a,protocol:o}}),disabled:t,children:[e.jsx(se,{children:e.jsx(ae,{})}),e.jsxs(oe,{children:[e.jsx(_,{value:"http",children:"HTTP"}),e.jsx(_,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(w,{type:"password",value:p,onChange:o=>j(o.target.value),onBlur:C,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(w,{type:"password",value:i,onChange:o=>b(o.target.value),onBlur:n,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx($,{onClick:m,disabled:l||!u,variant:"outline",className:"w-full",children:l?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),c&&e.jsx("div",{className:`p-3 rounded-md ${c.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:c.reachable?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",c.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:c.error||"Connection failed"})]})})})]})]})}function Se(){const{config:s,loading:t,saving:l,error:c,success:u,testResult:g,testing:p,editedHost:i,setEditedHost:f,editedPort:y,setEditedPort:j,editedAuthToken:b,setEditedAuthToken:v,editedManagementKey:N,setEditedManagementKey:C,editedLocalPort:n,setEditedLocalPort:d,fetchConfig:m,saveConfig:a,testConnection:P}=ue(),{fetchRawConfig:o}=re();if(h.useEffect(()=>{m(),o()},[m,o]),t||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(R,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const x=s.remote.enabled??!1,k=s.remote,S=s.fallback,U=s.remote.host??"",V=s.remote.port!==void 0?s.remote.port.toString():"",W=s.remote.auth_token??"",z=s.remote.management_key??"",q=(s.local.port??8317).toString(),E=i??U,A=y??V,I=b??W,H=N??z,K=n??q,O=()=>{const r=i??E;r!==s.remote.host&&a({remote:{...k,host:r}}),f(null)},G=()=>{const r=y??A,T=r===""?void 0:parseInt(r,10),F=T&&!isNaN(T)&&T>0?T:void 0;F!==s.remote.port&&a({remote:{...k,port:F}}),j(null)},Q=()=>{const r=b??I;r!==s.remote.auth_token&&a({remote:{...k,auth_token:r}}),v(null)},J=()=>{const r=N??H;r!==s.remote.management_key&&a({remote:{...k,management_key:r||void 0}}),C(null)},X=()=>{const r=parseInt(n??K,10);!isNaN(r)&&r!==s.local.port&&a({local:{...s.local,port:r}}),d(null)},Y=()=>{P({host:E,port:A,protocol:s.remote.protocol||"http",authToken:I})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${c||u?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(ne,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(me,{className:"h-4 w-4"}),e.jsx(le,{children:c})]}),u&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(D,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(ce,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure local or remote CLIProxy Plus connection for proxy-based profiles"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>a({remote:{...k,enabled:!1}}),disabled:l,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(xe,{className:`w-5 h-5 ${x?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Run CLIProxy Plus binary on this machine"})]}),e.jsxs("button",{onClick:()=>a({remote:{...k,enabled:!0}}),disabled:l,className:`p-4 rounded-lg border-2 text-left transition-all ${x?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(B,{className:`w-5 h-5 ${x?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect to a remote CLIProxy Plus server"})]})]})]}),x&&e.jsx(pe,{config:s,saving:l,testing:p,testResult:g,displayHost:E,displayPort:A,displayAuthToken:I,displayManagementKey:H,setEditedHost:f,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:C,onSaveHost:O,onSavePort:G,onSaveAuthToken:Q,onSaveManagementKey:J,onSaveConfig:a,onTestConnection:Y}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(M,{checked:S.enabled??!0,onCheckedChange:r=>a({fallback:{...S,enabled:r}}),disabled:l||!x})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(M,{checked:S.auto_start??!1,onCheckedChange:r=>a({fallback:{...S,auto_start:r}}),disabled:l||!x||!S.enabled})]})]})]}),!x&&e.jsx(he,{config:s,saving:l,displayLocalPort:K,setEditedLocalPort:d,onSaveLocalPort:X,onSaveConfig:a})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs($,{variant:"outline",size:"sm",onClick:()=>{m(),o()},disabled:t||l,className:"w-full",children:[e.jsx(R,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"Refresh"]})})]})}export{Se as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-CBgg0XeO.js";import{r as i}from"./react-vendor-B_CU-WTZ.js";import{aG as $,aH as F,I as P,aI as U,aD as _,aF as B,i as D,a as H}from"./index-D8K1YCe7.js";import{S as K}from"./switch-CmGBdPfU.js";import{t as z,j as q,D as J,J as V,m as Y,a0 as L,V as X,n as Z}from"./icons-CZDQWWm2.js";import"./tanstack-CxYN0q6L.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Q(){const{state:s}=$(),a=F(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),p=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,p]),g=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,p]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:p,saveGeminiModel:x,saveOpencodeModel:g}}function O({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:p,modelPlaceholder:x,showHint:g,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",y=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",E=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",I=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(z,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(K,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(P,{value:u,onChange:M=>S(M.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),p&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(q,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!g),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${E}`,children:[g?e.jsx(J,{className:"w-4 h-4"}):e.jsx(V,{className:"w-4 h-4"}),"How to install ",I," CLI"]}),g&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${y}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function ce(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:p,fetchConfig:x,fetchStatus:g,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=Q(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[y,E]=i.useState(!1),[I,M]=i.useState(!1);i.useEffect(()=>{x(),g(),n()},[x,g,n]);const N=s?.providers?.gemini?.enabled??!1,W=s?.providers?.grok?.enabled??!1,G=s?.providers?.opencode?.enabled??!1,A=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||W||G,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},R=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||G,providers:{...c,grok:{...c.grok,enabled:!b}}})},T=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||W||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(L,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${m||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx(B,{children:m})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Z,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(D,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(H,{variant:"ghost",size:"sm",onClick:g,disabled:l,children:e.jsx(L,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),e.jsx(O,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:A,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(O,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:G,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:T,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:p,modelPlaceholder:"opencode/grok-code",showHint:y,setShowHint:E,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(O,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:W,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,showHint:I,setShowHint:M,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(H,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(L,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{ce as default};
1
+ import{j as e}from"./radix-ui-CBgg0XeO.js";import{r as i}from"./react-vendor-B_CU-WTZ.js";import{aG as $,aH as F,I as P,aI as U,aD as _,aF as B,i as D,a as H}from"./index-B7MyxZLG.js";import{S as K}from"./switch-Kx7oj3ow.js";import{t as z,j as q,D as J,J as V,m as Y,a0 as L,V as X,n as Z}from"./icons-CZDQWWm2.js";import"./tanstack-CxYN0q6L.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Q(){const{state:s}=$(),a=F(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),p=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,p]),g=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,p]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:p,saveGeminiModel:x,saveOpencodeModel:g}}function O({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:p,modelPlaceholder:x,showHint:g,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",y=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",E=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",I=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(z,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(K,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(P,{value:u,onChange:M=>S(M.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),p&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(q,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!g),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${E}`,children:[g?e.jsx(J,{className:"w-4 h-4"}):e.jsx(V,{className:"w-4 h-4"}),"How to install ",I," CLI"]}),g&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${y}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function ce(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:p,fetchConfig:x,fetchStatus:g,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=Q(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[y,E]=i.useState(!1),[I,M]=i.useState(!1);i.useEffect(()=>{x(),g(),n()},[x,g,n]);const N=s?.providers?.gemini?.enabled??!1,W=s?.providers?.grok?.enabled??!1,G=s?.providers?.opencode?.enabled??!1,A=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||W||G,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},R=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||G,providers:{...c,grok:{...c.grok,enabled:!b}}})},T=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||W||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(L,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${m||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx(B,{children:m})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Z,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(D,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(H,{variant:"ghost",size:"sm",onClick:g,disabled:l,children:e.jsx(L,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),e.jsx(O,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:A,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(O,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:G,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:T,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:p,modelPlaceholder:"opencode/grok-code",showHint:y,setShowHint:E,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(O,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:W,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,showHint:I,setShowHint:M,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(H,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(L,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{ce as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-CBgg0XeO.js";import{r as f,c as fe}from"./react-vendor-B_CU-WTZ.js";import{u as M,S as h,c as d,P as y,B as I,a as H,b as ee,d as pe,e as se,C as ge,g as te,f as je,h as Ne,i as ye,j as be}from"./index-D8K1YCe7.js";import{C as p,a as g,b as N,c as S}from"./card-BmnReIPp.js";import{x as we,a2 as ae,a3 as z,a4 as re,v as ne,Q as ve,G as ke,a5 as Ce,a0 as $e,t as Y,U as Se,Z as le,q as Le,_ as G,a6 as De,s as Te,b as Fe,a7 as Re,a8 as Me}from"./icons-CZDQWWm2.js";import{u as Pe,a as P}from"./tanstack-CxYN0q6L.js";import{K as D,L as Q,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as ie,A as Be,C as Ue,X as qe,Y as V,T as oe,a as Z,P as Ie,b as Oe,c as Ke}from"./charts-CJC4bH8P.js";import"./notifications-dJQY2-U6.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Ee({data:s,isLoading:t}){const{privacyMode:a}=M();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(o=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},o))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:"Total Tokens",value:s?.totalTokens??0,icon:we,format:o=>R(o),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${R(s?.totalInputTokens??0)} in / ${R(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:o=>`$${o.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:z,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${l.toFixed(2)} (${r}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:o=>`$${o.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${R(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:o=>`$${o.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${R(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:i.map((o,n)=>{const c=o.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:o.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&y),children:o.format(o.value)}),o.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&y),children:o.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",o.bgColor),children:e.jsx(c,{className:d("h-4 w-4",o.color)})})]})})},n)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ge({model:s}){const{privacyMode:t}=M(),a=We(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&y),children:_e(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:d("space-y-1",t&&y),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function W({label:s,tokens:t,cost:a,color:l,icon:r}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:l}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:He(t)})]})]})]})}function We(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function He(s){return s.toLocaleString()}function _e(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const ze="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${t}${a}${l}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),L(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${ze}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||a.statusText)}const l=await a.json();return l.data||l}function Qe(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Ye(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Xe(){const s=Pe();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:D(new Date,30),to:new Date}),[a,l]=f.useState(!1),[r,i]=f.useState(null),[o,n]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{l(!0);try{await u()}finally{l(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:b,isLoading:v}=Qe(j),{data:C,isLoading:$}=Ye(j),{data:A,isLoading:B}=Ve(j),{data:U,isLoading:q}=Ze(j),{data:_,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:D(F,1),to:F}),x("hourly")},[]),de=f.useCallback(F=>{t(F),x("daily")},[]),xe=f.useMemo(()=>K?.lastFetch?Q(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),ue=f.useCallback((F,he)=>{const E=he.currentTarget.getBoundingClientRect();n({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:$,isHourlyLoading:B,isModelsLoading:q,isSessionsLoading:O,isLoading:v||$||q||O,handleRefresh:m,handleTodayClick:ce,handleDateRangeChange:de,handleModelClick:ue,handlePopoverClose:me,lastUpdatedText:xe}}function ts({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:D(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:D(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:D(new Date,90),to:new Date}}],className:l}){const[r,i]=fe.useState(!1),o=n=>!s||!s.from||!s.to||!n.from||!n.to?!1:k(s.from,"yyyy-MM-dd")===k(n.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(n.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",l),children:[a.map(n=>e.jsx(H,{variant:o(n.range)?"default":"outline",size:"sm",onClick:()=>t(n.range),children:n.label},n.label)),e.jsxs(ee,{open:r,onOpenChange:i,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:d("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(ge,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:l,isRefreshing:r,lastUpdatedText:i,viewMode:o}){return e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(ts,{value:s,onChange:t,presets:[{label:"7D",range:{from:D(new Date,7),to:new Date}},{label:"30D",range:{from:D(new Date,30),to:new Date}},{label:"Month",range:{from:Ae(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",i]}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:l,disabled:r,children:e.jsx($e,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]})]})}function rs({data:s,isLoading:t,granularity:a="daily",className:l}){const{privacyMode:r}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(c=>{const x="hour"in c?c.hour:c.date;return{...c,dateFormatted:ns(x,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",l)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",l),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:n,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:n,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",r&&"blur-[4px]"),children:m})};return e.jsx("div",{className:d("w-full h-full",l),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Be,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(o,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(o,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:n,payload:c,label:x})=>{if(!n||!c||!c.length)return null;const u=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),c.map((m,j)=>e.jsxs("p",{className:d("text-sm",r&&y),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",r&&y),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ns(s,t){if(t==="hourly"){const[l,r]=s.split(" ");if(l&&r){const i=new Date(`${l}T${r}:00Z`);return k(i,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(n=>({name:n.model,value:n.tokens,cost:n.cost,percentage:n.percentage,fill:te(n.model)})),[s]);if(t)return e.jsx(h,{className:d("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:n,payload:c})=>{if(!n||!c)return null;const x=c;if(!x.length)return null;const u=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:["$",u.cost.toFixed(4)]})]})},o=n=>n.percentage>5?`${n.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Oe,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:o,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((n,c)=>e.jsx(Ke,{fill:n.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(oe,{content:i})]})})})}function is(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function os({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,n=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(n/i.length),u=i.reduce((b,v)=>b+v.cost,0)/i.length,m=i[0],j=m?Q(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:o,avgTokens:c,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):r?e.jsxs(p,{className:d("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",l&&y),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:r.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:i.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Q(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",l&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[cs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function cs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ds({className:s,isLoading:t}){const{data:a,isLoading:l}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||l||a?.running&&i)return e.jsxs(p,{className:d("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(p,{className:d("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(o)return e.jsxs(p,{className:d("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=r?.totalRequests??0,x=r?.quotaExceededCount??0,u=c-x,m=c>0?Math.round(u/c*100):100,j=r?.tokens?.total??0,b=Object.entries(r?.requestsByModel??{}).sort((C,$)=>$[1]-C[1]).slice(0,4),v=b.length>0?b[0][1]:1;return e.jsxs(p,{className:d("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:x>0?`${x} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(De,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Te,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:b.map(([C,$])=>{const A=Math.round($/v*100),B=xs(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:B}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:$})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${A}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ms({models:s,isLoading:t,onModelClick:a,privacyMode:l}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>a(r,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(hs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",l&&y),children:us(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",l&&y),children:["$",r.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(fs,{})]})})]})}function hs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function fs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function ps({viewMode:s,trends:t,hourlyData:a,models:l,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:n,isSessionsLoading:c,isSummaryLoading:x,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(p,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(rs,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsx(ms,{models:l,isLoading:n,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:l||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(os,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(ds,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ls(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ds(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:l,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n,summary:c,isSummaryLoading:x,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,handleModelClick:B,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ss();return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:a,onTodayClick:l,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(ps,{viewMode:n,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,isSummaryLoading:x,onModelClick:B}),e.jsxs(ee,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(Ge,{model:U})})]})]})}export{Ds as AnalyticsPage,Ls as AnalyticsSkeleton};
1
+ import{j as e}from"./radix-ui-CBgg0XeO.js";import{r as f,c as fe}from"./react-vendor-B_CU-WTZ.js";import{u as M,S as h,c as d,P as y,B as I,a as H,b as ee,d as pe,e as se,C as ge,g as te,f as je,h as Ne,i as ye,j as be}from"./index-B7MyxZLG.js";import{C as p,a as g,b as N,c as S}from"./card-nbrHgs37.js";import{x as we,a2 as ae,a3 as z,a4 as re,v as ne,Q as ve,G as ke,a5 as Ce,a0 as $e,t as Y,U as Se,Z as le,q as Le,_ as G,a6 as De,s as Te,b as Fe,a7 as Re,a8 as Me}from"./icons-CZDQWWm2.js";import{u as Pe,a as P}from"./tanstack-CxYN0q6L.js";import{K as D,L as Q,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as ie,A as Be,C as Ue,X as qe,Y as V,T as oe,a as Z,P as Ie,b as Oe,c as Ke}from"./charts-CJC4bH8P.js";import"./notifications-dJQY2-U6.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Ee({data:s,isLoading:t}){const{privacyMode:a}=M();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(o=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},o))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:"Total Tokens",value:s?.totalTokens??0,icon:we,format:o=>R(o),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${R(s?.totalInputTokens??0)} in / ${R(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:o=>`$${o.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:z,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${l.toFixed(2)} (${r}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:o=>`$${o.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${R(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:o=>`$${o.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${R(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:i.map((o,n)=>{const c=o.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:o.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&y),children:o.format(o.value)}),o.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&y),children:o.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",o.bgColor),children:e.jsx(c,{className:d("h-4 w-4",o.color)})})]})})},n)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ge({model:s}){const{privacyMode:t}=M(),a=We(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&y),children:_e(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:d("space-y-1",t&&y),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function W({label:s,tokens:t,cost:a,color:l,icon:r}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:l}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:He(t)})]})]})]})}function We(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function He(s){return s.toLocaleString()}function _e(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const ze="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${t}${a}${l}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),L(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${ze}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||a.statusText)}const l=await a.json();return l.data||l}function Qe(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Ye(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Xe(){const s=Pe();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:D(new Date,30),to:new Date}),[a,l]=f.useState(!1),[r,i]=f.useState(null),[o,n]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{l(!0);try{await u()}finally{l(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:b,isLoading:v}=Qe(j),{data:C,isLoading:$}=Ye(j),{data:A,isLoading:B}=Ve(j),{data:U,isLoading:q}=Ze(j),{data:_,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:D(F,1),to:F}),x("hourly")},[]),de=f.useCallback(F=>{t(F),x("daily")},[]),xe=f.useMemo(()=>K?.lastFetch?Q(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),ue=f.useCallback((F,he)=>{const E=he.currentTarget.getBoundingClientRect();n({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:$,isHourlyLoading:B,isModelsLoading:q,isSessionsLoading:O,isLoading:v||$||q||O,handleRefresh:m,handleTodayClick:ce,handleDateRangeChange:de,handleModelClick:ue,handlePopoverClose:me,lastUpdatedText:xe}}function ts({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:D(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:D(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:D(new Date,90),to:new Date}}],className:l}){const[r,i]=fe.useState(!1),o=n=>!s||!s.from||!s.to||!n.from||!n.to?!1:k(s.from,"yyyy-MM-dd")===k(n.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(n.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",l),children:[a.map(n=>e.jsx(H,{variant:o(n.range)?"default":"outline",size:"sm",onClick:()=>t(n.range),children:n.label},n.label)),e.jsxs(ee,{open:r,onOpenChange:i,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:d("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(ge,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:l,isRefreshing:r,lastUpdatedText:i,viewMode:o}){return e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(ts,{value:s,onChange:t,presets:[{label:"7D",range:{from:D(new Date,7),to:new Date}},{label:"30D",range:{from:D(new Date,30),to:new Date}},{label:"Month",range:{from:Ae(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",i]}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:l,disabled:r,children:e.jsx($e,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]})]})}function rs({data:s,isLoading:t,granularity:a="daily",className:l}){const{privacyMode:r}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(c=>{const x="hour"in c?c.hour:c.date;return{...c,dateFormatted:ns(x,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",l)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",l),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:n,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:n,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",r&&"blur-[4px]"),children:m})};return e.jsx("div",{className:d("w-full h-full",l),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Be,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(o,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(o,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:n,payload:c,label:x})=>{if(!n||!c||!c.length)return null;const u=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),c.map((m,j)=>e.jsxs("p",{className:d("text-sm",r&&y),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",r&&y),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ns(s,t){if(t==="hourly"){const[l,r]=s.split(" ");if(l&&r){const i=new Date(`${l}T${r}:00Z`);return k(i,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(n=>({name:n.model,value:n.tokens,cost:n.cost,percentage:n.percentage,fill:te(n.model)})),[s]);if(t)return e.jsx(h,{className:d("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:n,payload:c})=>{if(!n||!c)return null;const x=c;if(!x.length)return null;const u=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:["$",u.cost.toFixed(4)]})]})},o=n=>n.percentage>5?`${n.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Oe,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:o,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((n,c)=>e.jsx(Ke,{fill:n.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(oe,{content:i})]})})})}function is(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function os({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,n=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(n/i.length),u=i.reduce((b,v)=>b+v.cost,0)/i.length,m=i[0],j=m?Q(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:o,avgTokens:c,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):r?e.jsxs(p,{className:d("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",l&&y),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:r.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:i.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Q(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",l&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[cs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function cs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ds({className:s,isLoading:t}){const{data:a,isLoading:l}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||l||a?.running&&i)return e.jsxs(p,{className:d("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(p,{className:d("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(o)return e.jsxs(p,{className:d("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=r?.totalRequests??0,x=r?.quotaExceededCount??0,u=c-x,m=c>0?Math.round(u/c*100):100,j=r?.tokens?.total??0,b=Object.entries(r?.requestsByModel??{}).sort((C,$)=>$[1]-C[1]).slice(0,4),v=b.length>0?b[0][1]:1;return e.jsxs(p,{className:d("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:x>0?`${x} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(De,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Te,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:b.map(([C,$])=>{const A=Math.round($/v*100),B=xs(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:B}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:$})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${A}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ms({models:s,isLoading:t,onModelClick:a,privacyMode:l}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>a(r,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(hs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",l&&y),children:us(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",l&&y),children:["$",r.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(fs,{})]})})]})}function hs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function fs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function ps({viewMode:s,trends:t,hourlyData:a,models:l,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:n,isSessionsLoading:c,isSummaryLoading:x,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(p,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(rs,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsx(ms,{models:l,isLoading:n,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:l||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(os,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(ds,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ls(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ds(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:l,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n,summary:c,isSummaryLoading:x,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,handleModelClick:B,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ss();return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:a,onTodayClick:l,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(ps,{viewMode:n,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,isSummaryLoading:x,onModelClick:B}),e.jsxs(ee,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(Ge,{model:U})})]})]})}export{Ds as AnalyticsPage,Ls as AnalyticsSkeleton};
@@ -1 +1 @@
1
- import{j as s}from"./radix-ui-CBgg0XeO.js";import{r as d}from"./react-vendor-B_CU-WTZ.js";import{C as l,a as m}from"./card-BmnReIPp.js";import{aB as c,aC as x,aD as u,aE as h,aF as p,a as g}from"./index-D8K1YCe7.js";import{x as j,Q as f,ay as N,T as b}from"./icons-CZDQWWm2.js";import"./tanstack-CxYN0q6L.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function E(){const[t,r]=d.useState("commands"),{data:e}=c(),{data:n,isLoading:i}=x(t),o=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(u,{variant:"warning",children:[s.jsx(b,{className:"h-4 w-4"}),s.jsx(h,{children:"Configuration Required"}),s.jsxs(p,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:o.map(a=>s.jsxs(g,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>r(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:i?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(l,{children:s.jsxs(m,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{E as SharedPage};
1
+ import{j as s}from"./radix-ui-CBgg0XeO.js";import{r as d}from"./react-vendor-B_CU-WTZ.js";import{C as l,a as m}from"./card-nbrHgs37.js";import{aB as c,aC as x,aD as u,aE as h,aF as p,a as g}from"./index-B7MyxZLG.js";import{x as j,Q as f,ay as N,T as b}from"./icons-CZDQWWm2.js";import"./tanstack-CxYN0q6L.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function E(){const[t,r]=d.useState("commands"),{data:e}=c(),{data:n,isLoading:i}=x(t),o=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(u,{variant:"warning",children:[s.jsx(b,{className:"h-4 w-4"}),s.jsx(h,{children:"Configuration Required"}),s.jsxs(p,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:o.map(a=>s.jsxs(g,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>r(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:i?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(l,{children:s.jsxs(m,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{E as SharedPage};
@@ -1 +1 @@
1
- import{j as a,a8 as s,a9 as n}from"./radix-ui-CBgg0XeO.js";import"./react-vendor-B_CU-WTZ.js";import{c as e}from"./index-D8K1YCe7.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
1
+ import{j as a,a8 as s,a9 as n}from"./radix-ui-CBgg0XeO.js";import"./react-vendor-B_CU-WTZ.js";import{c as e}from"./index-B7MyxZLG.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
@@ -24,7 +24,7 @@
24
24
  href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
25
25
  rel="stylesheet"
26
26
  />
27
- <script type="module" crossorigin src="/assets/index-D8K1YCe7.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-B7MyxZLG.js"></script>
28
28
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-B_CU-WTZ.js">
29
29
  <link rel="modulepreload" crossorigin href="/assets/radix-ui-CBgg0XeO.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/tanstack-CxYN0q6L.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "7.18.0-dev.3",
3
+ "version": "7.18.0-dev.4",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
5
5
  "keywords": [
6
6
  "cli",