@chenpu17/cc-gw 0.7.20 → 0.7.21

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.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/src/server/dist/index.js +42 -27
  3. package/src/web/dist/assets/{About-CE2fqYju.js → About-Bjq70P_K.js} +2 -2
  4. package/src/web/dist/assets/{ApiKeys-jnqKcfat.js → ApiKeys-BHwlIBRG.js} +1 -1
  5. package/src/web/dist/assets/{Dashboard-B61eM9AQ.js → Dashboard-Bv6E5M2u.js} +1 -1
  6. package/src/web/dist/assets/{Events-DXUNZen5.js → Events-DyqUKr1b.js} +1 -1
  7. package/src/web/dist/assets/{Help-DTQVUeCR.js → Help-BNn_Zuo4.js} +1 -1
  8. package/src/web/dist/assets/{Login-BcTP1zb_.js → Login-BHXuuVq3.js} +1 -1
  9. package/src/web/dist/assets/Logs-CRnJOy2J.js +6 -0
  10. package/src/web/dist/assets/{ModelManagement-D2ZQEDua.js → ModelManagement-DAE8AYAE.js} +1 -1
  11. package/src/web/dist/assets/{PageHeader-D2Zq1K4t.js → PageHeader-D2u2opjK.js} +1 -1
  12. package/src/web/dist/assets/{PageSection-wWtyIp2D.js → PageSection-jfq2rgUu.js} +1 -1
  13. package/src/web/dist/assets/Settings-CssUPWdg.js +6 -0
  14. package/src/web/dist/assets/{Skeleton-BRSmcxNh.js → Skeleton-BwMNCVcg.js} +1 -1
  15. package/src/web/dist/assets/{card-Dl49soGw.js → card-C9wVDhpJ.js} +1 -1
  16. package/src/web/dist/assets/{dialog-CW6Z62O9.js → dialog-DbEoPxgf.js} +1 -1
  17. package/src/web/dist/assets/{index-Cu1IXjrr.js → index-BjqieXJo.js} +1 -1
  18. package/src/web/dist/assets/{index-Bdp0nMlR.js → index-Blclkvp7.js} +4 -4
  19. package/src/web/dist/assets/{info-Yuz8DmBH.js → info-BmVX8zJd.js} +1 -1
  20. package/src/web/dist/assets/{input-B6w5gzdL.js → input-CGgq_gCJ.js} +1 -1
  21. package/src/web/dist/assets/{label-CuU6RIsU.js → label-BGUvZ4t2.js} +1 -1
  22. package/src/web/dist/assets/{refresh-cw-Duv0QKyb.js → refresh-cw-D7rJxbFV.js} +1 -1
  23. package/src/web/dist/assets/{select-Cfzsn-JK.js → select-Chuh7X1A.js} +1 -1
  24. package/src/web/dist/assets/{shield--mDWO-No.js → shield-Beuqdf31.js} +1 -1
  25. package/src/web/dist/assets/{switch-DoT-Ur3p.js → switch-XbPwmM_b.js} +1 -1
  26. package/src/web/dist/assets/{useApiQuery-CL9_n4sn.js → useApiQuery-DiX6xcfY.js} +1 -1
  27. package/src/web/dist/index.html +1 -1
  28. package/src/web/dist/assets/Logs-Cy6rL2PL.js +0 -6
  29. package/src/web/dist/assets/Settings-Bz_Hag2N.js +0 -6
