@chenpu17/cc-gw 0.7.17 → 0.7.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/server/dist/index.js +420 -155
- package/src/web/dist/assets/{About-T8buLoTf.js → About-BA_VxEEw.js} +2 -2
- package/src/web/dist/assets/ApiKeys-9iuHXiuE.js +16 -0
- package/src/web/dist/assets/Dashboard-BV9q_ZEH.js +16 -0
- package/src/web/dist/assets/{Events-BY6QDHf6.js → Events-CVDX7Sdl.js} +2 -2
- package/src/web/dist/assets/{Help-CXlj66Zk.js → Help-Q8aahW1e.js} +1 -1
- package/src/web/dist/assets/{Login-C227e592.js → Login-Cc9PcXNz.js} +1 -1
- package/src/web/dist/assets/Logs-EvCIbsmH.js +6 -0
- package/src/web/dist/assets/ModelManagement-Bb8NWZJD.js +6 -0
- package/src/web/dist/assets/{PageHeader-BatC8G-O.js → PageHeader-DE87PlB_.js} +1 -1
- package/src/web/dist/assets/{PageSection-HTrZH-H0.js → PageSection-BW4UtaTE.js} +1 -1
- package/src/web/dist/assets/Settings-hk35KMN5.js +6 -0
- package/src/web/dist/assets/Skeleton-DKmc2Oau.js +1 -0
- package/src/web/dist/assets/{card-DQb2ediN.js → card-B5QaMdIj.js} +1 -1
- package/src/web/dist/assets/{dialog-B9ZBo_5P.js → dialog-Bl93c96O.js} +3 -3
- package/src/web/dist/assets/{index-CprjNJ8x.js → index-Bkl9YQUf.js} +1 -1
- package/src/web/dist/assets/index-DDEa11GU.css +1 -0
- package/src/web/dist/assets/index-iaYfODK6.js +280 -0
- package/src/web/dist/assets/{info-BSxQbQAp.js → info-Dtepvi_0.js} +1 -1
- package/src/web/dist/assets/{input-x0jTfvyD.js → input-CRfONI49.js} +1 -1
- package/src/web/dist/assets/{label-t5tthgxG.js → label-sf3QNge5.js} +1 -1
- package/src/web/dist/assets/{refresh-cw-DHAoO4El.js → refresh-cw-ZDTq8wum.js} +1 -1
- package/src/web/dist/assets/select-DfAJfUCL.js +11 -0
- package/src/web/dist/assets/shield-wbL9EF4o.js +11 -0
- package/src/web/dist/assets/switch-DTxmu4vA.js +1 -0
- package/src/web/dist/assets/{useApiQuery-CkT-JtpV.js → useApiQuery-LZxVJXA3.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/src/web/dist/assets/ApiKeys-kkOS5njK.js +0 -16
- package/src/web/dist/assets/Dashboard-BuFP7xgE.js +0 -16
- package/src/web/dist/assets/Logs-A1_44nYh.js +0 -6
- package/src/web/dist/assets/ModelManagement-CZsts9T9.js +0 -1
- package/src/web/dist/assets/Settings-DDaFQ7RV.js +0 -11
- package/src/web/dist/assets/copy-8Dwvprhw.js +0 -6
- package/src/web/dist/assets/index-CsJ3GRy4.css +0 -1
- package/src/web/dist/assets/index-D-F4C6n_.js +0 -280
- package/src/web/dist/assets/select-fri8gRof.js +0 -11
- package/src/web/dist/assets/switch-BrV6LX33.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as i,a as n}from"./index-
|
|
1
|
+
import{r as s,j as i,a as n}from"./index-iaYfODK6.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-
|
|
1
|
+
import{r as o,j as r,a as t}from"./index-iaYfODK6.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};
|
|
@@ -0,0 +1,11 @@
|
|
|
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-iaYfODK6.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 _e=Pe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
7
|
+
* @license lucide-react v0.344.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const jt=Pe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function Ne(t,[o,e]){return Math.min(e,Math.max(o,t))}function Mt(t){const o=n.useRef({value:t,previous:t});return n.useMemo(()=>(o.current.value!==t&&(o.current.previous=o.current.value,o.current.value=t),o.current.previous),[t])}var At=[" ","Enter","ArrowUp","ArrowDown"],Dt=[" ","Enter"],Q="Select",[ie,de,Ot]=gt(Q),[oe]=vt(Q,[Ot,Re]),ue=Re(),[Lt,Y]=oe(Q),[kt,Bt]=oe(Q),je=t=>{const{__scopeSelect:o,children:e,open:a,defaultOpen:i,onOpenChange:p,value:l,defaultValue:c,onValueChange:s,dir:f,name:g,autoComplete:w,disabled:b,required:N,form:T}=t,d=ue(o),[v,y]=n.useState(null),[u,h]=n.useState(null),[M,A]=n.useState(!1),ne=mt(f),[R,O]=be({prop:a,defaultProp:i??!1,onChange:p,caller:Q}),[W,Z]=be({prop:l,defaultProp:c,onChange:s,caller:Q}),B=n.useRef(null),V=v?T||!!v.closest("form"):!0,[K,H]=n.useState(new Set),U=Array.from(K).map(E=>E.props.value).join(";");return r.jsx(ht,{...d,children:r.jsxs(Lt,{required:N,scope:o,trigger:v,onTriggerChange:y,valueNode:u,onValueNodeChange:h,valueNodeHasChildren:M,onValueNodeHasChildrenChange:A,contentId:Ie(),value:W,onValueChange:Z,open:R,onOpenChange:O,dir:ne,triggerPointerDownPosRef:B,disabled:b,children:[r.jsx(ie.Provider,{scope:o,children:r.jsx(kt,{scope:t.__scopeSelect,onNativeOptionAdd:n.useCallback(E=>{H(L=>new Set(L).add(E))},[]),onNativeOptionRemove:n.useCallback(E=>{H(L=>{const F=new Set(L);return F.delete(E),F})},[]),children:e})}),V?r.jsxs(tt,{"aria-hidden":!0,required:N,tabIndex:-1,name:g,autoComplete:w,value:W,onChange:E=>Z(E.target.value),disabled:b,form:T,children:[W===void 0?r.jsx("option",{value:""}):null,Array.from(K)]},U):null]})})};je.displayName=Q;var Me="SelectTrigger",Ae=n.forwardRef((t,o)=>{const{__scopeSelect:e,disabled:a=!1,...i}=t,p=ue(e),l=Y(Me,e),c=l.disabled||a,s=k(o,l.onTriggerChange),f=de(e),g=n.useRef("touch"),[w,b,N]=nt(d=>{const v=f().filter(h=>!h.disabled),y=v.find(h=>h.value===l.value),u=rt(v,d,y);u!==void 0&&l.onValueChange(u.value)}),T=d=>{c||(l.onOpenChange(!0),N()),d&&(l.triggerPointerDownPosRef.current={x:Math.round(d.pageX),y:Math.round(d.pageY)})};return r.jsx(xt,{asChild:!0,...p,children:r.jsx(j.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":ot(l.value)?"":void 0,...i,ref:s,onClick:P(i.onClick,d=>{d.currentTarget.focus(),g.current!=="mouse"&&T(d)}),onPointerDown:P(i.onPointerDown,d=>{g.current=d.pointerType;const v=d.target;v.hasPointerCapture(d.pointerId)&&v.releasePointerCapture(d.pointerId),d.button===0&&d.ctrlKey===!1&&d.pointerType==="mouse"&&(T(d),d.preventDefault())}),onKeyDown:P(i.onKeyDown,d=>{const v=w.current!=="";!(d.ctrlKey||d.altKey||d.metaKey)&&d.key.length===1&&b(d.key),!(v&&d.key===" ")&&At.includes(d.key)&&(T(),d.preventDefault())})})})});Ae.displayName=Me;var De="SelectValue",Oe=n.forwardRef((t,o)=>{const{__scopeSelect:e,className:a,style:i,children:p,placeholder:l="",...c}=t,s=Y(De,e),{onValueNodeHasChildrenChange:f}=s,g=p!==void 0,w=k(o,s.onValueNodeChange);return $(()=>{f(g)},[f,g]),r.jsx(j.span,{...c,ref:w,style:{pointerEvents:"none"},children:ot(s.value)?r.jsx(r.Fragment,{children:l}):p})});Oe.displayName=De;var Vt="SelectIcon",Le=n.forwardRef((t,o)=>{const{__scopeSelect:e,children:a,...i}=t;return r.jsx(j.span,{"aria-hidden":!0,...i,ref:o,children:a||"▼"})});Le.displayName=Vt;var Ht="SelectPortal",ke=t=>r.jsx(wt,{asChild:!0,...t});ke.displayName=Ht;var ee="SelectContent",Be=n.forwardRef((t,o)=>{const e=Y(ee,t.__scopeSelect),[a,i]=n.useState();if($(()=>{i(new DocumentFragment)},[]),!e.open){const p=a;return p?Ee.createPortal(r.jsx(Ve,{scope:t.__scopeSelect,children:r.jsx(ie.Slot,{scope:t.__scopeSelect,children:r.jsx("div",{children:t.children})})}),p):null}return r.jsx(He,{...t,ref:o})});Be.displayName=ee;var D=10,[Ve,q]=oe(ee),Ut="SelectContentImpl",Ft=bt("SelectContent.RemoveScroll"),He=n.forwardRef((t,o)=>{const{__scopeSelect:e,position:a="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:p,onPointerDownOutside:l,side:c,sideOffset:s,align:f,alignOffset:g,arrowPadding:w,collisionBoundary:b,collisionPadding:N,sticky:T,hideWhenDetached:d,avoidCollisions:v,...y}=t,u=Y(ee,e),[h,M]=n.useState(null),[A,ne]=n.useState(null),R=k(o,m=>M(m)),[O,W]=n.useState(null),[Z,B]=n.useState(null),V=de(e),[K,H]=n.useState(!1),U=n.useRef(!1);n.useEffect(()=>{if(h)return Ct(h)},[h]),It();const E=n.useCallback(m=>{const[I,..._]=V().map(x=>x.ref.current),[C]=_.slice(-1),S=document.activeElement;for(const x of m)if(x===S||(x==null||x.scrollIntoView({block:"nearest"}),x===I&&A&&(A.scrollTop=0),x===C&&A&&(A.scrollTop=A.scrollHeight),x==null||x.focus(),document.activeElement!==S))return},[V,A]),L=n.useCallback(()=>E([O,h]),[E,O,h]);n.useEffect(()=>{K&&L()},[K,L]);const{onOpenChange:F,triggerPointerDownPosRef:z}=u;n.useEffect(()=>{if(h){let m={x:0,y:0};const I=C=>{var S,x;m={x:Math.abs(Math.round(C.pageX)-(((S=z.current)==null?void 0:S.x)??0)),y:Math.abs(Math.round(C.pageY)-(((x=z.current)==null?void 0:x.y)??0))}},_=C=>{m.x<=10&&m.y<=10?C.preventDefault():h.contains(C.target)||F(!1),document.removeEventListener("pointermove",I),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",I),document.addEventListener("pointerup",_,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",_,{capture:!0})}}},[h,F,z]),n.useEffect(()=>{const m=()=>F(!1);return window.addEventListener("blur",m),window.addEventListener("resize",m),()=>{window.removeEventListener("blur",m),window.removeEventListener("resize",m)}},[F]);const[pe,ae]=nt(m=>{const I=V().filter(S=>!S.disabled),_=I.find(S=>S.ref.current===document.activeElement),C=rt(I,m,_);C&&setTimeout(()=>C.ref.current.focus())}),fe=n.useCallback((m,I,_)=>{const C=!U.current&&!_;(u.value!==void 0&&u.value===I||C)&&(W(m),C&&(U.current=!0))},[u.value]),me=n.useCallback(()=>h==null?void 0:h.focus(),[h]),te=n.useCallback((m,I,_)=>{const C=!U.current&&!_;(u.value!==void 0&&u.value===I||C)&&B(m)},[u.value]),le=a==="popper"?Se:Ue,re=le===Se?{side:c,sideOffset:s,align:f,alignOffset:g,arrowPadding:w,collisionBoundary:b,collisionPadding:N,sticky:T,hideWhenDetached:d,avoidCollisions:v}:{};return r.jsx(Ve,{scope:e,content:h,viewport:A,onViewportChange:ne,itemRefCallback:fe,selectedItem:O,onItemLeave:me,itemTextRefCallback:te,focusSelectedItem:L,selectedItemText:Z,position:a,isPositioned:K,searchRef:pe,children:r.jsx(Tt,{as:Ft,allowPinchZoom:!0,children:r.jsx(Nt,{asChild:!0,trapped:u.open,onMountAutoFocus:m=>{m.preventDefault()},onUnmountAutoFocus:P(i,m=>{var I;(I=u.trigger)==null||I.focus({preventScroll:!0}),m.preventDefault()}),children:r.jsx(Pt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:p,onPointerDownOutside:l,onFocusOutside:m=>m.preventDefault(),onDismiss:()=>u.onOpenChange(!1),children:r.jsx(le,{role:"listbox",id:u.contentId,"data-state":u.open?"open":"closed",dir:u.dir,onContextMenu:m=>m.preventDefault(),...y,...re,onPlaced:()=>H(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:P(y.onKeyDown,m=>{const I=m.ctrlKey||m.altKey||m.metaKey;if(m.key==="Tab"&&m.preventDefault(),!I&&m.key.length===1&&ae(m.key),["ArrowUp","ArrowDown","Home","End"].includes(m.key)){let C=V().filter(S=>!S.disabled).map(S=>S.ref.current);if(["ArrowUp","End"].includes(m.key)&&(C=C.slice().reverse()),["ArrowUp","ArrowDown"].includes(m.key)){const S=m.target,x=C.indexOf(S);C=C.slice(x+1)}setTimeout(()=>E(C)),m.preventDefault()}})})})})})})});He.displayName=Ut;var Wt="SelectItemAlignedPosition",Ue=n.forwardRef((t,o)=>{const{__scopeSelect:e,onPlaced:a,...i}=t,p=Y(ee,e),l=q(ee,e),[c,s]=n.useState(null),[f,g]=n.useState(null),w=k(o,R=>g(R)),b=de(e),N=n.useRef(!1),T=n.useRef(!0),{viewport:d,selectedItem:v,selectedItemText:y,focusSelectedItem:u}=l,h=n.useCallback(()=>{if(p.trigger&&p.valueNode&&c&&f&&d&&v&&y){const R=p.trigger.getBoundingClientRect(),O=f.getBoundingClientRect(),W=p.valueNode.getBoundingClientRect(),Z=y.getBoundingClientRect();if(p.dir!=="rtl"){const S=Z.left-O.left,x=W.left-S,X=R.left-x,J=R.width+X,he=Math.max(J,O.width),ve=window.innerWidth-D,ge=Ne(x,[D,Math.max(D,ve-he)]);c.style.minWidth=J+"px",c.style.left=ge+"px"}else{const S=O.right-Z.right,x=window.innerWidth-W.right-S,X=window.innerWidth-R.right-x,J=R.width+X,he=Math.max(J,O.width),ve=window.innerWidth-D,ge=Ne(x,[D,Math.max(D,ve-he)]);c.style.minWidth=J+"px",c.style.right=ge+"px"}const B=b(),V=window.innerHeight-D*2,K=d.scrollHeight,H=window.getComputedStyle(f),U=parseInt(H.borderTopWidth,10),E=parseInt(H.paddingTop,10),L=parseInt(H.borderBottomWidth,10),F=parseInt(H.paddingBottom,10),z=U+E+K+F+L,pe=Math.min(v.offsetHeight*5,z),ae=window.getComputedStyle(d),fe=parseInt(ae.paddingTop,10),me=parseInt(ae.paddingBottom,10),te=R.top+R.height/2-D,le=V-te,re=v.offsetHeight/2,m=v.offsetTop+re,I=U+E+m,_=z-I;if(I<=te){const S=B.length>0&&v===B[B.length-1].ref.current;c.style.bottom="0px";const x=f.clientHeight-d.offsetTop-d.offsetHeight,X=Math.max(le,re+(S?me:0)+x+L),J=I+X;c.style.height=J+"px"}else{const S=B.length>0&&v===B[0].ref.current;c.style.top="0px";const X=Math.max(te,U+d.offsetTop+(S?fe:0)+re)+_;c.style.height=X+"px",d.scrollTop=I-te+d.offsetTop}c.style.margin=`${D}px 0`,c.style.minHeight=pe+"px",c.style.maxHeight=V+"px",a==null||a(),requestAnimationFrame(()=>N.current=!0)}},[b,p.trigger,p.valueNode,c,f,d,v,y,p.dir,a]);$(()=>h(),[h]);const[M,A]=n.useState();$(()=>{f&&A(window.getComputedStyle(f).zIndex)},[f]);const ne=n.useCallback(R=>{R&&T.current===!0&&(h(),u==null||u(),T.current=!1)},[h,u]);return r.jsx(zt,{scope:e,contentWrapper:c,shouldExpandOnScrollRef:N,onScrollButtonChange:ne,children:r.jsx("div",{ref:s,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:r.jsx(j.div,{...i,ref:w,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});Ue.displayName=Wt;var Kt="SelectPopperPosition",Se=n.forwardRef((t,o)=>{const{__scopeSelect:e,align:a="start",collisionPadding:i=D,...p}=t,l=ue(e);return r.jsx(Rt,{...l,...p,ref:o,align:a,collisionPadding:i,style:{boxSizing:"border-box",...p.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Se.displayName=Kt;var[zt,Te]=oe(ee,{}),xe="SelectViewport",Fe=n.forwardRef((t,o)=>{const{__scopeSelect:e,nonce:a,...i}=t,p=q(xe,e),l=Te(xe,e),c=k(o,p.onViewportChange),s=n.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),r.jsx(ie.Slot,{scope:e,children:r.jsx(j.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:P(i.onScroll,f=>{const g=f.currentTarget,{contentWrapper:w,shouldExpandOnScrollRef:b}=l;if(b!=null&&b.current&&w){const N=Math.abs(s.current-g.scrollTop);if(N>0){const T=window.innerHeight-D*2,d=parseFloat(w.style.minHeight),v=parseFloat(w.style.height),y=Math.max(d,v);if(y<T){const u=y+N,h=Math.min(T,u),M=u-h;w.style.height=h+"px",w.style.bottom==="0px"&&(g.scrollTop=M>0?M:0,w.style.justifyContent="flex-end")}}}s.current=g.scrollTop})})})]})});Fe.displayName=xe;var We="SelectGroup",[$t,Gt]=oe(We),Yt=n.forwardRef((t,o)=>{const{__scopeSelect:e,...a}=t,i=Ie();return r.jsx($t,{scope:e,id:i,children:r.jsx(j.div,{role:"group","aria-labelledby":i,...a,ref:o})})});Yt.displayName=We;var Ke="SelectLabel",ze=n.forwardRef((t,o)=>{const{__scopeSelect:e,...a}=t,i=Gt(Ke,e);return r.jsx(j.div,{id:i.id,...a,ref:o})});ze.displayName=Ke;var ce="SelectItem",[qt,$e]=oe(ce),Ge=n.forwardRef((t,o)=>{const{__scopeSelect:e,value:a,disabled:i=!1,textValue:p,...l}=t,c=Y(ce,e),s=q(ce,e),f=c.value===a,[g,w]=n.useState(p??""),[b,N]=n.useState(!1),T=k(o,u=>{var h;return(h=s.itemRefCallback)==null?void 0:h.call(s,u,a,i)}),d=Ie(),v=n.useRef("touch"),y=()=>{i||(c.onValueChange(a),c.onOpenChange(!1))};if(a==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(qt,{scope:e,value:a,disabled:i,textId:d,isSelected:f,onItemTextChange:n.useCallback(u=>{w(h=>h||((u==null?void 0:u.textContent)??"").trim())},[]),children:r.jsx(ie.ItemSlot,{scope:e,value:a,disabled:i,textValue:g,children:r.jsx(j.div,{role:"option","aria-labelledby":d,"data-highlighted":b?"":void 0,"aria-selected":f&&b,"data-state":f?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:T,onFocus:P(l.onFocus,()=>N(!0)),onBlur:P(l.onBlur,()=>N(!1)),onClick:P(l.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:P(l.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:P(l.onPointerDown,u=>{v.current=u.pointerType}),onPointerMove:P(l.onPointerMove,u=>{var h;v.current=u.pointerType,i?(h=s.onItemLeave)==null||h.call(s):v.current==="mouse"&&u.currentTarget.focus({preventScroll:!0})}),onPointerLeave:P(l.onPointerLeave,u=>{var h;u.currentTarget===document.activeElement&&((h=s.onItemLeave)==null||h.call(s))}),onKeyDown:P(l.onKeyDown,u=>{var M;((M=s.searchRef)==null?void 0:M.current)!==""&&u.key===" "||(Dt.includes(u.key)&&y(),u.key===" "&&u.preventDefault())})})})})});Ge.displayName=ce;var se="SelectItemText",Ye=n.forwardRef((t,o)=>{const{__scopeSelect:e,className:a,style:i,...p}=t,l=Y(se,e),c=q(se,e),s=$e(se,e),f=Bt(se,e),[g,w]=n.useState(null),b=k(o,y=>w(y),s.onItemTextChange,y=>{var u;return(u=c.itemTextRefCallback)==null?void 0:u.call(c,y,s.value,s.disabled)}),N=g==null?void 0:g.textContent,T=n.useMemo(()=>r.jsx("option",{value:s.value,disabled:s.disabled,children:N},s.value),[s.disabled,s.value,N]),{onNativeOptionAdd:d,onNativeOptionRemove:v}=f;return $(()=>(d(T),()=>v(T)),[d,v,T]),r.jsxs(r.Fragment,{children:[r.jsx(j.span,{id:s.textId,...p,ref:b}),s.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Ee.createPortal(p.children,l.valueNode):null]})});Ye.displayName=se;var qe="SelectItemIndicator",Ze=n.forwardRef((t,o)=>{const{__scopeSelect:e,...a}=t;return $e(qe,e).isSelected?r.jsx(j.span,{"aria-hidden":!0,...a,ref:o}):null});Ze.displayName=qe;var we="SelectScrollUpButton",Xe=n.forwardRef((t,o)=>{const e=q(we,t.__scopeSelect),a=Te(we,t.__scopeSelect),[i,p]=n.useState(!1),l=k(o,a.onScrollButtonChange);return $(()=>{if(e.viewport&&e.isPositioned){let c=function(){const f=s.scrollTop>0;p(f)};const s=e.viewport;return c(),s.addEventListener("scroll",c),()=>s.removeEventListener("scroll",c)}},[e.viewport,e.isPositioned]),i?r.jsx(Qe,{...t,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:s}=e;c&&s&&(c.scrollTop=c.scrollTop-s.offsetHeight)}}):null});Xe.displayName=we;var ye="SelectScrollDownButton",Je=n.forwardRef((t,o)=>{const e=q(ye,t.__scopeSelect),a=Te(ye,t.__scopeSelect),[i,p]=n.useState(!1),l=k(o,a.onScrollButtonChange);return $(()=>{if(e.viewport&&e.isPositioned){let c=function(){const f=s.scrollHeight-s.clientHeight,g=Math.ceil(s.scrollTop)<f;p(g)};const s=e.viewport;return c(),s.addEventListener("scroll",c),()=>s.removeEventListener("scroll",c)}},[e.viewport,e.isPositioned]),i?r.jsx(Qe,{...t,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:s}=e;c&&s&&(c.scrollTop=c.scrollTop+s.offsetHeight)}}):null});Je.displayName=ye;var Qe=n.forwardRef((t,o)=>{const{__scopeSelect:e,onAutoScroll:a,...i}=t,p=q("SelectScrollButton",e),l=n.useRef(null),c=de(e),s=n.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return n.useEffect(()=>()=>s(),[s]),$(()=>{var g;const f=c().find(w=>w.ref.current===document.activeElement);(g=f==null?void 0:f.ref.current)==null||g.scrollIntoView({block:"nearest"})},[c]),r.jsx(j.div,{"aria-hidden":!0,...i,ref:o,style:{flexShrink:0,...i.style},onPointerDown:P(i.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(a,50))}),onPointerMove:P(i.onPointerMove,()=>{var f;(f=p.onItemLeave)==null||f.call(p),l.current===null&&(l.current=window.setInterval(a,50))}),onPointerLeave:P(i.onPointerLeave,()=>{s()})})}),Zt="SelectSeparator",et=n.forwardRef((t,o)=>{const{__scopeSelect:e,...a}=t;return r.jsx(j.div,{"aria-hidden":!0,...a,ref:o})});et.displayName=Zt;var Ce="SelectArrow",Xt=n.forwardRef((t,o)=>{const{__scopeSelect:e,...a}=t,i=ue(e),p=Y(Ce,e),l=q(Ce,e);return p.open&&l.position==="popper"?r.jsx(Et,{...i,...a,ref:o}):null});Xt.displayName=Ce;var Jt="SelectBubbleInput",tt=n.forwardRef(({__scopeSelect:t,value:o,...e},a)=>{const i=n.useRef(null),p=k(a,i),l=Mt(o);return n.useEffect(()=>{const c=i.current;if(!c)return;const s=window.HTMLSelectElement.prototype,g=Object.getOwnPropertyDescriptor(s,"value").set;if(l!==o&&g){const w=new Event("change",{bubbles:!0});g.call(c,o),c.dispatchEvent(w)}},[l,o]),r.jsx(j.select,{...e,style:{...St,...e.style},ref:p,defaultValue:o})});tt.displayName=Jt;function ot(t){return t===""||t===void 0}function nt(t){const o=yt(t),e=n.useRef(""),a=n.useRef(0),i=n.useCallback(l=>{const c=e.current+l;o(c),function s(f){e.current=f,window.clearTimeout(a.current),f!==""&&(a.current=window.setTimeout(()=>s(""),1e3))}(c)},[o]),p=n.useCallback(()=>{e.current="",window.clearTimeout(a.current)},[]);return n.useEffect(()=>()=>window.clearTimeout(a.current),[]),[e,i,p]}function rt(t,o,e){const i=o.length>1&&Array.from(o).every(f=>f===o[0])?o[0]:o,p=e?t.indexOf(e):-1;let l=Qt(t,Math.max(p,0));i.length===1&&(l=l.filter(f=>f!==e));const s=l.find(f=>f.textValue.toLowerCase().startsWith(i.toLowerCase()));return s!==e?s:void 0}function Qt(t,o){return t.map((e,a)=>t[(o+a)%t.length])}var eo=je,st=Ae,to=Oe,oo=Le,no=ke,at=Be,ro=Fe,lt=ze,ct=Ge,so=Ye,ao=Ze,it=Xe,dt=Je,ut=et;const mo=eo,ho=to,lo=n.forwardRef(({className:t,children:o,...e},a)=>r.jsxs(st,{ref:a,className:G("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...e,children:[o,r.jsx(oo,{asChild:!0,children:r.jsx(_e,{className:"h-4 w-4 opacity-50"})})]}));lo.displayName=st.displayName;const pt=n.forwardRef(({className:t,...o},e)=>r.jsx(it,{ref:e,className:G("flex cursor-default items-center justify-center py-1",t),...o,children:r.jsx(jt,{className:"h-4 w-4"})}));pt.displayName=it.displayName;const ft=n.forwardRef(({className:t,...o},e)=>r.jsx(dt,{ref:e,className:G("flex cursor-default items-center justify-center py-1",t),...o,children:r.jsx(_e,{className:"h-4 w-4"})}));ft.displayName=dt.displayName;const co=n.forwardRef(({className:t,children:o,position:e="popper",...a},i)=>r.jsx(no,{children:r.jsxs(at,{ref:i,className:G("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:e,...a,children:[r.jsx(pt,{}),r.jsx(ro,{className:G("p-1",e==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:o}),r.jsx(ft,{})]})}));co.displayName=at.displayName;const io=n.forwardRef(({className:t,...o},e)=>r.jsx(lt,{ref:e,className:G("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...o}));io.displayName=lt.displayName;const uo=n.forwardRef(({className:t,children:o,...e},a)=>r.jsxs(ct,{ref:a,className:G("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...e,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(ao,{children:r.jsx(_t,{className:"h-4 w-4"})})}),r.jsx(so,{children:o})]}));uo.displayName=ct.displayName;const po=n.forwardRef(({className:t,...o},e)=>r.jsx(ut,{ref:e,className:G("-mx-1 my-1 h-px bg-muted",t),...o}));po.displayName=ut.displayName;export{jt as C,mo as S,lo as a,ho as b,co as c,uo as d,_e as e,Mt as u};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as e}from"./index-iaYfODK6.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 a=e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
7
|
+
* @license lucide-react v0.344.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const t=e("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);export{a as C,t as S};
|
|
@@ -0,0 +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-iaYfODK6.js";import{u as A}from"./select-DfAJfUCL.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,a6 as pt,a7 as S,s as Z,a8 as H,m as $,a9 as tt,aa as bt,ab as Ot,ac as q,ad as Tt,ae as wt,af as yt,n as St,r as I,o as Qt,l as Mt,ag as xt,d as _t,t as Ut}from"./index-D-F4C6n_.js";var g,a,j,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,j);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))||H(this.options.staleTime,i(this,a))!==H(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,j),{state:L}=t;let l={...L},N=!1,f;if(s._optimisticResults){const R=this.hasListeners(),W=!R&>(t,s),_=R&&mt(t,r,s,h);(W||_)&&(l={...l,...wt(L.data,t.options)}),s._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:A,errorUpdatedAt:k,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)&&(A=i(this,O),f=i(this,F),k=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:A,errorUpdatedAt:k,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&<,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,j=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=H(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,j,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&&H(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(H(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 At=I.createContext(Nt()),kt=()=>I.useContext(At),Bt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ht=e=>{I.useEffect(()=>{e.clearReset()},[e])},jt=({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,A,k;const r=Lt(),h=kt(),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),Ht(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(jt({result:v,errorResetBoundary:h,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw v.error;if((A=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||A.call(f,c,v),c.experimental_prefetchInRender&&!tt&&Vt(v,r)){const m=w?Rt(c,p,h):(k=o.getQueryCache().get(c.queryHash))==null?void 0:k.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-iaYfODK6.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&>(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&<,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};
|
package/src/web/dist/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
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-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-iaYfODK6.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DDEa11GU.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body class="bg-slate-50 text-slate-900 dark:bg-slate-900 dark:text-slate-50">
|
|
12
12
|
<div id="root"></div>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{c as D,r as c,j as e,a as $,u as Z,b as de,L as pe,e as o,K as me,v as ue,d as K}from"./index-D-F4C6n_.js";import{E as ye}from"./index-CprjNJ8x.js";import{u as w}from"./useApiQuery-CkT-JtpV.js";import{P as xe,B as q}from"./PageHeader-BatC8G-O.js";import{P as z}from"./PageSection-HTrZH-H0.js";import{c as he}from"./clipboard-CALi6bTW.js";import{I as ge}from"./input-x0jTfvyD.js";import{L as I}from"./label-t5tthgxG.js";import{C as T,a as S}from"./card-DQb2ediN.js";import{P as fe,D as W,a as H,b as V,c as G,d as je,e as Q}from"./dialog-B9ZBo_5P.js";import{C as U}from"./copy-8Dwvprhw.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 ve=D("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
|
|
7
|
-
* @license lucide-react v0.344.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ke=D("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
12
|
-
* @license lucide-react v0.344.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Ne=D("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),_=c.forwardRef(({className:a,...r},y)=>e.jsx("textarea",{className:$("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background 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",a),ref:y,...r}));_.displayName="Textarea";const be=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function Pe(){const{t:a}=Z(),{pushToast:r}=de(),[y,m]=c.useState(!1),[x,h]=c.useState(""),[L,N]=c.useState(""),[l,b]=c.useState(null),[J,E]=c.useState(null),[p,X]=c.useState(7),[M,A]=c.useState(new Map),[Y,O]=c.useState(null),g=w(["api-keys"],{url:"/api/keys",method:"GET"}),j=w(["api-keys","overview",p],{url:"/api/stats/api-keys/overview",method:"GET",params:{days:p}}),f=w(["api-keys","usage",p],{url:"/api/stats/api-keys/usage",method:"GET",params:{days:p,limit:10}}),k=g.data??[],u=j.data,d=f.data??[],ee=k.some(s=>s.isWildcard),ae=u?u.totalKeys.toLocaleString():"-",se=u?u.enabledKeys.toLocaleString():"-",te=u?u.activeKeys.toLocaleString():"-",P=async()=>{var s,t;if(!x.trim()){r({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}try{const i=await K.post("/api/keys",{name:x.trim(),description:L.trim()||void 0});b(i.data),m(!1),h(""),N(""),g.refetch(),j.refetch(),f.refetch(),r({title:a("apiKeys.toast.keyCreated"),variant:"success"})}catch(i){r({title:a("apiKeys.toast.createFailure",{message:((t=(s=i.response)==null?void 0:s.data)==null?void 0:t.error)||i.message}),variant:"error"})}},ie=async(s,t)=>{var i,n;try{await K.patch(`/api/keys/${s}`,{enabled:!t}),g.refetch(),j.refetch(),r({title:a("apiKeys.toast.keyUpdated"),variant:"success"})}catch(v){r({title:a("apiKeys.toast.updateFailure",{message:((n=(i=v.response)==null?void 0:i.data)==null?void 0:n.error)||v.message}),variant:"error"})}},re=async s=>{var t,i;if(confirm(a("apiKeys.confirmDelete"))){E(s);try{await K.delete(`/api/keys/${s}`),g.refetch(),j.refetch(),f.refetch(),r({title:a("apiKeys.toast.keyDeleted"),variant:"success"})}catch(n){r({title:a("apiKeys.toast.deleteFailure",{message:((i=(t=n.response)==null?void 0:t.data)==null?void 0:i.error)||n.message}),variant:"error"})}finally{E(null)}}},ne=async s=>{var t,i;if(!M.has(s)){O(s);try{const n=await K.get(`/api/keys/${s}/reveal`);A(v=>new Map(v).set(s,n.data.key))}catch(n){r({title:a("apiKeys.toast.revealFailure"),description:((i=(t=n.response)==null?void 0:t.data)==null?void 0:i.error)||n.message,variant:"error"})}finally{O(null)}}},le=s=>{A(t=>{const i=new Map(t);return i.delete(s),i})},R=async s=>{try{await he(s),r({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(t){r({title:a("apiKeys.toast.copyFailure"),description:t instanceof Error?t.message:a("common.unknownError"),variant:"error"})}},F=s=>s?new Date(s).toLocaleString():a("common.noData"),ce=c.useMemo(()=>{const s=d.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:d.map(t=>t.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[d,a]),oe=c.useMemo(()=>{const s=d.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:d.map(t=>t.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:d.map(t=>t.outputTokens)}]}},[d,a]);return g.isLoading?e.jsx(pe,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(xe,{icon:e.jsx(me,{className:"h-5 w-5","aria-hidden":"true"}),title:a("apiKeys.title"),description:a("apiKeys.description"),actions:e.jsxs(o,{onClick:()=>m(!0),children:[e.jsx(fe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),e.jsx(z,{title:a("apiKeys.analytics.title"),description:a("apiKeys.analytics.description",{days:p}),actions:e.jsx("div",{className:"flex items-center gap-1 rounded-lg border p-1",children:be.map(s=>{const t=p===s.value;return e.jsx("button",{type:"button",onClick:()=>X(s.value),className:$("inline-flex h-7 items-center rounded-md px-3 text-xs font-medium transition-colors",t?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:a(s.labelKey)},s.value)})}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(C,{label:a("apiKeys.analytics.cards.total"),value:ae}),e.jsx(C,{label:a("apiKeys.analytics.cards.enabled"),value:se}),e.jsx(C,{label:a("apiKeys.analytics.cards.active",{days:p}),value:te})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(B,{title:a("apiKeys.analytics.charts.requests"),loading:f.isLoading,empty:d.length===0,emptyText:a("apiKeys.analytics.empty"),option:ce}),e.jsx(B,{title:a("apiKeys.analytics.charts.tokens"),loading:f.isLoading,empty:d.length===0,emptyText:a("apiKeys.analytics.empty"),option:oe})]})]})}),e.jsx(z,{title:a("apiKeys.list.title"),description:ee?a("apiKeys.wildcardHint"):void 0,children:k.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.list.empty")})}):e.jsx("div",{className:"grid gap-4",children:k.map(s=>{const t=(s.totalInputTokens+s.totalOutputTokens).toLocaleString(),i=M.get(s.id),n=Y===s.id;return e.jsx(T,{children:e.jsx(S,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:s.name}),s.isWildcard&&e.jsx(q,{variant:"secondary",children:a("apiKeys.wildcard")}),e.jsx(q,{variant:s.enabled?"default":"outline",children:s.enabled?a("apiKeys.status.enabled"):a("apiKeys.status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"rounded-md bg-muted px-3 py-1.5 font-mono text-sm",children:s.isWildcard?a("apiKeys.wildcard"):i??s.maskedKey??"********"}),!s.isWildcard&&e.jsx("div",{className:"flex items-center gap-1",children:i?e.jsxs(e.Fragment,{children:[e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void R(i),"aria-label":a("common.actions.copy"),title:a("common.actions.copy"),children:e.jsx(U,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(s.id),"aria-label":a("apiKeys.actions.hide"),title:a("apiKeys.actions.hide"),children:e.jsx(ve,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void ne(s.id),disabled:n,"aria-label":a("apiKeys.actions.reveal"),title:a("apiKeys.actions.reveal"),children:e.jsx(Ke,{className:"h-4 w-4","aria-hidden":"true"})})})]}),s.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.wildcardHint")}):s.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:s.description}):null,e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:F(s.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:F(s.lastUsedAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.requestCount")}),e.jsx("p",{className:"font-medium",children:s.requestCount.toLocaleString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.totalTokens")}),e.jsx("p",{className:"font-medium",children:t})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{variant:s.enabled?"outline":"default",size:"sm",onClick:()=>ie(s.id,s.enabled),children:s.enabled?a("apiKeys.actions.disable"):a("apiKeys.actions.enable")}),!s.isWildcard&&e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>re(s.id),disabled:J===s.id,"aria-label":a("apiKeys.actions.delete"),children:e.jsx(Ne,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})},s.id)})})}),e.jsx(W,{open:y,onOpenChange:m,children:e.jsxs(H,{children:[e.jsxs(V,{children:[e.jsx(G,{children:a("apiKeys.createNew")}),e.jsx(je,{children:a("apiKeys.createDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(I,{htmlFor:"keyName",children:[a("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(ge,{id:"keyName",value:x,onChange:s=>h(s.target.value),placeholder:a("apiKeys.keyNamePlaceholder"),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),P())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"keyDescription",children:a("apiKeys.descriptionLabel")}),e.jsx(_,{id:"keyDescription",value:L,onChange:s=>N(s.target.value),placeholder:a("apiKeys.keyDescriptionPlaceholder"),rows:3})]})]}),e.jsxs(Q,{children:[e.jsx(o,{variant:"outline",onClick:()=>{m(!1),h(""),N("")},children:a("common.actions.cancel")}),e.jsx(o,{onClick:()=>void P(),children:a("apiKeys.createAction")})]})]})}),e.jsx(W,{open:!!l,onOpenChange:()=>b(null),children:e.jsxs(H,{children:[e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600",children:e.jsx(ue,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(G,{children:a("apiKeys.keyCreated")})]})}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:a("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-md bg-muted px-4 py-3 font-mono text-sm",children:l==null?void 0:l.key}),(l==null?void 0:l.description)&&e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:l.description}),e.jsxs(Q,{children:[e.jsxs(o,{onClick:()=>void R((l==null?void 0:l.key)??""),children:[e.jsx(U,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("common.actions.copy")]}),e.jsx(o,{variant:"outline",onClick:()=>b(null),children:a("common.actions.close")})]})]})})]})}function C({label:a,value:r}){return e.jsx(T,{children:e.jsxs(S,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:r})]})})}function B({title:a,option:r,loading:y,empty:m,emptyText:x}){const{t:h}=Z();return e.jsx(T,{children:e.jsxs(S,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:a}),y?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:h("common.loadingShort")})}):m?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-lg border border-dashed",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:x})}):e.jsx(ye,{option:r,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}export{Pe as default};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{c as O,r as d,j as e,a as f,u as I,b as ne,d as ie,t as le,L as ce,B as D,e as me}from"./index-D-F4C6n_.js";import{E as he}from"./index-CprjNJ8x.js";import{P as ue,B as k}from"./PageHeader-BatC8G-O.js";import{P as X}from"./PageSection-HTrZH-H0.js";import{u as S}from"./useApiQuery-CkT-JtpV.js";import{C as G,a as Q}from"./card-DQb2ediN.js";import{S as xe,a as pe,b as be,c as ge,d as q}from"./select-fri8gRof.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 $=O("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/**
|
|
7
|
-
* @license lucide-react v0.344.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const fe=O("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
|
|
12
|
-
* @license lucide-react v0.344.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const ye=O("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),F=d.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-lg",children:e.jsx("table",{ref:a,className:f("w-full caption-bottom text-sm border-collapse",t),...s})}));F.displayName="Table";const H=d.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:f("bg-muted/40 [&_tr]:border-b [&_tr]:border-border/60",t),...s}));H.displayName="TableHeader";const _=d.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:f("[&_tr:last-child]:border-0",t),...s}));_.displayName="TableBody";const je=d.forwardRef(({className:t,...s},a)=>e.jsx("tfoot",{ref:a,className:f("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));je.displayName="TableFooter";const A=d.forwardRef(({className:t,...s},a)=>e.jsx("tr",{ref:a,className:f("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...s}));A.displayName="TableRow";const h=d.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:f("h-11 px-4 text-left align-middle text-xs font-semibold uppercase tracking-wider text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...s}));h.displayName="TableHead";const u=d.forwardRef(({className:t,...s},a)=>e.jsx("td",{ref:a,className:f("px-4 py-3 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...s}));u.displayName="TableCell";const ve=d.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:f("mt-4 text-sm text-muted-foreground",t),...s}));ve.displayName="TableCaption";function P(t,s,a){return t==null?"-":`${t.toLocaleString(void 0,a)} ${s}`}function W(t){if(t==null)return"-";if(t<1024)return`${t} B`;const s=["KB","MB","GB","TB"];let a=t/1024,r=0;for(;a>=1024&&r<s.length-1;)a/=1024,r+=1;return`${a.toFixed(a>=100?0:a>=10?1:2)} ${s[r]}`}function Ae(){var U,V,K;const{t}=I(),{pushToast:s}=ne(),[a,r]=d.useState("all"),[i,y]=d.useState(!1),x=a==="all"?void 0:a,Y=S(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"}),N=S(["stats","overview",a],{url:"/api/stats/overview",method:"GET",params:x?{endpoint:x}:void 0}),T=S(["stats","daily",14,a],{url:"/api/stats/daily",method:"GET",params:{days:14,...x?{endpoint:x}:{}}}),g=S(["stats","model",7,6,a],{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...x?{endpoint:x}:{}}}),E=S(["status"],{url:"/api/status",method:"GET"}),j=S(["db","info"],{url:"/api/db/info",method:"GET"}),z=j.refetch??(async()=>{}),C=S(["logs","recent",a],{url:"/api/logs",method:"GET",params:{limit:5,...x?{endpoint:x}:{}}},{refetchInterval:3e4});d.useEffect(()=>{N.isError&&N.error&&s({title:t("dashboard.toast.overviewError"),description:N.error.message,variant:"error"})},[N.isError,N.error,s,t]),d.useEffect(()=>{T.isError&&T.error&&s({title:t("dashboard.toast.dailyError"),description:T.error.message,variant:"error"})},[T.isError,T.error,s,t]),d.useEffect(()=>{g.isError&&g.error&&s({title:t("dashboard.toast.modelError"),description:g.error.message,variant:"error"})},[g.isError,g.error,s,t]),d.useEffect(()=>{E.isError&&E.error&&s({title:t("dashboard.toast.statusError"),description:E.error.message,variant:"error"})},[E.isError,E.error,s,t]),d.useEffect(()=>{j.isError&&j.error&&s({title:t("dashboard.toast.dbError"),description:j.error.message,variant:"error"})},[j.isError,j.error,s,t]);const Z=d.useCallback(async()=>{if(!i){y(!0);try{await ie.post("/api/db/compact"),await z(),s({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(n){const m=le(n);s({title:t("dashboard.toast.compactError.title"),description:m.message,variant:"error"})}finally{y(!1)}}},[i,s,z,t]);d.useEffect(()=>{C.isError&&C.error&&s({title:t("dashboard.toast.recentError"),description:C.error.message,variant:"error"})},[C.isError,C.error,s,t]);const o=N.data,v=T.data??[],l=g.data??[],L=E.data,R=j.data,ee=((U=C.data)==null?void 0:U.items)??[],te=R?W(R.totalBytes??R.sizeBytes):"-",ae=R?W(R.memoryRssBytes??0):"-",se=d.useMemo(()=>{const n=v.map(b=>b.date),m=t("dashboard.charts.barRequests"),c=t("dashboard.charts.lineInput"),B=t("dashboard.charts.lineOutput"),p=t("dashboard.charts.lineCacheRead"),J=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[m,c,B,p,J]},grid:{left:60,right:40,top:60,bottom:60},xAxis:{type:"category",data:n},yAxis:{type:"value"},series:[{name:m,type:"bar",data:v.map(b=>b.requestCount),itemStyle:{color:"hsl(var(--primary))",borderRadius:[4,4,0,0]}},{name:c,type:"line",data:v.map(b=>b.inputTokens),smooth:!0,itemStyle:{color:"#10b981"},lineStyle:{width:2}},{name:B,type:"line",data:v.map(b=>b.outputTokens),smooth:!0,itemStyle:{color:"#f59e0b"},lineStyle:{width:2}},{name:p,type:"line",data:v.map(b=>b.cacheReadTokens),smooth:!0,itemStyle:{color:"#8b5cf6"},lineStyle:{width:2}},{name:J,type:"line",data:v.map(b=>b.cacheCreationTokens),smooth:!0,itemStyle:{color:"#ec4899"},lineStyle:{width:2}}]}},[v,t]),re=d.useMemo(()=>{const n=l.map(p=>`${p.provider}/${p.model}`),m=t("dashboard.charts.barRequests"),c=t("dashboard.charts.lineInput"),B=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[m,c,B]},grid:{left:80,right:60,top:60,bottom:100},xAxis:{type:"category",data:n,axisLabel:{rotate:30}},yAxis:[{type:"value",name:m},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:m,type:"bar",data:l.map(p=>p.requests),itemStyle:{color:"#6366f1",borderRadius:[4,4,0,0]}},{name:c,type:"line",yAxisIndex:1,smooth:!0,data:l.map(p=>p.inputTokens??0),itemStyle:{color:"#10b981"}},{name:B,type:"line",yAxisIndex:1,smooth:!0,data:l.map(p=>p.outputTokens??0),itemStyle:{color:"#f59e0b"}}]}},[l,t]),oe=d.useMemo(()=>{const n=l.map(c=>`${c.provider}/${c.model}`),m=t("dashboard.charts.ttftLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:n,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:m,type:"bar",data:l.map(c=>c.avgTtftMs??0),itemStyle:{color:"hsl(var(--primary))",borderRadius:[4,4,0,0]}}]}},[l,t]),de=d.useMemo(()=>{const n=l.map(c=>`${c.provider}/${c.model}`),m=t("dashboard.charts.tpotLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:n,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:m,type:"bar",data:l.map(c=>c.avgTpotMs??0),itemStyle:{color:"#f59e0b",borderRadius:[4,4,0,0]}}]}},[l,t]);return N.isPending||E.isPending||j.isPending?e.jsx(ce,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ue,{icon:e.jsx(D,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("dashboard.filters.endpoint")}),e.jsxs(xe,{value:a,onValueChange:r,children:[e.jsx(pe,{className:"w-[140px]",children:e.jsx(be,{})}),e.jsxs(ge,{children:[e.jsx(q,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(q,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(q,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),(K=(V=Y.data)==null?void 0:V.endpoints)==null?void 0:K.map(n=>e.jsx(q,{value:n.id,children:n.label||n.id},n.id))]})]})]})}),L&&e.jsx(G,{children:e.jsxs(Q,{className:"flex flex-wrap items-center gap-3 pt-4",children:[e.jsx(k,{variant:"default",className:"bg-emerald-500",children:t("dashboard.status.listening",{host:L.host??"0.0.0.0",port:L.port})}),e.jsx(k,{variant:"secondary",children:t("dashboard.status.providers",{value:L.providers.toLocaleString()})}),e.jsx(k,{variant:"secondary",children:t("dashboard.status.todayRequests",{value:((o==null?void 0:o.today.requests)??0).toLocaleString()})}),e.jsx(k,{variant:"outline",children:t("dashboard.status.active",{value:(L.activeRequests??0).toLocaleString()})}),e.jsx(k,{variant:"outline",children:t("dashboard.status.dbSize",{value:te})}),e.jsx(k,{variant:"outline",children:t("dashboard.status.memory",{value:ae})}),e.jsx(me,{variant:"outline",size:"sm",onClick:Z,disabled:i,children:t(i?"dashboard.actions.compacting":"dashboard.actions.compact")})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(w,{icon:e.jsx($,{className:"h-5 w-5"}),title:t("dashboard.cards.todayRequests"),value:(o==null?void 0:o.today.requests)??0,suffix:t("common.units.request"),color:"blue"}),e.jsx(w,{icon:e.jsx(ye,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(o==null?void 0:o.today.inputTokens)??0,suffix:t("common.units.token"),color:"emerald"}),e.jsx(w,{icon:e.jsx($,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheRead"),value:(o==null?void 0:o.today.cacheReadTokens)??0,suffix:t("common.units.token"),color:"violet"}),e.jsx(w,{icon:e.jsx($,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheCreation"),value:(o==null?void 0:o.today.cacheCreationTokens)??0,suffix:t("common.units.token"),color:"rose"}),e.jsx(w,{icon:e.jsx(D,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(o==null?void 0:o.today.outputTokens)??0,suffix:t("common.units.token"),color:"amber"}),e.jsx(w,{icon:e.jsx(fe,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(o==null?void 0:o.today.avgLatencyMs)??0,suffix:t("common.units.ms"),color:"cyan"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(M,{title:t("dashboard.charts.requestsTitle"),description:t("dashboard.charts.requestsDesc"),loading:T.isPending,option:se,empty:!v.length,emptyText:t("dashboard.charts.empty")}),e.jsx(M,{title:t("dashboard.charts.modelTitle"),description:t("dashboard.charts.modelDesc"),loading:g.isPending,option:re,empty:!l.length,emptyText:t("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(M,{title:t("dashboard.charts.ttftTitle"),description:t("dashboard.charts.ttftDesc"),loading:g.isPending,option:oe,empty:!l.some(n=>n.avgTtftMs!=null&&n.avgTtftMs>0),emptyText:t("dashboard.charts.ttftEmpty")}),e.jsx(M,{title:t("dashboard.charts.tpotTitle"),description:t("dashboard.charts.tpotDesc"),loading:g.isPending,option:de,empty:!l.some(n=>n.avgTpotMs!=null&&n.avgTpotMs>0),emptyText:t("dashboard.charts.tpotEmpty")})]}),e.jsx(Te,{models:l,loading:g.isPending}),e.jsx(Ee,{loading:C.isPending,records:ee})]})}const Ne={blue:{gradient:"bg-gradient-to-br from-blue-500/10 via-blue-500/5 to-transparent",iconBg:"bg-blue-500/15",iconColor:"text-blue-600 dark:text-blue-400"},emerald:{gradient:"bg-gradient-to-br from-emerald-500/10 via-emerald-500/5 to-transparent",iconBg:"bg-emerald-500/15",iconColor:"text-emerald-600 dark:text-emerald-400"},amber:{gradient:"bg-gradient-to-br from-amber-500/10 via-amber-500/5 to-transparent",iconBg:"bg-amber-500/15",iconColor:"text-amber-600 dark:text-amber-400"},violet:{gradient:"bg-gradient-to-br from-violet-500/10 via-violet-500/5 to-transparent",iconBg:"bg-violet-500/15",iconColor:"text-violet-600 dark:text-violet-400"},rose:{gradient:"bg-gradient-to-br from-rose-500/10 via-rose-500/5 to-transparent",iconBg:"bg-rose-500/15",iconColor:"text-rose-600 dark:text-rose-400"},cyan:{gradient:"bg-gradient-to-br from-cyan-500/10 via-cyan-500/5 to-transparent",iconBg:"bg-cyan-500/15",iconColor:"text-cyan-600 dark:text-cyan-400"}};function w({icon:t,title:s,value:a,suffix:r,color:i="blue"}){const y=Ne[i];return e.jsx(G,{variant:"interactive",className:f("overflow-hidden",y.gradient),children:e.jsxs(Q,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:s}),t&&e.jsx("div",{className:f("flex h-10 w-10 items-center justify-center rounded-xl",y.iconBg,y.iconColor),children:t})]}),e.jsxs("p",{className:"text-3xl font-bold tracking-tight",children:[a.toLocaleString(),r&&e.jsx("span",{className:"ml-1.5 text-sm font-medium text-muted-foreground",children:r})]})]})})}function M({title:t,description:s,option:a,loading:r,empty:i,emptyText:y}){const{t:x}=I();return e.jsx(G,{children:e.jsxs(Q,{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold",children:t}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]}),r?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:x("common.loadingShort")})}):i?e.jsxs("div",{className:"flex h-[320px] flex-col items-center justify-center rounded-lg border border-dashed",children:[e.jsx(D,{className:"mb-2 h-10 w-10 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:y??x("dashboard.charts.empty")})]}):e.jsx(he,{option:a,style:{height:320},notMerge:!0,lazyUpdate:!0})]})})}function Te({models:t,loading:s}){const{t:a}=I(),r=t.length>0;return e.jsx(X,{title:a("dashboard.modelTable.title"),description:a("dashboard.modelTable.description"),children:s?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("common.loadingShort")})}):r?e.jsx("div",{className:"max-h-80 overflow-auto rounded-md border",children:e.jsxs(F,{children:[e.jsx(H,{children:e.jsxs(A,{children:[e.jsx(h,{children:a("dashboard.modelTable.columns.model")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.requests")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.latency")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.ttft")}),e.jsx(h,{className:"text-right",children:a("dashboard.modelTable.columns.tpot")})]})}),e.jsx(_,{children:t.map(i=>e.jsxs(A,{children:[e.jsx(u,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:i.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.model})]})}),e.jsx(u,{className:"text-right font-medium",children:i.requests.toLocaleString()}),e.jsx(u,{className:"text-right",children:P(i.avgLatencyMs,a("common.units.ms"))}),e.jsx(u,{className:"text-right",children:P(i.avgTtftMs,a("common.units.ms"))}),e.jsx(u,{className:"text-right",children:P(i.avgTpotMs,a("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${i.provider}/${i.model}`))})]})}):e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("dashboard.modelTable.empty")})})})}function Ee({records:t,loading:s}){const{t:a}=I();return e.jsx(X,{title:a("dashboard.recent.title"),description:a("dashboard.recent.subtitle",{count:5}),children:s?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("dashboard.recent.loading")})}):t.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a("dashboard.recent.empty")})}):e.jsx("div",{className:"max-h-80 overflow-auto rounded-md border",children:e.jsxs(F,{children:[e.jsx(H,{children:e.jsxs(A,{children:[e.jsx(h,{children:a("dashboard.recent.columns.time")}),e.jsx(h,{children:a("dashboard.recent.columns.endpoint")}),e.jsx(h,{children:a("dashboard.recent.columns.provider")}),e.jsx(h,{children:a("dashboard.recent.columns.route")}),e.jsx(h,{className:"text-right",children:a("dashboard.recent.columns.latency")}),e.jsx(h,{children:a("dashboard.recent.columns.status")})]})}),e.jsx(_,{children:t.map(r=>e.jsxs(A,{children:[e.jsx(u,{className:"text-xs",children:new Date(r.timestamp).toLocaleString()}),e.jsx(u,{className:"text-xs text-muted-foreground",children:r.endpoint==="anthropic"?a("logs.table.endpointAnthropic"):r.endpoint==="openai"?a("logs.table.endpointOpenAI"):r.endpoint}),e.jsx(u,{className:"font-medium",children:r.provider}),e.jsx(u,{children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:r.client_model??a("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"→"}),e.jsx("span",{className:"font-medium text-foreground",children:r.model})]})}),e.jsx(u,{className:"text-right font-medium",children:P(r.latency_ms,a("common.units.ms"))}),e.jsx(u,{children:e.jsx(k,{variant:r.error?"destructive":"default",children:(r.status_code??(r.error?500:200)).toString()})})]},r.id))})]})})})}export{Ae as default};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as be,u as U,b as me,r as n,d as we,t as ke,j as e,e as k,a as L,F as _e,f as Se,X as Ee,L as Te}from"./index-D-F4C6n_.js";import{u as F}from"./useApiQuery-CkT-JtpV.js";import{P as Ce,B as xe}from"./PageHeader-BatC8G-O.js";import{c as Le}from"./clipboard-CALi6bTW.js";import{I as Q}from"./input-x0jTfvyD.js";import{L as S}from"./label-t5tthgxG.js";import{C as re,a as ne}from"./card-DQb2ediN.js";import{S as M,a as z,b as O,c as q,d as w}from"./select-fri8gRof.js";import{R as De}from"./refresh-cw-DHAoO4El.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 Re=be("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"}]]),oe=[20,50,100];function de(s,r=!1){if(!s)return;const o=r?`${s}T23:59:59.999`:`${s}T00:00:00.000`,g=Date.parse(o);return Number.isFinite(g)?g:void 0}function ue(s){const r=new Date(s);return`${r.getFullYear()}-${`${r.getMonth()+1}`.padStart(2,"0")}-${`${r.getDate()}`.padStart(2,"0")} ${`${r.getHours()}`.padStart(2,"0")}:${`${r.getMinutes()}`.padStart(2,"0")}:${`${r.getSeconds()}`.padStart(2,"0")}`}function _(s){return s==null?"-":s.toLocaleString()}function E(s,r){const o=_(s);return o==="-"?"-":`${o} ${r}`}function Fe(s){return s?"true":"false"}function ce(s,r){if(!s||s.trim().length===0)return r;try{const o=JSON.parse(s);return JSON.stringify(o,null,2)}catch{return s}}function Qe(){var se,te,le,ae;const{t:s}=U(),{pushToast:r}=me(),[o,g]=n.useState("all"),[j,t]=n.useState("all"),[d,y]=n.useState(""),[m,v]=n.useState("all"),[l,h]=n.useState(""),[i,x]=n.useState(""),[c,p]=n.useState(1),[N,I]=n.useState(oe[0]),[K,H]=n.useState(null),[pe,V]=n.useState(!1),[D,W]=n.useState([]),[P,J]=n.useState(!1);n.useEffect(()=>{p(1)},[o,j,d,m,l,i,N,D]);const $=n.useMemo(()=>{const a={limit:N,offset:(c-1)*N};o!=="all"&&(a.provider=o),j!=="all"&&(a.endpoint=j),d.trim().length>0&&(a.model=d.trim()),m!=="all"&&(a.status=m);const u=de(l),A=de(i,!0);return u!==void 0&&(a.from=u),A!==void 0&&(a.to=A),D.length>0&&(a.apiKeys=D.join(",")),a},[o,j,d,m,l,i,c,N,D]),f=F(["logs",$],{url:"/api/logs",method:"GET",params:$}),T=F(["providers","all"],{url:"/api/providers",method:"GET"}),X=F(["api-keys"],{url:"/api/keys",method:"GET"}),he=F(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"});n.useEffect(()=>{f.isError&&f.error&&r({title:s("logs.toast.listError.title"),description:s("logs.toast.listError.desc",{message:f.error.message}),variant:"error"})},[f.isError,f.error,r,s]),n.useEffect(()=>{T.isError&&T.error&&r({title:s("logs.toast.providerError.title"),description:s("logs.toast.providerError.desc",{message:T.error.message}),variant:"error"})},[T.isError,T.error,r,s]);const C=((se=f.data)==null?void 0:se.total)??0,b=C>0?Math.ceil(C/N):0,Y=((te=f.data)==null?void 0:te.items)??[];n.useEffect(()=>{b>0&&c>b&&p(b)},[b,c]);const B=T.data??[],Z=n.useMemo(()=>{const a=new Map;for(const u of B)u.id&&a.set(u.id,u.label??u.id);return a},[B]),G=X.data??[],ee=n.useMemo(()=>{const a=new Map;for(const u of G)a.set(u.id,u);return a},[G]),fe=()=>{g("all"),y(""),t("all"),v("all"),h(""),x(""),W([])},ge=n.useCallback(async()=>{if(!P){J(!0);try{const a=C>0?Math.min(C,5e3):1e3,u={...$,limit:a,offset:0},A=await we.post("/api/logs/export",u,{responseType:"blob"}),Ne=new Blob([A.data],{type:"application/zip"}),ve=new Date().toISOString().replace(/[:.]/g,"-"),ie=URL.createObjectURL(Ne),R=document.createElement("a");R.href=ie,R.download=`cc-gw-logs-${ve}.zip`,document.body.appendChild(R),R.click(),R.remove(),URL.revokeObjectURL(ie),r({title:s("logs.toast.exportSuccess.title"),description:s("logs.toast.exportSuccess.desc"),variant:"success"})}catch(a){const u=ke(a);r({title:s("logs.toast.exportError.title"),description:s("logs.toast.exportError.desc",{message:u.message}),variant:"error"})}finally{J(!1)}}},[P,r,$,s,C]),je=n.useCallback(a=>{H(a),V(!0)},[]),ye=n.useCallback(()=>{V(!1),H(null)},[]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Ce,{icon:e.jsx(_e,{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:ge,disabled:P,children:[e.jsx(Re,{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:C.toLocaleString()})}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>f.refetch(),disabled:f.isFetching,children:[e.jsx(De,{className:L("mr-2 h-4 w-4",f.isFetching&&"animate-spin")}),f.isFetching?s("common.actions.refreshing"):s("logs.actions.manualRefresh")]})]})}),e.jsx(re,{children:e.jsxs(ne,{className:"pt-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:s("logs.filtersTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("logs.filtersDescription")})]}),e.jsx(k,{variant:"ghost",size:"sm",onClick:fe,children:s("common.actions.reset")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:s("logs.filters.provider")}),e.jsxs(M,{value:o,onValueChange:g,children:[e.jsx(z,{children:e.jsx(O,{})}),e.jsxs(q,{children:[e.jsx(w,{value:"all",children:s("logs.filters.providerAll")}),B.map(a=>e.jsx(w,{value:a.id,children:a.label??a.id},a.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:s("logs.filters.endpoint")}),e.jsxs(M,{value:j,onValueChange:t,children:[e.jsx(z,{children:e.jsx(O,{})}),e.jsxs(q,{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")}),(ae=(le=he.data)==null?void 0:le.endpoints)==null?void 0:ae.map(a=>e.jsx(w,{value:a.id,children:a.label||a.id},a.id))]})]})]}),e.jsx($e,{className:"md:col-span-2",apiKeys:G,selected:D,disabled:X.isLoading,onChange:W}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:s("logs.filters.modelId")}),e.jsx(Q,{value:d,onChange:a=>y(a.target.value),placeholder:s("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:s("logs.filters.status")}),e.jsxs(M,{value:m,onValueChange:a=>v(a),children:[e.jsx(z,{children:e.jsx(O,{})}),e.jsxs(q,{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(S,{children:s("logs.filters.startDate")}),e.jsx(Q,{type:"date",value:l,onChange:a=>h(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:s("logs.filters.endDate")}),e.jsx(Q,{type:"date",value:i,onChange:a=>x(a.target.value)})]})]})]})}),e.jsx(re,{children:e.jsxs(ne,{className:"p-0",children:[e.jsx("div",{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:f.isPending?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.loading")})}):Y.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")})}):Y.map((a,u)=>e.jsx(Ke,{record:a,providerLabelMap:Z,apiKeyMap:ee,onSelect:je,isEven:u%2===0},a.id))})]})}),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(M,{value:N.toString(),onValueChange:a=>I(Number(a)),children:[e.jsx(z,{className:"w-[80px]",children:e.jsx(O,{})}),e.jsx(q,{children:oe.map(a=>e.jsx(w,{value:a.toString(),children:a},a))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:()=>p(a=>Math.max(a-1,1)),disabled:c<=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:c,total:b})}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>p(a=>b===0?a:Math.min(a+1,b)),disabled:b===0||c>=b,children:s("logs.table.pagination.next")})]})]})]})}),e.jsx(Pe,{open:pe,logId:K,onClose:ye,providerLabelMap:Z,apiKeyMap:ee})]})}function Ke({record:s,providerLabelMap:r,apiKeyMap:o,onSelect:g,isEven:j}){const{t}=U(),d=r.get(s.provider)??s.provider,y=s.endpoint||"-",m=!!s.error,v=s.status_code,l=s.client_model??t("logs.table.requestedModelFallback"),h=s.api_key_id!=null?o.get(s.api_key_id):void 0,i=s.api_key_id==null?t("logs.table.apiKeyUnknown"):h!=null&&h.isWildcard?t("apiKeys.wildcard"):h!=null&&h.name?h.name:s.api_key_name?s.api_key_name:t("logs.table.apiKeyUnknown");return e.jsxs("tr",{className:L("transition-colors",j?"bg-muted/30":"","hover:bg-muted/50"),children:[e.jsx("td",{className:"px-3 py-2 text-xs",children:ue(s.timestamp)}),e.jsx("td",{className:"px-3 py-2 text-xs",children:y}),e.jsx("td",{className:"px-3 py-2 text-xs",children:e.jsx("div",{className:"max-w-[100px] truncate",title:d,children:d})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:e.jsx("div",{className:"max-w-[120px] truncate",title:l,children:l})}),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.input_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:_(s.cache_read_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:_(s.cache_creation_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:_(s.output_tokens)}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:E(s.latency_ms,"ms")}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:E(s.ttft_ms,"ms")}),e.jsx("td",{className:"px-3 py-2 text-right text-xs tabular-nums",children:E(s.tpot_ms,"ms/tk")}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx(xe,{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:t("logs.actions.detail")})})]})}function Pe({open:s,logId:r,onClose:o,providerLabelMap:g,apiKeyMap:j}){var x,c;const{t}=U(),{pushToast:d}=me(),y=n.useRef(null),m=F(["log-detail",r],{url:`/api/logs/${r}`,method:"GET"},{enabled:s&&r!==null,staleTime:3e4});n.useEffect(()=>{m.isError&&m.error&&d({title:t("logs.detail.loadError"),description:m.error.message,variant:"error"})},[m.isError,m.error,d,t]),n.useEffect(()=>{if(!s)return;const p=N=>{N.key==="Escape"&&o()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s,o]),n.useEffect(()=>{s&&y.current&&y.current.focus()},[s,r]);const v=n.useCallback(async(p,N,I)=>{if(!N){d({title:t("logs.detail.copy.empty",{label:p}),variant:"info"});return}try{await Le(N),d({title:t(I),variant:"success"})}catch(K){d({title:t("logs.detail.copy.failure"),description:K instanceof Error?K.message:t("logs.detail.copy.failureFallback"),variant:"error"})}},[d,t]);if(!s)return null;const l=m.data,h=l?g.get(l.provider)??l.provider:"",i=l&&l.api_key_id!=null?j.get(l.api_key_id):void 0;return typeof document>"u"?null:Se.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm",onClick:o}),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",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:t("logs.detail.title")}),l&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.detail.id",{id:l.id})})]}),e.jsxs(k,{ref:y,variant:"outline",size:"sm",onClick:o,children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),t("common.actions.close")]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:m.isPending?e.jsx(Te,{}):l?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:t("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:t("logs.detail.summary.route",{from:l.client_model??t("logs.detail.info.noRequestedModel"),to:l.model})}),e.jsx("span",{className:"text-muted-foreground",children:t("logs.detail.summary.latency",{value:E(l.latency_ms,t("common.units.ms"))})}),l.ttft_ms!==null&&e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",E(l.ttft_ms,t("common.units.ms"))]}),e.jsx(xe,{variant:l.error?"destructive":"default",children:(l.status_code??(l.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:t("logs.detail.info.time")}),e.jsx("dd",{className:"font-medium",children:ue(l.timestamp)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.sessionId")}),e.jsx("dd",{className:"font-medium",children:l.session_id??"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.endpoint")}),e.jsx("dd",{className:"font-medium",children:l.endpoint||"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("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:t("logs.detail.info.requestedModel")}),e.jsx("dd",{className:"font-medium",children:l.client_model??t("logs.detail.info.noRequestedModel")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.model")}),e.jsx("dd",{className:"font-medium",children:l.model})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.stream")}),e.jsx("dd",{className:"font-medium",children:Fe(l.stream)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.inputTokens")}),e.jsx("dd",{className:"font-medium",children:_(l.input_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.cacheReadTokens")}),e.jsx("dd",{className:"font-medium",children:_(l.cache_read_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.cacheCreationTokens")}),e.jsx("dd",{className:"font-medium",children:_(l.cache_creation_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.outputTokens")}),e.jsx("dd",{className:"font-medium",children:_(l.output_tokens)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.ttft")}),e.jsx("dd",{className:"font-medium",children:E(l.ttft_ms,t("common.units.ms"))})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.tpot")}),e.jsx("dd",{className:"font-medium",children:E(l.tpot_ms,t("common.units.msPerToken"))})]})]}),l.error&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.error")}),e.jsx("p",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:l.error})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t("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:t("logs.detail.apiKey.name")}),e.jsx("dd",{className:"font-medium",children:l.api_key_id==null&&!l.api_key_name?t("logs.detail.apiKey.missing"):i!=null&&i.isWildcard?t("apiKeys.wildcard"):(i==null?void 0:i.name)??l.api_key_name??t("logs.detail.apiKey.missing")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.apiKey.identifier")}),e.jsx("dd",{className:"font-medium",children:l.api_key_id??t("common.noData")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.apiKey.masked")}),e.jsx("dd",{className:"font-medium",children:i!=null&&i.isWildcard?t("apiKeys.wildcard"):(i==null?void 0:i.maskedKey)??l.api_key_name??t("logs.detail.apiKey.maskedUnavailable")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t("logs.detail.apiKey.lastUsed")}),e.jsx("dd",{className:"font-medium",children:i!=null&&i.lastUsedAt?new Date(i.lastUsedAt).toLocaleString():t("common.noData")})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:t("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:l.api_key_value_available?l.api_key_value_masked??t("logs.detail.apiKey.rawUnavailable"):t("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:t("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:t("logs.detail.payload.request")}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>{var p;return v(t("logs.detail.payload.request"),(p=l.payload)==null?void 0:p.prompt,"logs.detail.copy.requestSuccess")},children:t("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:ce((x=l.payload)==null?void 0:x.prompt,t("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:t("logs.detail.payload.response")}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>{var p;return v(t("logs.detail.payload.response"),(p=l.payload)==null?void 0:p.response,"logs.detail.copy.responseSuccess")},children:t("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:ce((c=l.payload)==null?void 0:c.response,t("logs.detail.payload.emptyResponse"))})]})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:t("logs.detail.loadError")})})]})]}),document.body)}function $e({apiKeys:s,selected:r,onChange:o,disabled:g,className:j}){const{t}=U(),[d,y]=n.useState(!1),m=n.useRef(null);n.useEffect(()=>{if(!d)return;const i=x=>{var c;(c=m.current)!=null&&c.contains(x.target)||y(!1)};return window.addEventListener("mousedown",i),()=>window.removeEventListener("mousedown",i)},[d]);const v=n.useMemo(()=>{if(r.length===0)return[];const i=new Map;for(const x of s)i.set(x.id,x);return r.map(x=>{const c=i.get(x);return c?c.isWildcard?t("apiKeys.wildcard"):c.name:null}).filter(x=>!!x)},[s,r,t]),l=r.length===0?t("logs.filters.apiKeyAll"):t("logs.filters.apiKeySelected",{count:r.length}),h=i=>{r.includes(i)?o(r.filter(x=>x!==i)):o([...r,i])};return e.jsxs("div",{className:L("relative space-y-2",j),ref:m,children:[e.jsx(S,{children:t("logs.filters.apiKey")}),e.jsxs("button",{type:"button",onClick:()=>y(i=>!i),disabled:g||s.length===0,title:t("logs.filters.apiKeyHint"),className:L("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",r.length>0&&"border-primary",d&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[l,v.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:v.join(", ")})]}),e.jsx("svg",{className:L("h-4 w-4 opacity-50 transition-transform",d&&"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"})})]}),d&&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:l}),e.jsx("button",{type:"button",onClick:()=>o([]),disabled:r.length===0,className:"text-primary hover:underline disabled:opacity-40",children:t("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[s.map(i=>{const x=i.isWildcard?t("apiKeys.wildcard"):i.name,c=r.includes(i.id);return e.jsxs("label",{className:L("flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm transition hover:bg-muted",c&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border",checked:c,onChange:()=>h(i.id)}),e.jsx("span",{className:"truncate",children:x})]},i.id)}),s.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:t("logs.filters.apiKeyAll")})]})]})]})}export{Qe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var st=s=>{throw TypeError(s)};var Ie=(s,a,c)=>a.has(s)||st("Cannot "+c);var E=(s,a,c)=>(Ie(s,a,"read from private field"),c?c.call(s):a.get(s)),ce=(s,a,c)=>a.has(s)?st("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(s):a.set(s,c),ue=(s,a,c,m)=>(Ie(s,a,"write to private field"),m?m.call(s,c):a.set(s,c),c),me=(s,a,c)=>(Ie(s,a,"access private method"),c);import{S as $t,s as Ft,i as at,k as zt,n as it,l as dt,r as f,m as Bt,o as Vt,u as Pe,j as e,b as ct,e as P,p as _t,a as Le,X as Be,d as X,q as ve,t as Re}from"./index-D-F4C6n_.js";import{u as qt,a as Ht}from"./useApiQuery-CkT-JtpV.js";import{P as Qt,B as he}from"./PageHeader-BatC8G-O.js";import{I as pe}from"./input-x0jTfvyD.js";import{L as Z}from"./label-t5tthgxG.js";import{C as Ke,a as $e}from"./card-DQb2ediN.js";import{S as ut}from"./switch-BrV6LX33.js";import{S as mt,a as ht,b as pt,c as xt,d as De}from"./select-fri8gRof.js";import{P as Ve,D as Gt,a as Xt,b as Yt,c as Jt,d as Wt,e as Zt}from"./dialog-B9ZBo_5P.js";import{R as es}from"./refresh-cw-DHAoO4El.js";var J,le,K,W,ee,Se,_e,ot,ts=(ot=class extends $t{constructor(a,c){super();ce(this,ee);ce(this,J);ce(this,le);ce(this,K);ce(this,W);ue(this,J,a),this.setOptions(c),this.bindMethods(),me(this,ee,Se).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(a){var m;const c=this.options;this.options=E(this,J).defaultMutationOptions(a),Ft(this.options,c)||E(this,J).getMutationCache().notify({type:"observerOptionsUpdated",mutation:E(this,K),observer:this}),c!=null&&c.mutationKey&&this.options.mutationKey&&at(c.mutationKey)!==at(this.options.mutationKey)?this.reset():((m=E(this,K))==null?void 0:m.state.status)==="pending"&&E(this,K).setOptions(this.options)}onUnsubscribe(){var a;this.hasListeners()||(a=E(this,K))==null||a.removeObserver(this)}onMutationUpdate(a){me(this,ee,Se).call(this),me(this,ee,_e).call(this,a)}getCurrentResult(){return E(this,le)}reset(){var a;(a=E(this,K))==null||a.removeObserver(this),ue(this,K,void 0),me(this,ee,Se).call(this),me(this,ee,_e).call(this)}mutate(a,c){var m;return ue(this,W,c),(m=E(this,K))==null||m.removeObserver(this),ue(this,K,E(this,J).getMutationCache().build(E(this,J),this.options)),E(this,K).addObserver(this),E(this,K).execute(a)}},J=new WeakMap,le=new WeakMap,K=new WeakMap,W=new WeakMap,ee=new WeakSet,Se=function(){var c;const a=((c=E(this,K))==null?void 0:c.state)??zt();ue(this,le,{...a,isPending:a.status==="pending",isSuccess:a.status==="success",isError:a.status==="error",isIdle:a.status==="idle",mutate:this.mutate,reset:this.reset})},_e=function(a){it.batch(()=>{var c,m,g,y,o,h,N,p;if(E(this,W)&&this.hasListeners()){const R=E(this,le).variables,F=E(this,le).context,T={client:E(this,J),meta:this.options.meta,mutationKey:this.options.mutationKey};(a==null?void 0:a.type)==="success"?((m=(c=E(this,W)).onSuccess)==null||m.call(c,a.data,R,F,T),(y=(g=E(this,W)).onSettled)==null||y.call(g,a.data,null,R,F,T)):(a==null?void 0:a.type)==="error"&&((h=(o=E(this,W)).onError)==null||h.call(o,a.error,R,F,T),(p=(N=E(this,W)).onSettled)==null||p.call(N,void 0,a.error,R,F,T))}this.listeners.forEach(R=>{R(E(this,le))})})},ot);function rt(s,a){const c=dt(),[m]=f.useState(()=>new ts(c,s));f.useEffect(()=>{m.setOptions(s)},[m,s]);const g=f.useSyncExternalStore(f.useCallback(o=>m.subscribe(it.batchCalls(o)),[m]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),y=f.useCallback((o,h)=>{m.mutate(o,h).catch(Bt)},[m]);if(g.error&&Vt(m.options.throwOnError,[g.error]))throw g.error;return{...g,mutate:y,mutateAsync:g.mutate}}function He(){return typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,10)}function ss(){return{_key:He(),id:"",label:""}}const Fe={openai:{baseUrl:"https://api.openai.com/v1"},deepseek:{baseUrl:"https://api.deepseek.com/v1"},huawei:{baseUrl:"https://api.modelarts-maas.com/v1"},kimi:{baseUrl:"https://api.moonshot.cn/v1"},anthropic:{baseUrl:"https://api.anthropic.com/v1"},custom:{}};function lt(s){return s?{id:s.id,label:s.label??s.id,baseUrl:s.baseUrl,apiKey:s.apiKey??"",type:s.type??"custom",defaultModel:s.defaultModel??"",models:(s.models??[]).map(a=>({...a,_key:He()})),authMode:s.authMode??"apiKey"}:{id:"",label:"",baseUrl:"",apiKey:"",type:"custom",defaultModel:"",models:[],authMode:"apiKey"}}function as(s){return{_key:He(),id:s.id,label:s.label}}function rs({open:s,mode:a,provider:c,existingProviderIds:m,onClose:g,onSubmit:y}){const{t:o}=Pe(),[h,N]=f.useState(()=>lt(c)),[p,R]=f.useState({}),[F,T]=f.useState(!1),[z,B]=f.useState(null),k=f.useRef(null),M=f.useRef(null),O=f.useRef(null),[A,je]=f.useState(a==="edit");f.useEffect(()=>{s&&(N(lt(c)),R({}),B(null),T(!1),je(a==="edit"))},[s,c,a]),f.useEffect(()=>{if(!s)return;const u=b=>{b.key==="Escape"&&g()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s,g]),f.useEffect(()=>{if(s){if(a==="create"&&O.current){O.current.focus();return}M.current&&M.current.focus()}},[s,a]);const ye=f.useMemo(()=>h.models.filter(u=>u.id.trim().length>0),[h.models]),xe=u=>b=>{N(w=>({...w,[u]:b}))},ke=u=>{N(b=>{const v=!A||b.label.trim().length===0||b.label===b.id?u:b.label;return{...b,id:u,label:v}})},ne=u=>{N(b=>{var Me;const v=Fe[u??"custom"]??Fe.custom,C=Object.values(Fe).map(te=>te.baseUrl).filter(te=>!!te),H=!b.baseUrl||C.includes(b.baseUrl),L=a==="create"&&(b.models.length===0||b.models.every(te=>te.id.trim().length===0)),G={...b,type:u,authMode:b.authMode??"apiKey"};return v!=null&&v.baseUrl&&H&&(G.baseUrl=v.baseUrl),v!=null&&v.models&&L&&(G.models=v.models.map(as),G.defaultModel=v.defaultModel??((Me=v.models[0])==null?void 0:Me.id)??""),G})},I=(u,b)=>{N(w=>{const v=[...w.models];return v[u]={...v[u],...b},{...w,models:v}})},Oe=(u,b)=>{N(w=>{const v=[...w.models],C=v[u];if(!C)return w;const H=!A||!C.label||C.label===C.id,L={...C,id:b,label:H?b:C.label};v[u]=L;const G=w.defaultModel===C.id?b:w.defaultModel;return{...w,models:v,defaultModel:G}})},V=u=>{N(b=>{if(u<0||u>=b.models.length)return b;const w=b.models.filter((C,H)=>H!==u);let v=b.defaultModel;return w.some(C=>C.id===v)||(v=""),{...b,models:w,defaultModel:v}})},Te=()=>{N(u=>({...u,models:[...u.models,ss()]}))},oe=u=>{N(b=>({...b,authMode:u}))},Ne=()=>{const u={},b=h.id.trim(),w=h.baseUrl.trim();if(a==="create"&&(b.length===0?u.id=o("providers.drawer.errors.idRequired"):m.includes(b)&&(u.id=o("providers.drawer.errors.idDuplicate"))),a==="edit"&&b.length===0&&(u.id=o("providers.drawer.errors.idRequired")),w.length===0)u.baseUrl=o("providers.drawer.errors.baseUrlInvalid");else try{new URL(w)}catch{u.baseUrl=o("providers.drawer.errors.baseUrlInvalid")}if(h.models.length>0){const v=new Set;h.models.some(H=>{const L=H.id.trim();return L.length===0||v.has(L)?!0:(v.add(L),!1)})&&(u.models=o("providers.drawer.errors.modelInvalid"))}return h.defaultModel&&!h.models.some(v=>v.id===h.defaultModel)&&(u.models=o("providers.drawer.errors.defaultInvalid")),R(u),Object.keys(u).length===0},ge=()=>{const u=h.models.map(v=>{var C;return{id:v.id.trim(),label:(C=v.label)!=null&&C.trim()?v.label.trim():void 0}}).filter(v=>v.id.length>0),b=c!=null&&c.extraHeaders&&Object.keys(c.extraHeaders).length>0?c.extraHeaders:void 0,w=h.authMode!=="apiKey"?h.authMode:void 0;return{id:h.id.trim(),label:h.label.trim()||h.id.trim(),baseUrl:h.baseUrl.trim(),apiKey:h.apiKey.trim()||void 0,type:h.type??"custom",defaultModel:h.defaultModel||void 0,models:u.length>0?u:void 0,extraHeaders:b,authMode:w}},we=async()=>{if(B(null),!!Ne()){T(!0);try{const u=ge();await y(u)}catch(u){B(o("providers.drawer.toast.saveFailure",{message:u instanceof Error?u.message:"unknown"})),T(!1);return}T(!1),g()}},fe=a==="create";return s?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-slate-900/60",onClick:g,"aria-hidden":"true"}),e.jsxs("aside",{ref:k,role:"dialog","aria-modal":"true","aria-labelledby":"provider-drawer-title","aria-describedby":"provider-drawer-desc",className:"flex h-full w-full max-w-3xl flex-col border-l border-slate-200 bg-white shadow-xl dark:border-slate-800 dark:bg-slate-900",children:[e.jsxs("header",{className:"flex items-center justify-between border-b border-slate-200 px-6 py-4 dark:border-slate-800",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"provider-drawer-title",className:"text-lg font-semibold",children:o(fe?"providers.drawer.createTitle":"providers.drawer.editTitle")}),e.jsx("p",{id:"provider-drawer-desc",className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.description")})]}),e.jsx("button",{type:"button",ref:M,onClick:g,className:"rounded-md border border-slate-200 px-3 py-1 text-sm transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:o("common.actions.close")})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:[e.jsxs("section",{className:"space-y-4","aria-labelledby":"provider-basic-fields",children:[e.jsx("div",{id:"provider-basic-fields",className:"sr-only",children:o("providers.drawer.description")}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx("button",{type:"button",onClick:()=>je(u=>!u),className:"rounded-md border border-slate-200 px-3 py-1 text-xs transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:o(A?"providers.drawer.fields.hideAdvanced":"providers.drawer.fields.showAdvanced")})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.id")}),e.jsx("input",{value:h.id,ref:O,onChange:u=>ke(u.target.value),disabled:!fe,placeholder:o("providers.drawer.fields.idPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60","aria-invalid":!!p.id}),p.id?e.jsx("span",{className:"text-xs text-red-500",children:p.id}):null]}),A?e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.label")}),e.jsx("input",{value:h.label,onChange:u=>xe("label")(u.target.value),placeholder:o("providers.drawer.fields.labelPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}):null]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.baseUrl")}),e.jsx("input",{value:h.baseUrl,onChange:u=>xe("baseUrl")(u.target.value),placeholder:o("providers.drawer.fields.baseUrlPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60","aria-invalid":!!p.baseUrl}),p.baseUrl?e.jsx("span",{className:"text-xs text-red-500",children:p.baseUrl}):null]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.type")}),e.jsxs("select",{value:h.type??"custom",onChange:u=>ne(u.target.value),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60",children:[e.jsx("option",{value:"openai",children:"OpenAI"}),e.jsx("option",{value:"deepseek",children:"DeepSeek"}),e.jsx("option",{value:"huawei",children:"华为云"}),e.jsx("option",{value:"kimi",children:"Kimi"}),e.jsx("option",{value:"anthropic",children:"Anthropic (Claude)"}),e.jsx("option",{value:"custom",children:"Custom"})]})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.apiKey")}),e.jsx("input",{value:h.apiKey,onChange:u=>xe("apiKey")(u.target.value),placeholder:o("providers.drawer.fields.apiKeyPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}),e.jsxs("fieldset",{className:"grid gap-2 rounded-lg border border-slate-200 p-3 text-xs dark:border-slate-700",children:[e.jsx("legend",{className:"px-1 text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.authMode")}),e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.authModeHint")}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"apiKey",checked:h.authMode==="apiKey",onChange:()=>oe("apiKey")}),e.jsx("span",{children:o("providers.drawer.fields.authModeApiKey")})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"authToken",checked:h.authMode==="authToken",onChange:()=>oe("authToken")}),e.jsx("span",{children:o("providers.drawer.fields.authModeAuthToken")})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"xAuthToken",checked:h.authMode==="xAuthToken",onChange:()=>oe("xAuthToken")}),e.jsx("span",{children:o("providers.drawer.fields.authModeXAuthToken")})]})]})]}),e.jsxs("section",{className:"mt-6 space-y-3","aria-labelledby":"provider-model-fields",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"provider-model-fields",className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.models")}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.modelsDescription")})]}),e.jsx("button",{type:"button",onClick:Te,className:"rounded-md border border-slate-200 px-3 py-1 text-xs transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:o("providers.drawer.fields.addModel")})]}),p.models?e.jsx("p",{className:"text-xs text-red-500",children:p.models}):null,e.jsxs("div",{className:"space-y-4",children:[h.models.map((u,b)=>e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-800/40",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.modelId")}),e.jsx("input",{value:u.id,onChange:w=>Oe(b,w.target.value),placeholder:o("providers.drawer.fields.modelIdPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}),A?e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.fields.modelLabel")}),e.jsx("input",{value:u.label??"",onChange:w=>I(b,{label:w.target.value}),placeholder:o("providers.drawer.fields.modelLabelPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}):null]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2 text-slate-600 dark:text-slate-300",children:[e.jsx("input",{type:"radio",name:"defaultModel",value:u.id,checked:h.defaultModel===u.id,onChange:()=>N(w=>({...w,defaultModel:u.id})),disabled:u.id.trim().length===0}),o("providers.drawer.fields.setDefault")]}),e.jsx("button",{type:"button",className:"text-red-500 transition hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>V(b),disabled:h.models.length===0,children:o("providers.drawer.fields.removeModel")})]})]},u._key)),h.models.length===0?e.jsx("div",{className:"rounded-xl border-2 border-amber-300 bg-gradient-to-br from-amber-50 to-yellow-50 p-5 shadow-md dark:border-amber-600/60 dark:from-amber-900/20 dark:to-yellow-900/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 text-2xl",children:"💡"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:o("providers.drawer.noModelsTitle")}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-800 dark:text-amber-300",children:o("providers.drawer.noModelsHint",{providerId:h.id||"provider-id"})}),e.jsxs("div",{className:"rounded-md bg-amber-100/80 p-2.5 dark:bg-amber-800/40",children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-amber-900 dark:text-amber-200",children:o("providers.drawer.routeExample")}),e.jsxs("code",{className:"block rounded bg-white px-2.5 py-1.5 font-mono text-xs text-amber-900 shadow-sm dark:bg-slate-900 dark:text-amber-100",children:['"claude-*": "',(h.id||"provider-id").trim()||"provider-id",':*"']})]})]})]})}):null]}),ye.length>1?e.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400",children:o("providers.drawer.defaultHint",{model:h.defaultModel||o("providers.card.noDefault")})}):null]})]}),e.jsxs("footer",{className:"flex items-center justify-between gap-3 border-t border-slate-200 px-6 py-4 text-sm dark:border-slate-800",children:[e.jsx("div",{className:"flex flex-col text-xs text-red-500","aria-live":"polite",children:z?e.jsx("span",{children:z}):null}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:g,className:"rounded-md border border-slate-200 px-4 py-2 transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",disabled:F,children:o("common.actions.cancel")}),e.jsx("button",{type:"button",onClick:we,className:"rounded-md bg-blue-600 px-4 py-2 text-white transition hover:bg-blue-700 disabled:opacity-60",disabled:F,children:o(F?"common.actions.saving":"common.actions.save")})]})]})]})]}):null}const ls=["claude-sonnet-4-5-20250929","claude-sonnet-4-5-20250929-thinking","claude-sonnet-4-20250514","claude-opus-4-1-20250805","claude-opus-4-1-20250805-thinking","claude-haiku-4-5-20251001","claude-haiku-4-5-20251001-thinking","claude-3-5-haiku-20241022"],ns=["gpt-4o-mini","gpt-4o","o4-mini","o4-large","gpt-5-codex"];function qe(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2,10)}function Y(s){return s?Object.entries(s).map(([a,c])=>({id:qe(),source:a,target:c})):[]}function ze(s,a){var g,y,o;if(!s)return{};const c={},m=s.endpointRouting??{};c.anthropic=Y(((g=m.anthropic)==null?void 0:g.modelRoutes)??s.modelRoutes??{}),c.openai=Y(((y=m.openai)==null?void 0:y.modelRoutes)??{});for(const h of a)(o=h.routing)!=null&&o.modelRoutes?c[h.id]=Y(h.routing.modelRoutes):c[h.id]=[];return c}function os(s,a){if(s==="anthropic")return!0;const c=a.find(m=>m.id===s);return c?c.paths&&c.paths.length>0?c.paths.some(m=>m.protocol==="anthropic"):c.protocol==="anthropic":!1}function is(s,a,c){var g,y,o;if(!a)return;if(s==="anthropic"||s==="openai")return(y=(g=a.endpointRouting)==null?void 0:g[s])==null?void 0:y.validation;const m=c.find(h=>h.id===s);return(o=m==null?void 0:m.routing)==null?void 0:o.validation}function ws(){const{t:s}=Pe(),{pushToast:a}=ct(),c=dt(),m=qt(["config","full"],{url:"/api/config",method:"GET"}),{data:g}=Ht({queryKey:["custom-endpoints"],queryFn:ve.list,refetchInterval:1e4}),y=(g==null?void 0:g.endpoints)??[],o=f.useMemo(()=>{const t=[{key:"providers",label:s("modelManagement.tabs.providers"),description:s("modelManagement.tabs.providersDesc"),isSystem:!0,canDelete:!1},{key:"anthropic",label:s("modelManagement.tabs.anthropic"),description:s("modelManagement.tabs.anthropicDesc"),isSystem:!0,canDelete:!1,protocols:["anthropic"]},{key:"openai",label:s("modelManagement.tabs.openai"),description:s("modelManagement.tabs.openaiDesc"),isSystem:!0,canDelete:!1,protocols:["openai-auto","openai-chat","openai-responses"]}],n=y.map(r=>{let l,i=[];if(r.paths&&r.paths.length>0){const d=r.paths.map(x=>`${x.path} (${x.protocol})`).join(", ");l=`${s("modelManagement.tabs.customEndpoint")}: ${d}`,i=[...new Set(r.paths.map(x=>x.protocol))]}else if(r.path){const d=r.protocol||"anthropic";l=`${s("modelManagement.tabs.customEndpoint")}: ${r.path} (${d})`,i=[d]}else l=s("modelManagement.tabs.customEndpoint");return{key:r.id,label:r.label,description:l,isSystem:!1,canDelete:r.deletable!==!1,protocols:i}});return[...t,...n]},[s,y]),[h,N]=f.useState("providers"),[p,R]=f.useState(null),[F,T]=f.useState(!1),[z,B]=f.useState("create"),[k,M]=f.useState(void 0),[O,A]=f.useState(null),[je,ye]=f.useState(!1),[xe,ke]=f.useState(void 0),[ne,I]=f.useState({}),[Oe,V]=f.useState({}),[Te,oe]=f.useState(null),[Ne,ge]=f.useState({}),[we,fe]=f.useState({}),[u,b]=f.useState({}),[w,v]=f.useState(null),[C,H]=f.useState(null),[L,G]=f.useState(null),[Me,te]=f.useState(!1),[Ue,Qe]=f.useState(null),[Ee,Ae]=f.useState(!0),[Ge,Xe]=f.useState({}),[gt,Ye]=f.useState(!1),_=(p==null?void 0:p.providers)??[],ft=_.length,be=f.useMemo(()=>[{key:"anthropic-beta",value:"claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",label:s("providers.testDialog.options.beta.label"),description:s("providers.testDialog.options.beta.description")}],[s]);f.useEffect(()=>{var t,n;if(m.data){const r=m.data;R(r),I(ze(r,y)),V({});const l={anthropic:((t=r.routingPresets)==null?void 0:t.anthropic)??[],openai:((n=r.routingPresets)==null?void 0:n.openai)??[]};for(const i of y)l[i.id]=i.routingPresets??[];ge(l)}},[m.data,y]),f.useEffect(()=>{m.isError&&m.error&&a({title:s("providers.toast.loadFailure",{message:m.error.message}),variant:"error"})},[m.isError,m.error,a,s]);const bt=f.useMemo(()=>{const t=new Map;for(const n of _){if(!n.defaultModel||!n.models)continue;const r=n.models.find(l=>l.id===n.defaultModel);r&&t.set(n.id,nt(r))}return t},[_]),Je=f.useMemo(()=>{const t=[],n=new Set;for(const l of _){const i=l.label||l.id,d=l.models??[];if(d.length>0)for(const j of d){const S=`${l.id}:${j.id}`;n.has(S)||(n.add(S),t.push({value:S,label:`${i} · ${j.label??j.id}`}))}else if(l.defaultModel){const j=`${l.id}:${l.defaultModel}`;n.has(j)||(n.add(j),t.push({value:j,label:`${i} · ${l.defaultModel}`}))}const x=`${l.id}:*`;n.has(x)||(n.add(x),t.push({value:x,label:s("settings.routing.providerPassthroughOption",{provider:i})}))}const r=[...ne.anthropic||[],...ne.openai||[]];for(const l of r){const i=l.target.trim();i&&!n.has(i)&&(n.add(i),t.push({value:i,label:i}))}return t},[_,ne,s]),We=(t,n)=>{ge(r=>({...r,[t]:n})),R(r=>{if(!r)return r;if(t==="anthropic"||t==="openai")return{...r,routingPresets:{...r.routingPresets,[t]:n}};const l=r.customEndpoints??[],i=l.findIndex(x=>x.id===t);if(i===-1)return r;const d=[...l];return d[i]={...d[i],routingPresets:n},{...r,customEndpoints:d}})},se=()=>p?!0:(a({title:s("settings.toast.missingConfig"),variant:"error"}),m.refetch(),!1),vt=(t,n)=>{fe(r=>({...r,[t]:n})),n.trim()&&b(r=>({...r,[t]:null}))},jt=async t=>{if(!se())return;const n=we[t].trim();if(!n){b(r=>({...r,[t]:s("modelManagement.validation.presetName")}));return}if(Ne[t].some(r=>r.name.toLowerCase()===n.toLowerCase())){b(r=>({...r,[t]:s("modelManagement.validation.presetDuplicate",{name:n})}));return}v(t);try{const l=(await X.post(`/api/routing-presets/${t}`,{name:n})).data.presets??[];We(t,l),fe(i=>({...i,[t]:""})),b(i=>({...i,[t]:null})),a({title:s("modelManagement.toast.presetSaved",{name:n}),variant:"success"})}catch(r){a({title:s("modelManagement.toast.presetSaveFailure",{message:r instanceof Error?r.message:"unknown"}),variant:"error"})}finally{v(null),m.refetch()}},yt=async(t,n)=>{var r,l,i;if(se()){H({endpoint:t,name:n.name});try{const x=(await X.post(`/api/routing-presets/${t}/apply`,{name:n.name})).data.config;if(x){R(x),I(ze(x,y));const j={anthropic:((r=x.routingPresets)==null?void 0:r.anthropic)??[],openai:((l=x.routingPresets)==null?void 0:l.openai)??[]};for(const S of y){const U=(i=x.customEndpoints)==null?void 0:i.find($=>$.id===S.id);j[S.id]=(U==null?void 0:U.routingPresets)??[]}ge(j)}else I(j=>({...j,[t]:Y(n.modelRoutes)}));a({title:s("modelManagement.toast.presetApplySuccess",{name:n.name}),variant:"success"})}catch(d){a({title:s("modelManagement.toast.presetApplyFailure",{message:d instanceof Error?d.message:"unknown"}),variant:"error"})}finally{H(null),m.refetch()}}},kt=async(t,n)=>{if(!(!se()||!window.confirm(s("modelManagement.confirm.deletePreset",{name:n.name})))){G({endpoint:t,name:n.name});try{const i=(await X.delete(`/api/routing-presets/${t}/${encodeURIComponent(n.name)}`)).data.presets??[];We(t,i),a({title:s("modelManagement.toast.presetDeleteSuccess",{name:n.name}),variant:"success"})}catch(l){a({title:s("modelManagement.toast.presetDeleteFailure",{message:l instanceof Error?l.message:"unknown"}),variant:"error"})}finally{G(null),m.refetch()}}},Nt=()=>{se()&&(B("create"),M(void 0),T(!0))},wt=t=>{se()&&(B("edit"),M(t),T(!0))},Mt=async t=>{if(!p)throw new Error(s("settings.toast.missingConfig"));const n=z==="create"?[..._,t]:_.map(i=>k&&i.id===k.id?{...t,id:k.id}:i),r={...p,providers:n};await X.put("/api/config",r),R(r),I(ze(r,y)),m.refetch();const l=z==="create"?s("providers.toast.createSuccess",{name:t.label||t.id}):s("providers.toast.updateSuccess",{name:t.label||t.id});a({title:l,variant:"success"})},Et=async t=>{const n=y.find(r=>r.id===t);if(n&&n.deletable!==!1&&confirm(s("modelManagement.deleteEndpointConfirm",{label:n.label})))try{await ve.delete(t),c.invalidateQueries({queryKey:["custom-endpoints"]}),a({title:s("modelManagement.deleteEndpointSuccess"),variant:"success"}),h===t&&N("providers")}catch(r){const l=Re(r);a({title:s("modelManagement.deleteEndpointError",{error:l.message}),variant:"error"})}},Ze=async(t,n)=>{A(t.id);try{const r=n&&(n.headers||n.query)?{headers:n.headers&&Object.keys(n.headers).length>0?n.headers:void 0,query:n.query&&n.query.trim().length>0?n.query.trim():void 0}:void 0,l=await X.post(`/api/providers/${t.id}/test`,r);l.data.ok?a({title:s("providers.toast.testSuccess"),description:s("providers.toast.testSuccessDesc",{status:l.data.status,duration:l.data.durationMs?`${l.data.durationMs} ms`:"—"}),variant:"success"}):a({title:s("providers.toast.testFailure",{message:`${l.data.status} ${l.data.statusText}`}),variant:"error"})}catch(r){a({title:s("providers.toast.testFailure",{message:r instanceof Error?r.message:"unknown"}),variant:"error"})}finally{A(null)}},Ct=t=>{if(t.type==="anthropic"){const n=t.extraHeaders??{},r=new Map(be.map(d=>[d.key.toLowerCase(),d])),l={};let i=!0;for(const d of be){const x=Object.entries(n).find(([j])=>j.toLowerCase()===d.key.toLowerCase());if(x){const[j,S]=x;String(S??"")===d.value||(i=!1,l[j]=String(S??""))}}for(const[d,x]of Object.entries(n))r.has(d.toLowerCase())||(l[d]=String(x??""));Xe(l),Ae(i),Qe(t),te(!0);return}Ze(t)},et=()=>{te(!1),Qe(null),Ae(!0),Xe({})},St=async()=>{if(!Ue)return;const t={};if(Ee)for(const l of be)t[l.key]=l.value;const n=new Map(be.map(l=>[l.key.toLowerCase(),l]));for(const[l,i]of Object.entries(Ge)){const d=l.toLowerCase();n.get(d)&&Ee||(t[l]=i)}const r=Ue;et(),await Ze(r,{headers:Object.keys(t).length>0?t:void 0,query:Ee?"beta=true":void 0})},Rt=async t=>{var S,U,$,ae;if(!se()||!window.confirm(s("providers.confirm.delete",{name:t.label||t.id})))return;const r=_.filter(q=>q.id!==t.id),l=q=>{const ie={};if(!q)return ie;for(const[D,de]of Object.entries(q)){if(!de)continue;const[re]=de.split(":");re&&re===t.id||de===t.id||(ie[D]=de)}return ie},i=(p==null?void 0:p.endpointRouting)??{},d=l(((S=i.anthropic)==null?void 0:S.modelRoutes)??(p==null?void 0:p.modelRoutes)??{}),x=l(((U=i.openai)==null?void 0:U.modelRoutes)??{}),j={...p,providers:r,modelRoutes:d,endpointRouting:{anthropic:{defaults:(($=i.anthropic)==null?void 0:$.defaults)??p.defaults,modelRoutes:d},openai:{defaults:((ae=i.openai)==null?void 0:ae.defaults)??p.defaults,modelRoutes:x}}};try{await X.put("/api/config",j),R(j),I({anthropic:Y(d),openai:Y(x)}),a({title:s("providers.toast.deleteSuccess",{name:t.label||t.id}),variant:"success"}),m.refetch()}catch(q){a({title:s("providers.toast.deleteFailure",{message:q instanceof Error?q.message:"unknown"}),variant:"error"})}},Dt=t=>{I(n=>({...n,[t]:[...n[t]||[],{id:qe(),source:"",target:""}]})),V(n=>({...n,[t]:null}))},Pt=async(t,n)=>{if(se()){Ye(!0);try{if(t==="anthropic"||t==="openai"){const r=p.endpointRouting?{...p.endpointRouting}:{},l=r[t]??{defaults:p.defaults,modelRoutes:(t==="anthropic"?p.modelRoutes:{})??{}},i={defaults:l.defaults??p.defaults,modelRoutes:l.modelRoutes??{}};let d=l.validation;n?(d={...d??{},mode:"claude-code"},d.allowExperimentalBlocks===void 0&&(d.allowExperimentalBlocks=!0)):d=void 0;const x=d?{...i,validation:d}:{...i},j={...r,[t]:x},S={...p,endpointRouting:j};await X.put("/api/config",S),R(S)}else{const r=p.customEndpoints??[],l=r.findIndex(ae=>ae.id===t);if(l===-1)throw new Error(s("modelManagement.toast.endpointNotFound"));const i=r[l],d=i.routing??{defaults:p.defaults,modelRoutes:{}};let x=d.validation;n?(x={...x??{},mode:"claude-code"},x.allowExperimentalBlocks===void 0&&(x.allowExperimentalBlocks=!0)):x=void 0;const j=x?{...d,validation:x}:{...d},S={...i,routing:j},U=[...r];U[l]=S;const $={...p,customEndpoints:U};await X.put("/api/config",$),R($)}a({title:s(n?"modelManagement.toast.claudeValidationEnabled":"modelManagement.toast.claudeValidationDisabled"),variant:"success"}),m.refetch()}catch(r){const l=Re(r);a({title:s("modelManagement.toast.claudeValidationFailure",{message:l.message}),variant:"error"})}finally{Ye(!1)}}},Ot=(t,n)=>{I(r=>{const l=r[t]||[];return l.some(i=>i.source.trim()===n.trim())?r:{...r,[t]:[...l,{id:qe(),source:n,target:""}]}}),V(r=>({...r,[t]:null}))},Ce=(t,n,r,l)=>{I(i=>({...i,[t]:(i[t]||[]).map(d=>d.id===n?{...d,[r]:l}:d)})),V(i=>({...i,[t]:null}))},Tt=(t,n)=>{I(r=>({...r,[t]:(r[t]||[]).filter(l=>l.id!==n)})),V(r=>({...r,[t]:null}))},Ut=t=>{var r,l;if(!p)return;const n=y.find(i=>i.id===t);if(n){const i=((r=n.routing)==null?void 0:r.modelRoutes)??{};I(d=>({...d,[t]:Y(i)}))}else{const i=p.endpointRouting??{},d=t,x=d==="anthropic"?p.modelRoutes??{}:{},j=((l=i[d])==null?void 0:l.modelRoutes)??x;I(S=>({...S,[t]:Y(j)}))}V(i=>({...i,[t]:null}))},At=async t=>{var l;if(!se())return;const n=ne[t]||[],r={};for(const i of n){const d=i.source.trim(),x=i.target.trim();if(!(!d&&!x)){if(!d||!x){V(j=>({...j,[t]:s("settings.validation.routePair")}));return}if(r[d]){V(j=>({...j,[t]:s("settings.validation.routeDuplicate",{model:d})}));return}r[d]=x}}V(i=>({...i,[t]:null})),oe(t);try{const i=y.find(d=>d.id===t);if(i){const d={...i.routing||{},modelRoutes:r,defaults:((l=i.routing)==null?void 0:l.defaults)||p.defaults};await ve.update(t,{routing:d}),c.invalidateQueries({queryKey:["custom-endpoints"]}),a({title:s("modelManagement.toast.routesSaved"),variant:"success"})}else{const d=p.endpointRouting?{...p.endpointRouting}:{},x=t,j=d[x]??{defaults:p.defaults,modelRoutes:x==="anthropic"?p.modelRoutes??{}:{}},S={...j,defaults:j.defaults??p.defaults,modelRoutes:r},U={...d,[x]:S},$={...p,endpointRouting:U,modelRoutes:x==="anthropic"?r:p.modelRoutes??{}};await X.put("/api/config",$),R($),a({title:s("modelManagement.toast.routesSaved"),variant:"success"}),m.refetch()}I(d=>({...d,[t]:Y(r)}))}catch(i){a({title:s("modelManagement.toast.routesSaveFailure",{message:i instanceof Error?i.message:"unknown"}),variant:"error"})}finally{oe(null)}},It=()=>e.jsx(Ke,{children:e.jsxs($e,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("providers.title")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s("providers.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(he,{variant:"secondary",children:s("providers.count",{count:ft})}),e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>m.refetch(),disabled:m.isFetching,children:[e.jsx(es,{className:Le("mr-2 h-4 w-4",m.isFetching&&"animate-spin")}),m.isFetching?s("common.actions.refreshing"):s("providers.actions.refresh")]}),e.jsxs(P,{size:"sm",onClick:Nt,children:[e.jsx(Ve,{className:"mr-2 h-4 w-4"}),s("providers.actions.add")]})]})]}),m.isPending||!p&&m.isFetching?e.jsx("div",{className:"flex min-h-[200px] items-center justify-center rounded-lg border bg-muted/50 text-sm text-muted-foreground",children:s("common.loading")}):_.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:s("providers.emptyState")}),e.jsx("p",{className:"mt-2 text-xs",children:s("providers.emptyStateSub",{default:"点击上方按钮添加您的第一个提供商"})})]}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:_.map(t=>e.jsx(Ke,{className:"flex flex-col",children:e.jsxs($e,{className:"flex flex-1 flex-col gap-4 pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:t.label||t.id}),t.type&&e.jsx(cs,{type:t.type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["ID: ",t.id]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",children:t.baseUrl})]}),t.defaultModel?e.jsx(he,{variant:"default",className:"text-xs",children:bt.get(t.id)??t.defaultModel}):e.jsx(he,{variant:"secondary",className:"text-xs",children:s("providers.card.noDefault")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{className:"text-xs",children:s("providers.card.modelsTitle")}),t.models&&t.models.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:t.models.map(n=>e.jsx(he,{variant:"outline",className:"text-xs",children:nt(n)},n.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.card.noModels")})]}),e.jsxs("div",{className:"mt-auto flex flex-wrap gap-2 pt-4 border-t",children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>wt(t),children:s("providers.actions.edit")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>Ct(t),disabled:O===t.id,children:O===t.id?s("common.actions.testingConnection"):s("providers.actions.test")}),e.jsx(P,{variant:"destructive",size:"sm",onClick:()=>Rt(t),children:s("providers.actions.delete")})]})]})},t.id))})]})}),Lt=t=>{const n=Ne[t]??[],r=we[t]??"",l=u[t],i=w===t;return e.jsxs("div",{className:"rounded-lg border border-dashed bg-muted/30 p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:s("modelManagement.presets.title")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s("modelManagement.presets.description")})]}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center",children:[e.jsx(pe,{value:r,onChange:d=>vt(t,d.target.value),placeholder:s("modelManagement.presets.namePlaceholder"),disabled:i,className:"w-full md:w-48"}),e.jsx(P,{onClick:()=>void jt(t),disabled:i,children:s(i?"modelManagement.presets.saving":"modelManagement.presets.save")})]})]}),l&&e.jsx("p",{className:"text-sm text-destructive",children:l}),n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:s("modelManagement.presets.empty")}):e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:n.map(d=>{const x=(C==null?void 0:C.endpoint)===t&&(C==null?void 0:C.name)===d.name,j=(L==null?void 0:L.endpoint)===t&&(L==null?void 0:L.name)===d.name;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-card px-4 py-3",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:d.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(P,{size:"sm",onClick:()=>void yt(t,d),disabled:x||j,children:s(x?"modelManagement.presets.applying":"modelManagement.presets.apply")}),e.jsx(P,{variant:"destructive",size:"sm",onClick:()=>void kt(t,d),disabled:j||x,children:s(j?"modelManagement.presets.deleting":"modelManagement.presets.delete")})]})]},d.name)})})]})},Kt=t=>{var ie;const n=ne[t]||[],r=Oe[t],l=o.find(D=>D.key===t),d=((ie=l==null?void 0:l.protocols)==null?void 0:ie.includes("anthropic"))??t==="anthropic"?ls:ns,x=Te===t,j=(l==null?void 0:l.label)??s(`modelManagement.tabs.${t}`),S=(l==null?void 0:l.isSystem)===!1?l.description:s(`settings.routing.descriptionByEndpoint.${t}`),U=`route-source-${t}`,$=os(t,y),ae=is(t,p,y),q=$&&(ae==null?void 0:ae.mode)==="claude-code";return e.jsx(Ke,{children:e.jsxs($e,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("settings.routing.titleByEndpoint",{endpoint:j})}),e.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:S}),e.jsx("p",{className:"max-w-3xl text-xs text-muted-foreground",children:s("settings.routing.wildcardHint")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>Dt(t),disabled:x,children:s("settings.routing.add")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>Ut(t),disabled:x,children:s("common.actions.reset")}),e.jsx(P,{size:"sm",onClick:()=>void At(t),disabled:x,children:s(x?"common.actions.saving":"modelManagement.actions.saveRoutes")})]})]}),$&&e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("modelManagement.claudeValidation.title")}),e.jsx("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:s("modelManagement.claudeValidation.description")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ut,{checked:q,onCheckedChange:D=>void Pt(t,D),disabled:gt}),e.jsx("span",{className:Le("text-xs font-medium",q?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:s(q?"modelManagement.claudeValidation.statusEnabled":"modelManagement.claudeValidation.statusDisabled")})]})]})}),Lt(t),r&&e.jsx("p",{className:"text-sm text-destructive",children:r}),n.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:s("settings.routing.empty")}),e.jsx("p",{className:"mt-2 text-xs",children:s("settings.routing.emptySub",{default:"点击上方按钮添加路由规则"})})]}):e.jsx("div",{className:"space-y-3",children:n.map((D,de)=>e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(he,{variant:"secondary",children:de+1}),e.jsx("span",{className:"text-sm font-medium",children:"路由规则"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:s("settings.routing.source")}),e.jsx(pe,{value:D.source,onChange:re=>Ce(t,D.id,"source",re.target.value),placeholder:"claude-3.5-sonnet",list:U,disabled:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:s("settings.routing.target")}),(()=>{const re=D.target.trim(),tt=Je.some(Q=>Q.value===re)?re:"__custom";return e.jsxs(e.Fragment,{children:[e.jsxs(mt,{value:tt,onValueChange:Q=>{Q==="__custom"?Ce(t,D.id,"target",re):Ce(t,D.id,"target",Q)},disabled:x,children:[e.jsx(ht,{children:e.jsx(pt,{})}),e.jsxs(xt,{children:[e.jsx(De,{value:"__custom",children:s("settings.routing.customTargetOption")}),Je.map(Q=>e.jsx(De,{value:Q.value,children:Q.label},Q.value))]})]}),tt==="__custom"&&e.jsx(pe,{value:D.target,onChange:Q=>Ce(t,D.id,"target",Q.target.value),placeholder:"providerId:modelId",disabled:x})]})})()]}),e.jsx("div",{className:"flex items-end",children:e.jsx(P,{variant:"destructive",size:"sm",onClick:()=>Tt(t,D.id),disabled:x,children:s("settings.routing.remove")})})]})]},D.id))}),e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-3",children:[e.jsx(Z,{children:s("settings.routing.suggested")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.map(D=>e.jsx(P,{variant:"outline",size:"sm",onClick:()=>Ot(t,D),disabled:x,children:D},`${t}-${D}`))})]}),e.jsx("datalist",{id:U,children:d.map(D=>e.jsx("option",{value:D},`${U}-${D}`))})]})})};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Qt,{icon:e.jsx(_t,{className:"h-5 w-5","aria-hidden":"true"}),title:s("modelManagement.title"),description:s("modelManagement.description"),actions:e.jsxs(P,{onClick:()=>{ke(void 0),ye(!0)},children:[e.jsx(Ve,{className:"mr-2 h-4 w-4"}),s("modelManagement.addEndpoint")]})}),e.jsx("div",{className:"flex flex-wrap gap-3",children:o.map(t=>{const n=h===t.key;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>N(t.key),className:Le("flex min-w-[200px] flex-col gap-1 rounded-lg border px-4 py-3 text-left transition-all",n?"border-primary bg-primary/5 text-primary":"border-border bg-card hover:bg-accent"),children:[e.jsx("span",{className:"font-medium",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]}),t.canDelete&&e.jsx("button",{onClick:r=>{r.stopPropagation(),Et(t.key)},className:"absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground text-xs hover:bg-destructive/90",title:s("common.delete"),children:e.jsx(Be,{className:"h-3 w-3"})})]},t.key)})}),h==="providers"?It():Kt(h),e.jsx(rs,{open:F,mode:z,provider:z==="edit"?k:void 0,existingProviderIds:_.map(t=>t.id).filter(t=>z==="edit"&&k?t!==k.id:!0),onClose:()=>{T(!1),M(void 0),B("create")},onSubmit:Mt}),e.jsx(us,{open:je,endpoint:xe,onClose:()=>{ye(!1),ke(void 0)},onSuccess:()=>{c.invalidateQueries({queryKey:["custom-endpoints"]})}}),e.jsx(ds,{open:Me,provider:Ue,options:be,preservedExtras:Ge,usePreset:Ee,onPresetChange:Ae,onConfirm:St,onClose:et})]})}function ds({open:s,provider:a,options:c,usePreset:m,preservedExtras:g,onPresetChange:y,onConfirm:o,onClose:h}){const{t:N}=Pe();return a?e.jsx(Gt,{open:s,onOpenChange:p=>!p&&h(),children:e.jsxs(Xt,{children:[e.jsxs(Yt,{children:[e.jsx(Jt,{children:N("providers.testDialog.title")}),e.jsx(Wt,{children:N("providers.testDialog.subtitle",{name:a.label||a.id})})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:N("providers.testDialog.description")}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-4",children:[e.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border",checked:m,onChange:p=>y(p.target.checked)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:N("providers.testDialog.presetLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N("providers.testDialog.presetDescription")}),e.jsxs("details",{className:"rounded-md bg-muted p-2 text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-primary hover:underline",children:N("providers.testDialog.presetPreviewSummary")}),e.jsx("div",{className:"mt-2 space-y-1",children:c.map(p=>e.jsxs("code",{className:"block rounded bg-background px-2 py-1 text-xs",children:[p.key,": ",p.value]},p.key))})]})]})]}),Object.keys(g).length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted p-4 text-xs space-y-2",children:[e.jsx("p",{className:"font-medium",children:N("providers.testDialog.preservedInfo")}),Object.entries(g).map(([p,R])=>e.jsxs("code",{className:"block rounded bg-background px-2 py-1",children:[p,": ",R]},p))]}),e.jsxs(Zt,{children:[e.jsx(P,{variant:"outline",onClick:h,children:N("providers.testDialog.cancel")}),e.jsx(P,{onClick:()=>void o(),children:N("providers.testDialog.primary")})]})]})}):null}function nt(s){return s.label&&s.label.trim().length>0?`${s.label} (${s.id})`:s.id}function cs({type:s}){const a={openai:{label:"OpenAI",variant:"success"},deepseek:{label:"DeepSeek",variant:"info"},huawei:{label:"华为云",variant:"warning"},kimi:{label:"Kimi",variant:"purple"},anthropic:{label:"Anthropic",variant:"pink"},custom:{label:"Custom",variant:"secondary"}},{label:c,variant:m}=a[s]||a.custom;return e.jsx(he,{variant:m,className:"text-xs",children:c})}function us({open:s,endpoint:a,onClose:c,onSuccess:m}){const{t:g}=Pe(),{pushToast:y}=ct(),[o,h]=f.useState({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0});f.useEffect(()=>{if(a){let k;a.paths&&a.paths.length>0?k=a.paths:a.path&&a.protocol?k=[{path:a.path,protocol:a.protocol}]:k=[{path:"",protocol:"openai-auto"}],h({id:a.id,label:a.label,paths:k,enabled:a.enabled!==!1})}else h({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0})},[a,s]);const N=rt({mutationFn:ve.create,onSuccess:()=>{y({title:g("modelManagement.createEndpointSuccess"),variant:"success"}),m(),c()},onError:k=>{const M=Re(k);y({title:g("modelManagement.createEndpointError",{error:M.message}),variant:"error"})}}),p=rt({mutationFn:k=>ve.update(k.id,k.updates),onSuccess:()=>{y({title:g("modelManagement.updateEndpointSuccess"),variant:"success"}),m(),c()},onError:k=>{const M=Re(k);y({title:g("modelManagement.updateEndpointError",{error:M.message}),variant:"error"})}}),R=()=>{h({...o,paths:[...o.paths,{path:"",protocol:"anthropic"}]})},F=k=>{if(o.paths.length===1){y({title:g("modelManagement.atLeastOnePath"),variant:"error"});return}const M=o.paths.filter((O,A)=>A!==k);h({...o,paths:M})},T=(k,M,O)=>{const A=[...o.paths];A[k]={...A[k],[M]:O},h({...o,paths:A})},z=k=>{if(k.preventDefault(),!o.id.trim()||!o.label.trim()){y({title:g("modelManagement.endpointValidationError"),variant:"error"});return}for(const O of o.paths)if(!O.path.trim()){y({title:g("modelManagement.pathValidationError"),variant:"error"});return}const M=o.paths.map(O=>({path:O.path.trim(),protocol:O.protocol}));a?p.mutate({id:a.id,updates:{label:o.label.trim(),paths:M,enabled:o.enabled}}):N.mutate({id:o.id.trim(),label:o.label.trim(),paths:M,enabled:o.enabled})},B=N.isPending||p.isPending;return s?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-40",onClick:c}),e.jsx("div",{className:"fixed inset-y-0 right-0 w-full max-w-md bg-card border-l shadow-xl z-50 overflow-y-auto",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b",children:[e.jsx("h2",{className:"text-lg font-semibold",children:g(a?"modelManagement.editEndpoint":"modelManagement.createEndpoint")}),e.jsx(P,{variant:"ghost",size:"sm",onClick:c,children:e.jsx(Be,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:z,className:"flex-1 p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Z,{children:[g("modelManagement.endpointId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(pe,{value:o.id,onChange:k=>h({...o,id:k.target.value}),placeholder:g("modelManagement.endpointIdPlaceholder"),disabled:!!a,required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g("modelManagement.endpointIdHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Z,{children:[g("modelManagement.endpointLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(pe,{value:o.label,onChange:k=>h({...o,label:k.target.value}),placeholder:g("modelManagement.endpointLabelPlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Z,{children:[g("modelManagement.endpointPaths")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(P,{type:"button",variant:"ghost",size:"sm",onClick:R,children:[e.jsx(Ve,{className:"mr-1 h-3 w-3"}),g("modelManagement.addPath")]})]}),e.jsx("div",{className:"space-y-3",children:o.paths.map((k,M)=>e.jsxs("div",{className:"rounded-lg border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(pe,{value:k.path,onChange:O=>T(M,"path",O.target.value),placeholder:g("modelManagement.endpointPathPlaceholder"),required:!0}),e.jsxs(mt,{value:k.protocol,onValueChange:O=>T(M,"protocol",O),children:[e.jsx(ht,{children:e.jsx(pt,{})}),e.jsxs(xt,{children:[e.jsx(De,{value:"anthropic",children:g("modelManagement.protocolAnthropic")}),e.jsx(De,{value:"openai-auto",children:g("modelManagement.protocolOpenAI")})]})]})]}),o.paths.length>1&&e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:()=>F(M),className:"text-destructive",children:e.jsx(Be,{className:"h-4 w-4"})})]}),M===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:g("modelManagement.endpointPathHint")})]},M))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ut,{id:"enabled",checked:o.enabled,onCheckedChange:k=>h({...o,enabled:k})}),e.jsx(Z,{htmlFor:"enabled",children:g("modelManagement.endpointEnabled")})]}),!a&&e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:g("modelManagement.endpointRoutingHint")})})]}),e.jsxs("div",{className:"flex gap-3 p-6 border-t",children:[e.jsx(P,{variant:"outline",className:"flex-1",onClick:c,disabled:B,children:g("common.cancel")}),e.jsx(P,{className:"flex-1",onClick:z,disabled:B,children:g(B?"common.saving":a?"common.save":"common.create")})]})]})})]}):null}export{ws as default};
|