@@ -1,4 +1,4 @@
1
- import{c}from"./index-Bdp0nMlR.js";/**
1
+ import{c}from"./index-Blclkvp7.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as s,j as i,a as n}from"./index-Bdp0nMlR.js";const a=s.forwardRef(({className:e,type:r,...o},t)=>i.jsx("input",{type:r,className:n("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...o}));a.displayName="Input";export{a as I};
1
+ import{r as s,j as i,a as n}from"./index-Blclkvp7.js";const a=s.forwardRef(({className:e,type:r,...o},t)=>i.jsx("input",{type:r,className:n("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...o}));a.displayName="Input";export{a as I};
@@ -1 +1 @@
1
- import{r as o,j as r,a as t}from"./index-Bdp0nMlR.js";const l=o.forwardRef(({className:e,...a},s)=>r.jsx("label",{ref:s,className:t("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...a}));l.displayName="Label";export{l as L};
1
+ import{r as o,j as r,a as t}from"./index-Blclkvp7.js";const l=o.forwardRef(({className:e,...a},s)=>r.jsx("label",{ref:s,className:t("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...a}));l.displayName="Label";export{l as L};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-Bdp0nMlR.js";/**
1
+ import{c as e}from"./index-Blclkvp7.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as Pe,r as n,o as Re,a5 as mt,p as be,j as r,R as ht,q as vt,v as Ie,a6 as gt,w as k,a7 as $,P as j,a8 as St,A as xt,x as P,z as wt,f as Ee,a9 as yt,D as Ct,H as It,E as Tt,G as bt,I as Nt,J as Pt,K as Rt,M as Et,a as G,Z as _t}from"./index-Bdp0nMlR.js";/**
1
+ import{c as Pe,r as n,o as Re,a5 as mt,p as be,j as r,R as ht,q as vt,v as Ie,a6 as gt,w as k,a7 as $,P as j,a8 as St,A as xt,x as P,z as wt,f as Ee,a9 as yt,D as Ct,H as It,E as Tt,G as bt,I as Nt,J as Pt,K as Rt,M as Et,a as G,Z as _t}from"./index-Blclkvp7.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-Bdp0nMlR.js";/**
1
+ import{c as e}from"./index-Blclkvp7.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as s,w as C,p as I,j as a,q as M,P as y,x as H,a4 as q,a as g}from"./index-Bdp0nMlR.js";import{u as A}from"./select-Cfzsn-JK.js";var b="Switch",[U]=M(b),[z,L]=U(b),P=s.forwardRef((t,o)=>{const{__scopeSwitch:e,name:n,checked:r,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:w,form:i,...v}=t,[l,p]=s.useState(null),S=C(o,h=>p(h)),k=s.useRef(!1),x=l?i||!!l.closest("form"):!0,[f,B]=I({prop:r,defaultProp:m??!1,onChange:w,caller:b});return a.jsxs(z,{scope:e,checked:f,disabled:c,children:[a.jsx(y.button,{type:"button",role:"switch","aria-checked":f,"aria-required":d,"data-state":j(f),"data-disabled":c?"":void 0,disabled:c,value:u,...v,ref:S,onClick:H(t.onClick,h=>{B(T=>!T),x&&(k.current=h.isPropagationStopped(),k.current||h.stopPropagation())})}),x&&a.jsx(N,{control:l,bubbles:!k.current,name:n,value:u,checked:f,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});P.displayName=b;var E="SwitchThumb",R=s.forwardRef((t,o)=>{const{__scopeSwitch:e,...n}=t,r=L(E,e);return a.jsx(y.span,{"data-state":j(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:o})});R.displayName=E;var O="SwitchBubbleInput",N=s.forwardRef(({__scopeSwitch:t,control:o,checked:e,bubbles:n=!0,...r},m)=>{const d=s.useRef(null),c=C(d,m),u=A(e),w=q(o);return s.useEffect(()=>{const i=d.current;if(!i)return;const v=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(v,"checked").set;if(u!==e&&p){const S=new Event("click",{bubbles:n});p.call(i,e),i.dispatchEvent(S)}},[u,e,n]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:e,...r,tabIndex:-1,ref:c,style:{...r.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});N.displayName=O;function j(t){return t?"checked":"unchecked"}var _=P,D=R;const F=s.forwardRef(({className:t,...o},e)=>a.jsx(_,{className:g("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...o,ref:e,children:a.jsx(D,{className:g("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));F.displayName=_.displayName;export{F as S};
1
+ import{r as s,w as C,p as I,j as a,q as M,P as y,x as H,a4 as q,a as g}from"./index-Blclkvp7.js";import{u as A}from"./select-Chuh7X1A.js";var b="Switch",[U]=M(b),[z,L]=U(b),P=s.forwardRef((t,o)=>{const{__scopeSwitch:e,name:n,checked:r,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:w,form:i,...v}=t,[l,p]=s.useState(null),S=C(o,h=>p(h)),k=s.useRef(!1),x=l?i||!!l.closest("form"):!0,[f,B]=I({prop:r,defaultProp:m??!1,onChange:w,caller:b});return a.jsxs(z,{scope:e,checked:f,disabled:c,children:[a.jsx(y.button,{type:"button",role:"switch","aria-checked":f,"aria-required":d,"data-state":j(f),"data-disabled":c?"":void 0,disabled:c,value:u,...v,ref:S,onClick:H(t.onClick,h=>{B(T=>!T),x&&(k.current=h.isPropagationStopped(),k.current||h.stopPropagation())})}),x&&a.jsx(N,{control:l,bubbles:!k.current,name:n,value:u,checked:f,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});P.displayName=b;var E="SwitchThumb",R=s.forwardRef((t,o)=>{const{__scopeSwitch:e,...n}=t,r=L(E,e);return a.jsx(y.span,{"data-state":j(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:o})});R.displayName=E;var O="SwitchBubbleInput",N=s.forwardRef(({__scopeSwitch:t,control:o,checked:e,bubbles:n=!0,...r},m)=>{const d=s.useRef(null),c=C(d,m),u=A(e),w=q(o);return s.useEffect(()=>{const i=d.current;if(!i)return;const v=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(v,"checked").set;if(u!==e&&p){const S=new Event("click",{bubbles:n});p.call(i,e),i.dispatchEvent(S)}},[u,e,n]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:e,...r,tabIndex:-1,ref:c,style:{...r.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});N.displayName=O;function j(t){return t?"checked":"unchecked"}var _=P,D=R;const F=s.forwardRef(({className:t,...o},e)=>a.jsx(_,{className:g("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...o,ref:e,children:a.jsx(D,{className:g("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));F.displayName=_.displayName;export{F as S};
@@ -1 +1 @@
1
- var ft=e=>{throw TypeError(e)};var Y=(e,t,s)=>t.has(e)||ft("Cannot "+s);var i=(e,t,s)=>(Y(e,t,"read from private field"),s?s.call(e):t.get(e)),b=(e,t,s)=>t.has(e)?ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),u=(e,t,s,r)=>(Y(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),d=(e,t,s)=>(Y(e,t,"access private method"),s);import{S as It,ab as pt,ac as S,s as Z,ad as j,l as $,ae as tt,af as bt,ag as Ot,ah as q,ai as Tt,aj as wt,ak as yt,n as St,r as I,m as Qt,k as Mt,al as xt,d as _t,t as Ut}from"./index-Bdp0nMlR.js";var g,a,H,y,Q,U,E,O,z,F,D,M,x,T,P,n,B,et,st,it,rt,at,nt,ht,Ct,vt,Ft=(vt=class extends It{constructor(t,s){super();b(this,n);b(this,g);b(this,a);b(this,H);b(this,y);b(this,Q);b(this,U);b(this,E);b(this,O);b(this,z);b(this,F);b(this,D);b(this,M);b(this,x);b(this,T);b(this,P,new Set);this.options=s,u(this,g,t),u(this,O,null),u(this,E,pt()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,a).addObserver(this),gt(i(this,a),this.options)?d(this,n,B).call(this):this.updateResult(),d(this,n,rt).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ot(i(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ot(i(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,d(this,n,at).call(this),d(this,n,nt).call(this),i(this,a).removeObserver(this)}setOptions(t){const s=this.options,r=i(this,a);if(this.options=i(this,g).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof S(this.options.enabled,i(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");d(this,n,ht).call(this),i(this,a).setOptions(this.options),s._defaulted&&!Z(this.options,s)&&i(this,g).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,a),observer:this});const h=this.hasListeners();h&&mt(i(this,a),r,this.options,s)&&d(this,n,B).call(this),this.updateResult(),h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||j(this.options.staleTime,i(this,a))!==j(s.staleTime,i(this,a)))&&d(this,n,et).call(this);const o=d(this,n,st).call(this);h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||o!==i(this,T))&&d(this,n,it).call(this,o)}getOptimisticResult(t){const s=i(this,g).getQueryCache().build(i(this,g),t),r=this.createResult(s,t);return Pt(this,r)&&(u(this,y,r),u(this,U,this.options),u(this,Q,i(this,a).state)),r}getCurrentResult(){return i(this,y)}trackResult(t,s){return new Proxy(t,{get:(r,h)=>(this.trackProp(h),s==null||s(h),h==="promise"&&!this.options.experimental_prefetchInRender&&i(this,E).status==="pending"&&i(this,E).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(r,h))})}trackProp(t){i(this,P).add(t)}getCurrentQuery(){return i(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=i(this,g).defaultQueryOptions(t),r=i(this,g).getQueryCache().build(i(this,g),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(t){return d(this,n,B).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,y)))}createResult(t,s){var dt;const r=i(this,a),h=this.options,o=i(this,y),c=i(this,Q),w=i(this,U),v=t!==r?t.state:i(this,H),{state:L}=t;let l={...L},N=!1,f;if(s._optimisticResults){const R=this.hasListeners(),W=!R&&gt(t,s),_=R&&mt(t,r,s,h);(W||_)&&(l={...l,...wt(L.data,t.options)}),s._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:k,errorUpdatedAt:A,status:m}=l;f=l.data;let V=!1;if(s.placeholderData!==void 0&&f===void 0&&m==="pending"){let R;o!=null&&o.isPlaceholderData&&s.placeholderData===(w==null?void 0:w.placeholderData)?(R=o.data,V=!0):R=typeof s.placeholderData=="function"?s.placeholderData((dt=i(this,D))==null?void 0:dt.state.data,i(this,D)):s.placeholderData,R!==void 0&&(m="success",f=yt(o==null?void 0:o.data,R,s),N=!0)}if(s.select&&f!==void 0&&!V)if(o&&f===(c==null?void 0:c.data)&&s.select===i(this,z))f=i(this,F);else try{u(this,z,s.select),f=s.select(f),f=yt(o==null?void 0:o.data,f,s),u(this,F,f),u(this,O,null)}catch(R){u(this,O,R)}i(this,O)&&(k=i(this,O),f=i(this,F),A=Date.now(),m="error");const G=l.fetchStatus==="fetching",J=m==="pending",X=m==="error",ut=J&&G,lt=f!==void 0,C={status:m,fetchStatus:l.fetchStatus,isPending:J,isSuccess:m==="success",isError:X,isInitialLoading:ut,isLoading:ut,data:f,dataUpdatedAt:l.dataUpdatedAt,error:k,errorUpdatedAt:A,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>v.dataUpdateCount||l.errorUpdateCount>v.errorUpdateCount,isFetching:G,isRefetching:G&&!J,isLoadingError:X&&!lt,isPaused:l.fetchStatus==="paused",isPlaceholderData:N,isRefetchError:X&&lt,isStale:ct(t,s),refetch:this.refetch,promise:i(this,E),isEnabled:S(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=K=>{C.status==="error"?K.reject(C.error):C.data!==void 0&&K.resolve(C.data)},W=()=>{const K=u(this,E,C.promise=pt());R(K)},_=i(this,E);switch(_.status){case"pending":t.queryHash===r.queryHash&&R(_);break;case"fulfilled":(C.status==="error"||C.data!==_.value)&&W();break;case"rejected":(C.status!=="error"||C.error!==_.reason)&&W();break}}return C}updateResult(){const t=i(this,y),s=this.createResult(i(this,a),this.options);if(u(this,Q,i(this,a).state),u(this,U,this.options),i(this,Q).data!==void 0&&u(this,D,i(this,a)),Z(s,t))return;u(this,y,s);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:h}=this.options,o=typeof h=="function"?h():h;if(o==="all"||!o&&!i(this,P).size)return!0;const c=new Set(o??i(this,P));return this.options.throwOnError&&c.add("error"),Object.keys(i(this,y)).some(w=>{const p=w;return i(this,y)[p]!==t[p]&&c.has(p)})};d(this,n,Ct).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&d(this,n,rt).call(this)}},g=new WeakMap,a=new WeakMap,H=new WeakMap,y=new WeakMap,Q=new WeakMap,U=new WeakMap,E=new WeakMap,O=new WeakMap,z=new WeakMap,F=new WeakMap,D=new WeakMap,M=new WeakMap,x=new WeakMap,T=new WeakMap,P=new WeakMap,n=new WeakSet,B=function(t){d(this,n,ht).call(this);let s=i(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch($)),s},et=function(){d(this,n,at).call(this);const t=j(this.options.staleTime,i(this,a));if(tt||i(this,y).isStale||!bt(t))return;const r=Ot(i(this,y).dataUpdatedAt,t)+1;u(this,M,q.setTimeout(()=>{i(this,y).isStale||this.updateResult()},r))},st=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,a)):this.options.refetchInterval)??!1},it=function(t){d(this,n,nt).call(this),u(this,T,t),!(tt||S(this.options.enabled,i(this,a))===!1||!bt(i(this,T))||i(this,T)===0)&&u(this,x,q.setInterval(()=>{(this.options.refetchIntervalInBackground||Tt.isFocused())&&d(this,n,B).call(this)},i(this,T)))},rt=function(){d(this,n,et).call(this),d(this,n,it).call(this,d(this,n,st).call(this))},at=function(){i(this,M)&&(q.clearTimeout(i(this,M)),u(this,M,void 0))},nt=function(){i(this,x)&&(q.clearInterval(i(this,x)),u(this,x,void 0))},ht=function(){const t=i(this,g).getQueryCache().build(i(this,g),this.options);if(t===i(this,a))return;const s=i(this,a);u(this,a,t),u(this,H,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ct=function(t){St.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(i(this,y))}),i(this,g).getQueryCache().notify({query:i(this,a),type:"observerResultsUpdated"})})},vt);function Dt(e,t){return S(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gt(e,t){return Dt(e,t)||e.state.data!==void 0&&ot(e,t,t.refetchOnMount)}function ot(e,t,s){if(S(t.enabled,e)!==!1&&j(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ct(e,t)}return!1}function mt(e,t,s,r){return(e!==t||S(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ct(e,s)}function ct(e,t){return S(t.enabled,e)!==!1&&e.isStaleByTime(j(t.staleTime,e))}function Pt(e,t){return!Z(e.getCurrentResult(),t)}var Et=I.createContext(!1),Lt=()=>I.useContext(Et);Et.Provider;function Nt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kt=I.createContext(Nt()),At=()=>I.useContext(kt),Bt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},jt=e=>{I.useEffect(()=>{e.clearReset()},[e])},Ht=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:h})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(h&&e.data===void 0||Qt(s,[e.error,r])),zt=e=>{if(e.suspense){const s=h=>h==="static"?h:Math.max(h??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...h)=>s(r(...h)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vt=(e,t)=>e.isLoading&&e.isFetching&&!t,Wt=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Rt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Kt(e,t,s){var l,N,f,k,A;const r=Lt(),h=At(),o=Mt(),c=o.defaultQueryOptions(e);(N=(l=o.getDefaultOptions().queries)==null?void 0:l._experimental_beforeQuery)==null||N.call(l,c),c._optimisticResults=r?"isRestoring":"optimistic",zt(c),Bt(c,h),jt(h);const w=!o.getQueryCache().get(c.queryHash),[p]=I.useState(()=>new t(o,c)),v=p.getOptimisticResult(c),L=!r&&e.subscribed!==!1;if(I.useSyncExternalStore(I.useCallback(m=>{const V=L?p.subscribe(St.batchCalls(m)):$;return p.updateResult(),V},[p,L]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),I.useEffect(()=>{p.setOptions(c)},[c,p]),Wt(c,v))throw Rt(c,p,h);if(Ht({result:v,errorResetBoundary:h,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw v.error;if((k=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||k.call(f,c,v),c.experimental_prefetchInRender&&!tt&&Vt(v,r)){const m=w?Rt(c,p,h):(A=o.getQueryCache().get(c.queryHash))==null?void 0:A.promise;m==null||m.catch($).finally(()=>{p.updateResult()})}return c.notifyOnChangeProps?v:p.trackResult(v)}function qt(e,t){return Kt(e,Ft)}function Yt(e,t,s){return qt({queryKey:e,placeholderData:xt,...s,queryFn:async()=>{try{return(await _t.request(t)).data}catch(r){throw Ut(r)}}})}export{qt as a,Yt as u};
1
+ var ft=e=>{throw TypeError(e)};var Y=(e,t,s)=>t.has(e)||ft("Cannot "+s);var i=(e,t,s)=>(Y(e,t,"read from private field"),s?s.call(e):t.get(e)),b=(e,t,s)=>t.has(e)?ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),u=(e,t,s,r)=>(Y(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),d=(e,t,s)=>(Y(e,t,"access private method"),s);import{S as It,ab as pt,ac as S,s as Z,ad as j,l as $,ae as tt,af as bt,ag as Ot,ah as q,ai as Tt,aj as wt,ak as yt,n as St,r as I,m as Qt,k as Mt,al as xt,d as _t,t as Ut}from"./index-Blclkvp7.js";var g,a,H,y,Q,U,E,O,z,F,D,M,x,T,P,n,B,et,st,it,rt,at,nt,ht,Ct,vt,Ft=(vt=class extends It{constructor(t,s){super();b(this,n);b(this,g);b(this,a);b(this,H);b(this,y);b(this,Q);b(this,U);b(this,E);b(this,O);b(this,z);b(this,F);b(this,D);b(this,M);b(this,x);b(this,T);b(this,P,new Set);this.options=s,u(this,g,t),u(this,O,null),u(this,E,pt()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,a).addObserver(this),gt(i(this,a),this.options)?d(this,n,B).call(this):this.updateResult(),d(this,n,rt).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ot(i(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ot(i(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,d(this,n,at).call(this),d(this,n,nt).call(this),i(this,a).removeObserver(this)}setOptions(t){const s=this.options,r=i(this,a);if(this.options=i(this,g).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof S(this.options.enabled,i(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");d(this,n,ht).call(this),i(this,a).setOptions(this.options),s._defaulted&&!Z(this.options,s)&&i(this,g).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,a),observer:this});const h=this.hasListeners();h&&mt(i(this,a),r,this.options,s)&&d(this,n,B).call(this),this.updateResult(),h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||j(this.options.staleTime,i(this,a))!==j(s.staleTime,i(this,a)))&&d(this,n,et).call(this);const o=d(this,n,st).call(this);h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||o!==i(this,T))&&d(this,n,it).call(this,o)}getOptimisticResult(t){const s=i(this,g).getQueryCache().build(i(this,g),t),r=this.createResult(s,t);return Pt(this,r)&&(u(this,y,r),u(this,U,this.options),u(this,Q,i(this,a).state)),r}getCurrentResult(){return i(this,y)}trackResult(t,s){return new Proxy(t,{get:(r,h)=>(this.trackProp(h),s==null||s(h),h==="promise"&&!this.options.experimental_prefetchInRender&&i(this,E).status==="pending"&&i(this,E).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(r,h))})}trackProp(t){i(this,P).add(t)}getCurrentQuery(){return i(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=i(this,g).defaultQueryOptions(t),r=i(this,g).getQueryCache().build(i(this,g),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(t){return d(this,n,B).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,y)))}createResult(t,s){var dt;const r=i(this,a),h=this.options,o=i(this,y),c=i(this,Q),w=i(this,U),v=t!==r?t.state:i(this,H),{state:L}=t;let l={...L},N=!1,f;if(s._optimisticResults){const R=this.hasListeners(),W=!R&&gt(t,s),_=R&&mt(t,r,s,h);(W||_)&&(l={...l,...wt(L.data,t.options)}),s._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:k,errorUpdatedAt:A,status:m}=l;f=l.data;let V=!1;if(s.placeholderData!==void 0&&f===void 0&&m==="pending"){let R;o!=null&&o.isPlaceholderData&&s.placeholderData===(w==null?void 0:w.placeholderData)?(R=o.data,V=!0):R=typeof s.placeholderData=="function"?s.placeholderData((dt=i(this,D))==null?void 0:dt.state.data,i(this,D)):s.placeholderData,R!==void 0&&(m="success",f=yt(o==null?void 0:o.data,R,s),N=!0)}if(s.select&&f!==void 0&&!V)if(o&&f===(c==null?void 0:c.data)&&s.select===i(this,z))f=i(this,F);else try{u(this,z,s.select),f=s.select(f),f=yt(o==null?void 0:o.data,f,s),u(this,F,f),u(this,O,null)}catch(R){u(this,O,R)}i(this,O)&&(k=i(this,O),f=i(this,F),A=Date.now(),m="error");const G=l.fetchStatus==="fetching",J=m==="pending",X=m==="error",ut=J&&G,lt=f!==void 0,C={status:m,fetchStatus:l.fetchStatus,isPending:J,isSuccess:m==="success",isError:X,isInitialLoading:ut,isLoading:ut,data:f,dataUpdatedAt:l.dataUpdatedAt,error:k,errorUpdatedAt:A,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>v.dataUpdateCount||l.errorUpdateCount>v.errorUpdateCount,isFetching:G,isRefetching:G&&!J,isLoadingError:X&&!lt,isPaused:l.fetchStatus==="paused",isPlaceholderData:N,isRefetchError:X&&lt,isStale:ct(t,s),refetch:this.refetch,promise:i(this,E),isEnabled:S(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=K=>{C.status==="error"?K.reject(C.error):C.data!==void 0&&K.resolve(C.data)},W=()=>{const K=u(this,E,C.promise=pt());R(K)},_=i(this,E);switch(_.status){case"pending":t.queryHash===r.queryHash&&R(_);break;case"fulfilled":(C.status==="error"||C.data!==_.value)&&W();break;case"rejected":(C.status!=="error"||C.error!==_.reason)&&W();break}}return C}updateResult(){const t=i(this,y),s=this.createResult(i(this,a),this.options);if(u(this,Q,i(this,a).state),u(this,U,this.options),i(this,Q).data!==void 0&&u(this,D,i(this,a)),Z(s,t))return;u(this,y,s);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:h}=this.options,o=typeof h=="function"?h():h;if(o==="all"||!o&&!i(this,P).size)return!0;const c=new Set(o??i(this,P));return this.options.throwOnError&&c.add("error"),Object.keys(i(this,y)).some(w=>{const p=w;return i(this,y)[p]!==t[p]&&c.has(p)})};d(this,n,Ct).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&d(this,n,rt).call(this)}},g=new WeakMap,a=new WeakMap,H=new WeakMap,y=new WeakMap,Q=new WeakMap,U=new WeakMap,E=new WeakMap,O=new WeakMap,z=new WeakMap,F=new WeakMap,D=new WeakMap,M=new WeakMap,x=new WeakMap,T=new WeakMap,P=new WeakMap,n=new WeakSet,B=function(t){d(this,n,ht).call(this);let s=i(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch($)),s},et=function(){d(this,n,at).call(this);const t=j(this.options.staleTime,i(this,a));if(tt||i(this,y).isStale||!bt(t))return;const r=Ot(i(this,y).dataUpdatedAt,t)+1;u(this,M,q.setTimeout(()=>{i(this,y).isStale||this.updateResult()},r))},st=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,a)):this.options.refetchInterval)??!1},it=function(t){d(this,n,nt).call(this),u(this,T,t),!(tt||S(this.options.enabled,i(this,a))===!1||!bt(i(this,T))||i(this,T)===0)&&u(this,x,q.setInterval(()=>{(this.options.refetchIntervalInBackground||Tt.isFocused())&&d(this,n,B).call(this)},i(this,T)))},rt=function(){d(this,n,et).call(this),d(this,n,it).call(this,d(this,n,st).call(this))},at=function(){i(this,M)&&(q.clearTimeout(i(this,M)),u(this,M,void 0))},nt=function(){i(this,x)&&(q.clearInterval(i(this,x)),u(this,x,void 0))},ht=function(){const t=i(this,g).getQueryCache().build(i(this,g),this.options);if(t===i(this,a))return;const s=i(this,a);u(this,a,t),u(this,H,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ct=function(t){St.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(i(this,y))}),i(this,g).getQueryCache().notify({query:i(this,a),type:"observerResultsUpdated"})})},vt);function Dt(e,t){return S(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gt(e,t){return Dt(e,t)||e.state.data!==void 0&&ot(e,t,t.refetchOnMount)}function ot(e,t,s){if(S(t.enabled,e)!==!1&&j(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ct(e,t)}return!1}function mt(e,t,s,r){return(e!==t||S(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ct(e,s)}function ct(e,t){return S(t.enabled,e)!==!1&&e.isStaleByTime(j(t.staleTime,e))}function Pt(e,t){return!Z(e.getCurrentResult(),t)}var Et=I.createContext(!1),Lt=()=>I.useContext(Et);Et.Provider;function Nt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kt=I.createContext(Nt()),At=()=>I.useContext(kt),Bt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},jt=e=>{I.useEffect(()=>{e.clearReset()},[e])},Ht=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:h})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(h&&e.data===void 0||Qt(s,[e.error,r])),zt=e=>{if(e.suspense){const s=h=>h==="static"?h:Math.max(h??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...h)=>s(r(...h)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vt=(e,t)=>e.isLoading&&e.isFetching&&!t,Wt=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Rt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Kt(e,t,s){var l,N,f,k,A;const r=Lt(),h=At(),o=Mt(),c=o.defaultQueryOptions(e);(N=(l=o.getDefaultOptions().queries)==null?void 0:l._experimental_beforeQuery)==null||N.call(l,c),c._optimisticResults=r?"isRestoring":"optimistic",zt(c),Bt(c,h),jt(h);const w=!o.getQueryCache().get(c.queryHash),[p]=I.useState(()=>new t(o,c)),v=p.getOptimisticResult(c),L=!r&&e.subscribed!==!1;if(I.useSyncExternalStore(I.useCallback(m=>{const V=L?p.subscribe(St.batchCalls(m)):$;return p.updateResult(),V},[p,L]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),I.useEffect(()=>{p.setOptions(c)},[c,p]),Wt(c,v))throw Rt(c,p,h);if(Ht({result:v,errorResetBoundary:h,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw v.error;if((k=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||k.call(f,c,v),c.experimental_prefetchInRender&&!tt&&Vt(v,r)){const m=w?Rt(c,p,h):(A=o.getQueryCache().get(c.queryHash))==null?void 0:A.promise;m==null||m.catch($).finally(()=>{p.updateResult()})}return c.notifyOnChangeProps?v:p.trackResult(v)}function qt(e,t){return Kt(e,Ft)}function Yt(e,t,s){return qt({queryKey:e,placeholderData:xt,...s,queryFn:async()=>{try{return(await _t.request(t)).data}catch(r){throw Ut(r)}}})}export{qt as a,Yt as u};
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
6
6
  <meta name="format-detection" content="telephone=no" />
7
7
  <title>cc-gw 控制台</title>
8
- <script type="module" crossorigin src="/assets/index-Bdp0nMlR.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-Blclkvp7.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-B1EJcuR-.css">
10
10
  </head>
11
11
  <body class="bg-slate-50 text-slate-900 dark:bg-slate-900 dark:text-slate-50">
@@ -1,6 +0,0 @@
1
- import{c as $e,u as H,b as ve,r,d as Fe,t as Ke,j as e,e as k,a as D,F as Me,X as Ne,f as Ae}from"./index-Bdp0nMlR.js";import{u as M}from"./useApiQuery-CL9_n4sn.js";import{T as Pe,a as K}from"./Skeleton-BRSmcxNh.js";import{P as ze,B as ee}from"./PageHeader-D2Zq1K4t.js";import{c as Oe}from"./clipboard-CALi6bTW.js";import{I as Z}from"./input-B6w5gzdL.js";import{L as C}from"./label-CuU6RIsU.js";import{C as he,a as fe}from"./card-Dl49soGw.js";import{C as Ie,e as qe,S as I,a as q,b as U,c as B,d as w}from"./select-Cfzsn-JK.js";import{R as Ue}from"./refresh-cw-Duv0QKyb.js";/**
2
- * @license lucide-react v0.344.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Be=$e("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),ge=[20,50,100];function je(s,n=!1){if(!s)return;const d=n?`${s}T23:59:59.999`:`${s}T00:00:00.000`,g=Date.parse(d);return Number.isFinite(g)?g:void 0}function be(s){const n=new Date(s);return`${n.getFullYear()}-${`${n.getMonth()+1}`.padStart(2,"0")}-${`${n.getDate()}`.padStart(2,"0")} ${`${n.getHours()}`.padStart(2,"0")}:${`${n.getMinutes()}`.padStart(2,"0")}:${`${n.getSeconds()}`.padStart(2,"0")}`}function S(s){return s==null?"-":s.toLocaleString()}function L(s,n){const d=S(s);return d==="-"?"-":`${d} ${n}`}function He(s){return s?"true":"false"}function ye(s,n){if(!s||s.trim().length===0)return n;try{const d=JSON.parse(s);return JSON.stringify(d,null,2)}catch{return s}}function is(){var de,ce,me,xe,ue;const{t:s}=H(),{pushToast:n}=ve(),[d,g]=r.useState("all"),[p,l]=r.useState("all"),[c,j]=r.useState(""),[m,v]=r.useState("all"),[a,h]=r.useState(""),[i,u]=r.useState(""),[x,f]=r.useState(1),[N,W]=r.useState(ge[0]),[A,se]=r.useState(null),[we,te]=r.useState(!1),[_,G]=r.useState([]),[P,le]=r.useState(!1),[ae,ke]=r.useState(!1),[Se,_e]=r.useState(!1),Q=r.useRef(null);r.useEffect(()=>{f(1)},[d,p,c,m,a,i,N,_]);const z=r.useMemo(()=>{const t={limit:N,offset:(x-1)*N};d!=="all"&&(t.provider=d),p!=="all"&&(t.endpoint=p),c.trim().length>0&&(t.model=c.trim()),m!=="all"&&(t.status=m);const o=je(a),E=je(i,!0);return o!==void 0&&(t.from=o),E!==void 0&&(t.to=E),_.length>0&&(t.apiKeys=_.join(",")),t},[d,p,c,m,a,i,x,N,_]),y=M(["logs",z],{url:"/api/logs",method:"GET",params:z}),T=M(["providers","all"],{url:"/api/providers",method:"GET"}),ie=M(["api-keys"],{url:"/api/keys",method:"GET"}),V=M(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"});r.useEffect(()=>{y.isError&&y.error&&n({title:s("logs.toast.listError.title"),description:s("logs.toast.listError.desc",{message:y.error.message}),variant:"error"})},[y.isError,y.error,n,s]),r.useEffect(()=>{T.isError&&T.error&&n({title:s("logs.toast.providerError.title"),description:s("logs.toast.providerError.desc",{message:T.error.message}),variant:"error"})},[T.isError,T.error,n,s]);const R=((de=y.data)==null?void 0:de.total)??0,b=R>0?Math.ceil(R/N):0,ne=((ce=y.data)==null?void 0:ce.items)??[];r.useEffect(()=>{b>0&&x>b&&f(b)},[b,x]);const J=T.data??[],O=r.useMemo(()=>{const t=new Map;for(const o of J)o.id&&t.set(o.id,o.label??o.id);return t},[J]),re=r.useMemo(()=>{var o;const t=new Map;t.set("anthropic",s("logs.filters.endpointAnthropic")),t.set("openai",s("logs.filters.endpointOpenAI"));for(const E of((o=V.data)==null?void 0:o.endpoints)??[])t.set(E.id,E.label||E.id);return t},[(me=V.data)==null?void 0:me.endpoints,s]),X=r.useMemo(()=>{const t=[];if(d!=="all"){const o=O.get(d)??d;t.push({key:"provider",label:`${s("logs.filters.provider")}: ${o}`,onRemove:()=>g("all")})}if(p!=="all"){const o=re.get(p)??p;t.push({key:"endpoint",label:`${s("logs.filters.endpoint")}: ${o}`,onRemove:()=>l("all")})}if(c.trim()&&t.push({key:"model",label:`${s("logs.filters.modelId")}: ${c.trim()}`,onRemove:()=>j("")}),m!=="all"){const o=s(m==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");t.push({key:"status",label:`${s("logs.filters.status")}: ${o}`,onRemove:()=>v("all")})}return a&&t.push({key:"from",label:`${s("logs.filters.startDate")}: ${a}`,onRemove:()=>h("")}),i&&t.push({key:"to",label:`${s("logs.filters.endDate")}: ${i}`,onRemove:()=>u("")}),_.length>0&&t.push({key:"apiKeys",label:s("logs.filters.apiKeySelected",{count:_.length}),onRemove:()=>G([])}),t},[d,O,p,re,c,m,a,i,_,s]),Y=ie.data??[],oe=r.useMemo(()=>{const t=new Map;for(const o of Y)t.set(o.id,o);return t},[Y]),Ee=()=>{g("all"),j(""),l("all"),v("all"),h(""),u(""),G([])},Ce=r.useCallback(async()=>{if(!P){le(!0);try{const t=R>0?Math.min(R,5e3):1e3,o={...z,limit:t,offset:0},E=await Fe.post("/api/logs/export",o,{responseType:"blob"}),Re=new Blob([E.data],{type:"application/zip"}),De=new Date().toISOString().replace(/[:.]/g,"-"),pe=URL.createObjectURL(Re),F=document.createElement("a");F.href=pe,F.download=`cc-gw-logs-${De}.zip`,document.body.appendChild(F),F.click(),F.remove(),URL.revokeObjectURL(pe),n({title:s("logs.toast.exportSuccess.title"),description:s("logs.toast.exportSuccess.desc"),variant:"success"})}catch(t){const o=Ke(t);n({title:s("logs.toast.exportError.title"),description:s("logs.toast.exportError.desc",{message:o.message}),variant:"error"})}finally{le(!1)}}},[P,n,z,s,R]),Le=r.useCallback(t=>{se(t),te(!0)},[]),Te=r.useCallback(()=>{te(!1),se(null)},[]),$=r.useCallback(()=>{const t=Q.current;if(!t)return;const o=t.scrollWidth-t.scrollLeft-t.clientWidth>1;_e(o)},[]);return r.useEffect(()=>{const t=Q.current;if(!t)return;$(),t.addEventListener("scroll",$,{passive:!0});const o=new ResizeObserver($);return o.observe(t),()=>{t.removeEventListener("scroll",$),o.disconnect()}},[$]),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ze,{icon:e.jsx(Me,{className:"h-5 w-5","aria-hidden":"true"}),title:s("logs.title"),description:s("logs.description"),actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(k,{onClick:Ce,disabled:P,children:[e.jsx(Be,{className:"mr-2 h-4 w-4"}),s(P?"common.actions.loading":"logs.actions.export")]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.summary.total",{value:R.toLocaleString()})}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>y.refetch(),disabled:y.isFetching,children:[e.jsx(Ue,{className:D("mr-2 h-4 w-4",y.isFetching&&"animate-spin")}),y.isFetching?s("common.actions.refreshing"):s("logs.actions.manualRefresh")]})]})}),e.jsx(he,{children:e.jsxs(fe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex flex-1 items-center gap-3 overflow-hidden",children:X.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:X.map(t=>e.jsxs(ee,{variant:"secondary",role:"button",tabIndex:0,className:"cursor-pointer gap-1 hover:bg-destructive/10 hover:text-destructive",onClick:t.onRemove,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),t.onRemove())},children:[t.label,e.jsx(Ne,{className:"h-3 w-3","aria-hidden":"true"})]},t.key))}):e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.filters.allRequests")})}),e.jsxs("div",{className:"flex items-center gap-2 ml-3 flex-shrink-0",children:[X.length>0&&e.jsx(k,{variant:"ghost",size:"sm",onClick:Ee,children:s("common.actions.reset")}),e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>ke(t=>!t),children:ae?e.jsxs(e.Fragment,{children:[s("common.filters.collapse"),e.jsx(Ie,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[s("common.filters.expand"),e.jsx(qe,{className:"ml-1 h-4 w-4"})]})})]})]}),ae&&e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2 xl:grid-cols-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.provider")}),e.jsxs(I,{value:d,onValueChange:g,children:[e.jsx(q,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(w,{value:"all",children:s("logs.filters.providerAll")}),J.map(t=>e.jsx(w,{value:t.id,children:t.label??t.id},t.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.endpoint")}),e.jsxs(I,{value:p,onValueChange:l,children:[e.jsx(q,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(w,{value:"all",children:s("logs.filters.endpointAll")}),e.jsx(w,{value:"anthropic",children:s("logs.filters.endpointAnthropic")}),e.jsx(w,{value:"openai",children:s("logs.filters.endpointOpenAI")}),(ue=(xe=V.data)==null?void 0:xe.endpoints)==null?void 0:ue.map(t=>e.jsx(w,{value:t.id,children:t.label||t.id},t.id))]})]})]}),e.jsx(Qe,{className:"md:col-span-2",apiKeys:Y,selected:_,disabled:ie.isLoading,onChange:G}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.modelId")}),e.jsx(Z,{value:c,onChange:t=>j(t.target.value),placeholder:s("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.status")}),e.jsxs(I,{value:m,onValueChange:t=>v(t),children:[e.jsx(q,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(w,{value:"all",children:s("logs.filters.statusAll")}),e.jsx(w,{value:"success",children:s("logs.filters.statusSuccess")}),e.jsx(w,{value:"error",children:s("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.startDate")}),e.jsx(Z,{type:"date",value:a,onChange:t=>h(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:s("logs.filters.endDate")}),e.jsx(Z,{type:"date",value:i,onChange:t=>u(t.target.value)})]})]})]})}),e.jsx(he,{children:e.jsxs(fe,{className:"p-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:Q,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1200px] text-sm",children:[e.jsx("thead",{className:"border-b bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.time")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.endpoint")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.provider")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.requestedModel")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.routedModel")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.apiKey")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.inputTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.cacheReadTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.cacheCreationTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.outputTokens")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.latency")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.ttft")}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.tpot")}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium",children:s("logs.table.columns.status")}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.error")}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium",children:s("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y",children:y.isPending?Array.from({length:8}).map((t,o)=>e.jsx(Pe,{columns:16},o)):ne.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:16,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:s("logs.table.empty")})}):ne.map((t,o)=>e.jsx(We,{record:t,providerLabelMap:O,apiKeyMap:oe,onSelect:Le,isEven:o%2===0},t.id))})]})}),Se&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-t p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.table.pagination.perPage")}),e.jsxs(I,{value:N.toString(),onValueChange:t=>W(Number(t)),children:[e.jsx(q,{className:"w-[80px]",children:e.jsx(U,{})}),e.jsx(B,{children:ge.map(t=>e.jsx(w,{value:t.toString(),children:t},t))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>f(t=>Math.max(t-1,1)),disabled:x<=1,children:s("logs.table.pagination.previous")}),e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.table.pagination.pageLabel",{page:b===0?0:x,total:b})}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>f(t=>b===0?t:Math.min(t+1,b)),disabled:b===0||x>=b,children:s("logs.table.pagination.next")})]})]})]})}),e.jsx(Ge,{open:we,logId:A,onClose:Te,providerLabelMap:O,apiKeyMap:oe})]})}function We({record:s,providerLabelMap:n,apiKeyMap:d,onSelect:g,isEven:p}){const{t:l}=H(),c=n.get(s.provider)??s.provider,j=s.endpoint||"-",m=!!s.error,v=s.status_code,a=s.client_model??l("logs.table.requestedModelFallback"),h=s.api_key_id!=null?d.get(s.api_key_id):void 0,i=s.api_key_id==null?l("logs.table.apiKeyUnknown"):h!=null&&h.isWildcard?l("apiKeys.wildcard"):h!=null&&h.name?h.name:s.api_key_name?s.api_key_name:l("logs.table.apiKeyUnknown");return e.jsxs("tr",{className:D("transition-colors",p?"bg-muted/30":"","hover:bg-muted/50"),children:[e.jsx("td",{className:"px-3 py-2 text-xs",children:be(s.timestamp)}),e.jsx("td",{className:"px-3 py-2 text-xs",children:j}),e.jsx("td",{className:"px-3 py-2 text-xs",children:e.jsx("div",{className:"max-w-[100px] truncate",title:c,children:c})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:e.jsx("div",{className:"max-w-[120px] truncate",title:a,children:a})}),e.jsx("td",{className:"px-3 py-2 text-xs",children:e.jsx("div",{className:"max-w-[120px] truncate",title:s.model,children:s.model})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:e.jsx("div",{className:"max-w-[90px] truncate",title:i,children:i})}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:S(s.input_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:S(s.cache_read_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:S(s.cache_creation_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:S(s.output_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:L(s.latency_ms,"ms")}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:L(s.ttft_ms,"ms")}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:L(s.tpot_ms,"ms/tk")}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx(ee,{variant:m?"destructive":"default",className:"text-xs",children:v??(m?500:200)})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:e.jsx("div",{className:"max-w-[100px] truncate",title:s.error??"",children:s.error?s.error:"-"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx(k,{variant:"outline",size:"sm",onClick:()=>g(s.id),children:l("logs.actions.detail")})})]})}function Ge({open:s,logId:n,onClose:d,providerLabelMap:g,apiKeyMap:p}){var u,x;const{t:l}=H(),{pushToast:c}=ve(),j=r.useRef(null),m=M(["log-detail",n],{url:`/api/logs/${n}`,method:"GET"},{enabled:s&&n!==null,staleTime:3e4});r.useEffect(()=>{m.isError&&m.error&&c({title:l("logs.detail.loadError"),description:m.error.message,variant:"error"})},[m.isError,m.error,c,l]),r.useEffect(()=>{if(!s)return;const f=N=>{N.key==="Escape"&&d()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,d]),r.useEffect(()=>{s&&j.current&&j.current.focus()},[s,n]);const v=r.useCallback(async(f,N,W)=>{if(!N){c({title:l("logs.detail.copy.empty",{label:f}),variant:"info"});return}try{await Oe(N),c({title:l(W),variant:"success"})}catch(A){c({title:l("logs.detail.copy.failure"),description:A instanceof Error?A.message:l("logs.detail.copy.failureFallback"),variant:"error"})}},[c,l]);if(!s)return null;const a=m.data,h=a?g.get(a.provider)??a.provider:"",i=a&&a.api_key_id!=null?p.get(a.api_key_id):void 0;return typeof document>"u"?null:Ae.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm animate-in fade-in duration-200",onClick:d}),e.jsxs("aside",{role:"dialog","aria-modal":"true",className:"flex h-full w-full max-w-xl flex-col border-l bg-card shadow-xl animate-in slide-in-from-right duration-300",children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-6 py-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:l("logs.detail.title")}),a&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l("logs.detail.id",{id:a.id})})]}),e.jsxs(k,{ref:j,variant:"outline",size:"sm",onClick:d,children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),l("common.actions.close")]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:m.isPending?e.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[e.jsx(K,{className:"h-5 w-40"}),e.jsx(K,{className:"h-4 w-full"}),e.jsx(K,{className:"h-4 w-3/4"}),e.jsx(K,{className:"h-32 w-full"}),e.jsx(K,{className:"h-4 w-1/2"})]}):a?e.jsxs("div",{className:"flex flex-col gap-6 px-6 py-5 text-sm",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.infoSection")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md bg-muted p-3 text-xs",children:[e.jsx("span",{className:"font-medium",children:l("logs.detail.summary.route",{from:a.client_model??l("logs.detail.info.noRequestedModel"),to:a.model})}),e.jsx("span",{className:"text-muted-foreground",children:l("logs.detail.summary.latency",{value:L(a.latency_ms,l("common.units.ms"))})}),a.ttft_ms!==null&&e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",L(a.ttft_ms,l("common.units.ms"))]}),e.jsx(ee,{variant:a.error?"destructive":"default",children:(a.status_code??(a.error?500:200)).toString()})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.time")}),e.jsx("dd",{className:"font-medium",children:be(a.timestamp)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.sessionId")}),e.jsx("dd",{className:"font-medium",children:a.session_id??"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.endpoint")}),e.jsx("dd",{className:"font-medium",children:a.endpoint||"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.provider")}),e.jsx("dd",{className:"font-medium",children:h})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.requestedModel")}),e.jsx("dd",{className:"font-medium",children:a.client_model??l("logs.detail.info.noRequestedModel")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.model")}),e.jsx("dd",{className:"font-medium",children:a.model})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.stream")}),e.jsx("dd",{className:"font-medium",children:He(a.stream)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.inputTokens")}),e.jsx("dd",{className:"font-medium",children:S(a.input_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.cacheReadTokens")}),e.jsx("dd",{className:"font-medium",children:S(a.cache_read_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.cacheCreationTokens")}),e.jsx("dd",{className:"font-medium",children:S(a.cache_creation_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.outputTokens")}),e.jsx("dd",{className:"font-medium",children:S(a.output_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.ttft")}),e.jsx("dd",{className:"font-medium",children:L(a.ttft_ms,l("common.units.ms"))})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.tpot")}),e.jsx("dd",{className:"font-medium",children:L(a.tpot_ms,l("common.units.msPerToken"))})]})]}),a.error&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:l("logs.detail.info.error")}),e.jsx("p",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:a.error})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.apiKey.title")}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.name")}),e.jsx("dd",{className:"font-medium",children:a.api_key_id==null&&!a.api_key_name?l("logs.detail.apiKey.missing"):i!=null&&i.isWildcard?l("apiKeys.wildcard"):(i==null?void 0:i.name)??a.api_key_name??l("logs.detail.apiKey.missing")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.identifier")}),e.jsx("dd",{className:"font-medium",children:a.api_key_id??l("common.noData")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.masked")}),e.jsx("dd",{className:"font-medium",children:i!=null&&i.isWildcard?l("apiKeys.wildcard"):(i==null?void 0:i.maskedKey)??a.api_key_name??l("logs.detail.apiKey.maskedUnavailable")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l("logs.detail.apiKey.lastUsed")}),e.jsx("dd",{className:"font-medium",children:i!=null&&i.lastUsedAt?new Date(i.lastUsedAt).toLocaleString():l("common.noData")})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:l("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:a.api_key_value_available?a.api_key_value_masked??l("logs.detail.apiKey.rawUnavailable"):l("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:l("logs.detail.apiKey.rawMaskedHint")})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.payload.request")}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>{var f;return v(l("logs.detail.payload.request"),(f=a.payload)==null?void 0:f.prompt,"logs.detail.copy.requestSuccess")},children:l("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap rounded-md border bg-muted p-3 text-xs",children:ye((u=a.payload)==null?void 0:u.prompt,l("logs.detail.payload.emptyRequest"))})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:l("logs.detail.payload.response")}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>{var f;return v(l("logs.detail.payload.response"),(f=a.payload)==null?void 0:f.response,"logs.detail.copy.responseSuccess")},children:l("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap rounded-md border bg-muted p-3 text-xs",children:ye((x=a.payload)==null?void 0:x.response,l("logs.detail.payload.emptyResponse"))})]})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:l("logs.detail.loadError")})})]})]}),document.body)}function Qe({apiKeys:s,selected:n,onChange:d,disabled:g,className:p}){const{t:l}=H(),[c,j]=r.useState(!1),m=r.useRef(null);r.useEffect(()=>{if(!c)return;const i=u=>{var x;(x=m.current)!=null&&x.contains(u.target)||j(!1)};return window.addEventListener("mousedown",i),()=>window.removeEventListener("mousedown",i)},[c]);const v=r.useMemo(()=>{if(n.length===0)return[];const i=new Map;for(const u of s)i.set(u.id,u);return n.map(u=>{const x=i.get(u);return x?x.isWildcard?l("apiKeys.wildcard"):x.name:null}).filter(u=>!!u)},[s,n,l]),a=n.length===0?l("logs.filters.apiKeyAll"):l("logs.filters.apiKeySelected",{count:n.length}),h=i=>{n.includes(i)?d(n.filter(u=>u!==i)):d([...n,i])};return e.jsxs("div",{className:D("relative space-y-2",p),ref:m,children:[e.jsx(C,{children:l("logs.filters.apiKey")}),e.jsxs("button",{type:"button",onClick:()=>j(i=>!i),disabled:g||s.length===0,title:l("logs.filters.apiKeyHint"),className:D("flex h-10 w-full items-center justify-between rounded-md border bg-background px-3 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n.length>0&&"border-primary",c&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[a,v.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:v.join(", ")})]}),e.jsx("svg",{className:D("h-4 w-4 opacity-50 transition-transform",c&&"rotate-180"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.25a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z",clipRule:"evenodd"})})]}),c&&e.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border bg-popover p-2 shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-muted px-3 py-2 text-xs",children:[e.jsx("span",{children:a}),e.jsx("button",{type:"button",onClick:()=>d([]),disabled:n.length===0,className:"text-primary hover:underline disabled:opacity-40",children:l("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[s.map(i=>{const u=i.isWildcard?l("apiKeys.wildcard"):i.name,x=n.includes(i.id);return e.jsxs("label",{className:D("flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm transition hover:bg-muted",x&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border",checked:x,onChange:()=>h(i.id)}),e.jsx("span",{className:"truncate",children:u})]},i.id)}),s.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:l("logs.filters.apiKeyAll")})]})]})]})}export{is as default};
@@ -1,6 +0,0 @@
1
- import{c as Oe,u as Be,b as _e,r as m,j as e,e as S,a3 as Ge,W as be,a as Qe,d as O}from"./index-Bdp0nMlR.js";import{u as fe}from"./useApiQuery-CL9_n4sn.js";import{P as We}from"./PageHeader-D2Zq1K4t.js";import{c as ze}from"./clipboard-CALi6bTW.js";import{I as j}from"./input-B6w5gzdL.js";import{L as c}from"./label-CuU6RIsU.js";import{C as E,a as F}from"./card-Dl49soGw.js";import{S as L}from"./switch-DoT-Ur3p.js";import{S as $e,a as Je,b as Ue,c as Xe,d as Ye}from"./select-Cfzsn-JK.js";import{S as Ze,C as et}from"./shield--mDWO-No.js";/**
2
- * @license lucide-react v0.344.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const z=Oe("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),tt=[{value:"fatal",labelKey:"fatal"},{value:"error",labelKey:"error"},{value:"warn",labelKey:"warn"},{value:"info",labelKey:"info"},{value:"debug",labelKey:"debug"},{value:"trace",labelKey:"trace"}],je=[{id:"section-basics",labelKey:"settings.sections.basics"},{id:"section-protocol",labelKey:"settings.sections.protocol"},{id:"section-security",labelKey:"settings.sections.security"},{id:"section-config-file",labelKey:"settings.sections.configFile"},{id:"section-cleanup",labelKey:"settings.sections.cleanup"}];function mt(){const{t}=Be(),{pushToast:u}=_e(),[ye,ve]=m.useState(je[0].id),K=m.useRef(new Map),Ne=m.useCallback(s=>{const a=K.current.get(s);a&&a.scrollIntoView({behavior:"smooth",block:"start"})},[]),q=m.useCallback(s=>a=>{a?K.current.set(s,a):K.current.delete(s)},[]),f=fe(["config","info"],{url:"/api/config/info",method:"GET"}),y=fe(["auth","web"],{url:"/api/auth/web",method:"GET"}),[r,$]=m.useState(null),[B,Pe]=m.useState(""),[n,p]=m.useState({port:"",host:"",logRetentionDays:"",storeRequestPayloads:!0,storeResponsePayloads:!0,logLevel:"info",requestLogging:!0,responseLogging:!0,bodyLimitMb:"10",enableRoutingFallback:!1,httpEnabled:!0,httpPort:"4100",httpHost:"127.0.0.1",httpsEnabled:!1,httpsPort:"4443",httpsHost:"127.0.0.1",httpsKeyPath:"",httpsCertPath:"",httpsCaPath:""}),[g,J]=m.useState({}),[_,U]=m.useState(!1),[X,Y]=m.useState(!1),[Z,ee]=m.useState(!1),[d,te]=m.useState(null),[l,R]=m.useState({enabled:!1,username:"",password:"",confirmPassword:""}),[H,D]=m.useState({}),[G,se]=m.useState(!1),ke=m.useMemo(()=>{if(!r)return null;const s=r.defaults;if(!s)return null;const a=[];return s.completion&&a.push(t("settings.defaults.completion",{model:s.completion})),s.reasoning&&a.push(t("settings.defaults.reasoning",{model:s.reasoning})),s.background&&a.push(t("settings.defaults.background",{model:s.background})),a.length>0?a.join(" | "):t("settings.defaults.none")},[r,t]),ae=m.useMemo(()=>l.enabled?d!=null&&d.hasPassword?l.username.trim()!==((d==null?void 0:d.username)??""):!0:!1,[l.enabled,l.username,d]);m.useEffect(()=>{var s,a,i,h,b,P,k,w,C,v,A;if(f.data){$(f.data.config),Pe(f.data.path);const M=f.data.config.storePayloads,T=N=>typeof N=="boolean"?N:typeof M=="boolean"?M:!0,o=f.data.config;p({port:String(o.port??((s=o.http)==null?void 0:s.port)??""),host:o.host??((a=o.http)==null?void 0:a.host)??"127.0.0.1",logRetentionDays:String(o.logRetentionDays??30),storeRequestPayloads:T(o.storeRequestPayloads),storeResponsePayloads:T(o.storeResponsePayloads),logLevel:o.logLevel??"info",requestLogging:o.requestLogging!==!1,responseLogging:o.responseLogging??o.requestLogging!==!1,bodyLimitMb:(()=>{const N=o.bodyLimit;return typeof N=="number"&&Number.isFinite(N)&&N>0?String(Math.max(1,Math.round(N/(1024*1024)))):"10"})(),enableRoutingFallback:o.enableRoutingFallback===!0,httpEnabled:((i=o.http)==null?void 0:i.enabled)!==!1,httpPort:String(((h=o.http)==null?void 0:h.port)??o.port??4100),httpHost:((b=o.http)==null?void 0:b.host)??o.host??"127.0.0.1",httpsEnabled:((P=o.https)==null?void 0:P.enabled)===!0,httpsPort:String(((k=o.https)==null?void 0:k.port)??4443),httpsHost:((w=o.https)==null?void 0:w.host)??o.host??"127.0.0.1",httpsKeyPath:((C=o.https)==null?void 0:C.keyPath)??"",httpsCertPath:((v=o.https)==null?void 0:v.certPath)??"",httpsCaPath:((A=o.https)==null?void 0:A.caPath)??""})}},[f.data]),m.useEffect(()=>{y.data&&(te(y.data),R({enabled:y.data.enabled,username:y.data.username??"",password:"",confirmPassword:""}),D({}))},[y.data]),m.useEffect(()=>{f.isError&&f.error&&u({title:t("settings.toast.loadFailure",{message:f.error.message}),variant:"error"})},[f.isError,f.error,u,t]),m.useEffect(()=>{y.isError&&y.error&&u({title:t("settings.toast.authLoadFailure",{message:y.error.message}),variant:"error"})},[y.isError,y.error,u,t]);const V=s=>a=>{p(i=>({...i,[s]:a}))},we=()=>{const s={};if(!n.httpEnabled&&!n.httpsEnabled&&(s.protocol="至少需要启用 HTTP 或 HTTPS 协议"),n.httpEnabled){const b=Number(n.httpPort);(!Number.isFinite(b)||b<1||b>65535)&&(s.httpPort="HTTP 端口必须在 1-65535 之间")}if(n.httpsEnabled){const b=Number(n.httpsPort);(!Number.isFinite(b)||b<1||b>65535)&&(s.httpsPort="HTTPS 端口必须在 1-65535 之间"),(!n.httpsKeyPath||!n.httpsCertPath)&&(s.protocol="HTTPS 已启用但缺少证书路径,请手动配置受信任的证书")}const a=Number(n.port);(!Number.isFinite(a)||a<1||a>65535)&&(s.port=t("settings.validation.port"));const i=Number(n.logRetentionDays);(!Number.isFinite(i)||i<1||i>365)&&(s.logRetentionDays=t("settings.validation.retention"));const h=Number(n.bodyLimitMb);return(!Number.isFinite(h)||h<1||h>2048)&&(s.bodyLimitMb=t("settings.validation.bodyLimit")),J(s),Object.keys(s).length===0},Ce=()=>{const s={},a=l.username.trim(),i=d?a!==(d.username??""):!0,h=l.enabled&&(!(d!=null&&d.hasPassword)||i);return l.enabled&&!a&&(s.username=t("settings.auth.validation.username")),l.password&&l.password.length<6&&(s.password=t("settings.auth.validation.minLength")),h&&!l.password&&(s.password=t("settings.auth.validation.passwordRequired")),(l.password||l.confirmPassword)&&l.password!==l.confirmPassword&&(s.confirmPassword=t("settings.auth.validation.confirmMismatch")),D(s),Object.keys(s).length===0},Le=async()=>{var s,a,i,h,b,P,k,w,C,v,A,M,T,o,N,re,ne,oe,ie,le,ce,de,he,me,pe,ue;if(!r){u({title:t("settings.toast.loadFailure",{message:t("settings.toast.missingConfig")}),variant:"error"});return}if(we()){U(!0);try{const I=Number(n.port),Ae=Number(n.logRetentionDays),Me=Number(n.bodyLimitMb),x={...r,http:{enabled:n.httpEnabled,port:Number(n.httpPort),host:n.httpHost.trim()||"127.0.0.1"},https:{enabled:n.httpsEnabled,port:Number(n.httpsPort),host:n.httpsHost.trim()||"127.0.0.1",keyPath:n.httpsKeyPath.trim(),certPath:n.httpsCertPath.trim(),caPath:n.httpsCaPath.trim()||void 0},port:I,host:n.host.trim()||void 0,logRetentionDays:Ae,storeRequestPayloads:n.storeRequestPayloads,storeResponsePayloads:n.storeResponsePayloads,logLevel:n.logLevel,requestLogging:n.requestLogging,responseLogging:n.responseLogging,bodyLimit:Math.max(1,Math.floor(Me*1024*1024)),enableRoutingFallback:n.enableRoutingFallback},ge={...x};delete ge.webAuth,await O.put("/api/config",ge),$({...x,webAuth:r.webAuth});const xe=W=>(W==null?void 0:W.trim())||void 0,Te=r.port??((s=r.http)==null?void 0:s.port)??4100,Ke=x.port??((a=x.http)==null?void 0:a.port)??4100,De=((i=r.host)==null?void 0:i.trim())||((b=(h=r.http)==null?void 0:h.host)==null?void 0:b.trim())||"127.0.0.1",Ve=((P=x.host)==null?void 0:P.trim())||((w=(k=x.http)==null?void 0:k.host)==null?void 0:w.trim())||"127.0.0.1",Ie=Te!==Ke||De!==Ve||((C=r.http)==null?void 0:C.enabled)!==((v=x.http)==null?void 0:v.enabled)||((A=r.http)==null?void 0:A.port)!==((M=x.http)==null?void 0:M.port)||(((T=r.http)==null?void 0:T.host)??r.host??"127.0.0.1")!==(((o=x.http)==null?void 0:o.host)??x.host??"127.0.0.1")||((N=r.https)==null?void 0:N.enabled)!==((re=x.https)==null?void 0:re.enabled)||((ne=r.https)==null?void 0:ne.port)!==((oe=x.https)==null?void 0:oe.port)||(((ie=r.https)==null?void 0:ie.host)??r.host??"127.0.0.1")!==(((le=x.https)==null?void 0:le.host)??x.host??"127.0.0.1")||((ce=r.https)==null?void 0:ce.keyPath)!==((de=x.https)==null?void 0:de.keyPath)||((he=r.https)==null?void 0:he.certPath)!==((me=x.https)==null?void 0:me.certPath)||xe((pe=r.https)==null?void 0:pe.caPath)!==xe((ue=x.https)==null?void 0:ue.caPath);u(Ie?{title:t("settings.toast.protocolRestartRequired"),variant:"success"}:{title:t("settings.toast.saveSuccess"),variant:"success"}),f.refetch()}catch(I){u({title:t("settings.toast.saveFailure",{message:I instanceof Error?I.message:"unknown"}),variant:"error"})}finally{U(!1)}}},Re=()=>{var s,a,i,h,b,P,k,w,C;r&&(p({port:String(r.port??""),host:r.host??"",logRetentionDays:String(r.logRetentionDays??30),storeRequestPayloads:typeof r.storeRequestPayloads=="boolean"?r.storeRequestPayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,storeResponsePayloads:typeof r.storeResponsePayloads=="boolean"?r.storeResponsePayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,logLevel:r.logLevel??"info",requestLogging:r.requestLogging!==!1,responseLogging:r.responseLogging??r.requestLogging!==!1,bodyLimitMb:(()=>{const v=r.bodyLimit;return typeof v=="number"&&Number.isFinite(v)&&v>0?String(Math.max(1,Math.round(v/(1024*1024)))):"10"})(),enableRoutingFallback:r.enableRoutingFallback===!0,httpEnabled:((s=r.http)==null?void 0:s.enabled)!==!1,httpPort:String(((a=r.http)==null?void 0:a.port)??r.port??4100),httpHost:((i=r.http)==null?void 0:i.host)??r.host??"127.0.0.1",httpsEnabled:((h=r.https)==null?void 0:h.enabled)===!0,httpsPort:String(((b=r.https)==null?void 0:b.port)??4443),httpsHost:((P=r.https)==null?void 0:P.host)??r.host??"127.0.0.1",httpsKeyPath:((k=r.https)==null?void 0:k.keyPath)??"",httpsCertPath:((w=r.https)==null?void 0:w.certPath)??"",httpsCaPath:((C=r.https)==null?void 0:C.caPath)??""}),J({}))},Se=async()=>{var s;if(Ce()){se(!0);try{const a={enabled:l.enabled,username:l.username.trim()||void 0};l.password&&(a.password=l.password);const h=(s=(await O.post("/api/auth/web",a)).data)==null?void 0:s.auth;h&&(te(h),R({enabled:h.enabled,username:h.username??"",password:"",confirmPassword:""}),D({})),u({title:t("settings.auth.toast.success"),variant:"success"}),y.refetch()}catch(a){const i=a instanceof Error?a.message:"unknown";u({title:t("settings.auth.toast.failure",{message:i}),variant:"error"})}finally{se(!1)}}},Ee=()=>{d&&(R({enabled:d.enabled,username:d.username??"",password:"",confirmPassword:""}),D({}))},Fe=async()=>{if(!B){u({title:t("settings.toast.copyFailure",{message:t("settings.file.unknown")}),variant:"error"});return}try{await ze(B),u({title:t("settings.toast.copySuccess"),variant:"success"})}catch(s){u({title:t("settings.toast.copyFailure",{message:s instanceof Error?s.message:"unknown"}),variant:"error"})}},He=async()=>{Y(!0);try{const a=(await O.post("/api/logs/cleanup")).data.deleted??0;u({title:a>0?t("settings.toast.cleanupSuccess",{count:a}):t("settings.toast.cleanupNone"),variant:"success"})}catch(s){u({title:t("settings.toast.cleanupFailure",{message:s instanceof Error?s.message:"unknown"}),variant:"error"})}finally{Y(!1)}},qe=async()=>{ee(!0);try{const s=await O.post("/api/logs/clear"),{deleted:a,metricsCleared:i}=s.data;u({title:t("settings.toast.clearAllSuccess",{logs:a,metrics:i}),variant:"success"})}catch(s){u({title:t("settings.toast.clearAllFailure",{message:s instanceof Error?s.message:"unknown"}),variant:"error"})}finally{ee(!1)}},Q=f.isPending||!r&&f.isFetching;return m.useEffect(()=>{if(Q)return;const s=Array.from(K.current.values());if(s.length===0)return;const a=new IntersectionObserver(i=>{for(const h of i)if(h.isIntersecting){ve(h.target.id);break}},{rootMargin:"-80px 0px -60% 0px",threshold:0});for(const i of s)a.observe(i);return()=>a.disconnect()},[Q]),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(We,{icon:e.jsx(Ge,{className:"h-5 w-5","aria-hidden":"true"}),title:t("settings.title"),description:t("settings.description"),actions:r?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",onClick:Re,disabled:_,children:t("common.actions.reset")}),e.jsx(S,{onClick:()=>void Le(),disabled:_,children:t(_?"common.actions.saving":"common.actions.save")})]}):null}),Q?e.jsx(E,{children:e.jsx(F,{className:"flex min-h-[220px] items-center justify-center",children:e.jsx(be,{})})}):r?e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[200px_1fr] gap-6",children:[e.jsx("nav",{className:"hidden xl:block",children:e.jsxs("div",{className:"sticky top-20 space-y-1",children:[e.jsx("p",{className:"mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:t("settings.sections.jump")}),je.map(s=>e.jsx("button",{type:"button",onClick:()=>Ne(s.id),className:Qe("block w-full rounded-md px-3 py-2 text-left text-sm transition-colors",ye===s.id?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:t(s.labelKey)},s.id))]})}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(E,{id:"section-basics",ref:q("section-basics"),children:e.jsxs(F,{className:"pt-6",children:[e.jsx("h3",{className:"mb-4 text-sm font-semibold",children:t("settings.sections.basics")}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.fields.port")}),e.jsx(j,{type:"number",min:1,max:65535,value:n.port,onChange:s=>V("port")(s.target.value),"aria-invalid":!!g.port}),g.port&&e.jsx("p",{className:"text-xs text-destructive",children:g.port})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.fields.host")}),e.jsx(j,{value:n.host,onChange:s=>V("host")(s.target.value),placeholder:t("settings.fields.hostPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.fields.retention")}),e.jsx(j,{type:"number",min:1,max:365,value:n.logRetentionDays,onChange:s=>V("logRetentionDays")(s.target.value),"aria-invalid":!!g.logRetentionDays}),g.logRetentionDays&&e.jsx("p",{className:"text-xs text-destructive",children:g.logRetentionDays})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.fields.bodyLimit")}),e.jsx(j,{type:"number",min:1,max:2048,value:n.bodyLimitMb,onChange:s=>V("bodyLimitMb")(s.target.value),"aria-invalid":!!g.bodyLimitMb}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.bodyLimitHint")}),g.bodyLimitMb&&e.jsx("p",{className:"text-xs text-destructive",children:g.bodyLimitMb})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.fields.logLevel")}),e.jsxs($e,{value:n.logLevel,onValueChange:s=>p(a=>({...a,logLevel:s})),children:[e.jsx(Je,{children:e.jsx(Ue,{})}),e.jsx(Xe,{children:tt.map(s=>e.jsx(Ye,{value:s.value,children:t(`settings.fields.logLevelOption.${s.labelKey}`)},s.value))})]})]}),e.jsxs("div",{className:"md:col-span-2 grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(c,{className:"text-sm font-medium",children:t("settings.fields.storeRequestPayloads")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.storeRequestPayloadsHint")})]}),e.jsx(L,{checked:n.storeRequestPayloads,onCheckedChange:s=>p(a=>({...a,storeRequestPayloads:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(c,{className:"text-sm font-medium",children:t("settings.fields.storeResponsePayloads")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.storeResponsePayloadsHint")})]}),e.jsx(L,{checked:n.storeResponsePayloads,onCheckedChange:s=>p(a=>({...a,storeResponsePayloads:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(c,{className:"text-sm font-medium",children:t("settings.fields.requestLogging")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.requestLoggingHint")})]}),e.jsx(L,{checked:n.requestLogging,onCheckedChange:s=>p(a=>({...a,requestLogging:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(c,{className:"text-sm font-medium",children:t("settings.fields.responseLogging")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.fields.responseLoggingHint")})]}),e.jsx(L,{checked:n.responseLogging,onCheckedChange:s=>p(a=>({...a,responseLogging:s}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-950",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(c,{className:"text-sm font-medium text-amber-700 dark:text-amber-300",children:t("settings.fields.enableRoutingFallback")}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:t("settings.fields.enableRoutingFallbackHint")})]}),e.jsx(L,{checked:n.enableRoutingFallback,onCheckedChange:s=>p(a=>({...a,enableRoutingFallback:s}))})]})]}),e.jsxs("div",{className:"md:col-span-2 rounded-lg border bg-muted/50 p-4",children:[e.jsx(c,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:t("settings.fields.defaults")}),e.jsx("p",{className:"mt-2 text-sm",children:ke??t("settings.defaults.none")})]})]})]})}),e.jsx(E,{id:"section-protocol",ref:q("section-protocol"),children:e.jsxs(F,{className:"pt-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.protocol")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.protocol.description")})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-950",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(z,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t("settings.protocol.restartWarning")}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:t("settings.protocol.restartHint")}),e.jsx("code",{className:"block rounded-md bg-amber-100 px-3 py-2 text-xs font-mono text-amber-900 dark:bg-amber-900 dark:text-amber-100",children:"cc-gw restart --daemon"}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:t("settings.protocol.restartTip")})]})]})}),g.protocol&&e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive",children:[e.jsx(z,{className:"inline h-4 w-4 mr-2"}),g.protocol]}),e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50/50 p-5 dark:border-blue-800 dark:bg-blue-950/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(c,{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:t("settings.protocol.http.enable")}),e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:t("settings.protocol.http.hint")})]}),e.jsx(L,{checked:n.httpEnabled,onCheckedChange:s=>p(a=>({...a,httpEnabled:s}))})]}),n.httpEnabled&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 mt-4 pt-4 border-t border-blue-200 dark:border-blue-800",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.protocol.http.port")}),e.jsx(j,{type:"number",min:1,max:65535,value:n.httpPort,onChange:s=>p(a=>({...a,httpPort:s.target.value})),"aria-invalid":!!g.httpPort}),g.httpPort&&e.jsx("p",{className:"text-xs text-destructive",children:g.httpPort})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.protocol.http.host")}),e.jsx(j,{value:n.httpHost,onChange:s=>p(a=>({...a,httpHost:s.target.value})),placeholder:"127.0.0.1"})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50/50 p-5 dark:border-green-800 dark:bg-green-950/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{className:"text-sm font-medium text-green-800 dark:text-green-200",children:t("settings.protocol.https.enable")}),e.jsx(Ze,{className:"h-4 w-4 text-green-600 dark:text-green-400"})]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:t("settings.protocol.https.hint")})]}),e.jsx(L,{checked:n.httpsEnabled,onCheckedChange:s=>p(a=>({...a,httpsEnabled:s}))})]}),n.httpsEnabled&&e.jsxs("div",{className:"space-y-4 mt-4 pt-4 border-t border-green-200 dark:border-green-800",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.protocol.https.port")}),e.jsx(j,{type:"number",min:1,max:65535,value:n.httpsPort,onChange:s=>p(a=>({...a,httpsPort:s.target.value})),"aria-invalid":!!g.httpsPort}),g.httpsPort&&e.jsx("p",{className:"text-xs text-destructive",children:g.httpsPort})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.protocol.https.host")}),e.jsx(j,{value:n.httpsHost,onChange:s=>p(a=>({...a,httpsHost:s.target.value})),placeholder:"127.0.0.1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.protocol.https.keyPath")}),e.jsx(j,{value:n.httpsKeyPath,onChange:s=>p(a=>({...a,httpsKeyPath:s.target.value})),placeholder:"~/.cc-gw/certs/key.pem",className:"font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.protocol.https.certPath")}),e.jsx(j,{value:n.httpsCertPath,onChange:s=>p(a=>({...a,httpsCertPath:s.target.value})),placeholder:"~/.cc-gw/certs/cert.pem",className:"font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.protocol.https.caPath")}),e.jsx(j,{value:n.httpsCaPath,onChange:s=>p(a=>({...a,httpsCaPath:s.target.value})),placeholder:"留空则不使用",className:"font-mono text-xs"})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-950",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(z,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t("settings.protocol.https.warning")}),e.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300 leading-relaxed",children:[e.jsx("strong",{children:t("settings.protocol.https.invalidCert")}),t("settings.protocol.https.invalidCertDetail")]}),e.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300 leading-relaxed",children:[e.jsx("strong",{children:t("settings.protocol.https.recommended")}),t("settings.protocol.https.recommendedDetail")]}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 leading-relaxed",children:t("settings.protocol.https.tip")})]})]})})]})]})]})}),e.jsx(E,{id:"section-security",ref:q("section-security"),children:e.jsxs(F,{className:"pt-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.security")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.auth.description")})]}),y.isPending&&!d?e.jsx("div",{className:"flex min-h-[120px] items-center justify-center",children:e.jsx(be,{})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-sm font-medium",children:t("settings.auth.enable")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.auth.enableHint")}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"rounded-full bg-muted px-3 py-1",children:"/ui"}),e.jsx("span",{className:"rounded-full bg-muted px-3 py-1",children:"/api/*"}),e.jsx("span",{className:"rounded-full bg-muted px-3 py-1",children:"Cookie Session"})]})]}),e.jsx(L,{checked:l.enabled,onCheckedChange:s=>R(a=>({...a,enabled:s}))})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(c,{children:t("settings.auth.username")}),e.jsx(j,{value:l.username,onChange:s=>R(a=>({...a,username:s.target.value})),placeholder:t("settings.auth.usernamePlaceholder")}),H.username&&e.jsx("p",{className:"text-xs text-destructive",children:H.username})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.auth.password")}),e.jsx(j,{type:"password",value:l.password,disabled:!l.enabled,onChange:s=>R(a=>({...a,password:s.target.value})),placeholder:t("settings.auth.passwordPlaceholder")}),H.password?e.jsx("p",{className:"text-xs text-destructive",children:H.password}):e.jsx("p",{className:"text-xs text-muted-foreground",children:t(ae?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:t("settings.auth.confirmPassword")}),e.jsx(j,{type:"password",value:l.confirmPassword,disabled:!l.enabled,onChange:s=>R(a=>({...a,confirmPassword:s.target.value})),placeholder:t("settings.auth.confirmPasswordPlaceholder")}),H.confirmPassword&&e.jsx("p",{className:"text-xs text-destructive",children:H.confirmPassword})]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:t("settings.auth.status")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:d!=null&&d.enabled?t("settings.auth.statusEnabled"):t("settings.auth.statusDisabled")}),(d==null?void 0:d.username)&&e.jsxs("div",{className:"mt-3 rounded-md bg-primary/10 px-3 py-2 text-xs font-medium text-primary",children:[t("settings.auth.username"),": ",d.username]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 text-xs text-muted-foreground",children:t(ae?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(S,{onClick:()=>void Se(),disabled:G,children:t(G?"common.actions.saving":"settings.auth.actions.save")}),e.jsx(S,{variant:"outline",onClick:Ee,disabled:G,children:t("common.actions.reset")})]})]})]})}),e.jsx(E,{id:"section-config-file",ref:q("section-config-file"),children:e.jsxs(F,{className:"pt-6 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.configFile")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.file.description")})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>void Fe(),children:[e.jsx(et,{className:"mr-2 h-4 w-4"}),t("common.actions.copy")]})]}),e.jsx("code",{className:"block break-all rounded-lg border bg-muted px-4 py-3 text-xs",children:B||t("settings.file.unknown")})]})}),e.jsx(E,{id:"section-cleanup",ref:q("section-cleanup"),children:e.jsxs(F,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:t("settings.sections.cleanup")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("settings.cleanup.description")})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(S,{variant:"outline",onClick:()=>void He(),disabled:X,className:"border-destructive/50 text-destructive hover:bg-destructive/10",children:t(X?"common.actions.cleaning":"common.actions.cleanup")}),e.jsx(S,{variant:"destructive",onClick:()=>void qe(),disabled:Z,children:t(Z?"settings.cleanup.clearingAll":"settings.cleanup.clearAll")})]}),e.jsx("p",{className:"text-xs text-destructive",children:t("settings.cleanup.clearAllWarning")})]})})]})]}):e.jsx(E,{children:e.jsx(F,{className:"pt-6",children:e.jsx("p",{className:"text-sm font-medium text-destructive",children:t("settings.toast.missingConfig")})})})]})}export{mt as default};