myapikey 0.42.8 → 0.42.9
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myapikey",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Personal LLM API gateway & proxy — one address + one API key for all your models. Forwards OpenAI & Anthropic calls to your backends with failover and a circuit breaker. Pure passthrough, no format translation. Self-hosted (CLI + web UI).",
|
|
6
6
|
"keywords": [
|
|
@@ -324,7 +324,7 @@ var gu=e=>{throw TypeError(e)};var Nm=(e,t,n)=>t.has(e)||gu("Cannot "+n);var Eo=
|
|
|
324
324
|
*
|
|
325
325
|
* This source code is licensed under the ISC license.
|
|
326
326
|
* See the LICENSE file in the root directory of this source tree.
|
|
327
|
-
*/const Ns=Ee("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Ws=re({__name:"DialogContent",props:{forceMount:{type:Boolean},disableOutsidePointerEvents:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=ae(()=>{const{class:l,...i}=n;return i}),a=At(o,s);return(l,i)=>(h(),V(r(Z1),null,{default:g(()=>[m(r(X1),{class:"fixed inset-0 z-50 bg-black/80"}),m(r(j1),Te(r(a),{class:r(He)("fixed left-[50%] top-[50%] z-50 flex max-h-[90vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 overflow-hidden border bg-background p-6 shadow-lg sm:rounded-lg",n.class)}),{default:g(()=>[ce(l.$slots,"default"),m(r(b1),{class:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background"},{default:g(()=>[m(r(To),{class:"h-4 w-4"}),i[0]||(i[0]=x("span",{class:"sr-only"},"Close",-1))]),_:1})]),_:3},16,["class"])]),_:3}))}}),Ks=re({__name:"DialogTitle",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),V(r(t0),{class:ge(r(He)("text-lg font-semibold leading-none tracking-tight",t.class))},{default:g(()=>[ce(n.$slots,"default")]),_:3},8,["class"]))}}),Gs=re({__name:"DialogDescription",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),V(r(W1),{class:ge(r(He)("text-sm text-muted-foreground",t.class))},{default:g(()=>[ce(n.$slots,"default")]),_:3},8,["class"]))}}),Zk=["for"],bt=re({__name:"Label",props:{class:{type:[Boolean,null,String,Object,Array]},for:{}},setup(e){const t=e;return(n,s)=>(h(),N("label",{for:t.for,class:ge(r(He)("text-sm font-medium leading-none text-foreground",t.class))},[ce(n.$slots,"default")],10,Zk))}}),ga=re({__name:"Popover",props:{defaultOpen:{type:Boolean},open:{type:Boolean},modal:{type:Boolean}},emits:["update:open"],setup(e,{emit:t}){const o=At(e,t);return(a,l)=>(h(),V(r(ew),Ct(Tt(r(o))),{default:g(()=>[ce(a.$slots,"default")]),_:3},16))}}),va=re({__name:"PopoverTrigger",props:{asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(h(),V(r(dw),Ct(Tt(t)),{default:g(()=>[ce(n.$slots,"default")]),_:3},16))}}),ya=re({__name:"PopoverContent",props:{forceMount:{type:Boolean},memoDependencies:{},side:{},sideOffset:{default:4},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=ae(()=>{const{class:l,...i}=n;return i}),a=At(o,s);return(l,i)=>(h(),V(r(uw),null,{default:g(()=>[m(r(lw),Te(r(a),{class:r(He)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",n.class)}),{default:g(()=>[ce(l.$slots,"default")]),_:3},16,["class"])]),_:3}))}}),eC={class:"relative w-full overflow-auto"},Qa=re({__name:"Table",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("div",eC,[x("table",{class:ge(r(He)("w-full caption-bottom text-sm",t.class))},[ce(n.$slots,"default")],2)]))}}),Za=re({__name:"TableHeader",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("thead",{class:ge(r(He)("[&_tr]:border-b",t.class))},[ce(n.$slots,"default")],2))}}),el=re({__name:"TableBody",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("tbody",{class:ge(r(He)("[&_tr:last-child]:border-0",t.class))},[ce(n.$slots,"default")],2))}}),Cn=re({__name:"TableRow",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("tr",{class:ge(r(He)("border-b transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",t.class))},[ce(n.$slots,"default")],2))}}),rt=re({__name:"TableHead",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("th",{class:ge(r(He)("h-10 px-3 text-left align-middle text-xs font-medium uppercase tracking-wide text-muted-foreground [&:has([role=checkbox])]:pr-0",t.class))},[ce(n.$slots,"default")],2))}}),nt=re({__name:"TableCell",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("td",{class:ge(r(He)("p-3 align-middle [&:has([role=checkbox])]:pr-0",t.class))},[ce(n.$slots,"default")],2))}}),Mm=re({__name:"Switch",props:es({class:{type:[Boolean,null,String,Object,Array]},id:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=e,n=Co(e,"modelValue");return(s,o)=>(h(),V(r(vk),{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=a=>n.value=a),id:t.id,class:ge(r(He)("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow 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.class))},{default:g(()=>[m(r(_k),{class:"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"})]),_:1},8,["modelValue","id","class"]))}}),Hr=re({__name:"Select",props:{open:{type:Boolean},defaultOpen:{type:Boolean},defaultValue:{},modelValue:{},nullableValue:{},by:{type:[String,Function]},dir:{},multiple:{type:Boolean},autocomplete:{},disabled:{type:Boolean},name:{},required:{type:Boolean}},emits:["update:modelValue","update:open"],setup(e,{emit:t}){const o=At(e,t);return(a,l)=>(h(),V(r(Ow),Ct(Tt(r(o))),{default:g(()=>[ce(a.$slots,"default")]),_:3},16))}}),jr=re({__name:"SelectTrigger",props:{disabled:{type:Boolean},reference:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=ae(()=>{const{class:s,...o}=t;return o});return(s,o)=>(h(),V(r(rk),Te(n.value,{class:r(He)("flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t.class)}),{default:g(()=>[ce(s.$slots,"default"),m(r(Gw),{"as-child":""},{default:g(()=>[m(r(Rn),{class:"h-4 w-4 opacity-50"})]),_:1})]),_:3},16,["class"]))}}),zr=re({__name:"SelectValue",props:{placeholder:{},asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(h(),V(r(lk),Ct(Tt(t)),{default:g(()=>[ce(n.$slots,"default")]),_:3},16))}}),Wr=re({__name:"SelectContent",props:{forceMount:{type:Boolean},position:{default:"popper"},bodyLock:{type:Boolean},memoDependencies:{},side:{},sideOffset:{},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["closeAutoFocus","escapeKeyDown","pointerDownOutside"],setup(e,{emit:t}){const n=e,s=t,o=ae(()=>{const{class:l,...i}=n;return i}),a=At(o,s);return(l,i)=>(h(),V(r(sk),null,{default:g(()=>[m(r(Ww),Te(r(a),{class:r(He)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n.position==="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",n.class)}),{default:g(()=>[m(r(uk),{class:ge(r(He)("p-1",n.position==="popper"&&"w-full min-w-[var(--reka-select-trigger-width)]"))},{default:g(()=>[ce(l.$slots,"default")]),_:3},8,["class"])]),_:3},16,["class"])]),_:3}))}}),tC={class:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center"},ds=re({__name:"SelectItem",props:{value:{},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=ae(()=>{const{class:s,...o}=t;return o});return(s,o)=>(h(),V(r(Jw),Te(n.value,{class:r(He)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t.class)}),{default:g(()=>[x("span",tC,[m(r(Zw),null,{default:g(()=>[m(r(rn),{class:"h-4 w-4"})]),_:1})]),m(r(tk),null,{default:g(()=>[ce(s.$slots,"default")]),_:3})]),_:3},16,["class"]))}}),nC={class:"relative"},sC=["aria-label"],oC={key:0,class:"mt-1.5 flex flex-wrap gap-1"},rC=["aria-label","onClick"],aC={key:0},lC={class:"flex-1 truncate font-mono"},iC=["onMousedown"],uC={key:1,class:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"},cC={class:"flex-1 truncate"},dC={key:1,class:"px-2 py-1 text-xs text-muted-foreground"},fC={key:2,class:"px-2 py-1 text-xs text-muted-foreground"},Im=re({__name:"Combobox",props:{modelValue:{},options:{},placeholder:{},limit:{default:300},multi:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,s=t,{t:o}=ft(),a=j(null),l=j(null),i=j(!1),u=j("");function c(){var Y,ee;i.value=!i.value,i.value&&((ee=(Y=l.value)==null?void 0:Y.$el)==null||ee.focus())}function d(Y){i.value&&(Y.stopPropagation(),Y.preventDefault(),i.value=!1)}const f=ae(()=>Array.isArray(n.modelValue)?n.modelValue:[]),p=ae(()=>{const Y=(n.multi?u.value:String(n.modelValue??"")).trim().toLowerCase();return Y?n.options.filter(ee=>ee.toLowerCase().includes(Y)):n.options}),y=ae(()=>p.value.slice(0,n.limit)),$=ae(()=>p.value.length-y.value.length);function A(Y){n.multi?(u.value=String(Y),i.value=!0):(s("update:modelValue",String(Y)),i.value=!0)}function E(Y){if(n.multi){const ee=f.value.includes(Y)?f.value.filter(Q=>Q!==Y):[...f.value,Y];s("update:modelValue",ee)}else s("update:modelValue",Y),i.value=!1}function C(Y){s("update:modelValue",f.value.filter(ee=>ee!==Y))}function k(Y){const ee=Y.split(/[\s,;]+/).map(fe=>fe.trim()).filter(Boolean);if(!ee.length)return;const Q=[...f.value];for(const fe of ee)Q.includes(fe)||Q.push(fe);s("update:modelValue",Q),u.value=""}function M(){n.multi&&k(u.value)}function S(Y){var Q;if(!n.multi)return;const ee=((Q=Y.clipboardData)==null?void 0:Q.getData("text"))??"";!ee.trim()||!/[\s,;]/.test(ee)||(Y.preventDefault(),k(ee))}function F(Y){var Q;const ee=Y.relatedTarget;ee&&((Q=a.value)!=null&&Q.contains(ee))||(i.value=!1)}const D=j(null),T=ae(()=>Math.min(Math.max(y.value.length*34+8,48),224));function I(){var Q;const Y=(Q=a.value)==null?void 0:Q.getBoundingClientRect();if(!Y)return;const ee=Y.bottom+6+T.value<=window.innerHeight;D.value={top:ee?Y.bottom+6:Math.max(Y.top-6-T.value,8),left:Math.max(Math.min(Y.left,window.innerWidth-Y.width-8),8),width:Y.width}}function G(){i.value&&I()}return Ie(i,async Y=>{Y?(await it(),I(),window.addEventListener("scroll",G,!0),window.addEventListener("resize",G)):(window.removeEventListener("scroll",G,!0),window.removeEventListener("resize",G))}),Ie(T,()=>i.value&&I()),ko(()=>{window.removeEventListener("scroll",G,!0),window.removeEventListener("resize",G)}),(Y,ee)=>(h(),N("div",{ref_key:"rootRef",ref:a,onFocusin:ee[2]||(ee[2]=Q=>i.value=!0),onFocusout:F},[x("div",nC,[m(r(mt),{ref_key:"inputRef",ref:l,"model-value":e.multi?u.value:e.modelValue,placeholder:e.placeholder,autocomplete:"off",spellcheck:"false",class:"pr-8","onUpdate:modelValue":A,onKeydown:[Tn(d,["esc"]),Tn(Re(M,["prevent"]),["enter"])],onPaste:S},null,8,["model-value","placeholder","onKeydown"]),x("button",{type:"button",tabindex:"-1",class:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm text-muted-foreground/70 transition-colors hover:text-foreground","aria-label":r(o)("combobox.toggle"),onMousedown:Re(c,["prevent"])},[m(r(Rn),{class:ge(["h-4 w-4 transition-transform",i.value?"rotate-180":""])},null,8,["class"])],40,sC)]),e.multi&&f.value.length?(h(),N("div",oC,[(h(!0),N(he,null,Pe(f.value,Q=>(h(),N("span",{key:Q,class:"inline-flex items-center gap-1 rounded-md border-transparent bg-primary text-primary-foreground shadow-sm px-2 py-0.5 font-mono text-xs"},[U(v(Q)+" ",1),x("button",{type:"button",class:"opacity-70 hover:opacity-100","aria-label":r(o)("common.dismiss"),onClick:fe=>C(Q)},[m(r(To),{class:"h-3 w-3"})],8,rC)]))),128))])):se("",!0),(h(),V(vr,{to:"body"},[i.value&&(y.value.length||e.multi&&u.value.trim())?(h(),N("ul",{key:0,class:"pointer-events-auto fixed z-[60] max-h-56 overflow-auto rounded-md border bg-popover p-1 text-sm shadow-md",style:en(D.value?{top:`${D.value.top}px`,left:`${D.value.left}px`,width:`${D.value.width}px`}:void 0),onPointerdown:ee[1]||(ee[1]=Re(()=>{},["stop"]))},[e.multi&&u.value.trim()?(h(),N("li",aC,[x("button",{type:"button",class:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left hover:bg-accent hover:text-accent-foreground",onMousedown:ee[0]||(ee[0]=Re(Q=>k(u.value),["prevent"]))},[m(r(Yn),{class:"h-3.5 w-3.5 shrink-0"}),x("span",lC,v(r(o)("combobox.add",{q:u.value.trim()})),1)],32)])):se("",!0),(h(!0),N(he,null,Pe(y.value,Q=>(h(),N("li",{key:Q},[x("button",{type:"button",class:ge(["flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono hover:bg-accent hover:text-accent-foreground",Q===e.modelValue||f.value.includes(Q)?"text-primary":""]),onMousedown:Re(fe=>E(Q),["prevent"])},[Q===e.modelValue||f.value.includes(Q)?(h(),V(r(rn),{key:0,class:"h-3.5 w-3.5 shrink-0"})):(h(),N("span",uC)),x("span",cC,v(Q),1)],42,iC)]))),128)),!y.value.length&&!(e.multi&&u.value.trim())?(h(),N("li",dC,v(r(o)("combobox.noMatch")),1)):$.value>0?(h(),N("li",fC,v(r(o)("combobox.more",{n:$.value})),1)):se("",!0)],36)):se("",!0)]))],544))}}),pC={class:"grid grid-cols-2 gap-x-3 gap-y-1"},mC={class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-xs text-foreground/80"},hC={class:"pt-1.5 text-xs leading-relaxed text-muted-foreground"},gC=re({__name:"SamplingPanel",props:{modelValue:{}},setup(e){const t=e,{t:n}=ft(),s=[{key:"temperature",helpKey:"models.editor.samplingTipTemp",ph:"0.0 – 2.0"},{key:"top_p",helpKey:"models.editor.samplingTipTopP",ph:"0.0 – 1.0"},{key:"top_k",helpKey:"models.editor.samplingTipTopK",ph:"0 = off"},{key:"presence_penalty",helpKey:"models.editor.samplingTipPres",ph:"-2 – 2"},{key:"frequency_penalty",helpKey:"models.editor.samplingTipFreq",ph:"-2 – 2"},{key:"seed",helpKey:"models.editor.samplingTipSeed",ph:"integer"}];function o(a,l){t.modelValue[a]=String(l??"")}return(a,l)=>(h(),N(he,null,[x("div",pC,[(h(),N(he,null,Pe(s,i=>x("div",{key:i.key,class:"flex items-center gap-1.5"},[x("span",mC,[U(v(i.key)+" ",1),m(r(Nk),{class:"h-3 w-3 opacity-60","aria-label":`${i.key}: ${r(n)(i.helpKey)}`,title:r(n)(i.helpKey)},null,8,["aria-label","title"])]),m(r(mt),{"model-value":t.modelValue[i.key],type:"number",step:"any",class:"ml-auto h-6 w-20 bg-background px-2 text-right font-mono text-xs",placeholder:i.ph,spellcheck:"false","aria-label":i.key,"onUpdate:modelValue":u=>o(i.key,u)},null,8,["model-value","placeholder","aria-label","onUpdate:modelValue"])])),64))]),x("p",hC,v(r(n)("models.editor.samplingTipBase")),1)],64))}}),vC={class:"flex flex-wrap gap-1"},yC=["aria-pressed","onClick"],_C={class:"pt-1.5 text-xs leading-relaxed text-muted-foreground"},bC=re({__name:"ThinkingPanel",props:es({format:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=Co(e,"modelValue"),n=e,{t:s}=ft(),o=["low","medium","high","xhigh"],a=["1024","4096","8192","16384"],l=n.format==="anthropic"?a:o;return(i,u)=>(h(),N(he,null,[x("div",vC,[(h(!0),N(he,null,Pe(r(l),c=>(h(),N("button",{key:c,type:"button",class:ge(["rounded border px-2 py-0.5 font-mono text-xs transition-colors",t.value===c?"border-primary bg-primary/15 font-medium text-primary":"border-border bg-background text-foreground/80 hover:text-foreground"]),"aria-pressed":t.value===c,onClick:d=>t.value=t.value===c?"":c},v(c),11,yC))),128))]),m(r(mt),{"model-value":t.value,class:"h-7 w-48 bg-background font-mono text-xs",spellcheck:"false",placeholder:n.format==="anthropic"?r(s)("models.editor.thinkingPhBudget"):r(s)("models.editor.thinkingPh"),list:n.format==="anthropic"?"thinking-budgets":"thinking-words","aria-label":r(s)("models.editor.thinkingLabel"),"onUpdate:modelValue":u[0]||(u[0]=c=>t.value=String(c??""))},null,8,["model-value","placeholder","list","aria-label"]),x("p",_C,v(r(s)("models.editor.thinkingTipBase")),1)],64))}}),xC={class:"flex shrink-0 items-center gap-2 pr-8"},wC={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},kC={class:"min-w-0"},CC={class:"min-h-0 flex-1 space-y-3 overflow-y-auto px-1 py-1.5"},SC={class:"space-y-1.5"},$C={key:0,class:"text-xs text-destructive"},TC={key:1,class:"text-xs text-muted-foreground"},AC={key:2,class:"text-xs text-muted-foreground"},EC={key:0,class:"rounded-md border border-dashed p-4 text-center text-sm text-muted-foreground"},OC={class:"space-y-2"},PC={class:"flex items-center justify-between"},MC={class:"text-xs text-muted-foreground"},IC={class:"flex items-center gap-1.5"},RC={class:"text-xs font-semibold"},LC={class:"font-mono text-[11px] text-muted-foreground"},DC={key:0,class:"px-1 py-0.5 text-xs text-muted-foreground"},NC=["draggable","onDragstart","onDragover","onDrop"],FC=["aria-label","title","onMousedown"],qC={class:"w-3.5 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground"},BC={class:"flex items-center gap-1.5"},VC={class:"w-44 shrink-0 [&_input]:h-7 [&_input]:text-xs"},UC=["title"],HC={class:"truncate font-mono"},jC={key:1,class:"opacity-40"},zC={class:"truncate font-mono"},WC={class:"space-y-2.5 rounded-[5px] bg-primary/[0.08] p-2.5"},KC={class:"space-y-1.5"},GC={class:"flex items-center justify-between"},YC={class:"text-xs font-medium text-foreground"},XC=["onClick"],JC={class:"space-y-1"},QC={class:"flex items-center justify-between"},ZC={class:"text-xs font-medium text-foreground"},eS=["onClick"],tS=["onClick"],nS={key:2,class:"inline-flex items-center gap-1 px-1 text-[11px] text-destructive"},sS={class:"flex items-center"},oS=["aria-expanded"],rS={key:0,class:"space-y-1 rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground"},aS={class:"space-y-1.5"},lS=["aria-expanded"],iS={key:0,class:"space-y-1.5 rounded-md border bg-muted/30 p-3"},uS={class:"text-xs text-muted-foreground"},cS={class:"flex shrink-0 justify-end gap-2"},dS=re({__name:"ModelEditor",props:es({providers:{},model:{},existingNames:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:es(["saved"],["update:open"]),setup(e,{emit:t}){const n=["openai","anthropic","responses"],s=[{key:"temperature",bounded:!0},{key:"top_p",bounded:!0},{key:"top_k",bounded:!1},{key:"presence_penalty",bounded:!0},{key:"frequency_penalty",bounded:!0},{key:"seed",bounded:!1}];function o(){return Object.fromEntries(s.map(_=>[_.key,""]))}const a=_=>s.some(w=>_.sampling[w.key].trim()!=="");function l(_){for(const w of s)_.sampling[w.key]=""}const i=j(null),u=(_,w)=>`${_}:${w}`,c=(_,w)=>i.value===u(_,w);function d(_,w,b){const q=u(_,w);b?i.value=q:i.value===q&&(i.value=null)}function f(_){const w={};for(const[b,q]of Object.entries(_))q.trim()!==""&&(w[b]=q);return on(Object.keys(w).length?w:void 0)}function p(_){const w=[];return _.thinking.trim()&&w.push(`${k("models.editor.thinkingLabel")}: ${_.thinking.trim()}`),a(_)&&w.push(`${k("models.editor.samplingLabel")}: ${f(_.sampling)}`),w.join(" · ")||k("models.editor.slotDefaults")}let y=0;function $(_){var b;const w=o();for(const q of s){const W=(b=_.sampling)==null?void 0:b[q.key];W!=null&&(w[q.key]=typeof W=="number"?JSON.stringify(W):String(W))}return{uid:++y,pid:_.id,model:_.model??"",thinking:_.thinking??"",sampling:w}}const A=e,E=Co(e,"open"),C=t,{t:k}=ft(),M=j(""),S=j({openai:[],anthropic:[],responses:[]}),F=j({openai:!1,anthropic:!1,responses:!1}),D=j(""),T=j(!1),I=j(""),G=j({}),Y=j(!1),ee=j(!1),Q=encodeURIComponent;function fe(_){return A.providers.find(w=>w.id===_)}function R(_,w){const b=fe(_);return b?w==="responses"?!!b.supportsResponses:b.formats.includes(w):!1}function O(_){return po(fe(_))}function L(){I.value="",G.value={},D.value="",Y.value=!1,S.value={openai:[],anthropic:[],responses:[]},F.value={openai:!1,anthropic:!1,responses:!1};const _=A.model;if(!_){ee.value=!1;return}M.value=_.name,D.value=_.paceRpm?String(_.paceRpm):"",ee.value=!!_.paceRpm;for(const w of n)S.value[w]=_[w].providers.map($),F.value[w]=_[w].enabled}Ie(E,_=>{_&&L()});function J(_){var w;S.value[_].push($({id:((w=A.providers[0])==null?void 0:w.id)??""}))}function ne(_,w){const b=S.value[_].findIndex(q=>q.uid===w);b!==-1&&(S.value[_].splice(b,1),delete G.value[_])}function pe(_){_.model="",_.thinking="",_.sampling=o()}const K=j(null),de=j(null),oe=(_,w)=>K.value===`${_}:${w}`,Ge=(_,w)=>{var b;return((b=de.value)==null?void 0:b.fmt)===_&&de.value.from===w};function qe(_,w){return Ge(_,w)?"bg-background/60 opacity-40":"bg-background/60"}function ve(_){const w=S.value[_],b=de.value&&de.value.fmt===_?de.value.to:null,q=[],W=X=>({key:"ph",ph:!0,slot:w[0],i:X}),H=(X,be)=>({key:X.uid,ph:!1,slot:X,i:be});for(let X=0;X<w.length;X++)b===X&&q.push(W(X)),q.push(H(w[X],X));return b!==null&&b>=w.length&&q.push(W(w.length)),q}function ye(_){K.value=_}function Z(){K.value=null}function xe(_,w,b){var q;if(K.value!==`${_}:${w}`){b.preventDefault();return}de.value={fmt:_,from:w,to:w},(q=b.dataTransfer)==null||q.setData("text/plain",""),b.dataTransfer&&(b.dataTransfer.effectAllowed="move")}function _e(_,w,b){if(!de.value||de.value.fmt!==_)return;b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move");const q=b.currentTarget.getBoundingClientRect();de.value.to=b.clientY>q.top+q.height/2?w+1:w}function Fe(_,w){!de.value||de.value.fmt!==_||w.target===w.currentTarget&&(w.preventDefault(),de.value.to=S.value[_].length)}function Le(_){const w=de.value;if(de.value=null,Z(),!w||w.fmt!==_||w.to===w.from||w.to===w.from+1)return;const b=S.value[_],[q]=b.splice(w.from,1);b.splice(w.to>w.from?w.to-1:w.to,0,q)}function B(){de.value=null,Z()}const z=ae(()=>!T.value&&(!!A.model||!!M.value.trim()));function te(){var b;I.value="",G.value={};const _=M.value.trim();if(!_)return I.value=k("models.editor.errNameRequired"),!1;if(_.includes("/"))return I.value=k("models.editor.errNameSlash"),!1;if(!A.model&&A.existingNames.includes(_))return I.value=k("models.editor.errNameExists",{name:_}),!1;for(const q of S.value.anthropic)if(q.thinking.trim()&&!/^\d+$/.test(q.thinking.trim()))return G.value.anthropic=k("models.editor.errThinkingBudget"),!1;const w={temperature:[0,2,!0],top_p:[0,1,!1],presence_penalty:[-2,2,!1],frequency_penalty:[-2,2,!1]};for(const q of n)for(const W of S.value[q])for(const{key:H,bounded:X}of s){const be=(b=W.sampling[H])==null?void 0:b.trim();if(!be)continue;const me=Number(be),Ae=w[H];if(!Number.isFinite(me)||Ae&&(me<Ae[0]||(Ae[2]?me>=Ae[1]:me>Ae[1])))return G.value[q]=X?k("models.editor.errSamplingRange",{key:H}):k("models.editor.errSampling"),!1;if(H==="seed"&&!Number.isInteger(me))return G.value[q]=k("models.editor.errSampling"),!1}return!0}function ue(_){var b;const w={};for(const q of s){const W=(b=_[q.key])==null?void 0:b.trim();W&&(w[q.key]=Number(W))}return Object.keys(w).length?w:void 0}function le(_){return _.map(w=>{const b={id:w.pid};w.model.trim()&&(b.model=w.model.trim()),w.thinking.trim()&&(b.thinking=w.thinking.trim());const q=ue(w.sampling);return q&&(b.sampling=q),b})}async function ie(){if(!(!z.value||!te())){T.value=!0;try{const _={};for(const b of n)_[b]={enabled:F.value[b],slots:le(S.value[b])};_.paceRpm=Number(D.value)||0;const w=await Be("PUT",`/admin/models/${Q(M.value.trim())}`,_);Ue(k("models.editor.savedToast",{name:w.model.name}),"success"),E.value=!1,C("saved",w.model)}catch(_){Ue(_.message,"error")}finally{T.value=!1}}}const P=ae(()=>A.providers.length>0);return(_,w)=>(h(),V(r(zs),{open:E.value,"onUpdate:open":w[5]||(w[5]=b=>E.value=b)},{default:g(()=>[m(r(Ws),{class:"max-w-xl"},{default:g(()=>[w[8]||(w[8]=x("datalist",{id:"thinking-words"},[x("option",{value:"low"}),x("option",{value:"medium"}),x("option",{value:"high"}),x("option",{value:"xhigh"})],-1)),w[9]||(w[9]=x("datalist",{id:"thinking-budgets"},[x("option",{value:"1024"}),x("option",{value:"4096"}),x("option",{value:"8192"}),x("option",{value:"16384"})],-1)),x("div",xC,[x("span",wC,[m(r(wo),{class:"h-4 w-4"})]),x("div",kC,[m(r(Ks),{class:"text-base"},{default:g(()=>[U(v(e.model?r(k)("models.editor.editTitle"):r(k)("models.editor.createTitle")),1)]),_:1}),m(r(Gs),null,{default:g(()=>[U(v(r(k)("models.editor.desc")),1)]),_:1})])]),x("div",CC,[x("div",SC,[m(r(bt),{for:"m-name"},{default:g(()=>[U(v(r(k)("models.editor.nameLabel")),1)]),_:1}),m(r(mt),{id:"m-name",modelValue:M.value,"onUpdate:modelValue":w[0]||(w[0]=b=>M.value=b),disabled:!!e.model,placeholder:r(k)("models.editor.namePh"),class:"font-mono",spellcheck:"false",autocomplete:"off"},null,8,["modelValue","disabled","placeholder"]),I.value?(h(),N("p",$C,v(I.value),1)):e.model?(h(),N("p",TC,v(r(k)("models.editor.nameEditHint")),1)):(h(),N("p",AC,v(r(k)("models.editor.nameHint")),1))]),P.value?(h(),N(he,{key:1},[x("div",OC,[x("div",PC,[m(r(bt),null,{default:g(()=>[U(v(r(k)("models.editor.chainTitle")),1)]),_:1}),x("span",MC,v(r(k)("models.editor.chainPriority")),1)]),(h(),N(he,null,Pe(n,b=>x("div",{key:b,class:"space-y-1 rounded-md border bg-muted/30 p-2"},[x("div",IC,[x("span",{class:ge(["h-2 w-2 rounded-full",r(pt)[b].solid])},null,2),x("span",RC,v(r(k)(r(_n)[b].label)),1),x("span",LC,v(r(_n)[b].endpoint),1),m(r(Mm),{modelValue:F.value[b],"onUpdate:modelValue":q=>F.value[b]=q,class:"ml-auto","aria-label":r(k)("models.editor.enabledLabel")},null,8,["modelValue","onUpdate:modelValue","aria-label"])]),S.value[b].length?(h(),V(Vf,{key:1,tag:"div",name:"slots",class:"space-y-1",onDragover:q=>Fe(b,q),onDrop:Re(q=>Le(b),["prevent"])},{default:g(()=>[(h(!0),N(he,null,Pe(ve(b),q=>(h(),N("div",{key:q.key,class:ge(["space-y-1",q.ph?"ph h-8 shrink-0 rounded border border-dashed border-primary/50 bg-primary/10":""]),draggable:!q.ph&&oe(b,q.i),onDragstart:W=>xe(b,q.i,W),onDragover:W=>_e(b,q.i,W),onDrop:Re(W=>Le(b),["prevent"]),onDragend:B,onMouseup:Z},[q.ph?se("",!0):(h(),N("div",{key:0,class:ge(["flex items-center gap-1 rounded px-1 py-0.5",qe(b,q.i)])},[x("button",{type:"button",class:"shrink-0 cursor-grab rounded p-0.5 text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":r(k)("models.editor.dragAria"),title:r(k)("models.editor.dragAria"),onMousedown:W=>ye(`${b}:${q.i}`)},[m(r(qk),{class:"h-3.5 w-3.5"})],40,FC),x("span",qC,v(q.i+1),1),m(r(Hr),{modelValue:q.slot.pid,"onUpdate:modelValue":[W=>q.slot.pid=W,W=>pe(q.slot)]},{default:g(()=>[m(r(jr),{class:"h-7 w-28 shrink-0 px-2 text-xs"},{default:g(()=>[m(r(zr),{placeholder:r(k)("models.editor.providerPh")},null,8,["placeholder"])]),_:1}),m(r(Wr),null,{default:g(()=>[(h(!0),N(he,null,Pe(e.providers.filter(W=>R(W.id,b)),W=>(h(),V(r(ds),{key:W.id,value:W.id,class:"text-xs"},{default:g(()=>[x("span",BC,[x("span",{class:ge(["h-1.5 w-1.5 rounded-full",r(ps)(W.id).solid])},null,2),U(" "+v(W.name),1)])]),_:2},1032,["value"]))),128))]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue"]),x("div",VC,[m(Im,{modelValue:q.slot.model,"onUpdate:modelValue":W=>q.slot.model=W,options:O(q.slot.pid),placeholder:r(k)("models.editor.upstreamPh")},null,8,["modelValue","onUpdate:modelValue","options","placeholder"])]),m(r(ga),{open:c(b,q.slot.uid),"onUpdate:open":W=>d(b,q.slot.uid,W)},{default:g(()=>[m(r(va),{"as-child":""},{default:g(()=>[x("button",{type:"button",class:ge(["ml-auto inline-flex h-7 max-w-44 min-w-0 shrink-0 cursor-pointer items-center gap-1 rounded-md border px-2 text-[11px] outline-none transition-colors",q.slot.thinking.trim()||a(q.slot)?"border-primary/40 bg-primary/10 text-primary":"border-dashed text-muted-foreground/70 hover:border-foreground/30 hover:text-foreground"]),title:p(q.slot)},[q.slot.thinking.trim()||a(q.slot)?(h(),N(he,{key:0},[q.slot.thinking.trim()?(h(),N(he,{key:0},[m(r(xo),{class:"h-3 w-3 shrink-0"}),x("span",HC,v(q.slot.thinking.trim()),1)],64)):se("",!0),q.slot.thinking.trim()&&a(q.slot)?(h(),N("span",jC,"·")):se("",!0),a(q.slot)?(h(),N(he,{key:2},[m(r(vs),{class:"h-3 w-3 shrink-0"}),x("span",zC,v(f(q.slot.sampling)),1)],64)):se("",!0)],64)):(h(),N(he,{key:1},[m(r(Yk),{class:"h-3 w-3 shrink-0"}),U(" "+v(r(k)("models.editor.slotDefaults")),1)],64))],10,UC)]),_:2},1024),m(r(ya),{align:"end",class:"w-96 rounded-md border-primary/30 p-1.5 shadow-lg"},{default:g(()=>[x("div",WC,[x("div",KC,[x("div",GC,[x("div",YC,v(r(k)("models.editor.thinkingLabel")),1),x("button",{type:"button",class:"cursor-pointer text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:W=>q.slot.thinking=""},v(r(k)("models.editor.thinkingClear")),9,XC)]),m(bC,{modelValue:q.slot.thinking,"onUpdate:modelValue":W=>q.slot.thinking=W,format:b},null,8,["modelValue","onUpdate:modelValue","format"])]),w[6]||(w[6]=x("div",{class:"border-t border-primary/15"},null,-1)),x("div",JC,[x("div",QC,[x("div",ZC,v(r(k)("models.editor.samplingLabel")),1),x("button",{type:"button",class:"cursor-pointer text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:W=>l(q.slot)},v(r(k)("models.editor.samplingClear")),9,eS)]),m(gC,{modelValue:q.slot.sampling,"onUpdate:modelValue":W=>q.slot.sampling=W},null,8,["modelValue","onUpdate:modelValue"])]),w[7]||(w[7]=x("div",{class:"border-t border-primary/15"},null,-1)),x("button",{type:"button",class:"-mx-1 flex w-full cursor-pointer items-center gap-1.5 rounded px-1 py-1 text-xs text-destructive transition-colors hover:bg-destructive/10",onClick:W=>{i.value=null,ne(b,q.slot.uid)}},[m(r(fr),{class:"h-3.5 w-3.5"}),U(v(r(k)("models.editor.removeSlot")),1)],8,tS)])]),_:2},1024)]),_:2},1032,["open","onUpdate:open"])],2))],42,NC))),128))]),_:2},1032,["onDragover","onDrop"])):(h(),N("div",DC,v(r(k)("models.editor.emptyChain")),1)),G.value[b]?(h(),N("span",nS,[m(r(pr),{class:"h-3 w-3"}),U(v(G.value[b]),1)])):se("",!0),m(r(we),{variant:"outline",size:"sm",class:"h-7 w-full border-dashed text-xs",disabled:!e.providers.some(q=>R(q.id,b)),onClick:q=>J(b)},{default:g(()=>[m(r(Yn),{class:"h-3.5 w-3.5"}),U(v(r(k)("models.editor.addSlot")),1)]),_:1},8,["disabled","onClick"])])),64))]),x("div",sS,[x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground","aria-expanded":Y.value,onClick:w[1]||(w[1]=b=>Y.value=!Y.value)},[m(r(cu),{class:"h-3.5 w-3.5"}),U(" "+v(r(k)("models.editor.helpToggle")),1)],8,oS)]),Y.value?(h(),N("div",rS,[x("p",null,v(r(k)("models.editor.helpUpstream")),1),x("p",null,v(r(k)("models.editor.helpThinking")),1),x("p",null,v(r(k)("models.editor.helpSampling")),1)])):se("",!0),x("div",aS,[x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground","aria-expanded":ee.value,onClick:w[2]||(w[2]=b=>ee.value=!ee.value)},[m(r(vs),{class:"h-3.5 w-3.5"}),U(" "+v(r(k)("models.editor.advancedToggle"))+" ",1),m(r(Rn),{class:ge(["h-3.5 w-3.5 transition-transform",{"rotate-180":ee.value}])},null,8,["class"])],8,lS),ee.value?(h(),N("div",iS,[m(r(bt),{for:"m-pace"},{default:g(()=>[U(v(r(k)("models.editor.paceLabel")),1)]),_:1}),m(r(mt),{id:"m-pace",modelValue:D.value,"onUpdate:modelValue":w[3]||(w[3]=b=>D.value=b),type:"number",min:"0",inputmode:"numeric",placeholder:r(k)("models.editor.pacePh"),class:"w-32"},null,8,["modelValue","placeholder"]),x("p",uS,v(r(k)("models.editor.paceHint")),1)])):se("",!0)])],64)):(h(),N("div",EC,v(r(k)("models.editor.noProviders")),1))]),x("div",cS,[m(r(we),{variant:"outline",disabled:T.value,onClick:w[4]||(w[4]=b=>E.value=!1)},{default:g(()=>[U(v(r(k)("common.cancel")),1)]),_:1},8,["disabled"]),m(r(we),{disabled:!z.value,onClick:ie},{default:g(()=>[T.value?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):se("",!0),U(" "+v(r(k)("models.editor.save")),1)]),_:1},8,["disabled"])])]),_:1})]),_:1},8,["open"]))}}),Rm=(e,t)=>{const n=e.__vccOpts||e;for(const[s,o]of t)n[s]=o;return n},fS=Rm(dS,[["__scopeId","data-v-2da19750"]]);function dd(e){let t=5381,n=-2128831035;for(let s=0;s<e.length;s++){const o=e.charCodeAt(s);t=(t<<5)+t+o|0,n=(n^o)*16777619|0}return(t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}function gi(e){if(Array.isArray(e))return e.map(gi);if(e&&typeof e=="object"){const t=e,n={};for(const[s,o]of Object.entries(t))s!=="cache_control"&&(n[s]=gi(o));return t.type==="input_text"&&(n.type="text"),n}return e}function pS(e){if(!e||typeof e!="object")return e;const t=gi({...e});return typeof t.content=="string"&&(t.content=[{type:"text",text:t.content}]),t.type==="message"&&delete t.type,t}const fd=80;function Lm(e){const t=e.replace(/\s+/g," ").trim();return t.length>fd?`${t.slice(0,fd)}…`:t}function*Dm(e){if(typeof e=="string"){e.trim()&&(yield e);return}if(Array.isArray(e)){for(const t of e)yield*Dm(t);return}if(e&&typeof e=="object"){const t=e.text;typeof t=="string"&&t.trim()&&(yield t)}}function mS(e){let t=e;for(;;){const n=/^\s*<([a-z][a-z0-9_-]*)((\s[^>]*)?)>/.exec(t);if(!n)return t;const s=t.indexOf(`</${n[1]}>`,n[0].length);if(s===-1)return t;t=t.slice(s+n[1].length+3)}}function hS(e){const t=s=>{const o=[];for(const a of e){if(!a||typeof a!="object")continue;const l=a;s.includes(l.role)&&o.push(...Dm(l.content))}return o},n=[...t(["user"]),...t(["assistant","system"])];for(const s of n){const o=mS(s).trim();if(o)return Lm(o)}return""}function gS(e,t){const n=new RegExp(`"${t}"\\s*:\\s*\\[`).exec(e);if(!n)return[];let s=n.index+n[0].length;const o=e.length,a=[];for(;;){for(;s<o&&/\s/.test(e[s]);)s++;if(s>=o||e[s]==="]")break;const l=s;let i=0,u=!1,c=!1,d=!1;for(;s<o;){const f=e[s++];if(u)c?c=!1:f==="\\"?c=!0:f==='"'&&(u=!1);else if(f==='"')u=!0;else if(f==="{"||f==="[")i++;else if((f==="}"||f==="]")&&(i--,i<=0)){d=!0;break}}if(!d||i!==0)break;for(a.push(e.slice(l,s));s<o&&/\s/.test(e[s]);)s++;if(e[s]===","){s++;continue}break}return a}function vS(e){const t=/"user_id"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(e);if(!t)return"";try{return JSON.parse(`"${t[1]}"`)}catch{return""}}function yS(e){var l;let t=null;try{t=JSON.parse(e)}catch{t=null}let n=[],s="";if(t&&typeof t=="object"){const i=t;typeof((l=i.metadata)==null?void 0:l.user_id)=="string"&&(s=i.metadata.user_id),Array.isArray(i.messages)?n=i.messages:Array.isArray(i.input)?n=i.input:typeof i.input=="string"&&i.input&&(n=[{role:"user",content:i.input}])}else{const i=/"messages"\s*:\s*\[/.test(e)?"messages":"input";n=gS(e,i).map(u=>{try{return JSON.parse(u)}catch{return null}}).filter(u=>u!==null),s=vS(e)}const o=[];let a="";for(const i of n)a=dd(`${a}|${dd(JSON.stringify(pS(i)))}`),o.push(a);return{hashes:o,uid:s,title:Lm(hS(n))}}function _S(e){const t=e.length,n=Array.from({length:t},(i,u)=>u),s=i=>{let u=i;for(;n[u]!==u;)u=n[u];for(;n[i]!==u;){const c=n[i];n[i]=u,i=c}return u},o=(i,u)=>{const c=s(i),d=s(u);c!==d&&(n[Math.max(c,d)]=Math.min(c,d))},a=new Map,l=new Map;for(let i=0;i<t;i++){const u=e[i];if(u.uid){const c=l.get(u.uid);c!==void 0?o(i,c):l.set(u.uid,i)}for(const c of u.hashes){const d=a.get(c);d!==void 0?o(i,d):a.set(c,i)}}return e.map((i,u)=>s(u))}function bS(e){const t=e.map(yS);return{ids:_S(t),shapes:t}}const xS={key:0,class:"space-y-2"},wS={key:0,class:"flex flex-wrap gap-x-3 gap-y-0.5 rounded-md border bg-muted/30 px-2.5 py-1.5"},kS={class:"text-foreground"},CS={class:"border-b bg-muted/30 px-2.5 py-1"},SS={class:"space-y-1.5 px-2.5 py-1.5"},$S={key:0,class:"break-all font-mono text-[11px] text-muted-foreground"},TS={key:1,class:"space-y-1"},AS=["src","alt","onClick"],ES={class:"flex flex-wrap items-center gap-x-2 font-mono text-[11px] text-muted-foreground"},OS={class:"break-all"},PS=["href"],MS={key:2,class:"rounded bg-muted/50 px-2 py-1"},IS={class:"flex items-center gap-1 font-mono text-[11px] font-medium"},RS={class:"mt-0.5 whitespace-pre-wrap break-all font-mono text-[11px] text-muted-foreground"},LS=["onClick"],DS={key:3},NS={key:0,class:"mb-0.5 text-[11px] font-medium text-muted-foreground"},FS=["onClick"],qS={key:1,class:"overflow-hidden rounded-md border"},BS={class:"border-b bg-muted/30 px-2.5 py-1 text-[11px] font-medium text-muted-foreground"},VS=["onClick"],US={class:"font-mono text-[11px] font-medium"},HS={key:0,class:"min-w-0 truncate text-[11px] text-muted-foreground"},jS={key:0,class:"space-y-1 px-2.5 pb-1.5"},zS={key:0,class:"whitespace-pre-wrap break-words text-xs text-muted-foreground"},WS={key:1,class:"whitespace-pre-wrap break-all font-mono text-[11px] text-muted-foreground"},KS={key:2,class:"flex flex-wrap items-center gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground"},GS={key:0},YS={key:1},XS={key:2},JS={key:3},QS={key:1,class:"max-h-96 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/50 p-3 font-mono text-xs"},ZS=["src","alt"],Qs=2e3,pd=160,md=re({__name:"DebugContent",props:{body:{},kind:{}},setup(e){const t=e,{t:n}=ft(),s=j(new Set),o=j(null);function a(R){const O=new Set(s.value);O.has(R)?O.delete(R):O.add(R),s.value=O}function l(R,O){return s.value.has(O)||R.length<=Qs?R:R.slice(0,Qs)}const i=R=>typeof R=="string"?R:R==null?"":String(R),u=R=>typeof R=="number"?R:void 0,c=R=>R.length>pd?`${R.slice(0,pd)}…`:R;function d(R){if(typeof R=="string")try{return JSON.stringify(JSON.parse(R),null,2)}catch{return R}try{return JSON.stringify(R,null,2)}catch{return i(R)}}function f(R){if(typeof R!="string")return R;try{return JSON.parse(R)}catch{return R}}function p(R,O=!1){return{t:"text",text:i(R),think:O||void 0}}function y(R){var J;const O=typeof R.image_url=="string"?R.image_url:((J=R.image_url)==null?void 0:J.url)??R.url;if(O)return O;const L=R.source;return(L==null?void 0:L.type)==="base64"&&typeof L.data=="string"?`data:${i(L.media_type)||"image/png"};base64,${L.data}`:(L==null?void 0:L.type)==="url"&&typeof L.url=="string"?L.url:""}function $(R){const O=y(R);if(!O||!/^data:image\//.test(O)&&!/^https?:\/\//.test(O)){const L=O?c(O):"";return{t:"note",text:L?`${n("models.debugImage")} · ${L}`:n("models.debugImage")}}return{t:"img",src:O,note:O.startsWith("data:")?`base64 ${(O.length/1024).toFixed(1)}KB`:c(O)}}function A(R){if(typeof R=="string")return[p(R)];if(!R||typeof R!="object")return R==null?[]:[p(d(R))];const O=R;switch(O.type){case"text":case"input_text":case"output_text":case"refusal":return[p(O.text??O.refusal)];case"thinking":return[p(O.thinking??O.text,!0)];case"redacted_thinking":return[{t:"note",text:n("models.debugThinking")}];case"image_url":case"input_image":case"image":return[$(O)];case"tool_use":case"function_call":return[{t:"call",name:i(O.name),args:d(O.type==="tool_use"?O.input:O.arguments)}];case"tool_result":return[...O.tool_use_id?[{t:"note",text:c(i(O.tool_use_id))}]:[],...E(O.content)];case"function_call_output":return[...O.call_id?[{t:"note",text:c(i(O.call_id))}]:[],...E(O.output)];default:return[p(d(O))]}}function E(R){return R==null?[]:Array.isArray(R)?R.flatMap(A):typeof R=="object"?A(R):[p(R)]}function C(R){return Array.isArray(R.tool_calls)?R.tool_calls.flatMap(O=>{const L=O==null?void 0:O.function;return L?[{t:"call",name:i(L.name),args:d(f(L.arguments))}]:[]}):[]}function k(R){if(typeof R=="string")return{role:"user",blocks:[p(R)]};if(!R||typeof R!="object")return null;const O=R,L=[...E(O.content),...C(O)];return L.length?{role:i(O.role)||"—",blocks:L}:null}function M(R){if(!R||typeof R!="object")return null;const O=R,L=O.function??O,J=i(L.name);if(!J)return null;const ne=i(L.description),pe=L.parameters??L.input_schema;return{name:J,desc:ne||void 0,schema:pe!=null?d(pe):void 0}}const S=new Set(["messages","tools","input","system","instructions","tool_choice"]);function F(R){const O=[];for(const[K,de]of Object.entries(R))S.has(K)||de==null||O.push({k:K,v:c(typeof de=="object"?JSON.stringify(de):String(de))});const L=[],J=R.system??R.instructions;J!=null&&L.push({role:"system",blocks:E(J)});const ne=typeof R.input=="string"?[R.input]:R.messages??R.input;if(Array.isArray(ne))for(const K of ne){const de=k(K);de&&L.push(de)}const pe=Array.isArray(R.tools)?R.tools.map(M).filter(K=>K!==null):[];return{params:O,cards:L,tools:pe}}function D(R){return/^\s*(event|data|id|retry):/m.test(R)}function T(R){const O=[];for(const L of R.split(`
|
|
327
|
+
*/const Ns=Ee("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Ws=re({__name:"DialogContent",props:{forceMount:{type:Boolean},disableOutsidePointerEvents:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=ae(()=>{const{class:l,...i}=n;return i}),a=At(o,s);return(l,i)=>(h(),V(r(Z1),null,{default:g(()=>[m(r(X1),{class:"fixed inset-0 z-50 bg-black/80"}),m(r(j1),Te(r(a),{class:r(He)("fixed left-[50%] top-[50%] z-50 flex max-h-[90vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 overflow-hidden border bg-background p-6 shadow-lg sm:rounded-lg",n.class)}),{default:g(()=>[ce(l.$slots,"default"),m(r(b1),{class:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background"},{default:g(()=>[m(r(To),{class:"h-4 w-4"}),i[0]||(i[0]=x("span",{class:"sr-only"},"Close",-1))]),_:1})]),_:3},16,["class"])]),_:3}))}}),Ks=re({__name:"DialogTitle",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),V(r(t0),{class:ge(r(He)("text-lg font-semibold leading-none tracking-tight",t.class))},{default:g(()=>[ce(n.$slots,"default")]),_:3},8,["class"]))}}),Gs=re({__name:"DialogDescription",props:{asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),V(r(W1),{class:ge(r(He)("text-sm text-muted-foreground",t.class))},{default:g(()=>[ce(n.$slots,"default")]),_:3},8,["class"]))}}),Zk=["for"],bt=re({__name:"Label",props:{class:{type:[Boolean,null,String,Object,Array]},for:{}},setup(e){const t=e;return(n,s)=>(h(),N("label",{for:t.for,class:ge(r(He)("text-sm font-medium leading-none text-foreground",t.class))},[ce(n.$slots,"default")],10,Zk))}}),ga=re({__name:"Popover",props:{defaultOpen:{type:Boolean},open:{type:Boolean},modal:{type:Boolean}},emits:["update:open"],setup(e,{emit:t}){const o=At(e,t);return(a,l)=>(h(),V(r(ew),Ct(Tt(r(o))),{default:g(()=>[ce(a.$slots,"default")]),_:3},16))}}),va=re({__name:"PopoverTrigger",props:{asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(h(),V(r(dw),Ct(Tt(t)),{default:g(()=>[ce(n.$slots,"default")]),_:3},16))}}),ya=re({__name:"PopoverContent",props:{forceMount:{type:Boolean},memoDependencies:{},side:{},sideOffset:{default:4},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside","openAutoFocus","closeAutoFocus"],setup(e,{emit:t}){const n=e,s=t,o=ae(()=>{const{class:l,...i}=n;return i}),a=At(o,s);return(l,i)=>(h(),V(r(uw),null,{default:g(()=>[m(r(lw),Te(r(a),{class:r(He)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",n.class)}),{default:g(()=>[ce(l.$slots,"default")]),_:3},16,["class"])]),_:3}))}}),eC={class:"relative w-full overflow-auto"},Qa=re({__name:"Table",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("div",eC,[x("table",{class:ge(r(He)("w-full caption-bottom text-sm",t.class))},[ce(n.$slots,"default")],2)]))}}),Za=re({__name:"TableHeader",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("thead",{class:ge(r(He)("[&_tr]:border-b",t.class))},[ce(n.$slots,"default")],2))}}),el=re({__name:"TableBody",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("tbody",{class:ge(r(He)("[&_tr:last-child]:border-0",t.class))},[ce(n.$slots,"default")],2))}}),Cn=re({__name:"TableRow",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("tr",{class:ge(r(He)("border-b transition-colors hover:bg-muted/40 data-[state=selected]:bg-muted",t.class))},[ce(n.$slots,"default")],2))}}),rt=re({__name:"TableHead",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("th",{class:ge(r(He)("h-10 px-3 text-left align-middle text-xs font-medium uppercase tracking-wide text-muted-foreground [&:has([role=checkbox])]:pr-0",t.class))},[ce(n.$slots,"default")],2))}}),nt=re({__name:"TableCell",props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e;return(n,s)=>(h(),N("td",{class:ge(r(He)("p-3 align-middle [&:has([role=checkbox])]:pr-0",t.class))},[ce(n.$slots,"default")],2))}}),Mm=re({__name:"Switch",props:es({class:{type:[Boolean,null,String,Object,Array]},id:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=e,n=Co(e,"modelValue");return(s,o)=>(h(),V(r(vk),{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=a=>n.value=a),id:t.id,class:ge(r(He)("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow 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.class))},{default:g(()=>[m(r(_k),{class:"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"})]),_:1},8,["modelValue","id","class"]))}}),Hr=re({__name:"Select",props:{open:{type:Boolean},defaultOpen:{type:Boolean},defaultValue:{},modelValue:{},nullableValue:{},by:{type:[String,Function]},dir:{},multiple:{type:Boolean},autocomplete:{},disabled:{type:Boolean},name:{},required:{type:Boolean}},emits:["update:modelValue","update:open"],setup(e,{emit:t}){const o=At(e,t);return(a,l)=>(h(),V(r(Ow),Ct(Tt(r(o))),{default:g(()=>[ce(a.$slots,"default")]),_:3},16))}}),jr=re({__name:"SelectTrigger",props:{disabled:{type:Boolean},reference:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=ae(()=>{const{class:s,...o}=t;return o});return(s,o)=>(h(),V(r(rk),Te(n.value,{class:r(He)("flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t.class)}),{default:g(()=>[ce(s.$slots,"default"),m(r(Gw),{"as-child":""},{default:g(()=>[m(r(Rn),{class:"h-4 w-4 opacity-50"})]),_:1})]),_:3},16,["class"]))}}),zr=re({__name:"SelectValue",props:{placeholder:{},asChild:{type:Boolean},as:{}},setup(e){const t=e;return(n,s)=>(h(),V(r(lk),Ct(Tt(t)),{default:g(()=>[ce(n.$slots,"default")]),_:3},16))}}),Wr=re({__name:"SelectContent",props:{forceMount:{type:Boolean},position:{default:"popper"},bodyLock:{type:Boolean},memoDependencies:{},side:{},sideOffset:{},sideFlip:{type:Boolean},align:{},alignOffset:{},alignFlip:{type:Boolean},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},hideShiftedArrow:{type:Boolean},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},disableUpdateOnLayoutShift:{type:Boolean},prioritizePosition:{type:Boolean},reference:{},dir:{},asChild:{type:Boolean},as:{},disableOutsidePointerEvents:{type:Boolean},class:{type:[Boolean,null,String,Object,Array]}},emits:["closeAutoFocus","escapeKeyDown","pointerDownOutside"],setup(e,{emit:t}){const n=e,s=t,o=ae(()=>{const{class:l,...i}=n;return i}),a=At(o,s);return(l,i)=>(h(),V(r(sk),null,{default:g(()=>[m(r(Ww),Te(r(a),{class:r(He)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n.position==="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",n.class)}),{default:g(()=>[m(r(uk),{class:ge(r(He)("p-1",n.position==="popper"&&"w-full min-w-[var(--reka-select-trigger-width)]"))},{default:g(()=>[ce(l.$slots,"default")]),_:3},8,["class"])]),_:3},16,["class"])]),_:3}))}}),tC={class:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center"},ds=re({__name:"SelectItem",props:{value:{},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){const t=e,n=ae(()=>{const{class:s,...o}=t;return o});return(s,o)=>(h(),V(r(Jw),Te(n.value,{class:r(He)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t.class)}),{default:g(()=>[x("span",tC,[m(r(Zw),null,{default:g(()=>[m(r(rn),{class:"h-4 w-4"})]),_:1})]),m(r(tk),null,{default:g(()=>[ce(s.$slots,"default")]),_:3})]),_:3},16,["class"]))}}),nC={class:"relative"},sC=["aria-label"],oC={key:0,class:"mt-1.5 flex flex-wrap gap-1"},rC=["aria-label","onClick"],aC={key:0},lC={class:"flex-1 truncate font-mono"},iC=["onMousedown"],uC={key:1,class:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"},cC={class:"flex-1 truncate"},dC={key:1,class:"px-2 py-1 text-xs text-muted-foreground"},fC={key:2,class:"px-2 py-1 text-xs text-muted-foreground"},Im=re({__name:"Combobox",props:{modelValue:{},options:{},placeholder:{},limit:{default:300},multi:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,s=t,{t:o}=ft(),a=j(null),l=j(null),i=j(!1),u=j("");function c(){var Y,ee;i.value=!i.value,i.value&&((ee=(Y=l.value)==null?void 0:Y.$el)==null||ee.focus())}function d(Y){i.value&&(Y.stopPropagation(),Y.preventDefault(),i.value=!1)}const f=ae(()=>Array.isArray(n.modelValue)?n.modelValue:[]),p=ae(()=>{const Y=(n.multi?u.value:String(n.modelValue??"")).trim().toLowerCase();return Y?n.options.filter(ee=>ee.toLowerCase().includes(Y)):n.options}),y=ae(()=>p.value.slice(0,n.limit)),$=ae(()=>p.value.length-y.value.length);function A(Y){n.multi?(u.value=String(Y),i.value=!0):(s("update:modelValue",String(Y)),i.value=!0)}function E(Y){if(n.multi){const ee=f.value.includes(Y)?f.value.filter(Q=>Q!==Y):[...f.value,Y];s("update:modelValue",ee)}else s("update:modelValue",Y),i.value=!1}function C(Y){s("update:modelValue",f.value.filter(ee=>ee!==Y))}function k(Y){const ee=Y.split(/[\s,;]+/).map(fe=>fe.trim()).filter(Boolean);if(!ee.length)return;const Q=[...f.value];for(const fe of ee)Q.includes(fe)||Q.push(fe);s("update:modelValue",Q),u.value=""}function M(){n.multi&&k(u.value)}function S(Y){var Q;if(!n.multi)return;const ee=((Q=Y.clipboardData)==null?void 0:Q.getData("text"))??"";!ee.trim()||!/[\s,;]/.test(ee)||(Y.preventDefault(),k(ee))}function F(Y){var Q;const ee=Y.relatedTarget;ee&&((Q=a.value)!=null&&Q.contains(ee))||(i.value=!1)}const D=j(null),T=ae(()=>Math.min(Math.max(y.value.length*34+8,48),224));function I(){var Q;const Y=(Q=a.value)==null?void 0:Q.getBoundingClientRect();if(!Y)return;const ee=Y.bottom+6+T.value<=window.innerHeight;D.value={top:ee?Y.bottom+6:Math.max(Y.top-6-T.value,8),left:Math.max(Math.min(Y.left,window.innerWidth-Y.width-8),8),width:Y.width}}function G(){i.value&&I()}return Ie(i,async Y=>{Y?(await it(),I(),window.addEventListener("scroll",G,!0),window.addEventListener("resize",G)):(window.removeEventListener("scroll",G,!0),window.removeEventListener("resize",G))}),Ie(T,()=>i.value&&I()),ko(()=>{window.removeEventListener("scroll",G,!0),window.removeEventListener("resize",G)}),(Y,ee)=>(h(),N("div",{ref_key:"rootRef",ref:a,onFocusin:ee[2]||(ee[2]=Q=>i.value=!0),onFocusout:F},[x("div",nC,[m(r(mt),{ref_key:"inputRef",ref:l,"model-value":e.multi?u.value:e.modelValue,placeholder:e.placeholder,autocomplete:"off",spellcheck:"false",class:"pr-8","onUpdate:modelValue":A,onKeydown:[Tn(d,["esc"]),Tn(Re(M,["prevent"]),["enter"])],onPaste:S},null,8,["model-value","placeholder","onKeydown"]),x("button",{type:"button",tabindex:"-1",class:"absolute right-2 top-1/2 -translate-y-1/2 rounded-sm text-muted-foreground/70 transition-colors hover:text-foreground","aria-label":r(o)("combobox.toggle"),onMousedown:Re(c,["prevent"])},[m(r(Rn),{class:ge(["h-4 w-4 transition-transform",i.value?"rotate-180":""])},null,8,["class"])],40,sC)]),e.multi&&f.value.length?(h(),N("div",oC,[(h(!0),N(he,null,Pe(f.value,Q=>(h(),N("span",{key:Q,class:"inline-flex items-center gap-1 rounded-md border-transparent bg-primary text-primary-foreground shadow-sm px-2 py-0.5 font-mono text-xs"},[U(v(Q)+" ",1),x("button",{type:"button",class:"opacity-70 hover:opacity-100","aria-label":r(o)("common.dismiss"),onClick:fe=>C(Q)},[m(r(To),{class:"h-3 w-3"})],8,rC)]))),128))])):se("",!0),(h(),V(vr,{to:"body"},[i.value&&(y.value.length||e.multi&&u.value.trim())?(h(),N("ul",{key:0,class:"pointer-events-auto fixed z-[60] max-h-56 overflow-auto rounded-md border bg-popover p-1 text-sm shadow-md",style:en(D.value?{top:`${D.value.top}px`,left:`${D.value.left}px`,width:`${D.value.width}px`}:void 0),onPointerdown:ee[1]||(ee[1]=Re(()=>{},["stop"]))},[e.multi&&u.value.trim()?(h(),N("li",aC,[x("button",{type:"button",class:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left hover:bg-accent hover:text-accent-foreground",onMousedown:ee[0]||(ee[0]=Re(Q=>k(u.value),["prevent"]))},[m(r(Yn),{class:"h-3.5 w-3.5 shrink-0"}),x("span",lC,v(r(o)("combobox.add",{q:u.value.trim()})),1)],32)])):se("",!0),(h(!0),N(he,null,Pe(y.value,Q=>(h(),N("li",{key:Q},[x("button",{type:"button",class:ge(["flex w-full items-center gap-2 rounded px-2 py-1.5 text-left font-mono hover:bg-accent hover:text-accent-foreground",Q===e.modelValue||f.value.includes(Q)?"text-primary":""]),onMousedown:Re(fe=>E(Q),["prevent"])},[Q===e.modelValue||f.value.includes(Q)?(h(),V(r(rn),{key:0,class:"h-3.5 w-3.5 shrink-0"})):(h(),N("span",uC)),x("span",cC,v(Q),1)],42,iC)]))),128)),!y.value.length&&!(e.multi&&u.value.trim())?(h(),N("li",dC,v(r(o)("combobox.noMatch")),1)):$.value>0?(h(),N("li",fC,v(r(o)("combobox.more",{n:$.value})),1)):se("",!0)],36)):se("",!0)]))],544))}}),pC={class:"grid gap-y-1.5"},mC={class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-xs text-foreground/80"},hC={class:"pt-1.5 text-xs leading-relaxed text-muted-foreground"},gC=re({__name:"SamplingPanel",props:{modelValue:{}},setup(e){const t=e,{t:n}=ft(),s=[{key:"temperature",helpKey:"models.editor.samplingTipTemp",ph:"0.0 – 2.0"},{key:"top_p",helpKey:"models.editor.samplingTipTopP",ph:"0.0 – 1.0"},{key:"top_k",helpKey:"models.editor.samplingTipTopK",ph:"0 = off"},{key:"presence_penalty",helpKey:"models.editor.samplingTipPres",ph:"-2 – 2"},{key:"frequency_penalty",helpKey:"models.editor.samplingTipFreq",ph:"-2 – 2"},{key:"seed",helpKey:"models.editor.samplingTipSeed",ph:"integer"}];function o(a,l){t.modelValue[a]=String(l??"")}return(a,l)=>(h(),N(he,null,[x("div",pC,[(h(),N(he,null,Pe(s,i=>x("div",{key:i.key,class:"flex items-center gap-1.5"},[x("span",mC,[U(v(i.key)+" ",1),m(r(Nk),{class:"h-3 w-3 opacity-60","aria-label":`${i.key}: ${r(n)(i.helpKey)}`,title:r(n)(i.helpKey)},null,8,["aria-label","title"])]),m(r(mt),{"model-value":t.modelValue[i.key],type:"number",step:"any",class:"ml-auto h-6 w-20 bg-background px-2 text-right font-mono text-xs",placeholder:i.ph,spellcheck:"false","aria-label":i.key,"onUpdate:modelValue":u=>o(i.key,u)},null,8,["model-value","placeholder","aria-label","onUpdate:modelValue"])])),64))]),x("p",hC,v(r(n)("models.editor.samplingTipBase")),1)],64))}}),vC={class:"flex flex-wrap gap-1"},yC=["aria-pressed","onClick"],_C={class:"pt-1.5 text-xs leading-relaxed text-muted-foreground"},bC=re({__name:"ThinkingPanel",props:es({format:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=Co(e,"modelValue"),n=e,{t:s}=ft(),o=["low","medium","high","xhigh"],a=["1024","4096","8192","16384"],l=n.format==="anthropic"?a:o;return(i,u)=>(h(),N(he,null,[x("div",vC,[(h(!0),N(he,null,Pe(r(l),c=>(h(),N("button",{key:c,type:"button",class:ge(["rounded border px-2 py-0.5 font-mono text-xs transition-colors",t.value===c?"border-primary bg-primary/15 font-medium text-primary":"border-border bg-background text-foreground/80 hover:text-foreground"]),"aria-pressed":t.value===c,onClick:d=>t.value=t.value===c?"":c},v(c),11,yC))),128))]),m(r(mt),{"model-value":t.value,class:"h-7 w-48 bg-background font-mono text-xs",spellcheck:"false",placeholder:n.format==="anthropic"?r(s)("models.editor.thinkingPhBudget"):r(s)("models.editor.thinkingPh"),list:n.format==="anthropic"?"thinking-budgets":"thinking-words","aria-label":r(s)("models.editor.thinkingLabel"),"onUpdate:modelValue":u[0]||(u[0]=c=>t.value=String(c??""))},null,8,["model-value","placeholder","list","aria-label"]),x("p",_C,v(r(s)("models.editor.thinkingTipBase")),1)],64))}}),xC={class:"flex shrink-0 items-center gap-2 pr-8"},wC={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},kC={class:"min-w-0"},CC={class:"min-h-0 flex-1 space-y-3 overflow-y-auto px-1 py-1.5"},SC={class:"space-y-1.5"},$C={key:0,class:"text-xs text-destructive"},TC={key:1,class:"text-xs text-muted-foreground"},AC={key:2,class:"text-xs text-muted-foreground"},EC={key:0,class:"rounded-md border border-dashed p-4 text-center text-sm text-muted-foreground"},OC={class:"space-y-2"},PC={class:"flex items-center justify-between"},MC={class:"text-xs text-muted-foreground"},IC={class:"flex items-center gap-1.5"},RC={class:"text-xs font-semibold"},LC={class:"font-mono text-[11px] text-muted-foreground"},DC={key:0,class:"px-1 py-0.5 text-xs text-muted-foreground"},NC=["draggable","onDragstart","onDragover","onDrop"],FC=["aria-label","title","onMousedown"],qC={class:"w-3.5 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground"},BC={class:"flex items-center gap-1.5"},VC={class:"w-44 shrink-0 [&_input]:h-7 [&_input]:text-xs"},UC=["title"],HC={class:"truncate font-mono"},jC={key:1,class:"opacity-40"},zC={class:"truncate font-mono"},WC={class:"space-y-2.5 rounded-[5px] bg-primary/[0.08] p-2.5"},KC={class:"space-y-1.5"},GC={class:"flex items-center justify-between"},YC={class:"text-xs font-medium text-foreground"},XC=["onClick"],JC={class:"space-y-1"},QC={class:"flex items-center justify-between"},ZC={class:"text-xs font-medium text-foreground"},eS=["onClick"],tS=["onClick"],nS={key:2,class:"inline-flex items-center gap-1 px-1 text-[11px] text-destructive"},sS={class:"flex items-center"},oS=["aria-expanded"],rS={key:0,class:"space-y-1 rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground"},aS={class:"space-y-1.5"},lS=["aria-expanded"],iS={key:0,class:"space-y-1.5 rounded-md border bg-muted/30 p-3"},uS={class:"text-xs text-muted-foreground"},cS={class:"flex shrink-0 justify-end gap-2"},dS=re({__name:"ModelEditor",props:es({providers:{},model:{},existingNames:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:es(["saved"],["update:open"]),setup(e,{emit:t}){const n=["openai","anthropic","responses"],s=[{key:"temperature",bounded:!0},{key:"top_p",bounded:!0},{key:"top_k",bounded:!1},{key:"presence_penalty",bounded:!0},{key:"frequency_penalty",bounded:!0},{key:"seed",bounded:!1}];function o(){return Object.fromEntries(s.map(_=>[_.key,""]))}const a=_=>s.some(w=>_.sampling[w.key].trim()!=="");function l(_){for(const w of s)_.sampling[w.key]=""}const i=j(null),u=(_,w)=>`${_}:${w}`,c=(_,w)=>i.value===u(_,w);function d(_,w,b){const q=u(_,w);b?i.value=q:i.value===q&&(i.value=null)}function f(_){const w={};for(const[b,q]of Object.entries(_))q.trim()!==""&&(w[b]=q);return on(Object.keys(w).length?w:void 0)}function p(_){const w=[];return _.thinking.trim()&&w.push(`${k("models.editor.thinkingLabel")}: ${_.thinking.trim()}`),a(_)&&w.push(`${k("models.editor.samplingLabel")}: ${f(_.sampling)}`),w.join(" · ")||k("models.editor.slotDefaults")}let y=0;function $(_){var b;const w=o();for(const q of s){const W=(b=_.sampling)==null?void 0:b[q.key];W!=null&&(w[q.key]=typeof W=="number"?JSON.stringify(W):String(W))}return{uid:++y,pid:_.id,model:_.model??"",thinking:_.thinking??"",sampling:w}}const A=e,E=Co(e,"open"),C=t,{t:k}=ft(),M=j(""),S=j({openai:[],anthropic:[],responses:[]}),F=j({openai:!1,anthropic:!1,responses:!1}),D=j(""),T=j(!1),I=j(""),G=j({}),Y=j(!1),ee=j(!1),Q=encodeURIComponent;function fe(_){return A.providers.find(w=>w.id===_)}function R(_,w){const b=fe(_);return b?w==="responses"?!!b.supportsResponses:b.formats.includes(w):!1}function O(_){return po(fe(_))}function L(){I.value="",G.value={},D.value="",Y.value=!1,S.value={openai:[],anthropic:[],responses:[]},F.value={openai:!1,anthropic:!1,responses:!1};const _=A.model;if(!_){ee.value=!1;return}M.value=_.name,D.value=_.paceRpm?String(_.paceRpm):"",ee.value=!!_.paceRpm;for(const w of n)S.value[w]=_[w].providers.map($),F.value[w]=_[w].enabled}Ie(E,_=>{_&&L()});function J(_){var w;S.value[_].push($({id:((w=A.providers[0])==null?void 0:w.id)??""}))}function ne(_,w){const b=S.value[_].findIndex(q=>q.uid===w);b!==-1&&(S.value[_].splice(b,1),delete G.value[_])}function pe(_){_.model="",_.thinking="",_.sampling=o()}const K=j(null),de=j(null),oe=(_,w)=>K.value===`${_}:${w}`,Ge=(_,w)=>{var b;return((b=de.value)==null?void 0:b.fmt)===_&&de.value.from===w};function qe(_,w){return Ge(_,w)?"bg-background/60 opacity-40":"bg-background/60"}function ve(_){const w=S.value[_],b=de.value&&de.value.fmt===_?de.value.to:null,q=[],W=X=>({key:"ph",ph:!0,slot:w[0],i:X}),H=(X,be)=>({key:X.uid,ph:!1,slot:X,i:be});for(let X=0;X<w.length;X++)b===X&&q.push(W(X)),q.push(H(w[X],X));return b!==null&&b>=w.length&&q.push(W(w.length)),q}function ye(_){K.value=_}function Z(){K.value=null}function xe(_,w,b){var q;if(K.value!==`${_}:${w}`){b.preventDefault();return}de.value={fmt:_,from:w,to:w},(q=b.dataTransfer)==null||q.setData("text/plain",""),b.dataTransfer&&(b.dataTransfer.effectAllowed="move")}function _e(_,w,b){if(!de.value||de.value.fmt!==_)return;b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move");const q=b.currentTarget.getBoundingClientRect();de.value.to=b.clientY>q.top+q.height/2?w+1:w}function Fe(_,w){!de.value||de.value.fmt!==_||w.target===w.currentTarget&&(w.preventDefault(),de.value.to=S.value[_].length)}function Le(_){const w=de.value;if(de.value=null,Z(),!w||w.fmt!==_||w.to===w.from||w.to===w.from+1)return;const b=S.value[_],[q]=b.splice(w.from,1);b.splice(w.to>w.from?w.to-1:w.to,0,q)}function B(){de.value=null,Z()}const z=ae(()=>!T.value&&(!!A.model||!!M.value.trim()));function te(){var b;I.value="",G.value={};const _=M.value.trim();if(!_)return I.value=k("models.editor.errNameRequired"),!1;if(_.includes("/"))return I.value=k("models.editor.errNameSlash"),!1;if(!A.model&&A.existingNames.includes(_))return I.value=k("models.editor.errNameExists",{name:_}),!1;for(const q of S.value.anthropic)if(q.thinking.trim()&&!/^\d+$/.test(q.thinking.trim()))return G.value.anthropic=k("models.editor.errThinkingBudget"),!1;const w={temperature:[0,2,!0],top_p:[0,1,!1],presence_penalty:[-2,2,!1],frequency_penalty:[-2,2,!1]};for(const q of n)for(const W of S.value[q])for(const{key:H,bounded:X}of s){const be=(b=W.sampling[H])==null?void 0:b.trim();if(!be)continue;const me=Number(be),Ae=w[H];if(!Number.isFinite(me)||Ae&&(me<Ae[0]||(Ae[2]?me>=Ae[1]:me>Ae[1])))return G.value[q]=X?k("models.editor.errSamplingRange",{key:H}):k("models.editor.errSampling"),!1;if(H==="seed"&&!Number.isInteger(me))return G.value[q]=k("models.editor.errSampling"),!1}return!0}function ue(_){var b;const w={};for(const q of s){const W=(b=_[q.key])==null?void 0:b.trim();W&&(w[q.key]=Number(W))}return Object.keys(w).length?w:void 0}function le(_){return _.map(w=>{const b={id:w.pid};w.model.trim()&&(b.model=w.model.trim()),w.thinking.trim()&&(b.thinking=w.thinking.trim());const q=ue(w.sampling);return q&&(b.sampling=q),b})}async function ie(){if(!(!z.value||!te())){T.value=!0;try{const _={};for(const b of n)_[b]={enabled:F.value[b],slots:le(S.value[b])};_.paceRpm=Number(D.value)||0;const w=await Be("PUT",`/admin/models/${Q(M.value.trim())}`,_);Ue(k("models.editor.savedToast",{name:w.model.name}),"success"),E.value=!1,C("saved",w.model)}catch(_){Ue(_.message,"error")}finally{T.value=!1}}}const P=ae(()=>A.providers.length>0);return(_,w)=>(h(),V(r(zs),{open:E.value,"onUpdate:open":w[5]||(w[5]=b=>E.value=b)},{default:g(()=>[m(r(Ws),{class:"max-w-xl"},{default:g(()=>[w[8]||(w[8]=x("datalist",{id:"thinking-words"},[x("option",{value:"low"}),x("option",{value:"medium"}),x("option",{value:"high"}),x("option",{value:"xhigh"})],-1)),w[9]||(w[9]=x("datalist",{id:"thinking-budgets"},[x("option",{value:"1024"}),x("option",{value:"4096"}),x("option",{value:"8192"}),x("option",{value:"16384"})],-1)),x("div",xC,[x("span",wC,[m(r(wo),{class:"h-4 w-4"})]),x("div",kC,[m(r(Ks),{class:"text-base"},{default:g(()=>[U(v(e.model?r(k)("models.editor.editTitle"):r(k)("models.editor.createTitle")),1)]),_:1}),m(r(Gs),null,{default:g(()=>[U(v(r(k)("models.editor.desc")),1)]),_:1})])]),x("div",CC,[x("div",SC,[m(r(bt),{for:"m-name"},{default:g(()=>[U(v(r(k)("models.editor.nameLabel")),1)]),_:1}),m(r(mt),{id:"m-name",modelValue:M.value,"onUpdate:modelValue":w[0]||(w[0]=b=>M.value=b),disabled:!!e.model,placeholder:r(k)("models.editor.namePh"),class:"font-mono",spellcheck:"false",autocomplete:"off"},null,8,["modelValue","disabled","placeholder"]),I.value?(h(),N("p",$C,v(I.value),1)):e.model?(h(),N("p",TC,v(r(k)("models.editor.nameEditHint")),1)):(h(),N("p",AC,v(r(k)("models.editor.nameHint")),1))]),P.value?(h(),N(he,{key:1},[x("div",OC,[x("div",PC,[m(r(bt),null,{default:g(()=>[U(v(r(k)("models.editor.chainTitle")),1)]),_:1}),x("span",MC,v(r(k)("models.editor.chainPriority")),1)]),(h(),N(he,null,Pe(n,b=>x("div",{key:b,class:"space-y-1 rounded-md border bg-muted/30 p-2"},[x("div",IC,[x("span",{class:ge(["h-2 w-2 rounded-full",r(pt)[b].solid])},null,2),x("span",RC,v(r(k)(r(_n)[b].label)),1),x("span",LC,v(r(_n)[b].endpoint),1),m(r(Mm),{modelValue:F.value[b],"onUpdate:modelValue":q=>F.value[b]=q,class:"ml-auto","aria-label":r(k)("models.editor.enabledLabel")},null,8,["modelValue","onUpdate:modelValue","aria-label"])]),S.value[b].length?(h(),V(Vf,{key:1,tag:"div",name:"slots",class:"space-y-1",onDragover:q=>Fe(b,q),onDrop:Re(q=>Le(b),["prevent"])},{default:g(()=>[(h(!0),N(he,null,Pe(ve(b),q=>(h(),N("div",{key:q.key,class:ge(["space-y-1",q.ph?"ph h-8 shrink-0 rounded border border-dashed border-primary/50 bg-primary/10":""]),draggable:!q.ph&&oe(b,q.i),onDragstart:W=>xe(b,q.i,W),onDragover:W=>_e(b,q.i,W),onDrop:Re(W=>Le(b),["prevent"]),onDragend:B,onMouseup:Z},[q.ph?se("",!0):(h(),N("div",{key:0,class:ge(["flex items-center gap-1 rounded px-1 py-0.5",qe(b,q.i)])},[x("button",{type:"button",class:"shrink-0 cursor-grab rounded p-0.5 text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":r(k)("models.editor.dragAria"),title:r(k)("models.editor.dragAria"),onMousedown:W=>ye(`${b}:${q.i}`)},[m(r(qk),{class:"h-3.5 w-3.5"})],40,FC),x("span",qC,v(q.i+1),1),m(r(Hr),{modelValue:q.slot.pid,"onUpdate:modelValue":[W=>q.slot.pid=W,W=>pe(q.slot)]},{default:g(()=>[m(r(jr),{class:"h-7 w-28 shrink-0 px-2 text-xs"},{default:g(()=>[m(r(zr),{placeholder:r(k)("models.editor.providerPh")},null,8,["placeholder"])]),_:1}),m(r(Wr),null,{default:g(()=>[(h(!0),N(he,null,Pe(e.providers.filter(W=>R(W.id,b)),W=>(h(),V(r(ds),{key:W.id,value:W.id,class:"text-xs"},{default:g(()=>[x("span",BC,[x("span",{class:ge(["h-1.5 w-1.5 rounded-full",r(ps)(W.id).solid])},null,2),U(" "+v(W.name),1)])]),_:2},1032,["value"]))),128))]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue"]),x("div",VC,[m(Im,{modelValue:q.slot.model,"onUpdate:modelValue":W=>q.slot.model=W,options:O(q.slot.pid),placeholder:r(k)("models.editor.upstreamPh")},null,8,["modelValue","onUpdate:modelValue","options","placeholder"])]),m(r(ga),{open:c(b,q.slot.uid),"onUpdate:open":W=>d(b,q.slot.uid,W)},{default:g(()=>[m(r(va),{"as-child":""},{default:g(()=>[x("button",{type:"button",class:ge(["ml-auto inline-flex h-7 max-w-44 min-w-0 shrink-0 cursor-pointer items-center gap-1 rounded-md border px-2 text-[11px] outline-none transition-colors",q.slot.thinking.trim()||a(q.slot)?"border-primary/40 bg-primary/10 text-primary":"border-dashed text-muted-foreground/70 hover:border-foreground/30 hover:text-foreground"]),title:p(q.slot)},[q.slot.thinking.trim()||a(q.slot)?(h(),N(he,{key:0},[q.slot.thinking.trim()?(h(),N(he,{key:0},[m(r(xo),{class:"h-3 w-3 shrink-0"}),x("span",HC,v(q.slot.thinking.trim()),1)],64)):se("",!0),q.slot.thinking.trim()&&a(q.slot)?(h(),N("span",jC,"·")):se("",!0),a(q.slot)?(h(),N(he,{key:2},[m(r(vs),{class:"h-3 w-3 shrink-0"}),x("span",zC,v(f(q.slot.sampling)),1)],64)):se("",!0)],64)):(h(),N(he,{key:1},[m(r(Yk),{class:"h-3 w-3 shrink-0"}),U(" "+v(r(k)("models.editor.slotDefaults")),1)],64))],10,UC)]),_:2},1024),m(r(ya),{align:"end",class:"w-96 rounded-md border-primary/30 p-1.5 shadow-lg"},{default:g(()=>[x("div",WC,[x("div",KC,[x("div",GC,[x("div",YC,v(r(k)("models.editor.thinkingLabel")),1),x("button",{type:"button",class:"cursor-pointer text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:W=>q.slot.thinking=""},v(r(k)("models.editor.thinkingClear")),9,XC)]),m(bC,{modelValue:q.slot.thinking,"onUpdate:modelValue":W=>q.slot.thinking=W,format:b},null,8,["modelValue","onUpdate:modelValue","format"])]),w[6]||(w[6]=x("div",{class:"border-t border-primary/15"},null,-1)),x("div",JC,[x("div",QC,[x("div",ZC,v(r(k)("models.editor.samplingLabel")),1),x("button",{type:"button",class:"cursor-pointer text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:W=>l(q.slot)},v(r(k)("models.editor.samplingClear")),9,eS)]),m(gC,{modelValue:q.slot.sampling,"onUpdate:modelValue":W=>q.slot.sampling=W},null,8,["modelValue","onUpdate:modelValue"])]),w[7]||(w[7]=x("div",{class:"border-t border-primary/15"},null,-1)),x("button",{type:"button",class:"-mx-1 flex w-full cursor-pointer items-center gap-1.5 rounded px-1 py-1 text-xs text-destructive transition-colors hover:bg-destructive/10",onClick:W=>{i.value=null,ne(b,q.slot.uid)}},[m(r(fr),{class:"h-3.5 w-3.5"}),U(v(r(k)("models.editor.removeSlot")),1)],8,tS)])]),_:2},1024)]),_:2},1032,["open","onUpdate:open"])],2))],42,NC))),128))]),_:2},1032,["onDragover","onDrop"])):(h(),N("div",DC,v(r(k)("models.editor.emptyChain")),1)),G.value[b]?(h(),N("span",nS,[m(r(pr),{class:"h-3 w-3"}),U(v(G.value[b]),1)])):se("",!0),m(r(we),{variant:"outline",size:"sm",class:"h-7 w-full border-dashed text-xs",disabled:!e.providers.some(q=>R(q.id,b)),onClick:q=>J(b)},{default:g(()=>[m(r(Yn),{class:"h-3.5 w-3.5"}),U(v(r(k)("models.editor.addSlot")),1)]),_:1},8,["disabled","onClick"])])),64))]),x("div",sS,[x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground","aria-expanded":Y.value,onClick:w[1]||(w[1]=b=>Y.value=!Y.value)},[m(r(cu),{class:"h-3.5 w-3.5"}),U(" "+v(r(k)("models.editor.helpToggle")),1)],8,oS)]),Y.value?(h(),N("div",rS,[x("p",null,v(r(k)("models.editor.helpUpstream")),1),x("p",null,v(r(k)("models.editor.helpThinking")),1),x("p",null,v(r(k)("models.editor.helpSampling")),1)])):se("",!0),x("div",aS,[x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground","aria-expanded":ee.value,onClick:w[2]||(w[2]=b=>ee.value=!ee.value)},[m(r(vs),{class:"h-3.5 w-3.5"}),U(" "+v(r(k)("models.editor.advancedToggle"))+" ",1),m(r(Rn),{class:ge(["h-3.5 w-3.5 transition-transform",{"rotate-180":ee.value}])},null,8,["class"])],8,lS),ee.value?(h(),N("div",iS,[m(r(bt),{for:"m-pace"},{default:g(()=>[U(v(r(k)("models.editor.paceLabel")),1)]),_:1}),m(r(mt),{id:"m-pace",modelValue:D.value,"onUpdate:modelValue":w[3]||(w[3]=b=>D.value=b),type:"number",min:"0",inputmode:"numeric",placeholder:r(k)("models.editor.pacePh"),class:"w-32"},null,8,["modelValue","placeholder"]),x("p",uS,v(r(k)("models.editor.paceHint")),1)])):se("",!0)])],64)):(h(),N("div",EC,v(r(k)("models.editor.noProviders")),1))]),x("div",cS,[m(r(we),{variant:"outline",disabled:T.value,onClick:w[4]||(w[4]=b=>E.value=!1)},{default:g(()=>[U(v(r(k)("common.cancel")),1)]),_:1},8,["disabled"]),m(r(we),{disabled:!z.value,onClick:ie},{default:g(()=>[T.value?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):se("",!0),U(" "+v(r(k)("models.editor.save")),1)]),_:1},8,["disabled"])])]),_:1})]),_:1},8,["open"]))}}),Rm=(e,t)=>{const n=e.__vccOpts||e;for(const[s,o]of t)n[s]=o;return n},fS=Rm(dS,[["__scopeId","data-v-2da19750"]]);function dd(e){let t=5381,n=-2128831035;for(let s=0;s<e.length;s++){const o=e.charCodeAt(s);t=(t<<5)+t+o|0,n=(n^o)*16777619|0}return(t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}function gi(e){if(Array.isArray(e))return e.map(gi);if(e&&typeof e=="object"){const t=e,n={};for(const[s,o]of Object.entries(t))s!=="cache_control"&&(n[s]=gi(o));return t.type==="input_text"&&(n.type="text"),n}return e}function pS(e){if(!e||typeof e!="object")return e;const t=gi({...e});return typeof t.content=="string"&&(t.content=[{type:"text",text:t.content}]),t.type==="message"&&delete t.type,t}const fd=80;function Lm(e){const t=e.replace(/\s+/g," ").trim();return t.length>fd?`${t.slice(0,fd)}…`:t}function*Dm(e){if(typeof e=="string"){e.trim()&&(yield e);return}if(Array.isArray(e)){for(const t of e)yield*Dm(t);return}if(e&&typeof e=="object"){const t=e.text;typeof t=="string"&&t.trim()&&(yield t)}}function mS(e){let t=e;for(;;){const n=/^\s*<([a-z][a-z0-9_-]*)((\s[^>]*)?)>/.exec(t);if(!n)return t;const s=t.indexOf(`</${n[1]}>`,n[0].length);if(s===-1)return t;t=t.slice(s+n[1].length+3)}}function hS(e){const t=s=>{const o=[];for(const a of e){if(!a||typeof a!="object")continue;const l=a;s.includes(l.role)&&o.push(...Dm(l.content))}return o},n=[...t(["user"]),...t(["assistant","system"])];for(const s of n){const o=mS(s).trim();if(o)return Lm(o)}return""}function gS(e,t){const n=new RegExp(`"${t}"\\s*:\\s*\\[`).exec(e);if(!n)return[];let s=n.index+n[0].length;const o=e.length,a=[];for(;;){for(;s<o&&/\s/.test(e[s]);)s++;if(s>=o||e[s]==="]")break;const l=s;let i=0,u=!1,c=!1,d=!1;for(;s<o;){const f=e[s++];if(u)c?c=!1:f==="\\"?c=!0:f==='"'&&(u=!1);else if(f==='"')u=!0;else if(f==="{"||f==="[")i++;else if((f==="}"||f==="]")&&(i--,i<=0)){d=!0;break}}if(!d||i!==0)break;for(a.push(e.slice(l,s));s<o&&/\s/.test(e[s]);)s++;if(e[s]===","){s++;continue}break}return a}function vS(e){const t=/"user_id"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(e);if(!t)return"";try{return JSON.parse(`"${t[1]}"`)}catch{return""}}function yS(e){var l;let t=null;try{t=JSON.parse(e)}catch{t=null}let n=[],s="";if(t&&typeof t=="object"){const i=t;typeof((l=i.metadata)==null?void 0:l.user_id)=="string"&&(s=i.metadata.user_id),Array.isArray(i.messages)?n=i.messages:Array.isArray(i.input)?n=i.input:typeof i.input=="string"&&i.input&&(n=[{role:"user",content:i.input}])}else{const i=/"messages"\s*:\s*\[/.test(e)?"messages":"input";n=gS(e,i).map(u=>{try{return JSON.parse(u)}catch{return null}}).filter(u=>u!==null),s=vS(e)}const o=[];let a="";for(const i of n)a=dd(`${a}|${dd(JSON.stringify(pS(i)))}`),o.push(a);return{hashes:o,uid:s,title:Lm(hS(n))}}function _S(e){const t=e.length,n=Array.from({length:t},(i,u)=>u),s=i=>{let u=i;for(;n[u]!==u;)u=n[u];for(;n[i]!==u;){const c=n[i];n[i]=u,i=c}return u},o=(i,u)=>{const c=s(i),d=s(u);c!==d&&(n[Math.max(c,d)]=Math.min(c,d))},a=new Map,l=new Map;for(let i=0;i<t;i++){const u=e[i];if(u.uid){const c=l.get(u.uid);c!==void 0?o(i,c):l.set(u.uid,i)}for(const c of u.hashes){const d=a.get(c);d!==void 0?o(i,d):a.set(c,i)}}return e.map((i,u)=>s(u))}function bS(e){const t=e.map(yS);return{ids:_S(t),shapes:t}}const xS={key:0,class:"space-y-2"},wS={key:0,class:"flex flex-wrap gap-x-3 gap-y-0.5 rounded-md border bg-muted/30 px-2.5 py-1.5"},kS={class:"text-foreground"},CS={class:"border-b bg-muted/30 px-2.5 py-1"},SS={class:"space-y-1.5 px-2.5 py-1.5"},$S={key:0,class:"break-all font-mono text-[11px] text-muted-foreground"},TS={key:1,class:"space-y-1"},AS=["src","alt","onClick"],ES={class:"flex flex-wrap items-center gap-x-2 font-mono text-[11px] text-muted-foreground"},OS={class:"break-all"},PS=["href"],MS={key:2,class:"rounded bg-muted/50 px-2 py-1"},IS={class:"flex items-center gap-1 font-mono text-[11px] font-medium"},RS={class:"mt-0.5 whitespace-pre-wrap break-all font-mono text-[11px] text-muted-foreground"},LS=["onClick"],DS={key:3},NS={key:0,class:"mb-0.5 text-[11px] font-medium text-muted-foreground"},FS=["onClick"],qS={key:1,class:"overflow-hidden rounded-md border"},BS={class:"border-b bg-muted/30 px-2.5 py-1 text-[11px] font-medium text-muted-foreground"},VS=["onClick"],US={class:"font-mono text-[11px] font-medium"},HS={key:0,class:"min-w-0 truncate text-[11px] text-muted-foreground"},jS={key:0,class:"space-y-1 px-2.5 pb-1.5"},zS={key:0,class:"whitespace-pre-wrap break-words text-xs text-muted-foreground"},WS={key:1,class:"whitespace-pre-wrap break-all font-mono text-[11px] text-muted-foreground"},KS={key:2,class:"flex flex-wrap items-center gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground"},GS={key:0},YS={key:1},XS={key:2},JS={key:3},QS={key:1,class:"max-h-96 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/50 p-3 font-mono text-xs"},ZS=["src","alt"],Qs=2e3,pd=160,md=re({__name:"DebugContent",props:{body:{},kind:{}},setup(e){const t=e,{t:n}=ft(),s=j(new Set),o=j(null);function a(R){const O=new Set(s.value);O.has(R)?O.delete(R):O.add(R),s.value=O}function l(R,O){return s.value.has(O)||R.length<=Qs?R:R.slice(0,Qs)}const i=R=>typeof R=="string"?R:R==null?"":String(R),u=R=>typeof R=="number"?R:void 0,c=R=>R.length>pd?`${R.slice(0,pd)}…`:R;function d(R){if(typeof R=="string")try{return JSON.stringify(JSON.parse(R),null,2)}catch{return R}try{return JSON.stringify(R,null,2)}catch{return i(R)}}function f(R){if(typeof R!="string")return R;try{return JSON.parse(R)}catch{return R}}function p(R,O=!1){return{t:"text",text:i(R),think:O||void 0}}function y(R){var J;const O=typeof R.image_url=="string"?R.image_url:((J=R.image_url)==null?void 0:J.url)??R.url;if(O)return O;const L=R.source;return(L==null?void 0:L.type)==="base64"&&typeof L.data=="string"?`data:${i(L.media_type)||"image/png"};base64,${L.data}`:(L==null?void 0:L.type)==="url"&&typeof L.url=="string"?L.url:""}function $(R){const O=y(R);if(!O||!/^data:image\//.test(O)&&!/^https?:\/\//.test(O)){const L=O?c(O):"";return{t:"note",text:L?`${n("models.debugImage")} · ${L}`:n("models.debugImage")}}return{t:"img",src:O,note:O.startsWith("data:")?`base64 ${(O.length/1024).toFixed(1)}KB`:c(O)}}function A(R){if(typeof R=="string")return[p(R)];if(!R||typeof R!="object")return R==null?[]:[p(d(R))];const O=R;switch(O.type){case"text":case"input_text":case"output_text":case"refusal":return[p(O.text??O.refusal)];case"thinking":return[p(O.thinking??O.text,!0)];case"redacted_thinking":return[{t:"note",text:n("models.debugThinking")}];case"image_url":case"input_image":case"image":return[$(O)];case"tool_use":case"function_call":return[{t:"call",name:i(O.name),args:d(O.type==="tool_use"?O.input:O.arguments)}];case"tool_result":return[...O.tool_use_id?[{t:"note",text:c(i(O.tool_use_id))}]:[],...E(O.content)];case"function_call_output":return[...O.call_id?[{t:"note",text:c(i(O.call_id))}]:[],...E(O.output)];default:return[p(d(O))]}}function E(R){return R==null?[]:Array.isArray(R)?R.flatMap(A):typeof R=="object"?A(R):[p(R)]}function C(R){return Array.isArray(R.tool_calls)?R.tool_calls.flatMap(O=>{const L=O==null?void 0:O.function;return L?[{t:"call",name:i(L.name),args:d(f(L.arguments))}]:[]}):[]}function k(R){if(typeof R=="string")return{role:"user",blocks:[p(R)]};if(!R||typeof R!="object")return null;const O=R,L=[...E(O.content),...C(O)];return L.length?{role:i(O.role)||"—",blocks:L}:null}function M(R){if(!R||typeof R!="object")return null;const O=R,L=O.function??O,J=i(L.name);if(!J)return null;const ne=i(L.description),pe=L.parameters??L.input_schema;return{name:J,desc:ne||void 0,schema:pe!=null?d(pe):void 0}}const S=new Set(["messages","tools","input","system","instructions","tool_choice"]);function F(R){const O=[];for(const[K,de]of Object.entries(R))S.has(K)||de==null||O.push({k:K,v:c(typeof de=="object"?JSON.stringify(de):String(de))});const L=[],J=R.system??R.instructions;J!=null&&L.push({role:"system",blocks:E(J)});const ne=typeof R.input=="string"?[R.input]:R.messages??R.input;if(Array.isArray(ne))for(const K of ne){const de=k(K);de&&L.push(de)}const pe=Array.isArray(R.tools)?R.tools.map(M).filter(K=>K!==null):[];return{params:O,cards:L,tools:pe}}function D(R){return/^\s*(event|data|id|retry):/m.test(R)}function T(R){const O=[];for(const L of R.split(`
|
|
328
328
|
`)){const J=L.trim();if(!J.startsWith("data:"))continue;const ne=J.slice(5).trim();if(!(!ne||ne==="[DONE]"))try{O.push(JSON.parse(ne))}catch{}}return O}function I(R){var ve,ye;let O="",L="";const J=new Map;let ne,pe,K;const de=Z=>{let xe=J.get(Z);return xe||(xe={name:"",args:""},J.set(Z,xe)),xe},oe=Z=>{if(!Z||typeof Z!="object")return;const xe=Z;ne=u(xe.prompt_tokens)??u(xe.input_tokens)??ne,pe=u(xe.completion_tokens)??u(xe.output_tokens)??pe};for(const Z of R){if(Array.isArray(Z.choices)){const _e=Z.choices[0],Fe=_e==null?void 0:_e.delta;if(Fe&&(typeof Fe.content=="string"&&(O+=Fe.content),typeof Fe.reasoning_content=="string"&&(L+=Fe.reasoning_content),Array.isArray(Fe.tool_calls)))for(const Le of Fe.tool_calls){const B=de(typeof Le.index=="number"?Le.index:0),z=Le.function;typeof(z==null?void 0:z.name)=="string"&&(B.name+=z.name),typeof(z==null?void 0:z.arguments)=="string"&&(B.args+=z.arguments)}typeof(_e==null?void 0:_e.finish_reason)=="string"&&_e.finish_reason&&(K=_e.finish_reason)}oe(Z.usage);const xe=i(Z.type);if(xe==="message_start"&&oe((ve=Z.message)==null?void 0:ve.usage),xe==="content_block_delta"){const _e=Z.delta;typeof(_e==null?void 0:_e.text)=="string"&&(O+=_e.text),typeof(_e==null?void 0:_e.thinking)=="string"&&(L+=_e.thinking),typeof(_e==null?void 0:_e.partial_json)=="string"&&(de(typeof Z.index=="number"?Z.index:0).args+=_e.partial_json)}if(xe==="content_block_start"){const _e=Z.content_block;(_e==null?void 0:_e.type)==="tool_use"&&(de(typeof Z.index=="number"?Z.index:0).name=i(_e.name))}if(xe==="message_delta"){const _e=Z.delta;typeof(_e==null?void 0:_e.stop_reason)=="string"&&_e.stop_reason&&(K=_e.stop_reason),oe(Z.usage)}xe==="response.output_text.delta"&&typeof Z.delta=="string"&&(O+=Z.delta),xe==="response.completed"&&oe((ye=Z.response)==null?void 0:ye.usage)}const Ge=[];L&&Ge.push({role:"assistant",blocks:[p(L,!0)]});const qe=[...J.values()].filter(Z=>Z.name||Z.args).map(Z=>({t:"call",name:Z.name,args:Z.args?d(Z.args):void 0}));return(O||qe.length)&&Ge.push({role:"assistant",blocks:[...O?[p(O)]:[],...qe]}),{cards:Ge,inp:ne,out:pe,finish:K,chunks:R.length}}function G(R){if(Array.isArray(R.choices)){const O=[];let L;for(const ne of R.choices){const pe=ne.message;if(!pe)continue;const K=[...typeof pe.reasoning_content=="string"&&pe.reasoning_content?[p(pe.reasoning_content,!0)]:[],...E(pe.content),...C(pe)];K.length&&O.push({role:i(pe.role)||"assistant",blocks:K}),typeof ne.finish_reason=="string"&&ne.finish_reason&&(L=ne.finish_reason)}const J=R.usage;return!O.length&&!J?null:{cards:O,inp:u(J==null?void 0:J.prompt_tokens),out:u(J==null?void 0:J.completion_tokens),finish:L}}if(Array.isArray(R.content)){const O=E(R.content),L=R.usage;return!O.length&&!L?null:{cards:O.length?[{role:"assistant",blocks:O}]:[],inp:u(L==null?void 0:L.input_tokens),out:u(L==null?void 0:L.output_tokens),finish:typeof R.stop_reason=="string"&&R.stop_reason?R.stop_reason:void 0}}if(Array.isArray(R.output)){const O=[];for(const J of R.output)if(J.type==="function_call")O.push({role:"assistant",blocks:[{t:"call",name:i(J.name),args:d(f(J.arguments))}]});else if(J.type==="message"){const ne=E(J.content);ne.length&&O.push({role:i(J.role)||"assistant",blocks:ne})}const L=R.usage;return!O.length&&!L?null:{cards:O,inp:u(L==null?void 0:L.input_tokens),out:u(L==null?void 0:L.output_tokens),finish:i(R.status)||void 0}}return null}const Y=ae(()=>{if(t.kind!=="request"||!t.body)return null;try{return F(JSON.parse(t.body))}catch{return null}}),ee=ae(()=>{if(t.kind!=="response"||!t.body)return null;try{const R=G(JSON.parse(t.body));if(R)return R}catch{if(D(t.body)){const R=T(t.body);if(R.length)return I(R)}}return null}),Q=ae(()=>{var R,O;return((R=Y.value)==null?void 0:R.cards)??((O=ee.value)==null?void 0:O.cards)??[]}),fe=ae(()=>{if(!t.body)return"";try{return JSON.stringify(JSON.parse(t.body),null,2)}catch{return t.body}});return(R,O)=>(h(),N(he,null,[Y.value||ee.value?(h(),N("div",xS,[Y.value&&Y.value.params.length?(h(),N("div",wS,[(h(!0),N(he,null,Pe(Y.value.params,L=>(h(),N("span",{key:L.k,class:"font-mono text-[11px] text-muted-foreground"},[x("span",kS,v(L.k),1),U("="+v(L.v),1)]))),128))])):se("",!0),(h(!0),N(he,null,Pe(Q.value,(L,J)=>(h(),N("div",{key:J,class:"overflow-hidden rounded-md border"},[x("div",CS,[m(r(Oe),{variant:"secondary",class:"font-mono text-[10px]"},{default:g(()=>[U(v(L.role),1)]),_:2},1024)]),x("div",SS,[(h(!0),N(he,null,Pe(L.blocks,(ne,pe)=>(h(),N(he,{key:pe},[ne.t==="note"?(h(),N("p",$S,v(ne.text),1)):ne.t==="img"?(h(),N("div",TS,[x("img",{src:ne.src,alt:r(n)("models.debugImage"),loading:"lazy",class:"max-h-28 max-w-full cursor-zoom-in rounded border bg-muted/30 object-contain",onClick:K=>o.value=ne.src},null,8,AS),x("p",ES,[x("span",OS,v(ne.note),1),ne.src.startsWith("data:")?se("",!0):(h(),N("a",{key:0,href:ne.src,target:"_blank",rel:"noreferrer",class:"text-primary hover:underline",onClick:O[0]||(O[0]=Re(()=>{},["stop"]))},v(r(n)("models.debugOpen")),9,PS))])])):ne.t==="call"?(h(),N("div",MS,[x("p",IS,[m(r(cd),{class:"h-3 w-3 shrink-0 text-muted-foreground"}),U(v(ne.name),1)]),ne.args?(h(),N(he,{key:0},[x("pre",RS,v(l(ne.args,`${J}-${pe}`)),1),ne.args.length>Qs?(h(),N("button",{key:0,type:"button",class:"text-[11px] text-primary hover:underline",onClick:K=>a(`${J}-${pe}`)},v(s.value.has(`${J}-${pe}`)?r(n)("models.debugLess"):r(n)("models.debugMore",{n:ne.args.length-Qs})),9,LS)):se("",!0)],64)):se("",!0)])):(h(),N("div",DS,[ne.think?(h(),N("p",NS,v(r(n)("models.debugThinking")),1)):se("",!0),x("p",{class:ge(["whitespace-pre-wrap break-words text-xs leading-relaxed",ne.think?"italic text-muted-foreground":""])},v(l(ne.text,`${J}-${pe}`)),3),ne.text.length>Qs?(h(),N("button",{key:1,type:"button",class:"mt-0.5 text-[11px] text-primary hover:underline",onClick:K=>a(`${J}-${pe}`)},v(s.value.has(`${J}-${pe}`)?r(n)("models.debugLess"):r(n)("models.debugMore",{n:ne.text.length-Qs})),9,FS)):se("",!0)]))],64))),128))])]))),128)),Y.value&&Y.value.tools.length?(h(),N("div",qS,[x("div",BS,v(r(n)("models.debugTools"))+" ("+v(Y.value.tools.length)+")",1),(h(!0),N(he,null,Pe(Y.value.tools,(L,J)=>(h(),N("div",{key:J,class:"border-b last:border-b-0"},[x("button",{type:"button",class:"flex w-full items-center gap-1.5 px-2.5 py-1 text-left hover:bg-muted/50",onClick:ne=>a(`tool-${J}`)},[m(r(Tm),{class:ge(["h-3 w-3 shrink-0 text-muted-foreground transition-transform",s.value.has(`tool-${J}`)?"rotate-90":""])},null,8,["class"]),m(r(cd),{class:"h-3 w-3 shrink-0 text-muted-foreground"}),x("span",US,v(L.name),1),L.desc?(h(),N("span",HS,v(L.desc),1)):se("",!0)],8,VS),s.value.has(`tool-${J}`)?(h(),N("div",jS,[L.desc?(h(),N("p",zS,v(L.desc),1)):se("",!0),L.schema?(h(),N("pre",WS,v(L.schema),1)):se("",!0)])):se("",!0)]))),128))])):se("",!0),ee.value&&(ee.value.inp!=null||ee.value.out!=null||ee.value.finish||ee.value.chunks)?(h(),N("div",KS,[ee.value.inp!=null?(h(),N("span",GS,v(r(n)("models.debugTokIn"))+" "+v(ee.value.inp),1)):se("",!0),ee.value.out!=null?(h(),N("span",YS,v(r(n)("models.debugTokOut"))+" "+v(ee.value.out),1)):se("",!0),ee.value.finish?(h(),N("span",XS,v(r(n)("models.debugFinish"))+": "+v(ee.value.finish),1)):se("",!0),ee.value.chunks?(h(),N("span",JS,v(r(n)("models.debugChunks",{n:ee.value.chunks})),1)):se("",!0)])):se("",!0)])):(h(),N("pre",QS,v(fe.value),1)),(h(),V(vr,{to:"body"},[o.value?(h(),N("div",{key:0,class:"fixed inset-0 z-[60] flex cursor-zoom-out items-center justify-center bg-black/80 p-8",onClick:O[1]||(O[1]=L=>o.value=null)},[x("img",{src:o.value,alt:r(n)("models.debugImage"),class:"max-h-full max-w-full rounded object-contain shadow-lg"},null,8,ZS)])):se("",!0)]))],64))}}),e2={class:"flex flex-wrap items-center gap-1.5"},t2={class:"font-medium"},n2={key:0,class:"font-mono text-xs text-muted-foreground"},s2={class:"ml-auto flex items-center gap-2"},o2={class:"flex items-center rounded-md border p-0.5"},r2={class:"font-mono text-xs text-muted-foreground"},a2={key:0,class:"flex items-center gap-1 overflow-x-auto pb-1"},l2=["title","onClick"],i2={key:1,class:"text-xs text-destructive"},u2={class:"space-y-1"},c2={class:"flex items-center justify-between"},d2={class:"text-xs font-medium text-muted-foreground"},f2={class:"flex items-center"},p2={key:0,class:"max-h-[60vh] overflow-y-auto"},m2={key:1,class:"max-h-96 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/50 p-3 font-mono text-xs"},h2={key:2,class:"space-y-1"},g2={class:"flex items-center justify-between"},v2={class:"text-xs font-medium text-muted-foreground"},y2={class:"flex items-center"},_2={key:0,class:"max-h-[60vh] overflow-y-auto"},b2={key:1,class:"max-h-96 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/50 p-3 font-mono text-xs"},x2={class:"flex items-center gap-2"},w2={class:"min-w-0 flex-1 text-sm"},k2={class:"flex items-center rounded-md border p-0.5"},C2={class:"text-xs text-muted-foreground"},S2={key:0,class:"space-y-1"},$2={class:"flex items-center justify-between"},T2={class:"text-xs font-medium text-muted-foreground"},A2={class:"max-h-80 divide-y overflow-y-auto rounded-md border"},E2=["onClick"],O2={class:"w-16 shrink-0 font-mono text-xs text-muted-foreground"},P2=["title"],M2=["onClick"],I2={class:"w-16 shrink-0 font-mono text-xs text-muted-foreground"},R2={class:"min-w-0 max-w-40 truncate font-medium"},L2=["title"],D2=["title"],N2=["title"],F2={class:"ml-auto shrink-0 font-mono text-xs text-muted-foreground"},q2={key:1,class:"flex flex-col items-center gap-2 px-4 py-10 text-center"},B2={class:"flex size-9 items-center justify-center rounded-lg bg-muted text-muted-foreground"},V2={class:"text-sm text-muted-foreground"},U2={key:2,class:"rounded-md border border-dashed px-3 py-6 text-center text-sm text-muted-foreground"},Tl=300,H2=re({__name:"ModelDebugDialog",props:{open:{type:Boolean},model:{}},emits:["update:open","changed"],setup(e,{emit:t}){const n=e,s=t,{t:o}=ft(),a=j(!1),l=j([]),i=j([]),u=j(!1),c=j(!1),d=j(null);async function f(){if(n.model){u.value=!0;try{const R=await Be("GET",`/admin/models/${encodeURIComponent(n.model.name)}/debug`);a.value=R.enabled,l.value=R.captures,i.value=R.failures}catch(R){Ue(R.message,"error")}finally{u.value=!1}}}Ie(()=>n.open,R=>{R&&(d.value=null,C.value=null,f())});async function p(R){if(!(!n.model||c.value)){c.value=!0;try{const O=await Be("PUT",`/admin/models/${encodeURIComponent(n.model.name)}/debug`,{enabled:R===!0});a.value=O.enabled,O.enabled||(l.value=[]),s("changed")}catch(O){Ue(O.message,"error")}finally{c.value=!1}}}async function y(){if(!(!n.model||u.value)){u.value=!0;try{await Be("DELETE",`/admin/models/${encodeURIComponent(n.model.name)}/debug/fails`),i.value=[]}catch(R){Ue(R.message,"error")}finally{u.value=!1}}}const $=R=>R.status>=400||R.status===0,A=ae(()=>{const R=l.value.filter(O=>!$(O));return[...i.value.map(O=>({c:O,auto:!0})),...R.map(O=>({c:O,auto:!1}))].sort((O,L)=>L.c.ts-O.c.ts)}),E=j("conv"),C=j(null),k=ae(()=>{const{ids:R,shapes:O}=bS(A.value.map(ne=>ne.c.request)),L=new Map(A.value.map((ne,pe)=>[ne,O[pe]])),J=new Map;A.value.forEach((ne,pe)=>{let K=J.get(R[pe]);K||(K={key:`c${R[pe]}`,title:"",items:[],lastTs:0,fails:0},J.set(R[pe],K)),K.items.push(ne),ne.c.ts>K.lastTs&&(K.lastTs=ne.c.ts),$(ne.c)&&(K.fails+=1)});for(const ne of J.values())ne.items.sort((pe,K)=>pe.c.ts-K.c.ts),ne.title=ne.items.map(pe=>{var K;return((K=L.get(pe))==null?void 0:K.title)??""}).find(Boolean)||o("models.debugConvNoUser");return[...J.values()].sort((ne,pe)=>pe.lastTs-ne.lastTs)});function M(R){C.value=R.items,d.value=R.items[R.items.length-1].c}function S(R){C.value=null,d.value=R.c}function F(R){return new Date(R).toLocaleTimeString([],{hour12:!1})}function D(R){if(!R)return"0B";const O=new TextEncoder().encode(R).length;return O>=1024?`${(O/1024).toFixed(1)}KB`:`${O}B`}const T=j(!1),I=j("content");Ie(d,()=>{T.value=!1,I.value="content"});function G(R,O){if(typeof R=="string")return R.length<=Tl?R:(O.cut=!0,`${R.slice(0,Tl)}…${o("models.debugOmitted",{n:R.length-Tl})}`);if(Array.isArray(R))return R.map(L=>G(L,O));if(R&&typeof R=="object"){const L={};for(const[J,ne]of Object.entries(R))L[J]=G(ne,O);return L}return R}function Y(R){if(!R)return{text:"",cut:!1};try{const O=JSON.parse(R),L={cut:!1},J=G(O,L);return{text:JSON.stringify(T.value?O:J,null,2),cut:L.cut}}catch{return{text:R,cut:!1}}}const ee=ae(()=>{var R;return Y((R=d.value)==null?void 0:R.request)}),Q=ae(()=>{var R;return Y((R=d.value)==null?void 0:R.response)});async function fe(R){if(!R)return;const O=await xr(R);Ue(o(O?"connect.copied":"connect.copyFailed"),O?"success":"error")}return(R,O)=>(h(),V(r(zs),{open:e.open,"onUpdate:open":O[9]||(O[9]=L=>s("update:open",L))},{default:g(()=>[m(r(Ws),{class:"max-w-3xl"},{default:g(()=>[m(r(Ks),{class:"text-base"},{default:g(()=>{var L;return[U(v(r(o)("models.debugTitle",{name:((L=e.model)==null?void 0:L.name)??""})),1)]}),_:1}),m(r(Gs),{class:"sr-only"},{default:g(()=>[U(v(r(o)("models.debugDesc")),1)]),_:1}),d.value?(h(),N(he,{key:0},[x("div",e2,[m(r(we),{variant:"ghost",size:"sm",class:"h-7 px-2 text-muted-foreground",onClick:O[0]||(O[0]=L=>d.value=null)},{default:g(()=>[m(r(Rk),{class:"h-3.5 w-3.5"}),U(v(r(o)("models.debugBack")),1)]),_:1}),O[11]||(O[11]=x("span",{class:"h-4 w-px bg-border","aria-hidden":"true"},null,-1)),x("span",{class:ge(["h-1.5 w-1.5 shrink-0 rounded-full",r(ps)(d.value.providerId).solid])},null,2),x("span",t2,v(d.value.provider),1),d.value.upstreamModel?(h(),N("span",n2,"› "+v(d.value.upstreamModel),1)):se("",!0),m(r(Oe),{variant:"outline",class:"shrink-0"},{default:g(()=>[U(v(r(Lt)(d.value.format)),1)]),_:1}),d.value.stream?(h(),V(r(Oe),{key:1,variant:"secondary",class:"shrink-0"},{default:g(()=>[...O[10]||(O[10]=[U("SSE",-1)])]),_:1})):se("",!0),d.value.status===0?(h(),V(r(Oe),{key:2,variant:"secondary",class:"shrink-0"},{default:g(()=>[U(v(r(o)("models.debugNetwork")),1)]),_:1})):d.value.status<300?(h(),V(r(Oe),{key:3,variant:"success",class:"shrink-0"},{default:g(()=>[U(v(d.value.status),1)]),_:1})):(h(),V(r(Oe),{key:4,variant:"destructive",class:"shrink-0"},{default:g(()=>[U(v(d.value.status),1)]),_:1})),d.value.truncated?(h(),V(r(Oe),{key:5,variant:"secondary",class:"shrink-0"},{default:g(()=>[U(v(r(o)("models.debugTruncated")),1)]),_:1})):se("",!0),x("div",s2,[x("div",o2,[x("button",{type:"button",class:ge(["rounded px-1.5 py-0.5 text-[11px]",I.value==="content"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"]),onClick:O[1]||(O[1]=L=>I.value="content")},v(r(o)("models.debugViewContent")),3),x("button",{type:"button",class:ge(["rounded px-1.5 py-0.5 text-[11px]",I.value==="raw"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"]),onClick:O[2]||(O[2]=L=>I.value="raw")},v(r(o)("models.debugViewRaw")),3)]),x("span",r2,v(F(d.value.ts))+" · "+v(d.value.ms)+"ms",1)])]),C.value&&C.value.length>1?(h(),N("div",a2,[(h(!0),N(he,null,Pe(C.value,(L,J)=>(h(),N("button",{key:`a${L.c.ts}-${J}`,type:"button",class:ge(["flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors",L.c===d.value?"border-foreground/30 bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/50"]),title:`${L.c.provider}${L.c.upstreamModel?` › ${L.c.upstreamModel}`:""} · ${L.c.ms}ms`,onClick:ne=>d.value=L.c},[x("span",{class:ge(["h-1.5 w-1.5 rounded-full",r(ps)(L.c.providerId).solid])},null,2),U(" "+v(F(L.c.ts))+" ",1),x("span",{class:ge(L.c.status===0||L.c.status>=400?"text-destructive":"text-emerald-500")},v(L.c.status||"×"),3)],10,l2))),128))])):se("",!0),d.value.error?(h(),N("p",i2,v(d.value.error),1)):se("",!0),x("div",u2,[x("div",c2,[x("span",d2,v(r(o)("models.debugReq"))+" · "+v(D(d.value.request)),1),x("div",f2,[I.value==="raw"&&ee.value.cut?(h(),V(r(we),{key:0,variant:"ghost",size:"sm",class:"h-6 px-2 text-[11px] text-muted-foreground",onClick:O[3]||(O[3]=L=>T.value=!T.value)},{default:g(()=>[U(v(T.value?r(o)("models.debugCollapse"):r(o)("models.debugExpand")),1)]),_:1})):se("",!0),m(r(we),{variant:"ghost",size:"icon",class:"size-6 text-muted-foreground",title:r(o)("connect.copy"),"aria-label":r(o)("connect.copy"),onClick:O[4]||(O[4]=L=>fe(d.value.request))},{default:g(()=>[m(r(kn),{class:"h-3 w-3"})]),_:1},8,["title","aria-label"])])]),I.value==="content"?(h(),N("div",p2,[m(md,{body:d.value.request,kind:"request"},null,8,["body"])])):(h(),N("pre",m2,v(ee.value.text),1))]),d.value.response!==void 0?(h(),N("div",h2,[x("div",g2,[x("span",v2,v(r(o)("models.debugResp"))+" · "+v(D(d.value.response)),1),x("div",y2,[I.value==="raw"&&Q.value.cut?(h(),V(r(we),{key:0,variant:"ghost",size:"sm",class:"h-6 px-2 text-[11px] text-muted-foreground",onClick:O[5]||(O[5]=L=>T.value=!T.value)},{default:g(()=>[U(v(T.value?r(o)("models.debugCollapse"):r(o)("models.debugExpand")),1)]),_:1})):se("",!0),m(r(we),{variant:"ghost",size:"icon",class:"size-6 text-muted-foreground",title:r(o)("connect.copy"),"aria-label":r(o)("connect.copy"),onClick:O[6]||(O[6]=L=>fe(d.value.response))},{default:g(()=>[m(r(kn),{class:"h-3 w-3"})]),_:1},8,["title","aria-label"])])]),I.value==="content"?(h(),N("div",_2,[m(md,{body:d.value.response,kind:"response"},null,8,["body"])])):(h(),N("pre",b2,v(Q.value.text),1))])):se("",!0)],64)):(h(),N(he,{key:1},[x("div",x2,[m(r(Mm),{"model-value":a.value,disabled:c.value||u.value,"aria-label":r(o)("models.debugSwitch"),"onUpdate:modelValue":p},null,8,["model-value","disabled","aria-label"]),x("span",w2,v(r(o)("models.debugSwitch")),1),x("div",k2,[x("button",{type:"button",class:ge(["rounded px-1.5 py-0.5 text-[11px]",E.value==="conv"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"]),onClick:O[7]||(O[7]=L=>E.value="conv")},v(r(o)("models.debugModeConv")),3),x("button",{type:"button",class:ge(["rounded px-1.5 py-0.5 text-[11px]",E.value==="flat"?"bg-muted font-medium text-foreground":"text-muted-foreground hover:text-foreground"]),onClick:O[8]||(O[8]=L=>E.value="flat")},v(r(o)("models.debugModeFlat")),3)]),m(r(we),{variant:"outline",size:"icon",class:"size-8 shrink-0",disabled:u.value,title:r(o)("models.debugRefresh"),"aria-label":r(o)("models.debugRefresh"),onClick:f},{default:g(()=>[u.value?(h(),V(r(gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),V(r(Vs),{key:1,class:"h-3.5 w-3.5"}))]),_:1},8,["disabled","title","aria-label"])]),x("p",C2,v(r(o)("models.debugHint")),1),A.value.length?(h(),N("div",S2,[x("div",$2,[x("span",T2,v(r(o)("models.debugFailsTitle",{n:i.value.length})),1),i.value.length?(h(),V(r(we),{key:0,variant:"ghost",size:"icon",class:"size-6 text-muted-foreground",disabled:u.value,title:r(o)("models.debugClearFails"),"aria-label":r(o)("models.debugClearFails"),onClick:y},{default:g(()=>[m(r(To),{class:"h-3 w-3"})]),_:1},8,["disabled","title","aria-label"])):se("",!0)]),x("div",A2,[E.value==="conv"?(h(!0),N(he,{key:0},Pe(k.value,L=>(h(),N("button",{key:L.key,type:"button",class:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-muted/50",onClick:J=>M(L)},[x("span",O2,v(F(L.lastTs)),1),x("span",{class:"min-w-0 flex-1 truncate",title:L.title},v(L.title),9,P2),L.fails?(h(),V(r(Oe),{key:0,variant:"destructive",class:"shrink-0 text-[10px]"},{default:g(()=>[U(v(r(o)("models.debugConvFails",{n:L.fails})),1)]),_:2},1024)):se("",!0),m(r(Oe),{variant:"secondary",class:"shrink-0 text-[10px]"},{default:g(()=>[U(v(r(o)("models.debugConvReqs",{n:L.items.length})),1)]),_:2},1024)],8,E2))),128)):(h(!0),N(he,{key:1},Pe(A.value,(L,J)=>(h(),N("button",{key:`${L.c.ts}-${J}`,type:"button",class:"flex w-full cursor-pointer flex-wrap items-center gap-x-2 gap-y-0.5 px-3 py-1.5 text-left transition-colors hover:bg-muted/50",onClick:ne=>S(L)},[x("span",I2,v(F(L.c.ts)),1),x("span",{class:ge(["h-1.5 w-1.5 shrink-0 rounded-full",r(ps)(L.c.providerId).solid])},null,2),x("span",R2,v(L.c.provider),1),L.c.upstreamModel?(h(),N("span",{key:0,class:"min-w-0 max-w-40 truncate font-mono text-xs text-muted-foreground",title:L.c.upstreamModel},"› "+v(L.c.upstreamModel),9,L2)):se("",!0),L.c.status===0?(h(),V(r(Oe),{key:1,variant:"secondary",class:"shrink-0"},{default:g(()=>[U(v(r(o)("models.debugNetwork")),1)]),_:1})):L.c.status<300?(h(),V(r(Oe),{key:2,variant:"success",class:"shrink-0 font-mono"},{default:g(()=>[U(v(L.c.status),1)]),_:2},1024)):(h(),V(r(Oe),{key:3,variant:"destructive",class:"shrink-0 font-mono"},{default:g(()=>[U(v(L.c.status),1)]),_:2},1024)),L.c.thinking?(h(),N("span",{key:4,class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-[10px] text-muted-foreground",title:r(o)("models.editor.thinkingLabel")},[m(r(xo),{class:"h-2.5 w-2.5"}),U(v(L.c.thinking.value),1)],8,D2)):se("",!0),r(on)(L.c.sampling)?(h(),N("span",{key:5,class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-[10px] text-muted-foreground",title:r(o)("models.editor.samplingLabel")},[m(r(vs),{class:"h-2.5 w-2.5"}),U(v(r(on)(L.c.sampling)),1)],8,N2)):se("",!0),L.auto?(h(),V(r(Oe),{key:6,variant:"secondary",class:"shrink-0 text-[10px]"},{default:g(()=>[U(v(r(o)("models.debugAutoTag")),1)]),_:1})):se("",!0),x("span",F2,v(L.c.ms)+"ms · "+v(D(L.c.request))+"/"+v(D(L.c.response)),1)],8,M2))),128))])])):a.value?(h(),N("div",q2,[x("span",B2,[m(r(Uo),{class:"size-4"})]),x("p",V2,v(r(o)("models.debugEmpty")),1)])):(h(),N("div",U2,v(r(o)("models.debugEmptyOff")),1))],64))]),_:1})]),_:1},8,["open"]))}}),j2={class:"space-y-2"},z2={class:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground"},W2={key:0,class:"font-normal"},K2={key:1,class:"font-normal"},G2=["title"],Y2={class:"w-3 shrink-0 text-right text-[10px] tabular-nums text-muted-foreground/60"},X2={class:"min-w-0 flex-1 leading-tight"},J2={class:"truncate text-xs font-medium"},Q2={key:0,class:"flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-muted-foreground"},Z2=["title"],e$=["title"],t$=["title"],n$={key:1,class:"shrink-0 font-mono text-[11px] font-semibold text-destructive"},s$=["title","aria-label","onClick"],o$=["title","aria-label","onClick"],r$={key:0,class:"rounded-md bg-destructive/10 px-2 py-1.5 font-mono text-[11px] break-all whitespace-pre-wrap text-destructive"},a$={class:"opacity-70"},hd=re({__name:"ChainDetails",props:{model:{},line:{},active:{},fails:{},slotState:{type:Function},slotTitle:{type:Function},slotClass:{type:Function},probeSlot:{type:Function}},setup(e){const t=e,{t:n}=ft();function s(l){const i=(t.fails??[]).filter(u=>u.providerId===t.line.slots[l].id);return i.length?i.reduce((u,c)=>c.ts>=u.ts?c:u):void 0}const o=j(null);function a(l){o.value=o.value===l?null:l}return(l,i)=>(h(),N("div",j2,[x("div",z2,[(h(!0),N(he,null,Pe(e.line.fs,u=>(h(),N(he,{key:u},[x("span",{class:ge(["h-1.5 w-1.5 rounded-full",r(pt)[u].solid])},null,2),U(" "+v(r(n)(r(_n)[u].label)),1)],64))),128)),e.line.enabled?se("",!0):(h(),N("span",W2,"· "+v(r(n)("models.routeDisabled")),1)),e.active!==void 0?(h(),N("span",K2,"· "+v(r(n)("models.chainActiveHint")),1)):se("",!0)]),x("div",{class:ge(["space-y-1",{"opacity-60":!e.line.enabled}])},[(h(!0),N(he,null,Pe(e.line.slots,(u,c)=>{var d,f,p,y;return h(),N(he,{key:c},[x("div",{class:ge(["flex items-center gap-2 rounded-md border px-2 py-1.5 transition-colors",[e.slotClass(e.model,e.line,c),c===e.active?"ring-1 ring-primary/60":""]]),title:e.slotState(e.model,e.line,c)?e.slotTitle(e.model,e.line,c):void 0},[x("span",Y2,v(c+1),1),x("span",{class:ge(["h-1.5 w-1.5 shrink-0 rounded-full",r(ps)(u.id).solid])},null,2),x("div",X2,[x("div",J2,v(u.name),1),u.model||u.thinking||r(on)(u.sampling)?(h(),N("div",Q2,[u.model?(h(),N("span",{key:0,class:"min-w-0 truncate",title:u.model},"› "+v(u.model),9,Z2)):se("",!0),u.thinking?(h(),N("span",{key:1,class:"inline-flex shrink-0 items-center gap-0.5",title:r(n)("models.editor.thinkingLabel")},[m(r(xo),{class:"h-2.5 w-2.5"}),U(v(u.thinking),1)],8,e$)):se("",!0),r(on)(u.sampling)?(h(),N("span",{key:2,class:"inline-flex shrink-0 items-center gap-0.5",title:r(n)("models.editor.samplingLabel")},[m(r(vs),{class:"h-2.5 w-2.5"}),U(v(r(on)(u.sampling)),1)],8,t$)):se("",!0)])):se("",!0)]),e.line.enabled?(h(),N(he,{key:0},[((d=e.slotState(e.model,e.line,c))==null?void 0:d.state)==="ok"?(h(),V(r(rn),{key:0,class:"h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"})):((f=e.slotState(e.model,e.line,c))==null?void 0:f.state)==="fail"?(h(),N("span",n$,v(((p=e.slotState(e.model,e.line,c))==null?void 0:p.status)||"✗"),1)):se("",!0),s(c)?(h(),N("button",{key:2,type:"button",class:"inline-flex shrink-0 items-center gap-0.5 rounded px-0.5 font-mono text-[10px] font-semibold text-destructive transition-colors hover:bg-destructive/10",title:r(n)("models.chainFailHint"),"aria-label":r(n)("models.chainFailHint"),onClick:Re($=>a(c),["stop"])},[m(r(pr),{class:"h-3 w-3"}),U(v(s(c).status||"?"),1)],8,s$)):se("",!0),((y=e.slotState(e.model,e.line,c))==null?void 0:y.state)!=="testing"?(h(),N("button",{key:3,type:"button",class:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/40 transition-colors hover:bg-accent hover:text-accent-foreground",title:r(n)("models.testSourceHint"),"aria-label":`${r(n)("models.testSource")} · ${u.name}`,onClick:Re($=>e.probeSlot(e.model,e.line,c),["stop"])},[m(r(Ns),{class:"h-3 w-3"})],8,o$)):(h(),V(r(gt),{key:4,class:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}))],64)):se("",!0)],10,G2),o.value===c&&s(c)?(h(),N("div",r$,[x("span",a$,"HTTP "+v(s(c).status)+" · ",1),U(v(s(c).error||r(n)("models.probeFail")),1)])):se("",!0)],64)}),128))],2)]))}}),l$={class:"flex gap-3 pr-8"},i$={key:0,class:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-destructive/15 text-destructive"},u$={class:"min-w-0 flex-1 space-y-1.5"},c$={class:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"},fu=re({__name:"ConfirmDialog",props:es({title:{},description:{},confirmText:{default:""},cancelText:{default:""},variant:{default:"default"},loading:{type:Boolean,default:!1}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:es(["confirm"],["update:open"]),setup(e,{emit:t}){const{t:n}=ft(),s=Co(e,"open"),o=t;return(a,l)=>(h(),V(r(zs),{open:s.value,"onUpdate:open":l[2]||(l[2]=i=>s.value=i)},{default:g(()=>[m(r(Ws),{class:"max-w-sm"},{default:g(()=>[x("div",l$,[e.variant==="destructive"?(h(),N("span",i$,[m(r(pr),{class:"h-4 w-4"})])):se("",!0),x("div",u$,[m(r(Ks),{class:"text-base leading-tight"},{default:g(()=>[U(v(e.title),1)]),_:1}),e.description?(h(),V(r(Gs),{key:0},{default:g(()=>[U(v(e.description),1)]),_:1})):se("",!0)])]),x("div",c$,[m(r(we),{variant:"outline",disabled:e.loading,onClick:l[0]||(l[0]=i=>s.value=!1)},{default:g(()=>[U(v(e.cancelText||r(n)("common.cancel")),1)]),_:1},8,["disabled"]),m(r(we),{variant:e.variant,disabled:e.loading,onClick:l[1]||(l[1]=i=>o("confirm"))},{default:g(()=>[e.loading?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):se("",!0),U(" "+v(e.confirmText||r(n)("common.confirm")),1)]),_:1},8,["variant","disabled"])])]),_:1})]),_:1},8,["open"]))}}),d$={class:"space-y-4"},f$={class:"flex flex-wrap items-center gap-2"},p$={class:"relative min-w-[180px] flex-1"},m$={class:"flex items-center rounded-md border p-0.5"},h$={key:0,class:"py-8 text-center text-sm text-muted-foreground"},g$={key:1,class:"py-8 text-center text-sm text-destructive"},v$={class:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/15 text-primary"},y$={class:"space-y-1"},_$={class:"font-medium"},b$={class:"max-w-sm text-sm text-muted-foreground"},x$={class:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/15 text-primary"},w$={class:"space-y-1"},k$={class:"font-medium"},C$={class:"max-w-sm text-sm text-muted-foreground"},S$={key:4,class:"py-8 text-center text-sm text-muted-foreground"},$$={key:5,class:"grid items-stretch gap-3 md:grid-cols-2"},T$={class:"flex h-full flex-col gap-3 p-4"},A$={class:"flex min-w-0 items-center gap-1.5"},E$={class:"truncate font-mono text-sm font-semibold"},O$=["title","aria-label","onClick"],P$={class:"opacity-0 transition-all focus-within:opacity-100 group-hover:opacity-100"},M$={class:"min-w-0 flex-1 space-y-1.5"},I$=["title","aria-label","onClick"],R$=["title","aria-label"],L$={class:"shrink-0 font-medium"},D$=["title"],N$=["title"],F$=["title"],q$={key:0,class:"text-xs text-muted-foreground"},B$={key:1,class:"rounded-md border border-dashed px-2.5 py-2 text-xs text-muted-foreground"},V$={key:6,class:"overflow-hidden rounded-lg border"},U$={class:"space-y-1"},H$={class:"font-mono text-sm font-medium"},j$={key:0,class:"flex flex-wrap items-center gap-1"},z$={class:"flex flex-wrap items-center gap-1.5"},W$=["title","aria-label","onClick"],K$={key:0,class:"min-w-0 space-y-1"},G$=["title"],Y$=["title","aria-label"],X$={class:"shrink-0 font-medium"},J$=["title"],Q$=["title"],Z$=["title"],eT={key:1,class:"text-xs text-muted-foreground"},tT={key:1,class:"text-xs text-muted-foreground"},nT={key:1,class:"text-xs text-muted-foreground"},sT={class:"flex items-center justify-end gap-0.5"},oT={class:"space-y-1.5"},rT={class:"text-xs text-muted-foreground"},aT={class:"flex justify-end gap-2"},gd="myapikey.view.models",lT=re({__name:"Models",emits:["goto"],setup(e,{emit:t}){const n=t,{t:s}=ft(),o=j(localStorage.getItem(gd)==="table"?"table":"cards");function a(_){o.value=_;try{localStorage.setItem(gd,_)}catch{}}const l=["openai","anthropic","responses"],i=j([]),u=j([]),c=j(!1),d=j(""),f=j(""),p=j(!1),y=j(null),$=j(!1);function A(_){y.value=_,$.value=!1,p.value=!0}function E(){y.value=null,$.value=!0,p.value=!0}function C(){L()}const k=j(!1),M=j(null),S=j(""),F=j(!1),D=j(!1),T=j(null);function I(_){T.value=_,D.value=!0}function G(_){M.value=_,S.value=_.name,k.value=!0}async function Y(){const _=M.value,w=S.value.trim();if(!(!_||!w||w===_.name)){F.value=!0;try{await Be("POST",`/admin/models/${ee(_.name)}/rename`,{name:w}),await L(),Ue(s("models.renamedToast",{from:_.name,to:w}),"success"),k.value=!1}catch(b){Ue(b.message,"error")}finally{F.value=!1}}}const ee=encodeURIComponent,Q=j(null),fe=j(!1),R=j(!1);async function O(){const _=Q.value;if(_){R.value=!0;try{await Be("DELETE",`/admin/models/${ee(_.name)}`),i.value=i.value.filter(w=>w.name!==_.name),Ue(s("models.removedToast",{name:_.name}),"success"),fe.value=!1}catch(w){Ue(w.message,"error")}finally{R.value=!1}}}async function L(){c.value=!0,d.value="";try{const[_,w]=await Promise.all([Be("GET","/admin/models"),Be("GET","/admin/providers")]);i.value=_.models,u.value=w.providers}catch(_){d.value=_.message}finally{c.value=!1}}at(L);const J=ae(()=>{const _=f.value.trim().toLowerCase();return i.value.filter(w=>!_||w.name.toLowerCase().includes(_))});function ne(_){return l.filter(w=>_[w].enabled)}const pe=_=>{const w=q=>q.map(W=>`${W.id}|${W.model??""}|${W.thinking??""}|${JSON.stringify(W.sampling??{})}`).join(">"),b=[];for(const q of l){if(!_[q].providers.length)continue;const W=`${_[q].enabled}|${w(_[q].providers)}`,H=b.find(X=>X.key===W);H?H.fs.push(q):b.push({fs:[q],enabled:_[q].enabled,slots:_[q].providers,key:W})}return b};function K(_,w){const b=(_.lastRoute??[]).filter(q=>w.fs.includes(q.format));if(b.length){const q=b.reduce((H,X)=>X.ts>=H.ts?X:H),W=w.slots.findIndex(H=>H.id===q.providerId);if(W>=0)return{s:w.slots[W],i:W,actual:!0}}return{s:w.slots[0],i:0,actual:!1}}function de(_,w){return(_.lastFail??[]).filter(b=>w.fs.includes(b.format))}function oe(_,w){return _[w].enabled?"on":_[w].providers.length?"off":"none"}function Ge(_,w){const b=oe(_,w);return b==="on"?`border-transparent ${pt[w].solid} text-white shadow-sm`:b==="off"?"border-dashed border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground":"border-transparent text-muted-foreground/40"}function qe(_,w){const b=oe(_,w);return b==="on"?`${s(_n[w].label)} · ${s("models.chipOn")}`:b==="off"?`${s(_n[w].label)} · ${s("models.chipOff")}`:`${s(_n[w].label)} · ${s("models.chipNa")}`}async function ve(_,w){if(oe(_,w)==="none")return;const b=_[w].providers.map(q=>({id:q.id,...q.model?{model:q.model}:{},...q.thinking?{thinking:q.thinking}:{},...q.sampling&&Object.keys(q.sampling).length?{sampling:q.sampling}:{}}));try{await Be("PUT",`/admin/models/${ee(_.name)}`,{[w]:{enabled:!_[w].enabled,slots:b}}),_[w].enabled=!_[w].enabled,Ue(s(_[w].enabled?"models.enabledToast":"models.disabledToast",{name:`${_.name} [${w}]`}),"success")}catch(q){Ue(q.message,"error")}}function ye(_,w){const b=_[w].providers;if(!b.length)return!1;const q=W=>po(u.value.find(H=>H.id===W));return!b.some(W=>q(W.id).includes(W.model??_.name))&&b.some(W=>q(W.id).length>0)}function Z(_){return ne(_).some(w=>ye(_,w))}const xe=j({}),_e=j({});async function Fe(_){const w=ne(_);if(w.length){for(const b of w)xe.value[`${_.name}:${b}`]=!0;await Promise.all(w.map(async b=>{const q=`${_.name}:${b}`;try{const W=await Be("POST",`/admin/models/${ee(_.name)}/test?format=${b}`);_e.value[q]=W.result}catch(W){_e.value[q]={ok:!1,status:0,format:b,error:W.message}}finally{xe.value[q]=!1}}))}}function Le(_){let w=!1,b=null,q=null;for(const W of ne(_)){const H=`${_.name}:${W}`;xe.value[H]&&(w=!0);const X=_e.value[H];X!=null&&X.ok&&!b?b=X:X&&!X.ok&&!q&&(q=X)}return w?{state:"testing"}:b?{state:"ok",provider:b.provider}:q?{state:"fail",status:q.status,error:q.error}:null}const B=j({}),z=j({});async function te(_,w,b){const q=w.fs.filter(W=>!B.value[`${_.name}:${W}:${b}`]);if(q.length){for(const W of q)B.value[`${_.name}:${W}:${b}`]=!0;await Promise.all(q.map(async W=>{const H=`${_.name}:${W}:${b}`;try{const X=await Be("POST",`/admin/models/${ee(_.name)}/providers/test?format=${W}&index=${b}`);z.value[H]=X.result}catch(X){z.value[H]={ok:!1,status:0,format:W,error:X.message}}finally{B.value[H]=!1}}))}}function ue(_,w,b){let q=!1,W=null,H=null;for(const X of w.fs){const be=`${_.name}:${X}:${b}`;B.value[be]&&(q=!0);const me=z.value[be];me!=null&&me.ok&&!W?W=me:me&&!me.ok&&!H&&(H=me)}return q?{state:"testing"}:W?{state:"ok",provider:W.provider}:H?{state:"fail",status:H.status,error:H.error}:null}function le(_,w,b){const q=ue(_,w,b);return(q==null?void 0:q.state)==="ok"?"border-emerald-500/40 bg-emerald-500/10":(q==null?void 0:q.state)==="fail"?"border-destructive/40 bg-destructive/10":"border-transparent bg-muted/60"}function ie(_,w,b){return w.fs.map(q=>{const W=z.value[`${_.name}:${q}:${b}`],H=s(_n[q].label);return W?W.ok?`${H} ✓ ${s("models.probeOk")}${W.provider?` (${W.provider})`:""}`:`${H} ✗ ${W.status||"?"}${W.error?` ${W.error}`:""}`:H}).join(`
|
|
329
329
|
`)}async function P(_){const w=await xr(_);Ue(s(w?"connect.copied":"connect.copyFailed"),w?"success":"error")}return(_,w)=>(h(),N("div",d$,[x("div",f$,[x("div",p$,[m(r(du),{class:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),m(r(mt),{modelValue:f.value,"onUpdate:modelValue":w[0]||(w[0]=b=>f.value=b),placeholder:r(s)("models.searchPh"),class:"pl-8"},null,8,["modelValue","placeholder"])]),x("div",m$,[m(r(we),{variant:"ghost",size:"icon",class:ge(["h-6 w-6",o.value==="cards"?"bg-accent text-accent-foreground":"text-muted-foreground"]),title:r(s)("common.viewCards"),"aria-label":r(s)("common.viewCards"),onClick:w[1]||(w[1]=b=>a("cards"))},{default:g(()=>[m(r(Em),{class:"h-3.5 w-3.5"})]),_:1},8,["class","title","aria-label"]),m(r(we),{variant:"ghost",size:"icon",class:ge(["h-6 w-6",o.value==="table"?"bg-accent text-accent-foreground":"text-muted-foreground"]),title:r(s)("common.viewTable"),"aria-label":r(s)("common.viewTable"),onClick:w[2]||(w[2]=b=>a("table"))},{default:g(()=>[m(r(Pm),{class:"h-3.5 w-3.5"})]),_:1},8,["class","title","aria-label"])]),m(r(we),{onClick:w[3]||(w[3]=b=>E())},{default:g(()=>[m(r(Yn),{class:"h-4 w-4"}),U(v(r(s)("models.newModel")),1)]),_:1})]),c.value?(h(),N("p",h$,v(r(s)("common.loading")),1)):d.value?(h(),N("p",g$,v(d.value),1)):!u.value.length&&!i.value.length?(h(),V(r(Vt),{key:2},{default:g(()=>[m(r(Zt),{class:"flex flex-col items-center gap-3 py-12 text-center"},{default:g(()=>[x("span",v$,[m(r(wo),{class:"h-5 w-5"})]),x("div",y$,[x("div",_$,v(r(s)("models.emptyNoSources")),1),x("p",b$,v(r(s)("models.emptyNoSourcesHint")),1)]),m(r(we),{onClick:w[4]||(w[4]=b=>n("goto","sources"))},{default:g(()=>[m(r(Yn),{class:"h-4 w-4"}),U(v(r(s)("sources.add")),1)]),_:1})]),_:1})]),_:1})):!J.value.length&&!f.value?(h(),V(r(Vt),{key:3},{default:g(()=>[m(r(Zt),{class:"flex flex-col items-center gap-3 py-12 text-center"},{default:g(()=>[x("span",x$,[m(r(Am),{class:"h-5 w-5"})]),x("div",w$,[x("div",k$,v(r(s)("models.emptyNoModels")),1),x("p",C$,v(r(s)("models.emptyNoModelsHint")),1)]),m(r(we),{onClick:w[5]||(w[5]=b=>E())},{default:g(()=>[m(r(Yn),{class:"h-4 w-4"}),U(v(r(s)("models.newModel")),1)]),_:1})]),_:1})]),_:1})):J.value.length?o.value==="cards"?(h(),N("div",$$,[(h(!0),N(he,null,Pe(J.value,b=>(h(),V(r(Vt),{key:b.name,class:"group cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/30",onClick:q=>A(b)},{default:g(()=>{var q,W,H,X,be;return[x("div",T$,[x("div",A$,[x("span",E$,v(b.name),1),x("button",{type:"button",title:r(s)("connect.copy"),"aria-label":r(s)("connect.copy"),class:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 opacity-0 transition-all hover:bg-accent hover:text-accent-foreground focus-visible:opacity-100 focus-visible:outline-none group-hover:opacity-100",onClick:Re(me=>P(b.name),["stop"])},[m(r(kn),{class:"h-3 w-3"})],8,O$),b.paceRpm?(h(),V(r(Oe),{key:0,variant:"outline",class:"shrink-0 gap-1",title:r(s)("models.paceBadgeHint",{n:b.paceRpm,s:Math.max(1,Math.round(60/b.paceRpm))})},{default:g(()=>[m(r(Go),{class:"h-3 w-3"}),U(v(r(s)("models.paceBadge",{n:b.paceRpm})),1)]),_:2},1032,["title"])):se("",!0),b.debugCapture?(h(),V(r(Oe),{key:1,variant:"outline",class:"shrink-0 cursor-pointer gap-1",title:r(s)("models.debugBadgeHint"),onClick:Re(me=>I(b),["stop"])},{default:g(()=>[m(r(Uo),{class:"h-3 w-3"}),U(v(r(s)("models.debugOnBadge")),1)]),_:1},8,["title","onClick"])):se("",!0),((q=Le(b))==null?void 0:q.state)==="testing"?(h(),V(r(Oe),{key:2,variant:"muted",class:"shrink-0 gap-1"},{default:g(()=>[m(r(gt),{class:"h-3 w-3 animate-spin"}),U(v(r(s)("models.probeTesting")),1)]),_:1})):((W=Le(b))==null?void 0:W.state)==="ok"?(h(),V(r(Oe),{key:3,variant:"success",class:"shrink-0",title:r(s)("models.probeOkHint",{name:((H=Le(b))==null?void 0:H.provider)??""})},{default:g(()=>[U(v(r(s)("models.probeOk")),1)]),_:1},8,["title"])):((X=Le(b))==null?void 0:X.state)==="fail"?(h(),V(r(Oe),{key:4,variant:"destructive",class:"shrink-0",title:((be=Le(b))==null?void 0:be.error)||r(s)("models.probeFailHint")},{default:g(()=>{var me;return[U(v(r(s)("models.probeFail"))+" · "+v(((me=Le(b))==null?void 0:me.status)||"?"),1)]}),_:2},1032,["title"])):Z(b)?(h(),V(r(Oe),{key:5,variant:"secondary",class:"shrink-0 gap-1",title:r(s)("models.delistedHint")},{default:g(()=>[m(r(pr),{class:"h-3 w-3"}),U(v(r(s)("models.delisted")),1)]),_:1},8,["title"])):se("",!0),x("div",{class:"ml-auto flex shrink-0 items-center gap-0.5",onClick:w[6]||(w[6]=Re(()=>{},["stop"]))},[m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground opacity-0 transition-all focus-visible:opacity-100 focus-visible:outline-none group-hover:opacity-100",title:r(s)("models.debug"),"aria-label":r(s)("models.debug"),onClick:me=>I(b)},{default:g(()=>[m(r(Uo),{class:"h-4 w-4"})]),_:1},8,["title","aria-label","onClick"]),m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground opacity-0 transition-all focus-visible:opacity-100 focus-visible:outline-none group-hover:opacity-100",disabled:!ne(b).length||!!Le(b)&&Le(b).state==="testing",title:r(s)("models.testModel"),"aria-label":r(s)("models.testModel"),onClick:me=>Fe(b)},{default:g(()=>{var me;return[((me=Le(b))==null?void 0:me.state)==="testing"?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),V(r(Ns),{key:1,class:"h-4 w-4"}))]}),_:2},1032,["disabled","title","aria-label","onClick"]),m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground opacity-0 transition-all focus-visible:opacity-100 focus-visible:outline-none group-hover:opacity-100",title:r(s)("models.edit"),"aria-label":r(s)("models.edit"),onClick:me=>A(b)},{default:g(()=>[m(r(ao),{class:"h-4 w-4"})]),_:1},8,["title","aria-label","onClick"]),x("div",P$,[m(r(fi),null,{default:g(()=>[m(r(pi),null,{default:g(()=>[m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground","aria-label":r(s)("models.moreActions")},{default:g(()=>[m(r(hi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),m(r(mi),{align:"end"},{default:g(()=>[m(r(Vo),{onSelect:me=>G(b)},{default:g(()=>[m(r(ao)),U(" "+v(r(s)("models.renameModel")),1)]),_:1},8,["onSelect"]),m(r(ld)),m(r(Vo),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:me=>{Q.value=b,fe.value=!0}},{default:g(()=>[m(r(fr)),U(" "+v(r(s)("models.removeModel")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)])])]),x("div",M$,[pe(b).length?(h(!0),N(he,{key:0},Pe(pe(b),me=>(h(),N("div",{key:me.key,class:ge(["flex flex-wrap items-center gap-x-1.5 gap-y-1",{"opacity-60":!me.enabled}])},[(h(!0),N(he,null,Pe(me.fs,Ae=>(h(),N("button",{key:Ae,type:"button",title:qe(b,Ae),"aria-label":qe(b,Ae),class:ge(["inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium transition-colors",Ge(b,Ae)]),onClick:Re(Ze=>ve(b,Ae),["stop"])},v(r(s)(r(_n)[Ae].label)),11,I$))),128)),w[18]||(w[18]=x("span",{class:"h-4 w-px shrink-0 bg-border","aria-hidden":"true"},null,-1)),m(r(ga),null,{default:g(()=>[m(r(va),{"as-child":""},{default:g(()=>[x("button",{type:"button",class:ge(["inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs transition-colors hover:bg-accent hover:text-accent-foreground",le(b,me,K(b,me).i)]),title:r(s)("models.chainListHint"),"aria-label":r(s)("models.chainListHint"),onClick:w[7]||(w[7]=Re(()=>{},["stop"]))},[x("span",{class:ge(["h-1.5 w-1.5 shrink-0 rounded-full",r(ps)(K(b,me).s.id).solid])},null,2),x("span",L$,v(K(b,me).s.name),1),K(b,me).s.model?(h(),N("span",{key:0,class:"min-w-0 truncate font-mono text-muted-foreground",title:K(b,me).s.model},"› "+v(K(b,me).s.model),9,D$)):se("",!0),K(b,me).s.thinking?(h(),N("span",{key:1,class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-[10px] text-muted-foreground",title:r(s)("models.editor.thinkingLabel")},[m(r(xo),{class:"h-2.5 w-2.5"}),U(v(K(b,me).s.thinking),1)],8,N$)):se("",!0),r(on)(K(b,me).s.sampling)?(h(),N("span",{key:2,class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-[10px] text-muted-foreground",title:r(s)("models.editor.samplingLabel")},[m(r(vs),{class:"h-2.5 w-2.5"}),U(v(r(on)(K(b,me).s.sampling)),1)],8,F$)):se("",!0),m(r(Rn),{class:"h-3 w-3 shrink-0 text-muted-foreground/60"})],10,R$)]),_:2},1024),m(r(ya),{align:"start",class:"w-80 p-3"},{default:g(()=>[m(hd,{model:b,line:me,active:K(b,me).actual?K(b,me).i:void 0,fails:de(b,me),"slot-state":ue,"slot-title":ie,"slot-class":le,"probe-slot":te},null,8,["model","line","active","fails"])]),_:2},1024)]),_:2},1024),me.enabled?se("",!0):(h(),N("span",q$,"· "+v(r(s)("models.routeDisabled")),1))],2))),128)):(h(),N("div",B$,v(r(s)("models.unroutedHint")),1))])])]}),_:2},1032,["onClick"]))),128))])):(h(),N("div",V$,[m(r(Qa),null,{default:g(()=>[m(r(Za),null,{default:g(()=>[m(r(Cn),{class:"hover:bg-transparent"},{default:g(()=>[m(r(rt),null,{default:g(()=>[U(v(r(s)("models.colName")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(s)("models.colFormats")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(s)("models.colChain")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(s)("models.colPace")),1)]),_:1}),m(r(rt),{class:"w-[128px] text-right"},{default:g(()=>[U(v(r(s)("models.colActions")),1)]),_:1})]),_:1})]),_:1}),m(r(el),null,{default:g(()=>[(h(!0),N(he,null,Pe(J.value,b=>(h(),V(r(Cn),{key:b.name,class:"group cursor-pointer",onClick:q=>A(b)},{default:g(()=>[m(r(nt),null,{default:g(()=>{var q,W,H,X;return[x("div",U$,[x("span",H$,v(b.name),1),b.paceRpm||b.debugCapture||Le(b)||Z(b)?(h(),N("div",j$,[b.paceRpm?(h(),V(r(Oe),{key:0,variant:"outline",class:"gap-1",title:r(s)("models.paceBadgeHint",{n:b.paceRpm,s:Math.max(1,Math.round(60/b.paceRpm))})},{default:g(()=>[m(r(Go),{class:"h-3 w-3"}),U(v(r(s)("models.paceBadge",{n:b.paceRpm})),1)]),_:2},1032,["title"])):se("",!0),b.debugCapture?(h(),V(r(Oe),{key:1,variant:"outline",class:"cursor-pointer gap-1",title:r(s)("models.debugBadgeHint"),onClick:Re(be=>I(b),["stop"])},{default:g(()=>[m(r(Uo),{class:"h-3 w-3"}),U(v(r(s)("models.debugOnBadge")),1)]),_:1},8,["title","onClick"])):se("",!0),((q=Le(b))==null?void 0:q.state)==="ok"?(h(),V(r(Oe),{key:2,variant:"success",title:r(s)("models.probeOkHint",{name:((W=Le(b))==null?void 0:W.provider)??""})},{default:g(()=>[U(v(r(s)("models.probeOk")),1)]),_:1},8,["title"])):((H=Le(b))==null?void 0:H.state)==="fail"?(h(),V(r(Oe),{key:3,variant:"destructive",title:((X=Le(b))==null?void 0:X.error)||r(s)("models.probeFailHint")},{default:g(()=>{var be;return[U(v(r(s)("models.probeFail"))+" · "+v(((be=Le(b))==null?void 0:be.status)||"?"),1)]}),_:2},1032,["title"])):Z(b)?(h(),V(r(Oe),{key:4,variant:"secondary",class:"gap-1",title:r(s)("models.delistedHint")},{default:g(()=>[m(r(pr),{class:"h-3 w-3"}),U(v(r(s)("models.delisted")),1)]),_:1},8,["title"])):se("",!0)])):se("",!0)])]}),_:2},1024),m(r(nt),{onClick:w[8]||(w[8]=Re(()=>{},["stop"]))},{default:g(()=>[x("div",z$,[(h(),N(he,null,Pe(l,q=>(h(),N(he,{key:q},[oe(b,q)!=="none"?(h(),N("button",{key:0,type:"button",title:qe(b,q),"aria-label":qe(b,q),class:ge(["inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium transition-colors",Ge(b,q)]),onClick:W=>ve(b,q)},v(r(s)(r(_n)[q].label)),11,W$)):se("",!0)],64))),64))])]),_:2},1024),m(r(nt),null,{default:g(()=>[pe(b).length?(h(),N("div",K$,[(h(!0),N(he,null,Pe(pe(b),q=>(h(),N("div",{key:q.key,class:ge(["flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1",{"opacity-60":!q.enabled}])},[pe(b).length>1?(h(!0),N(he,{key:0},Pe(q.fs,W=>(h(),N("span",{key:W,class:ge(["h-1.5 w-1.5 shrink-0 rounded-full",r(pt)[W].solid]),title:r(s)(r(_n)[W].label)},null,10,G$))),128)):se("",!0),m(r(ga),null,{default:g(()=>[m(r(va),{"as-child":""},{default:g(()=>[x("button",{type:"button",class:ge(["inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs transition-colors hover:bg-accent hover:text-accent-foreground",le(b,q,K(b,q).i)]),title:r(s)("models.chainListHint"),"aria-label":r(s)("models.chainListHint"),onClick:w[9]||(w[9]=Re(()=>{},["stop"]))},[x("span",{class:ge(["h-1.5 w-1.5 shrink-0 rounded-full",r(ps)(K(b,q).s.id).solid])},null,2),x("span",X$,v(K(b,q).s.name),1),K(b,q).s.model?(h(),N("span",{key:0,class:"min-w-0 truncate font-mono text-muted-foreground",title:K(b,q).s.model},"› "+v(K(b,q).s.model),9,J$)):se("",!0),K(b,q).s.thinking?(h(),N("span",{key:1,class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-[10px] text-muted-foreground",title:r(s)("models.editor.thinkingLabel")},[m(r(xo),{class:"h-2.5 w-2.5"}),U(v(K(b,q).s.thinking),1)],8,Q$)):se("",!0),r(on)(K(b,q).s.sampling)?(h(),N("span",{key:2,class:"inline-flex shrink-0 items-center gap-0.5 font-mono text-[10px] text-muted-foreground",title:r(s)("models.editor.samplingLabel")},[m(r(vs),{class:"h-2.5 w-2.5"}),U(v(r(on)(K(b,q).s.sampling)),1)],8,Z$)):se("",!0),m(r(Rn),{class:"h-3 w-3 shrink-0 text-muted-foreground/60"})],10,Y$)]),_:2},1024),m(r(ya),{align:"start",class:"w-80 p-3"},{default:g(()=>[m(hd,{model:b,line:q,active:K(b,q).actual?K(b,q).i:void 0,fails:de(b,q),"slot-state":ue,"slot-title":ie,"slot-class":le,"probe-slot":te},null,8,["model","line","active","fails"])]),_:2},1024)]),_:2},1024),q.enabled?se("",!0):(h(),N("span",eT,"· "+v(r(s)("models.routeDisabled")),1))],2))),128))])):(h(),N("span",tT,v(r(s)("models.unroutedHint")),1))]),_:2},1024),m(r(nt),{class:"whitespace-nowrap"},{default:g(()=>[b.paceRpm?(h(),V(r(Oe),{key:0,variant:"outline",class:"gap-1",title:r(s)("models.paceBadgeHint",{n:b.paceRpm,s:Math.max(1,Math.round(60/b.paceRpm))})},{default:g(()=>[m(r(Go),{class:"h-3 w-3"}),U(v(r(s)("models.paceBadge",{n:b.paceRpm})),1)]),_:2},1032,["title"])):(h(),N("span",nT,"—"))]),_:2},1024),m(r(nt),{onClick:w[10]||(w[10]=Re(()=>{},["stop"]))},{default:g(()=>[x("div",sT,[m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground",title:r(s)("models.debug"),"aria-label":r(s)("models.debug"),onClick:q=>I(b)},{default:g(()=>[m(r(Uo),{class:"h-3.5 w-3.5"})]),_:1},8,["title","aria-label","onClick"]),m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground",disabled:!ne(b).length||!!Le(b)&&Le(b).state==="testing",title:r(s)("models.testModel"),"aria-label":r(s)("models.testModel"),onClick:q=>Fe(b)},{default:g(()=>{var q;return[((q=Le(b))==null?void 0:q.state)==="testing"?(h(),V(r(gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),V(r(Ns),{key:1,class:"h-3.5 w-3.5"}))]}),_:2},1032,["disabled","title","aria-label","onClick"]),m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground",title:r(s)("models.edit"),"aria-label":r(s)("models.edit"),onClick:q=>A(b)},{default:g(()=>[m(r(ao),{class:"h-3.5 w-3.5"})]),_:1},8,["title","aria-label","onClick"]),m(r(fi),null,{default:g(()=>[m(r(pi),null,{default:g(()=>[m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground","aria-label":r(s)("models.moreActions")},{default:g(()=>[m(r(hi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),m(r(mi),{align:"end"},{default:g(()=>[m(r(Vo),{onSelect:q=>G(b)},{default:g(()=>[m(r(ao)),U(" "+v(r(s)("models.renameModel")),1)]),_:1},8,["onSelect"]),m(r(ld)),m(r(Vo),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:q=>{Q.value=b,fe.value=!0}},{default:g(()=>[m(r(fr)),U(" "+v(r(s)("models.removeModel")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)])]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})])):(h(),N("p",S$,v(r(s)("models.noMatch")),1)),m(fS,{open:p.value,"onUpdate:open":w[11]||(w[11]=b=>p.value=b),model:$.value?null:y.value,providers:u.value,"existing-names":i.value.map(b=>b.name),onSaved:C},null,8,["open","model","providers","existing-names"]),m(H2,{open:D.value,"onUpdate:open":w[12]||(w[12]=b=>D.value=b),model:T.value,onChanged:w[13]||(w[13]=b=>L())},null,8,["open","model"]),m(r(zs),{open:k.value,"onUpdate:open":w[16]||(w[16]=b=>k.value=b)},{default:g(()=>[m(r(Ws),{class:"max-w-sm"},{default:g(()=>[m(r(Ks),{class:"text-base"},{default:g(()=>[U(v(r(s)("models.renameModel")),1)]),_:1}),m(r(Gs),null,{default:g(()=>[U(v(r(s)("models.renameDesc")),1)]),_:1}),x("div",oT,[m(r(bt),{for:"rename-input"},{default:g(()=>[U(v(r(s)("models.editor.nameLabel")),1)]),_:1}),m(r(mt),{id:"rename-input",modelValue:S.value,"onUpdate:modelValue":w[14]||(w[14]=b=>S.value=b),class:"font-mono",spellcheck:"false",autocomplete:"off",onKeydown:Tn(Y,["enter"])},null,8,["modelValue"]),x("p",rT,v(r(s)("models.renameHint")),1)]),x("div",aT,[m(r(we),{variant:"outline",disabled:F.value,onClick:w[15]||(w[15]=b=>k.value=!1)},{default:g(()=>[U(v(r(s)("common.cancel")),1)]),_:1},8,["disabled"]),m(r(we),{disabled:F.value||!S.value.trim(),onClick:Y},{default:g(()=>[F.value?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):se("",!0),U(v(r(s)("settings.save")),1)]),_:1},8,["disabled"])])]),_:1})]),_:1},8,["open"]),m(fu,{open:fe.value,"onUpdate:open":w[17]||(w[17]=b=>fe.value=b),variant:"destructive",title:r(s)("models.removeModel"),description:Q.value?r(s)("models.confirmRemove",{name:Q.value.name}):"","confirm-text":r(s)("models.removeModel"),loading:R.value,onConfirm:O},null,8,["open","title","description","confirm-text","loading"])]))}}),Al=re({__name:"Checkbox",props:es({class:{type:[Boolean,null,String,Object,Array]},id:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const t=e,n=Co(e,"modelValue");return(s,o)=>(h(),V(r(Sx),{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=a=>n.value=a),id:t.id,class:ge(r(He)("peer h-4 w-4 shrink-0 cursor-pointer rounded-[4px] border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t.class))},{default:g(()=>[m(r(Tx),{class:"flex h-full w-full items-center justify-center text-current"},{default:g(()=>[m(r(rn),{class:"h-3.5 w-3.5"})]),_:1})]),_:1},8,["modelValue","id","class"]))}}),iT=re({__name:"Separator",props:{class:{type:[Boolean,null,String,Object,Array]},orientation:{}},setup(e){const t=e;return(n,s)=>(h(),V(r(pk),{orientation:t.orientation??"horizontal",class:ge(r(He)("shrink-0 bg-border",t.orientation==="vertical"?"h-full w-px":"h-px w-full",t.class))},null,8,["orientation","class"]))}}),uT={class:"flex shrink-0 items-center gap-2 pr-8"},cT={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary"},dT={class:"min-w-0"},fT={class:"min-h-0 flex-1 space-y-3.5 overflow-y-auto px-1 py-1"},pT={class:"space-y-1.5"},mT={class:"space-y-1.5"},hT={class:"space-y-2 rounded-md border bg-background/50 p-3"},gT={class:"space-y-2"},vT={class:"flex items-center gap-2.5"},yT={class:"text-sm font-medium leading-none"},_T={class:"flex items-center gap-2.5 pl-7"},bT={class:"flex items-center gap-2.5"},xT={class:"text-sm font-medium leading-none"},wT={key:0,class:"space-y-1.5"},kT={class:"text-xs text-muted-foreground"},CT={key:1,class:"space-y-1.5"},ST={class:"text-xs text-muted-foreground"},$T=["aria-expanded"],TT={key:2,class:"space-y-1.5 rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground"},AT={class:"font-medium text-foreground"},ET={class:"font-medium text-foreground"},OT={class:"font-medium text-foreground"},PT={class:"space-y-1.5"},MT={class:"flex items-center justify-between"},IT={key:0,class:"text-xs text-muted-foreground"},RT={class:"space-y-1.5"},LT=["aria-expanded"],DT={key:0,class:"space-y-1.5 rounded-md border bg-muted/30 p-3"},NT={class:"text-xs text-muted-foreground"},FT={key:3,class:"text-sm text-destructive"},qT={class:"flex shrink-0 justify-end gap-2"},BT=re({__name:"SourceDialog",props:es({provider:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:es(["saved"],["update:open"]),setup(e,{emit:t}){const n=e,s=Co(e,"open"),o=t,{t:a}=ft(),l=j(""),i=j(""),u=j(""),c=j(""),d=j(""),f=j(!0),p=j(!1),y=j(!1),$=j(!1),A=j(!1),E=j(""),C=j(!1);function k(T){if(T==="openai"){if(f.value&&!p.value)return;f.value=!f.value}else{if(p.value&&!f.value)return;p.value=!p.value}}const M=()=>{const T=[];return f.value&&T.push("openai"),p.value&&T.push("anthropic"),T};function S(){var I;E.value="",$.value=!1,A.value=!!((I=n.provider)!=null&&I.rpm);const T=n.provider;if(!T){l.value="",i.value="",u.value="",c.value="",d.value="",f.value=!0,p.value=!1,y.value=!1;return}l.value=T.name,i.value=T.baseUrlOpenai,u.value=T.baseUrlAnthropic,c.value="",d.value=T.rpm?String(T.rpm):"",f.value=T.formats.includes("openai"),p.value=T.formats.includes("anthropic"),y.value=!!T.supportsResponses}Ie(s,T=>{T&&S()});function F(){if(!M().length)E.value=a("sources.errFormat");else if(!n.provider&&(!l.value.trim()||!c.value))E.value=a("sources.errRequired");else if(n.provider&&!l.value.trim())E.value=a("sources.errNameRequired");else if(f.value&&!i.value.trim()||p.value&&!u.value.trim())E.value=a("sources.errBaseUrl");else return E.value="",!0;return!1}async function D(){if(!C.value&&F()){C.value=!0;try{const T={name:l.value.trim(),baseUrlOpenai:i.value.trim(),baseUrlAnthropic:u.value.trim(),formats:M(),supportsResponses:f.value&&y.value,rpm:Number(d.value)||0};c.value&&(T.apiKey=c.value);const I=n.provider?await Be("PUT",`/admin/providers/${n.provider.id}`,T):await Be("POST","/admin/providers",T);Ue(a(n.provider?"sources.updated":"sources.added"),"success"),s.value=!1,o("saved",I.provider)}catch(T){Ue(T.message,"error")}finally{C.value=!1}}}return(T,I)=>(h(),V(r(zs),{open:s.value,"onUpdate:open":I[11]||(I[11]=G=>s.value=G)},{default:g(()=>[m(r(Ws),{class:"max-w-lg"},{default:g(()=>{var G;return[x("div",uT,[x("span",cT,[m(r(wo),{class:"h-4 w-4"})]),x("div",dT,[m(r(Ks),{class:"text-base"},{default:g(()=>[U(v(e.provider?r(a)("sources.editTitle"):r(a)("sources.add")),1)]),_:1}),m(r(Gs),null,{default:g(()=>[U(v(e.provider?r(a)("sources.dialogEditDesc"):r(a)("sources.dialogCreateDesc")),1)]),_:1})])]),x("div",fT,[x("div",pT,[m(r(bt),{for:"s-name"},{default:g(()=>[U(v(r(a)("sources.nameLabel")),1)]),_:1}),m(r(mt),{id:"s-name",modelValue:l.value,"onUpdate:modelValue":I[0]||(I[0]=Y=>l.value=Y),placeholder:r(a)("sources.namePh"),autocomplete:"off","aria-label":"name"},null,8,["modelValue","placeholder"])]),x("div",mT,[m(r(bt),null,{default:g(()=>[U(v(r(a)("sources.formats")),1)]),_:1}),x("div",hT,[x("div",gT,[x("div",vT,[m(r(Al),{"model-value":f.value,disabled:f.value&&!p.value,"aria-label":"openai","onUpdate:modelValue":I[1]||(I[1]=Y=>k("openai"))},null,8,["model-value","disabled"]),x("span",yT,v(r(Bo).openai),1),I[12]||(I[12]=x("span",{class:"text-xs text-muted-foreground"},"/chat/completions",-1))]),x("div",_T,[m(r(Al),{modelValue:y.value,"onUpdate:modelValue":I[2]||(I[2]=Y=>y.value=Y),disabled:!f.value,"aria-label":r(a)("sources.responses")},null,8,["modelValue","disabled","aria-label"]),x("span",{class:ge(["text-sm leading-none",f.value?"":"text-muted-foreground"])},v(r(a)("sources.responses")),3),I[13]||(I[13]=x("span",{class:"text-xs text-muted-foreground"},"/responses",-1))])]),m(r(iT)),x("div",bT,[m(r(Al),{"model-value":p.value,disabled:p.value&&!f.value,"aria-label":"anthropic","onUpdate:modelValue":I[3]||(I[3]=Y=>k("anthropic"))},null,8,["model-value","disabled"]),x("span",xT,v(r(Bo).anthropic),1),I[14]||(I[14]=x("span",{class:"text-xs text-muted-foreground"},"/messages",-1))])])]),f.value?(h(),N("div",wT,[m(r(bt),{for:"s-url-openai"},{default:g(()=>[U(v(r(a)("sources.urlLabelOpenai")),1)]),_:1}),m(r(mt),{id:"s-url-openai",modelValue:i.value,"onUpdate:modelValue":I[4]||(I[4]=Y=>i.value=Y),placeholder:r(a)("sources.urlPhOpenai"),autocomplete:"off","aria-label":"openai base url"},null,8,["modelValue","placeholder"]),x("p",kT,v(r(a)("sources.urlHintOpenai")),1)])):se("",!0),p.value?(h(),N("div",CT,[m(r(bt),{for:"s-url-anthropic"},{default:g(()=>[U(v(r(a)("sources.urlLabelAnthropic")),1)]),_:1}),m(r(mt),{id:"s-url-anthropic",modelValue:u.value,"onUpdate:modelValue":I[5]||(I[5]=Y=>u.value=Y),placeholder:r(a)("sources.urlPhAnthropic"),autocomplete:"off","aria-label":"anthropic base url"},null,8,["modelValue","placeholder"]),x("p",ST,v(r(a)("sources.urlHintAnthropic")),1)])):se("",!0),x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground","aria-expanded":$.value,onClick:I[6]||(I[6]=Y=>$.value=!$.value)},[m(r(cu),{class:"h-3.5 w-3.5"}),U(" "+v(r(a)("sources.baseHelpToggle"))+" ",1),m(r(Rn),{class:ge(["h-3.5 w-3.5 transition-transform",{"rotate-180":$.value}])},null,8,["class"])],8,$T),$.value?(h(),N("div",TT,[x("p",null,v(r(a)("sources.baseHelpSplit")),1),x("p",null,[x("span",AT,v(r(Bo).openai),1),U(" — "+v(r(a)("sources.baseHelpOpenai")),1)]),x("p",null,[x("span",ET,v(r(Bo).anthropic),1),U(" — "+v(r(a)("sources.baseHelpAnthropic")),1)]),x("p",null,[x("span",OT,v(r(a)("sources.responses")),1),U(" — "+v(r(a)("sources.responsesNote")),1)])])):se("",!0),x("div",PT,[x("div",MT,[m(r(bt),{for:"s-key"},{default:g(()=>[U(v(r(a)("sources.keyLabel")),1)]),_:1}),(G=e.provider)!=null&&G.apiKey?(h(),N("span",IT,v(r(a)("sources.currentKeyLabel"))+": "+v(e.provider.apiKey),1)):se("",!0)]),m(r(mt),{id:"s-key",modelValue:c.value,"onUpdate:modelValue":I[7]||(I[7]=Y=>c.value=Y),type:"password",placeholder:e.provider?r(a)("sources.keyPhEdit"):r(a)("sources.keyPh"),autocomplete:"new-password","aria-label":"api key"},null,8,["modelValue","placeholder"])]),x("div",RT,[x("button",{type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground","aria-expanded":A.value,onClick:I[8]||(I[8]=Y=>A.value=!A.value)},[m(r(vs),{class:"h-3.5 w-3.5"}),U(" "+v(r(a)("sources.advancedToggle"))+" ",1),m(r(Rn),{class:ge(["h-3.5 w-3.5 transition-transform",{"rotate-180":A.value}])},null,8,["class"])],8,LT),A.value?(h(),N("div",DT,[m(r(bt),{for:"s-rpm"},{default:g(()=>[U(v(r(a)("sources.rpmLabel")),1)]),_:1}),m(r(mt),{id:"s-rpm",modelValue:d.value,"onUpdate:modelValue":I[9]||(I[9]=Y=>d.value=Y),type:"number",min:"0",inputmode:"numeric",placeholder:r(a)("sources.rpmPh"),"aria-label":"rpm"},null,8,["modelValue","placeholder"]),x("p",NT,v(r(a)("sources.rpmHint")),1)])):se("",!0)]),E.value?(h(),N("p",FT,v(E.value),1)):se("",!0)]),x("div",qT,[m(r(we),{variant:"outline",disabled:C.value,onClick:I[10]||(I[10]=Y=>s.value=!1)},{default:g(()=>[U(v(r(a)("common.cancel")),1)]),_:1},8,["disabled"]),m(r(we),{disabled:C.value,onClick:D},{default:g(()=>[C.value?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):se("",!0),U(" "+v(r(a)("sources.saveBtn")),1)]),_:1},8,["disabled"])])]}),_:1})]),_:1},8,["open"]))}}),VT={class:"space-y-2.5"},UT={class:"flex items-center gap-2"},HT={class:"relative min-w-0 flex-1"},jT={class:"flex items-center gap-2"},zT={class:"relative min-w-0 flex-1"},WT={key:0,class:"text-xs text-muted-foreground"},KT={key:0,class:"flex flex-col items-center gap-2 px-4 py-10 text-center"},GT={class:"flex size-9 items-center justify-center rounded-lg bg-muted text-muted-foreground"},YT={class:"text-sm text-muted-foreground"},XT={key:0,class:"px-3 py-6 text-center text-xs text-muted-foreground"},JT=["data-mname","title","onClick"],QT={class:"min-w-0 flex-1 truncate font-mono text-sm"},ZT=["disabled","aria-label","onClick"],eA=["disabled","title","aria-label","onClick"],tA=re({__name:"SourceModelsDialog",props:{open:{type:Boolean},provider:{}},emits:["update:open","saved"],setup(e,{emit:t}){const n=e,s=t,{t:o}=ft(),a=j(""),l=j(""),i=j([]),u=j(""),c=j(null),d=j(null),f=j(null),p=j(new Set);let y;function $(R){p.value=new Set(R),clearTimeout(y),y=setTimeout(()=>p.value.clear(),1600)}ko(()=>clearTimeout(y)),Ie(()=>n.open,async R=>{var O,L,J;R&&(a.value="",l.value="",i.value=[...((O=n.provider)==null?void 0:O.extraModels)??[]],p.value.clear(),Y.value.clear(),ee.value={},await it(),(J=(L=c.value)==null?void 0:L.$el)==null||J.focus())}),Ie(()=>n.provider,R=>{n.open&&R&&(i.value=[...R.extraModels??[]])});const A=ae(()=>{var R;return((R=n.provider)==null?void 0:R.discoveredModels)??[]}),E=ae(()=>po({discoveredModels:A.value,extraModels:i.value}).map(O=>({name:O,manual:i.value.includes(O)&&!A.value.includes(O)}))),C=ae(()=>{const R=a.value.trim().toLowerCase();return R?E.value.filter(O=>O.name.toLowerCase().includes(R)):E.value}),k=ae(()=>{const R=l.value.trim();return!!R&&E.value.some(O=>O.name===R)}),M=ae(()=>!!l.value.trim()&&!k.value);function S(R){i.value=[...R.extraModels??[]],s("saved",R)}async function F(R){const O=await Be("PUT",`/admin/providers/${n.provider.id}/extra-models`,{models:R});return S(O.provider),O.provider}async function D(){var O,L,J,ne;if(!n.provider||u.value||!M.value)return;const R=[...new Set(l.value.split(/[\s,;]+/).map(pe=>pe.trim()).filter(Boolean))].filter(pe=>!i.value.includes(pe));if(R.length){u.value="add";try{await F([...i.value,...R]),l.value="",$(R),Ue(o("sources.modelAdded",{n:R.length}),"success"),await it(),(L=(O=f.value)==null?void 0:O.querySelector(`[data-mname="${CSS.escape(R[0])}"]`))==null||L.scrollIntoView({block:"nearest"}),(ne=(J=d.value)==null?void 0:J.$el)==null||ne.focus()}catch(pe){Ue(pe.message,"error")}finally{u.value=""}}}async function T(R){if(!u.value){u.value="remove";try{await F(i.value.filter(O=>O!==R)),Ue(o("sources.modelRemoved",{name:R}),"success")}catch(O){Ue(O.message,"error")}finally{u.value=""}}}async function I(){if(!(!n.provider||u.value)){u.value="refresh";try{const R=await Be("POST",`/admin/providers/${n.provider.id}/discover`);S({...n.provider,discoveredModels:R.models}),Ue(o("sources.refreshDone",{name:n.provider.name}),R.models.length?"success":"default")}catch(R){Ue(R.message,"error")}finally{u.value=""}}}async function G(R){const O=await xr(R);Ue(o(O?"connect.copied":"connect.copyFailed"),O?"success":"error")}const Y=j(new Set),ee=j({});async function Q(R){if(!(!n.provider||Y.value.has(R))){Y.value.add(R);try{const O=await Be("POST",`/admin/providers/${n.provider.id}/test?model=${encodeURIComponent(R)}`);ee.value={...ee.value,[R]:O.results}}catch(O){Ue(O.message,"error")}finally{Y.value.delete(R)}}}function fe(R){a.value&&(R.stopPropagation(),R.preventDefault(),a.value="")}return(R,O)=>(h(),V(r(zs),{open:e.open,"onUpdate:open":O[2]||(O[2]=L=>s("update:open",L))},{default:g(()=>[m(r(Ws),{class:"max-w-lg"},{default:g(()=>[m(r(Ks),{class:"text-base"},{default:g(()=>[U(v(r(o)("sources.modelsTitle")),1)]),_:1}),m(r(Gs),{class:"sr-only"},{default:g(()=>{var L;return[U(v(r(o)("sources.modelsDesc",{name:((L=e.provider)==null?void 0:L.name)??""})),1)]}),_:1}),x("div",VT,[x("div",UT,[x("div",HT,[m(r(du),{class:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),m(r(mt),{ref_key:"inputRef",ref:c,modelValue:a.value,"onUpdate:modelValue":O[0]||(O[0]=L=>a.value=L),placeholder:r(o)("sources.modelsSearchPh"),autocomplete:"off",spellcheck:"false",class:"pl-8 font-mono",onKeydown:Tn(fe,["esc"])},null,8,["modelValue","placeholder"])]),m(r(we),{variant:"outline",size:"icon",class:"size-9 shrink-0",disabled:u.value!=="",title:r(o)("sources.refreshModels"),"aria-label":r(o)("sources.refreshModels"),onClick:I},{default:g(()=>[u.value==="refresh"?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),V(r(Vs),{key:1,class:"h-4 w-4"}))]),_:1},8,["disabled","title","aria-label"])]),x("div",jT,[x("div",zT,[m(r(Yn),{class:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),m(r(mt),{ref_key:"addRef",ref:d,modelValue:l.value,"onUpdate:modelValue":O[1]||(O[1]=L=>l.value=L),placeholder:r(o)("sources.modelsAddPh"),autocomplete:"off",spellcheck:"false",class:"pl-8 font-mono",onKeydown:Tn(Re(D,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"])]),m(r(we),{variant:"outline",class:"shrink-0",disabled:!M.value||u.value!=="",onClick:D},{default:g(()=>[u.value==="add"?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),V(r(Yn),{key:1,class:"h-4 w-4"})),U(v(r(o)("sources.modelsAddBtn")),1)]),_:1},8,["disabled"])]),k.value?(h(),N("p",WT,v(r(o)("sources.modelsAddExists",{q:l.value.trim()})),1)):se("",!0),x("div",{ref_key:"listRef",ref:f,class:"max-h-80 divide-y overflow-y-auto rounded-md border"},[E.value.length?(h(),N(he,{key:1},[C.value.length?se("",!0):(h(),N("div",XT,v(r(o)("sources.modelsNoMatch")),1)),(h(!0),N(he,null,Pe(C.value,L=>(h(),N("div",{key:L.name,"data-mname":L.name,class:ge(["flex cursor-pointer items-center gap-2 px-3 py-1.5 transition-colors hover:bg-muted/50",p.value.has(L.name)?"row-flash":""]),title:`${L.name} · ${r(o)("sources.modelCopyTip")}`,onClick:J=>G(L.name)},[x("span",QT,v(L.name),1),ee.value[L.name]?(h(!0),N(he,{key:0},Pe(ee.value[L.name],J=>(h(),V(r(Oe),{key:J.format,variant:J.ok?"success":"destructive",class:"shrink-0 font-mono",title:`${r(Lt)(J.format)} · ${J.status||"?"} · ${J.ms} ms${J.error?" · "+J.error:""}`},{default:g(()=>[U(v(J.ok?"✓":"✗")+" "+v(r(Lt)(J.format))+" "+v(J.ok?`${J.ms}ms`:J.status||"–"),1)]),_:2},1032,["variant","title"]))),128)):se("",!0),L.manual?(h(),V(r(Oe),{key:1,variant:"secondary",class:"shrink-0"},{default:g(()=>[U(v(r(o)("sources.modelTagManual")),1)]),_:1})):se("",!0),L.manual?(h(),N("button",{key:2,type:"button",class:"-mr-1 flex size-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-destructive",disabled:u.value!=="","aria-label":r(o)("sources.modelRemove"),onClick:Re(J=>T(L.name),["stop"])},[m(r(To),{class:"h-3.5 w-3.5"})],8,ZT)):se("",!0),x("button",{type:"button",class:"-mr-1 flex size-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",disabled:Y.value.has(L.name),title:r(o)("sources.testBtn"),"aria-label":`${r(o)("sources.testBtn")} ${L.name}`,onClick:Re(J=>Q(L.name),["stop"])},[Y.value.has(L.name)?(h(),V(r(gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),V(r(Ns),{key:1,class:"h-3.5 w-3.5"}))],8,eA)],10,JT))),128))],64)):(h(),N("div",KT,[x("span",GT,[m(r(zk),{class:"size-4"})]),x("p",YT,v(r(o)("sources.modelsEmpty")),1)]))],512)])]),_:1})]),_:1},8,["open"]))}}),nA=Rm(tA,[["__scopeId","data-v-35cb6f16"]]),sA={class:"space-y-4"},oA={class:"flex flex-wrap items-center justify-between gap-2"},rA={class:"flex items-center gap-2"},aA={class:"text-base font-semibold"},lA={class:"text-sm text-muted-foreground"},iA={key:0,class:"flex items-center gap-2"},uA={class:"flex items-center rounded-md border p-0.5"},cA={key:0,class:"py-8 text-center text-sm text-muted-foreground"},dA={key:1,class:"py-8 text-center text-sm text-destructive"},fA={class:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/15 text-primary"},pA={class:"space-y-1"},mA={class:"font-medium"},hA={class:"max-w-sm text-sm text-muted-foreground"},gA={key:0,class:"flex flex-wrap items-center gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2.5"},vA={class:"min-w-0 flex-1 text-sm"},yA={key:1,class:"grid items-stretch gap-3 md:grid-cols-2"},_A={class:"flex h-full flex-col gap-3 p-4"},bA={class:"flex min-w-0 flex-wrap items-center gap-1.5"},xA={class:"truncate text-sm font-semibold"},wA=["title","aria-label","onClick"],kA={class:"min-w-0 flex-1 space-y-1"},CA={key:0,class:"truncate font-mono text-xs text-muted-foreground"},SA={class:"opacity-60"},$A={key:1,class:"truncate font-mono text-xs text-muted-foreground"},TA={class:"opacity-60"},AA={class:"flex items-center gap-1 border-t pt-3"},EA={key:2,class:"overflow-hidden rounded-lg border"},OA={class:"flex flex-wrap gap-1"},PA={class:"max-w-[300px] space-y-0.5 font-mono text-xs text-muted-foreground"},MA=["title"],IA={class:"opacity-60"},RA=["title"],LA={class:"opacity-60"},DA=["title"],NA={key:1},FA=["title","aria-label","onClick"],qA={class:"flex items-center justify-end gap-0.5"},BA={class:"space-y-3"},VA={class:"text-xs text-muted-foreground"},UA={key:0,class:"space-y-1.5"},HA={class:"flex flex-wrap gap-1.5"},jA=["onClick"],zA={key:1,class:"space-y-1.5 rounded-md border bg-muted/30 p-2.5"},WA={class:"shrink-0 tabular-nums text-muted-foreground"},KA=["title"],GA={class:"flex justify-end gap-2"},vd="myapikey.view.sources",YA=re({__name:"Sources",emits:["goto"],setup(e,{emit:t}){const{t:n}=ft(),s=t,o=j([]),a=j(!0),l=j(!1),i=j(""),u=j(localStorage.getItem(vd)==="table"?"table":"cards");function c(ve){u.value=ve;try{localStorage.setItem(vd,ve)}catch{}}const d=j(!1),f=j(null);function p(){f.value=null,d.value=!0}function y(ve){f.value=ve,d.value=!0}function $(ve){const ye=o.value.some(Z=>Z.id===ve.id);o.value=ye?o.value.map(Z=>Z.id===ve.id?ve:Z):[...o.value,ve]}const A=j({});async function E(ve){A.value[ve.id]=!0;try{const ye=await Be("POST",`/admin/providers/${ve.id}/discover`);o.value=o.value.map(Z=>Z.id===ve.id?{...Z,discoveredModels:ye.models}:Z),Ue(n("sources.refreshDone",{name:ve.name}),ye.models.length?"success":"default")}catch(ye){Ue(ye.message,"error")}finally{A.value[ve.id]=!1}}const C=j(null),k=j(!1),M=j(!1),S=j(!1),F=j(null),D=j(""),T=j({}),I=j(!1),G=j(null),Y=ae(()=>F.value?po(F.value):[]);function ee(ve){return[...ve.formats,...ve.supportsResponses?["responses"]:[]]}function Q(ve){F.value=ve,D.value=po(ve)[0]??"",T.value=Object.fromEntries(ee(ve).map(ye=>[ye,!0])),G.value=null,S.value=!0}async function fe(){const ve=F.value,ye=D.value.trim();if(!ve||!ye||I.value)return;const Z=ee(ve),xe=Z.filter(_e=>T.value[_e]);if(xe.length){I.value=!0,G.value=null;try{const _e=xe.length<Z.length?xe.map(Le=>`&format=${Le}`).join(""):"",Fe=await Be("POST",`/admin/providers/${ve.id}/test?model=${encodeURIComponent(ye)}${_e}`);G.value=Fe.results}catch(_e){Ue(_e.message,"error")}finally{I.value=!1}}}function R(ve,ye){return ve&&ye in pt?`border-transparent ${pt[ye].solid} text-white shadow-sm`:ve?"border-transparent bg-primary text-primary-foreground shadow-sm":"border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground"}async function O(){const ve=C.value;if(!(!ve||M.value)){M.value=!0;try{await Be("DELETE",`/admin/providers/${ve.id}`),o.value=o.value.filter(ye=>ye.id!==ve.id),Ue(n("sources.removed",{name:ve.name}),"success"),k.value=!1}catch(ye){Ue(ye.message,"error")}finally{M.value=!1}}}function L(ve){return po(ve).length}function J(ve){return L(ve)>0?"found":ve.discoveredAt?"empty":"never"}function ne(ve){const ye=J(ve);return ye==="found"?n("sources.discoveredCount",{n:L(ve)}):n(ye==="empty"?"sources.noModelsFound":"sources.notScanned")}function pe(ve){const ye=J(ve);return n(ye==="empty"?"sources.noModelsHint":ye==="never"?"sources.notScannedHint":"sources.modelsOpenHint")}const K=j(!1),de=j(null);function oe(ve){de.value=ve,K.value=!0}function Ge(ve){return ve in pt?pt[ve].badge:""}async function qe(){l.value=!0,i.value="";try{const[ve,ye]=await Promise.all([Be("GET","/admin/providers"),Be("GET","/admin/models").catch(()=>null)]);o.value=ve.providers,a.value=!!(ye!=null&&ye.models.length)}catch(ve){i.value=ve.message}finally{l.value=!1}}return at(qe),(ve,ye)=>(h(),N("div",sA,[x("div",oA,[x("div",rA,[m(r(wo),{class:"h-4 w-4 text-primary"}),x("span",aA,v(r(n)("sources.pageTitle")),1),x("span",lA,v(r(n)("sources.pageDesc")),1)]),o.value.length?(h(),N("div",iA,[x("div",uA,[m(r(we),{variant:"ghost",size:"icon",class:ge(["h-6 w-6",u.value==="cards"?"bg-accent text-accent-foreground":"text-muted-foreground"]),title:r(n)("common.viewCards"),"aria-label":r(n)("common.viewCards"),onClick:ye[0]||(ye[0]=Z=>c("cards"))},{default:g(()=>[m(r(Em),{class:"h-3.5 w-3.5"})]),_:1},8,["class","title","aria-label"]),m(r(we),{variant:"ghost",size:"icon",class:ge(["h-6 w-6",u.value==="table"?"bg-accent text-accent-foreground":"text-muted-foreground"]),title:r(n)("common.viewTable"),"aria-label":r(n)("common.viewTable"),onClick:ye[1]||(ye[1]=Z=>c("table"))},{default:g(()=>[m(r(Pm),{class:"h-3.5 w-3.5"})]),_:1},8,["class","title","aria-label"])]),m(r(we),{size:"sm",onClick:p},{default:g(()=>[m(r(Yn),{class:"h-4 w-4"}),U(v(r(n)("sources.add")),1)]),_:1})])):se("",!0)]),l.value?(h(),N("p",cA,v(r(n)("common.loading")),1)):i.value?(h(),N("p",dA,v(i.value),1)):o.value.length?(h(),N(he,{key:3},[a.value?se("",!0):(h(),N("div",gA,[x("p",vA,v(r(n)("sources.nextHint")),1),m(r(we),{size:"sm",onClick:ye[2]||(ye[2]=Z=>s("goto","models"))},{default:g(()=>[U(v(r(n)("sources.nextCta")),1)]),_:1})])),u.value==="cards"?(h(),N("div",yA,[(h(!0),N(he,null,Pe(o.value,Z=>(h(),V(r(Vt),{key:Z.id,class:"group cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/30",onClick:xe=>y(Z)},{default:g(()=>[x("div",_A,[x("div",bA,[x("span",xA,v(Z.name),1),(h(!0),N(he,null,Pe(Z.formats,xe=>(h(),V(r(Oe),{key:xe,variant:"outline",class:ge(["shrink-0",Ge(xe)])},{default:g(()=>[U(v(r(Lt)(xe)),1)]),_:2},1032,["class"]))),128)),Z.supportsResponses?(h(),V(r(Oe),{key:0,variant:"outline",class:ge(["shrink-0",r(pt).responses.badge])},{default:g(()=>[U(v(r(Lt)("responses")),1)]),_:1},8,["class"])):se("",!0),Z.rpm?(h(),V(r(Oe),{key:1,variant:"outline",class:"shrink-0",title:r(n)("sources.rpmBadgeHint")},{default:g(()=>[U(v(r(n)("sources.rpmBadge",{n:Z.rpm})),1)]),_:2},1032,["title"])):se("",!0),x("button",{type:"button",class:"shrink-0 rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring",title:pe(Z),"aria-label":r(n)("sources.modelsTitle"),onClick:Re(xe=>oe(Z),["stop"])},[m(r(Oe),{variant:"muted",class:"cursor-pointer gap-1 pr-1.5 transition-colors hover:bg-accent hover:text-accent-foreground"},{default:g(()=>[U(v(ne(Z))+" ",1),m(r(Rn),{class:"size-3 opacity-60"})]),_:2},1024)],8,wA)]),x("div",kA,[Z.formats.includes("openai")?(h(),N("div",CA,[x("span",SA,v(r(Lt)("openai"))+" ·",1),U(" "+v(Z.baseUrlOpenai),1)])):se("",!0),Z.formats.includes("anthropic")?(h(),N("div",$A,[x("span",TA,v(r(Lt)("anthropic"))+" ·",1),U(" "+v(Z.baseUrlAnthropic),1)])):se("",!0)]),x("div",AA,[m(r(we),{variant:"ghost",size:"sm",class:"h-7 gap-1.5 px-2 text-xs",onClick:Re(xe=>Q(Z),["stop"])},{default:g(()=>[m(r(Ns),{class:"h-3.5 w-3.5"}),U(v(r(n)("sources.testBtn")),1)]),_:1},8,["onClick"]),m(r(we),{variant:"ghost",size:"sm",class:"h-7 gap-1.5 px-2 text-xs",disabled:A.value[Z.id],onClick:Re(xe=>E(Z),["stop"])},{default:g(()=>[A.value[Z.id]?(h(),V(r(gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),V(r(Vs),{key:1,class:"h-3.5 w-3.5"})),U(v(r(n)("sources.refreshModels")),1)]),_:2},1032,["disabled","onClick"]),m(r(we),{variant:"ghost",size:"sm",class:"h-7 gap-1.5 px-2 text-xs",onClick:Re(xe=>y(Z),["stop"])},{default:g(()=>[m(r(ao),{class:"h-3.5 w-3.5"}),U(v(r(n)("sources.editLabel")),1)]),_:1},8,["onClick"]),x("div",{class:"ml-auto",onClick:ye[3]||(ye[3]=Re(()=>{},["stop"]))},[m(r(fi),null,{default:g(()=>[m(r(pi),null,{default:g(()=>[m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground","aria-label":r(n)("sources.moreActions")},{default:g(()=>[m(r(hi),{class:"h-4 w-4"})]),_:1},8,["aria-label"])]),_:1}),m(r(mi),{align:"end"},{default:g(()=>[m(r(Vo),{class:"text-destructive focus:bg-destructive/10 focus:text-destructive",onSelect:xe=>{C.value=Z,k.value=!0}},{default:g(()=>[m(r(fr)),U(" "+v(r(n)("sources.deleteLabel")),1)]),_:1},8,["onSelect"])]),_:2},1024)]),_:2},1024)])])])]),_:2},1032,["onClick"]))),128))])):(h(),N("div",EA,[m(r(Qa),null,{default:g(()=>[m(r(Za),null,{default:g(()=>[m(r(Cn),{class:"hover:bg-transparent"},{default:g(()=>[m(r(rt),null,{default:g(()=>[U(v(r(n)("sources.colName")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(n)("sources.colFormats")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(n)("sources.colBaseUrl")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(n)("sources.colRpm")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(n)("sources.colDiscovered")),1)]),_:1}),m(r(rt),{class:"w-[168px] text-right"},{default:g(()=>[U(v(r(n)("sources.colActions")),1)]),_:1})]),_:1})]),_:1}),m(r(el),null,{default:g(()=>[(h(!0),N(he,null,Pe(o.value,Z=>(h(),V(r(Cn),{key:Z.id,class:"cursor-pointer",onClick:xe=>y(Z)},{default:g(()=>[m(r(nt),{class:"max-w-[160px] truncate font-medium",title:Z.name},{default:g(()=>[U(v(Z.name),1)]),_:2},1032,["title"]),m(r(nt),null,{default:g(()=>[x("div",OA,[(h(!0),N(he,null,Pe(Z.formats,xe=>(h(),V(r(Oe),{key:xe,variant:"outline",class:ge(Ge(xe))},{default:g(()=>[U(v(r(Lt)(xe)),1)]),_:2},1032,["class"]))),128)),Z.supportsResponses?(h(),V(r(Oe),{key:0,variant:"outline",class:ge(r(pt).responses.badge)},{default:g(()=>[U(v(r(Lt)("responses")),1)]),_:1},8,["class"])):se("",!0)])]),_:2},1024),m(r(nt),null,{default:g(()=>[x("div",PA,[Z.formats.includes("openai")?(h(),N("div",{key:0,class:"truncate",title:Z.baseUrlOpenai},[x("span",IA,v(r(Lt)("openai"))+" · ",1),U(v(Z.baseUrlOpenai),1)],8,MA)):se("",!0),Z.formats.includes("anthropic")?(h(),N("div",{key:1,class:"truncate",title:Z.baseUrlAnthropic},[x("span",LA,v(r(Lt)("anthropic"))+" · ",1),U(v(Z.baseUrlAnthropic),1)],8,RA)):se("",!0)])]),_:2},1024),m(r(nt),{class:"whitespace-nowrap text-xs text-muted-foreground"},{default:g(()=>[Z.rpm?(h(),N("span",{key:0,title:r(n)("sources.rpmBadgeHint"),class:"font-mono"},v(r(n)("sources.rpmBadge",{n:Z.rpm})),9,DA)):(h(),N("span",NA,"—"))]),_:2},1024),m(r(nt),null,{default:g(()=>[x("button",{type:"button",class:"rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring",title:pe(Z),"aria-label":r(n)("sources.modelsTitle"),onClick:Re(xe=>oe(Z),["stop"])},[m(r(Oe),{variant:"muted",class:"cursor-pointer gap-1 pr-1.5 transition-colors hover:bg-accent hover:text-accent-foreground"},{default:g(()=>[U(v(ne(Z))+" ",1),m(r(Rn),{class:"size-3 opacity-60"})]),_:2},1024)],8,FA)]),_:2},1024),m(r(nt),{onClick:ye[4]||(ye[4]=Re(()=>{},["stop"]))},{default:g(()=>[x("div",qA,[m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground",title:r(n)("sources.testBtn"),"aria-label":r(n)("sources.testBtn"),onClick:xe=>Q(Z)},{default:g(()=>[m(r(Ns),{class:"h-3.5 w-3.5"})]),_:1},8,["title","aria-label","onClick"]),m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground",disabled:A.value[Z.id],title:r(n)("sources.refreshModels"),"aria-label":r(n)("sources.refreshModels"),onClick:xe=>E(Z)},{default:g(()=>[A.value[Z.id]?(h(),V(r(gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),V(r(Vs),{key:1,class:"h-3.5 w-3.5"}))]),_:2},1032,["disabled","title","aria-label","onClick"]),m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-muted-foreground",title:r(n)("sources.editLabel"),"aria-label":r(n)("sources.editLabel"),onClick:xe=>y(Z)},{default:g(()=>[m(r(ao),{class:"h-3.5 w-3.5"})]),_:1},8,["title","aria-label","onClick"]),m(r(we),{variant:"ghost",size:"icon",class:"h-7 w-7 text-destructive hover:text-destructive",title:r(n)("sources.deleteLabel"),"aria-label":r(n)("sources.deleteLabel"),onClick:xe=>{C.value=Z,k.value=!0}},{default:g(()=>[m(r(fr),{class:"h-3.5 w-3.5"})]),_:1},8,["title","aria-label","onClick"])])]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})]))],64)):(h(),V(r(Vt),{key:2},{default:g(()=>[m(r(Zt),{class:"flex flex-col items-center gap-3 py-12 text-center"},{default:g(()=>[x("span",fA,[m(r(wo),{class:"h-5 w-5"})]),x("div",pA,[x("div",mA,v(r(n)("sources.emptyTitle")),1),x("p",hA,v(r(n)("sources.emptyHint")),1)]),m(r(we),{onClick:p},{default:g(()=>[m(r(Yn),{class:"h-4 w-4"}),U(v(r(n)("sources.add")),1)]),_:1})]),_:1})]),_:1})),m(BT,{open:d.value,"onUpdate:open":ye[5]||(ye[5]=Z=>d.value=Z),provider:f.value,onSaved:$},null,8,["open","provider"]),m(nA,{open:K.value,"onUpdate:open":ye[6]||(ye[6]=Z=>K.value=Z),provider:de.value,onSaved:$},null,8,["open","provider"]),m(r(zs),{open:S.value,"onUpdate:open":ye[9]||(ye[9]=Z=>S.value=Z)},{default:g(()=>[m(r(Ws),{class:"max-w-md"},{default:g(()=>[m(r(Ks),{class:"text-base"},{default:g(()=>[U(v(r(n)("sources.testTitle")),1)]),_:1}),m(r(Gs),null,{default:g(()=>[U(v(r(n)("sources.testDesc")),1)]),_:1}),x("div",BA,[x("div",{class:"space-y-1.5",onKeydown:Tn(fe,["enter"])},[m(r(bt),null,{default:g(()=>[U(v(r(n)("sources.testModelLabel")),1)]),_:1}),m(Im,{modelValue:D.value,"onUpdate:modelValue":ye[7]||(ye[7]=Z=>D.value=Z),options:Y.value,placeholder:r(n)("sources.testModelPh")},null,8,["modelValue","options","placeholder"]),x("p",VA,v(r(n)("sources.testModelHint")),1)],32),F.value?(h(),N("div",UA,[m(r(bt),null,{default:g(()=>[U(v(r(n)("sources.formats")),1)]),_:1}),x("div",HA,[(h(!0),N(he,null,Pe(ee(F.value),Z=>(h(),N("button",{key:Z,type:"button",class:ge(["inline-flex items-center rounded-md border px-2 py-0.5 font-mono text-xs font-medium transition-colors",R(!!T.value[Z],Z)]),onClick:xe=>T.value[Z]=!T.value[Z]},v(r(Lt)(Z)),11,jA))),128))])])):se("",!0),G.value?(h(),N("div",zA,[(h(!0),N(he,null,Pe(G.value,Z=>(h(),N("div",{key:Z.format,class:"flex min-w-0 items-center gap-2 text-xs"},[m(r(Oe),{variant:"outline",class:ge(Ge(Z.format))},{default:g(()=>[U(v(r(Lt)(Z.format)),1)]),_:2},1032,["class"]),Z.ok?(h(),V(r(Oe),{key:0,variant:"success",class:"shrink-0"},{default:g(()=>[U(v(r(n)("models.probeOk")),1)]),_:1})):(h(),V(r(Oe),{key:1,variant:"destructive",class:"shrink-0"},{default:g(()=>[U(v(r(n)("models.probeFail"))+" · "+v(Z.status||"?"),1)]),_:2},1024)),x("span",WA,v(Z.ms)+" ms",1),Z.error?(h(),N("span",{key:2,class:"min-w-0 truncate text-destructive",title:Z.error},v(Z.error),9,KA)):se("",!0)]))),128))])):se("",!0)]),x("div",GA,[m(r(we),{variant:"outline",disabled:I.value,onClick:ye[8]||(ye[8]=Z=>S.value=!1)},{default:g(()=>[U(v(r(n)("common.cancel")),1)]),_:1},8,["disabled"]),m(r(we),{disabled:I.value||!D.value.trim(),onClick:fe},{default:g(()=>[I.value?(h(),V(r(gt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),V(r(Ns),{key:1,class:"h-4 w-4"})),U(v(r(n)("sources.testRun")),1)]),_:1},8,["disabled"])])]),_:1})]),_:1},8,["open"]),m(fu,{open:k.value,"onUpdate:open":ye[10]||(ye[10]=Z=>k.value=Z),variant:"destructive",title:r(n)("sources.remove"),description:C.value?r(n)("sources.confirmRemove",{name:C.value.name}):"","confirm-text":r(n)("sources.remove"),loading:M.value,onConfirm:O},null,8,["open","title","description","confirm-text","loading"])]))}}),XA={class:"flex items-center justify-between gap-2"},JA={class:"flex gap-1"},QA={class:"sr-only"},ZA={class:"flex flex-wrap items-center gap-2"},eE={class:"relative flex-1 sm:max-w-sm"},tE={key:0,class:"inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground"},nE={class:"space-y-2.5"},sE={class:"flex items-center justify-between"},oE={class:"text-xs font-medium"},rE={class:"space-y-2"},aE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},lE={class:"text-xs text-muted-foreground"},iE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},uE={class:"text-xs text-muted-foreground"},cE={class:"grid grid-cols-[3.5rem_1fr] items-center gap-2"},dE={class:"text-xs text-muted-foreground"},fE={key:0,class:"flex flex-wrap items-center gap-1.5"},pE={class:"text-muted-foreground"},mE={class:"font-medium"},hE=["aria-label","onClick"],gE={class:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground"},vE={key:1,class:"space-y-2 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3"},yE={class:"flex items-center gap-1.5 text-xs font-medium text-amber-700 dark:text-amber-400"},_E={class:"space-y-1.5"},bE={class:"font-medium"},xE={class:"break-all text-muted-foreground"},wE={key:2,class:"space-y-2 rounded-lg border border-orange-500/30 bg-orange-500/5 p-3"},kE={class:"flex items-center gap-1.5 text-xs font-medium text-orange-700 dark:text-orange-400"},CE={class:"space-y-1.5"},SE={class:"font-medium"},$E={class:"text-muted-foreground"},TE={key:3,class:"py-6 text-center text-sm text-muted-foreground"},AE={key:4,class:"py-6 text-center text-sm text-muted-foreground"},EE={key:5,class:"overflow-x-auto"},OE={class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},PE={class:"font-mono text-muted-foreground"},ME={class:"font-medium"},IE={class:"text-muted-foreground"},RE={class:"text-muted-foreground"},LE={class:"break-all text-muted-foreground"},DE={key:0,class:"text-muted-foreground/60"},NE={class:"inline-flex items-center gap-1.5"},FE={class:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 px-2 py-2 text-xs sm:grid-cols-[auto_1fr_auto_1fr]"},qE={class:"text-muted-foreground"},BE={class:"font-mono"},VE={class:"text-muted-foreground"},UE={class:"font-mono"},HE={class:"text-muted-foreground"},jE={class:"text-muted-foreground"},zE={class:"break-all font-mono"},WE={class:"text-muted-foreground"},KE={class:"flex items-center gap-1.5 font-mono"},GE={class:"text-muted-foreground"},YE={class:"break-all font-mono"},XE={class:"text-muted-foreground"},JE={class:"font-mono"},QE={class:"text-foreground/80"},ZE={class:"text-foreground/80"},eO={class:"text-amber-600 dark:text-amber-400"},tO={class:"text-muted-foreground"},nO={class:"break-all font-mono"},yd="myapikey.logs.filters",sO=re({__name:"Logs",setup(e){const{t}=ft(),n=j([]),s=j(!0),o=j(!1),a=j([]),l=j([]),i=j("all"),u=j("all"),c=j("all"),d=j(""),f=j(new Set),p=j(!1);try{const K=JSON.parse(localStorage.getItem(yd)||"null");K&&(typeof K.model=="string"&&(i.value=K.model),typeof K.provider=="string"&&(u.value=K.provider),(K.status==="success"||K.status==="error")&&(c.value=K.status),typeof K.query=="string"&&(d.value=K.query))}catch{}Ie([i,u,c,d],()=>{try{localStorage.setItem(yd,JSON.stringify({model:i.value,provider:u.value,status:c.value,query:d.value}))}catch{}});let y;async function $(){o.value=!0;try{const[K,de]=await Promise.all([Be("GET","/admin/logs").catch(()=>null),Be("GET","/admin/circuit").catch(()=>null)]);K&&(n.value=K.logs),de&&(a.value=de.providers.filter(oe=>oe.state==="cooling"),l.value=de.providers.filter(oe=>oe.rpm>0&&oe.rpmUsed>=oe.rpm&&oe.state!=="cooling"))}finally{o.value=!1}}async function A(K){await Be("POST",`/admin/circuit/${K}/reset`).catch(()=>{}),await $()}function E(){C(),y=window.setInterval($,4e3)}function C(){y&&(clearInterval(y),y=void 0)}function k(){s.value=!s.value,s.value?($(),E()):C()}function M(K){return K>=200&&K<300?"success":K>=400?"destructive":"muted"}function S(K){var de;return((de=pt[K])==null?void 0:de.badge)??""}function F(K){return K<1e3?`${K}ms`:`${(K/1e3).toFixed(1)}s`}function D(K){return K?K<1e3?String(K):K<1e6?(K/1e3).toFixed(K<1e4?1:0).replace(/\.0$/,"")+"k":(K/1e6).toFixed(1)+"M":"0"}function T(K){if(K<=0)return"0";const de=Math.round(K*1e3)/10;return Number.isInteger(de)?String(de):de.toFixed(1)}function I(K){return new Date(K).toLocaleTimeString()}function G(K){return new Date(K).toLocaleString()}function Y(K){return`${K.ts}-${K.model}-${K.provider}-${K.status}-${K.kind??"call"}`}function ee(K){return f.value.has(Y(K))}function Q(K){const de=new Set(f.value),oe=Y(K);de.has(oe)?de.delete(oe):de.add(oe),f.value=de}const fe=ae(()=>[...new Set(n.value.map(K=>K.model))].sort()),R=ae(()=>[...new Set(n.value.map(K=>K.provider))].sort()),O=ae(()=>{const K=d.value.trim().toLowerCase();return n.value.filter(de=>{var oe;return!(i.value!=="all"&&de.model!==i.value||u.value!=="all"&&de.provider!==u.value||c.value==="success"&&!(de.status>=200&&de.status<300)||c.value==="error"&&de.status<400||K&&!(de.model.toLowerCase().includes(K)||(oe=de.upstreamModel)!=null&&oe.toLowerCase().includes(K)||de.provider.toLowerCase().includes(K)))})}),L=ae(()=>{const K=O.value.filter(qe=>qe.kind!=="cooldown"),de=K.length,oe=K.filter(qe=>qe.status>=400).length,Ge=de?Math.round(K.reduce((qe,ve)=>qe+ve.ms,0)/de):0;return{total:de,fail:oe,avgMs:Ge,errorRateStr:T(de?oe/de:0)}}),J=ae(()=>(i.value!=="all"?1:0)+(u.value!=="all"?1:0)+(c.value!=="all"?1:0)),ne=ae(()=>{const K=[];return i.value!=="all"&&K.push({key:"model",label:t("logs.filter.model"),value:i.value,clear:()=>i.value="all"}),u.value!=="all"&&K.push({key:"provider",label:t("logs.filter.provider"),value:u.value,clear:()=>u.value="all"}),c.value!=="all"&&K.push({key:"status",label:t("logs.filter.status"),value:c.value==="success"?t("logs.filter.success"):t("logs.filter.error"),clear:()=>c.value="all"}),K});function pe(){i.value="all",u.value="all",c.value="all"}return at(()=>{$(),E()}),cn(C),(K,de)=>(h(),V(r(Vt),null,{default:g(()=>[m(r(zn),null,{default:g(()=>[x("div",XA,[m(r(Wn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[m(r(Sm),{class:"h-4 w-4 text-primary"}),U(" "+v(r(t)("logs.title"))+" ",1),s.value?(h(),V(r(Oe),{key:0,variant:"success",class:"gap-1.5"},{default:g(()=>[de[5]||(de[5]=x("span",{class:"relative flex h-1.5 w-1.5"},[x("span",{class:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),x("span",{class:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})],-1)),U(" "+v(r(t)("logs.live")),1)]),_:1})):se("",!0)]),_:1}),x("div",JA,[m(r(we),{variant:"outline",size:"sm",disabled:o.value,onClick:$},{default:g(()=>[o.value?(h(),V(r(gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),V(r(Vs),{key:1,class:"h-3.5 w-3.5"})),x("span",QA,v(r(t)("logs.refresh")),1)]),_:1},8,["disabled"]),m(r(we),{variant:"outline",size:"sm","aria-pressed":s.value,onClick:k},{default:g(()=>[s.value?(h(),V(r(Wk),{key:0,class:"h-3.5 w-3.5"})):(h(),V(r(Kk),{key:1,class:"h-3.5 w-3.5"})),U(" "+v(s.value?r(t)("logs.pause"):r(t)("logs.resume")),1)]),_:1},8,["aria-pressed"])])]),m(r(Ds),null,{default:g(()=>[U(v(r(t)("logs.desc")),1)]),_:1})]),_:1}),m(r(Zt),{class:"space-y-3"},{default:g(()=>[x("div",ZA,[x("div",eE,[m(r(du),{class:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),m(r(mt),{modelValue:d.value,"onUpdate:modelValue":de[0]||(de[0]=oe=>d.value=oe),placeholder:r(t)("logs.searchPh"),class:"h-8 pl-8"},null,8,["modelValue","placeholder"])]),m(r(ga),{open:p.value,"onUpdate:open":de[4]||(de[4]=oe=>p.value=oe)},{default:g(()=>[m(r(va),{"as-child":""},{default:g(()=>[m(r(we),{variant:"outline",size:"sm",class:"h-8 gap-1.5"},{default:g(()=>[m(r(Fk),{class:"h-3.5 w-3.5"}),U(" "+v(r(t)("logs.filter.title"))+" ",1),J.value?(h(),N("span",tE,v(J.value),1)):se("",!0)]),_:1})]),_:1}),m(r(ya),{align:"start",class:"w-72 p-3"},{default:g(()=>[x("div",nE,[x("div",sE,[x("span",oE,v(r(t)("logs.filter.title")),1),J.value?(h(),N("button",{key:0,type:"button",class:"text-xs text-primary hover:underline",onClick:pe},v(r(t)("logs.filter.clear")),1)):se("",!0)]),x("div",rE,[x("div",aE,[x("span",lE,v(r(t)("logs.filter.model")),1),m(r(Hr),{modelValue:i.value,"onUpdate:modelValue":de[1]||(de[1]=oe=>i.value=oe)},{default:g(()=>[m(r(jr),{class:"h-8 w-full"},{default:g(()=>[m(r(zr),{placeholder:r(t)("logs.filter.model")},null,8,["placeholder"])]),_:1}),m(r(Wr),null,{default:g(()=>[m(r(ds),{value:"all"},{default:g(()=>[U(v(r(t)("logs.filter.all")),1)]),_:1}),(h(!0),N(he,null,Pe(fe.value,oe=>(h(),V(r(ds),{key:oe,value:oe},{default:g(()=>[U(v(oe),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])]),x("div",iE,[x("span",uE,v(r(t)("logs.filter.provider")),1),m(r(Hr),{modelValue:u.value,"onUpdate:modelValue":de[2]||(de[2]=oe=>u.value=oe)},{default:g(()=>[m(r(jr),{class:"h-8 w-full"},{default:g(()=>[m(r(zr),{placeholder:r(t)("logs.filter.provider")},null,8,["placeholder"])]),_:1}),m(r(Wr),null,{default:g(()=>[m(r(ds),{value:"all"},{default:g(()=>[U(v(r(t)("logs.filter.all")),1)]),_:1}),(h(!0),N(he,null,Pe(R.value,oe=>(h(),V(r(ds),{key:oe,value:oe},{default:g(()=>[U(v(oe),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])]),x("div",cE,[x("span",dE,v(r(t)("logs.filter.status")),1),m(r(Hr),{modelValue:c.value,"onUpdate:modelValue":de[3]||(de[3]=oe=>c.value=oe)},{default:g(()=>[m(r(jr),{class:"h-8 w-full"},{default:g(()=>[m(r(zr),{placeholder:r(t)("logs.filter.status")},null,8,["placeholder"])]),_:1}),m(r(Wr),null,{default:g(()=>[m(r(ds),{value:"all"},{default:g(()=>[U(v(r(t)("logs.filter.all")),1)]),_:1}),m(r(ds),{value:"success"},{default:g(()=>[U(v(r(t)("logs.filter.success")),1)]),_:1}),m(r(ds),{value:"error"},{default:g(()=>[U(v(r(t)("logs.filter.error")),1)]),_:1})]),_:1})]),_:1},8,["modelValue"])])])])]),_:1})]),_:1},8,["open"])]),ne.value.length?(h(),N("div",fE,[(h(!0),N(he,null,Pe(ne.value,oe=>(h(),N("span",{key:oe.key,class:"inline-flex items-center gap-1 rounded-full border border-input bg-muted/40 py-0.5 pl-2.5 pr-1 text-xs"},[x("span",pE,v(oe.label)+":",1),x("span",mE,v(oe.value),1),x("button",{type:"button",class:"rounded-full p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":r(t)("logs.filter.remove",{label:oe.label}),onClick:oe.clear},[m(r(To),{class:"h-3 w-3"})],8,hE)]))),128)),x("button",{type:"button",class:"text-xs text-muted-foreground hover:text-foreground",onClick:pe},v(r(t)("logs.filter.clear")),1)])):se("",!0),x("div",gE,[x("span",null,v(r(t)("logs.summary.window",{n:L.value.total})),1),x("span",{class:ge({"text-destructive":L.value.fail>0})},v(r(t)("logs.summary.errorRate",{pct:L.value.errorRateStr})),3),x("span",null,v(r(t)("logs.summary.avgLatency",{ms:F(L.value.avgMs)})),1)]),a.value.length?(h(),N("div",vE,[x("div",yE,[m(r($l),{class:"h-4 w-4"}),U(" "+v(r(t)("logs.circuit.stripTitle")),1)]),x("ul",_E,[(h(!0),N(he,null,Pe(a.value,oe=>(h(),N("li",{key:oe.id,class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},[x("span",bE,v(oe.name),1),m(r(Oe),{variant:"warning",class:"gap-1 whitespace-nowrap"},{default:g(()=>[m(r($l),{class:"h-3 w-3"}),U(" "+v(r(t)("logs.circuit.remaining",{s:oe.secondsLeft})),1)]),_:2},1024),x("span",xE,v(oe.lastReason||r(t)("logs.circuit.reasonUnknown")),1),m(r(we),{variant:"outline",size:"sm",class:"ml-auto h-6 gap-1",onClick:Ge=>A(oe.id)},{default:g(()=>[m(r(Vs),{class:"h-3 w-3"}),U(" "+v(r(t)("logs.circuit.reset")),1)]),_:1},8,["onClick"])]))),128))])])):se("",!0),l.value.length?(h(),N("div",wE,[x("div",kE,[m(r(Go),{class:"h-4 w-4"}),U(" "+v(r(t)("logs.pacing.stripTitle")),1)]),x("ul",CE,[(h(!0),N(he,null,Pe(l.value,oe=>(h(),N("li",{key:oe.id,class:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"},[x("span",SE,v(oe.name),1),m(r(Oe),{variant:"outline",class:"gap-1 whitespace-nowrap"},{default:g(()=>[m(r(Go),{class:"h-3 w-3"}),U(" "+v(r(t)("logs.pacing.at",{used:oe.rpmUsed,cap:oe.rpm})),1)]),_:2},1024),x("span",$E,v(r(t)("logs.pacing.reason")),1)]))),128))])])):se("",!0),n.value.length?O.value.length?(h(),N("div",EE,[m(r(Qa),null,{default:g(()=>[m(r(Za),null,{default:g(()=>[m(r(Cn),null,{default:g(()=>[m(r(rt),{class:"w-8"}),m(r(rt),null,{default:g(()=>[U(v(r(t)("logs.col.time")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(t)("logs.col.model")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(t)("logs.col.provider")),1)]),_:1}),m(r(rt),null,{default:g(()=>[U(v(r(t)("logs.col.format")),1)]),_:1}),m(r(rt),{class:"text-right"},{default:g(()=>[U(v(r(t)("logs.col.latency")),1)]),_:1}),m(r(rt),{class:"text-right"},{default:g(()=>[U(v(r(t)("logs.col.status")),1)]),_:1})]),_:1})]),_:1}),m(r(el),null,{default:g(()=>[(h(!0),N(he,null,Pe(O.value,oe=>(h(),N(he,{key:Y(oe)},[oe.kind==="cooldown"?(h(),V(r(Cn),{key:0,class:"bg-amber-500/5 hover:bg-amber-500/10"},{default:g(()=>[m(r(nt),{colspan:"7",class:"py-2"},{default:g(()=>[x("div",OE,[x("span",PE,v(I(oe.ts)),1),m(r(Oe),{variant:"warning",class:"gap-1 whitespace-nowrap"},{default:g(()=>[m(r($l),{class:"h-3 w-3"}),U(" "+v(r(t)("logs.circuit.badge")),1)]),_:1}),x("span",ME,v(oe.provider),1),x("span",IE,v(r(t)("logs.circuit.failures",{n:oe.fails})),1),x("span",RE,v(r(t)("logs.circuit.cooldown",{s:Math.round((oe.cooldownMs??0)/1e3)})),1),x("span",LE,v(oe.error||r(t)("logs.circuit.reasonUnknown")),1)])]),_:2},1024)]),_:2},1024)):(h(),N(he,{key:1},[m(r(Cn),{class:"cursor-pointer hover:bg-muted/50",onClick:Ge=>Q(oe)},{default:g(()=>[m(r(nt),{class:"w-8 text-muted-foreground"},{default:g(()=>[(h(),V(yr(ee(oe)?r(Rn):r(Tm)),{class:"h-3.5 w-3.5"}))]),_:2},1024),m(r(nt),{class:"font-mono text-xs text-muted-foreground",title:G(oe.ts)},{default:g(()=>[U(v(I(oe.ts)),1)]),_:2},1032,["title"]),m(r(nt),{class:"font-mono text-xs"},{default:g(()=>[U(v(oe.model),1),oe.upstreamModel?(h(),N("span",DE," → "+v(oe.upstreamModel),1)):se("",!0)]),_:2},1024),m(r(nt),{class:"text-sm"},{default:g(()=>[U(v(oe.provider),1)]),_:2},1024),m(r(nt),null,{default:g(()=>[x("span",NE,[m(r(Oe),{variant:"outline",class:ge(S(oe.format))},{default:g(()=>[U(v(r(Lt)(oe.format)),1)]),_:2},1032,["class"]),oe.stream?(h(),V(r(Oe),{key:0,variant:"muted",class:"text-[10px]"},{default:g(()=>[U(v(r(t)("logs.stream")),1)]),_:1})):se("",!0),oe.thinking?(h(),V(r(Oe),{key:1,variant:"muted",class:"gap-1 font-mono text-[10px]",title:r(t)("logs.detail.thinking")+" · "+(oe.thinking.from==="default"?r(t)("logs.thinkingDefault"):r(t)("logs.thinkingClient"))},{default:g(()=>[m(r(xo),{class:"h-3 w-3"}),U(v(oe.thinking.value),1)]),_:2},1032,["title"])):se("",!0),oe.sampling?(h(),V(r(Oe),{key:2,variant:"muted",class:"gap-1 font-mono text-[10px]",title:r(t)("logs.detail.sampling")},{default:g(()=>[m(r(vs),{class:"h-3 w-3"}),U(v(r(on)(oe.sampling)),1)]),_:2},1032,["title"])):se("",!0)])]),_:2},1024),m(r(nt),{class:"text-right font-mono text-xs text-muted-foreground"},{default:g(()=>[U(v(F(oe.ms)),1)]),_:2},1024),m(r(nt),{class:"text-right"},{default:g(()=>[m(r(Oe),{variant:M(oe.status),class:"font-mono"},{default:g(()=>[U(v(oe.status),1)]),_:2},1032,["variant"])]),_:2},1024)]),_:2},1032,["onClick"]),ee(oe)?(h(),V(r(Cn),{key:0,class:"hover:bg-transparent"},{default:g(()=>[m(r(nt),{colspan:"7",class:"bg-muted/30"},{default:g(()=>[x("dl",FE,[x("dt",qE,v(r(t)("logs.detail.time")),1),x("dd",BE,v(G(oe.ts)),1),x("dt",VE,v(r(t)("logs.detail.latency")),1),x("dd",UE,v(F(oe.ms)),1),x("dt",HE,v(r(t)("logs.detail.stream")),1),x("dd",null,v(oe.stream?r(t)("logs.detail.streamYes"):r(t)("logs.detail.streamNo")),1),oe.upstreamModel?(h(),N(he,{key:0},[x("dt",jE,v(r(t)("logs.detail.upstreamModel")),1),x("dd",zE,v(oe.upstreamModel),1)],64)):se("",!0),oe.thinking?(h(),N(he,{key:1},[x("dt",WE,v(r(t)("logs.detail.thinking")),1),x("dd",KE,[U(v(oe.thinking.value)+" ",1),m(r(Oe),{variant:"muted",class:"text-[10px]"},{default:g(()=>[U(v(oe.thinking.from==="default"?r(t)("logs.thinkingDefault"):r(t)("logs.thinkingClient")),1)]),_:2},1024)])],64)):se("",!0),oe.sampling?(h(),N(he,{key:2},[x("dt",GE,v(r(t)("logs.detail.sampling")),1),x("dd",YE,v(r(q_)(oe.sampling)),1)],64)):se("",!0),oe.usage?(h(),N(he,{key:3},[x("dt",XE,v(r(t)("logs.detail.tokens")),1),x("dd",JE,[x("span",QE,"↑ "+v(D(oe.usage.input)),1),de[7]||(de[7]=x("span",{class:"text-muted-foreground/50"}," · ",-1)),x("span",ZE,"↓ "+v(D(oe.usage.output)),1),oe.usage.estimated?(h(),V(r(Oe),{key:0,variant:"muted",class:"ml-1.5 text-[10px]"},{default:g(()=>[U("≈ "+v(r(t)("logs.detail.estimated")),1)]),_:1})):se("",!0),(oe.usage.cacheRead||0)+(oe.usage.cacheCreation||0)?(h(),N(he,{key:1},[de[6]||(de[6]=x("span",{class:"text-muted-foreground/50"}," · ",-1)),x("span",eO,"⚡ "+v(r(t)("logs.detail.cache"))+" "+v(D((oe.usage.cacheRead||0)+(oe.usage.cacheCreation||0))),1)],64)):se("",!0)])],64)):se("",!0),x("dt",tO,v(r(t)("logs.detail.error")),1),x("dd",nO,v(oe.error||r(t)("logs.detail.errorNone")),1)])]),_:2},1024)]),_:2},1024)):se("",!0)],64))],64))),128))]),_:1})]),_:1})])):(h(),N("p",AE,v(r(t)("logs.noMatch")),1)):(h(),N("p",TE,v(r(t)("logs.empty")),1))]),_:1})]),_:1}))}}),oO={key:0,class:"py-4 text-center text-xs text-muted-foreground"},rO={class:"flex items-center gap-1.5"},aO={class:"truncate font-mono text-xs"},lO={class:"flex items-center gap-2"},iO={class:"h-1.5 w-full max-w-[120px] overflow-hidden rounded-full bg-muted"},uO={class:"font-mono text-xs tabular-nums"},cO={key:0},dO={class:"text-foreground/80"},fO={class:"text-foreground/80"},pO={key:1,class:"text-muted-foreground/40"},mO={key:0,class:"inline-flex flex-col items-end leading-tight"},hO={class:"text-amber-600 dark:text-amber-400"},gO={class:"text-[10px] text-muted-foreground/60"},vO={key:1,class:"text-muted-foreground/40"},Fr=re({__name:"StatsBreakdown",props:{title:{},buckets:{},max:{},kind:{}},setup(e){const{t}=ft();function n(d){return d<1e3?`${d}ms`:`${(d/1e3).toFixed(1)}s`}function s(d){return d?d<1e3?String(d):d<1e6?(d/1e3).toFixed(d<1e4?1:0).replace(/\.0$/,"")+"k":(d/1e6).toFixed(1)+"M":"0"}function o(d){if(!d)return"0%";const f=Math.round(d*1e3)/10;return(f%1===0?f.toFixed(0):f.toFixed(1))+"%"}const a=e,l=()=>a.buckets.some(d=>d.inputTokens||d.outputTokens),i=()=>a.buckets.some(d=>d.cacheRead||d.cacheCreation);function u(d,f){return f?Math.round(d/f*100):0}function c(d){var f;return(f=pt[d])==null?void 0:f.solid}return(d,f)=>(h(),V(r(Vt),null,{default:g(()=>[m(r(zn),{class:"pb-2"},{default:g(()=>[m(r(Wn),{class:"text-sm"},{default:g(()=>[U(v(e.title),1)]),_:1})]),_:1}),m(r(Zt),null,{default:g(()=>[e.buckets.length?(h(),V(r(Qa),{key:1},{default:g(()=>[m(r(Za),null,{default:g(()=>[m(r(Cn),null,{default:g(()=>[m(r(rt),null,{default:g(()=>[U(v(r(t)("stats.col.name")),1)]),_:1}),m(r(rt),{class:"w-1/3"},{default:g(()=>[U(v(r(t)("stats.col.calls")),1)]),_:1}),m(r(rt),{class:"text-right"},{default:g(()=>[U(v(r(t)("stats.col.success")),1)]),_:1}),m(r(rt),{class:"text-right"},{default:g(()=>[U(v(r(t)("stats.col.error")),1)]),_:1}),m(r(rt),{class:"text-right"},{default:g(()=>[U(v(r(t)("stats.col.avgLatency")),1)]),_:1}),l()?(h(),V(r(rt),{key:0,class:"text-right"},{default:g(()=>[U(v(r(t)("stats.col.tokens")),1)]),_:1})):se("",!0),i()?(h(),V(r(rt),{key:1,class:"text-right"},{default:g(()=>[U(v(r(t)("stats.col.cacheHit")),1)]),_:1})):se("",!0)]),_:1})]),_:1}),m(r(el),null,{default:g(()=>[(h(!0),N(he,null,Pe(e.buckets,p=>(h(),V(r(Cn),{key:p.key},{default:g(()=>[m(r(nt),{class:"py-1.5"},{default:g(()=>[x("div",rO,[e.kind==="format"&&c(p.key)?(h(),N("span",{key:0,class:ge(["h-2 w-2 shrink-0 rounded-full",c(p.key)])},null,2)):e.kind==="provider"&&p.id?(h(),N("span",{key:1,class:ge(["h-2 w-2 shrink-0 rounded-full",r(ps)(p.id).solid])},null,2)):se("",!0),x("span",aO,v(e.kind==="format"?r(Lt)(p.key):p.key),1)])]),_:2},1024),m(r(nt),{class:"py-1.5"},{default:g(()=>[x("div",lO,[x("div",iO,[x("div",{class:"h-full rounded-full bg-primary/50",style:en({width:u(p.calls,e.max)+"%"})},null,4)]),x("span",uO,v(p.calls),1)])]),_:2},1024),m(r(nt),{class:"py-1.5 text-right font-mono text-xs text-emerald-600 dark:text-emerald-400"},{default:g(()=>[U(v(p.success),1)]),_:2},1024),m(r(nt),{class:ge(["py-1.5 text-right font-mono text-xs",p.error?"text-destructive":"text-muted-foreground"])},{default:g(()=>[U(v(p.error),1)]),_:2},1032,["class"]),m(r(nt),{class:"py-1.5 text-right font-mono text-xs text-muted-foreground"},{default:g(()=>[U(v(n(p.avgMs)),1)]),_:2},1024),l()?(h(),V(r(nt),{key:0,class:"py-1.5 text-right font-mono text-xs tabular-nums"},{default:g(()=>[p.inputTokens||p.outputTokens?(h(),N("span",cO,[x("span",dO,v(s(p.inputTokens)),1),f[0]||(f[0]=x("span",{class:"text-muted-foreground/50"}," / ",-1)),x("span",fO,v(s(p.outputTokens)),1)])):(h(),N("span",pO,"—"))]),_:2},1024)):se("",!0),i()?(h(),V(r(nt),{key:1,class:"py-1.5 text-right font-mono text-xs tabular-nums"},{default:g(()=>[p.cacheRead||p.cacheCreation?(h(),N("span",mO,[x("span",hO,v(o(p.cacheHitRate)),1),x("span",gO,"↑"+v(s(p.cacheRead)),1)])):(h(),N("span",vO,"—"))]),_:2},1024)):se("",!0)]),_:2},1024))),128))]),_:1})]),_:1})):(h(),N("p",oO,v(r(t)("stats.empty")),1))]),_:1})]),_:1}))}}),yO={class:"flex flex-wrap items-center justify-between gap-2"},_O={class:"flex items-center gap-2"},bO={class:"inline-flex rounded-md border bg-muted/30 p-0.5"},xO=["onClick"],wO={class:"sr-only"},kO={key:0,class:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground"},CO={key:1,class:"py-10 text-center text-sm text-muted-foreground"},SO={class:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6"},$O={class:"rounded-lg border bg-muted/20 p-3"},TO={class:"text-xs text-muted-foreground"},AO={class:"mt-1 font-mono text-xl tabular-nums"},EO={class:"rounded-lg border bg-muted/20 p-3"},OO={class:"text-xs text-muted-foreground"},PO={class:"mt-1 font-mono text-xl tabular-nums text-emerald-600 dark:text-emerald-400"},MO={class:"rounded-lg border bg-muted/20 p-3"},IO={class:"text-xs text-muted-foreground"},RO={class:"mt-1 font-mono text-xl tabular-nums text-destructive"},LO={class:"rounded-lg border bg-muted/20 p-3"},DO={class:"text-xs text-muted-foreground"},NO={class:"mt-1 font-mono text-xl tabular-nums"},FO={class:"rounded-lg border bg-muted/20 p-3"},qO={class:"text-xs text-muted-foreground"},BO={class:"mt-1 font-mono text-xl tabular-nums"},VO={class:"rounded-lg border bg-muted/20 p-3"},UO={class:"text-xs text-muted-foreground"},HO={class:"mt-1 font-mono text-xl tabular-nums"},jO={key:0,class:"grid grid-cols-3 gap-2"},zO={class:"rounded-lg border bg-muted/20 p-3"},WO={class:"text-xs text-muted-foreground"},KO={class:"mt-1 font-mono text-lg tabular-nums"},GO={class:"rounded-lg border bg-muted/20 p-3"},YO={class:"text-xs text-muted-foreground"},XO={class:"mt-1 font-mono text-lg tabular-nums"},JO={class:"rounded-lg border bg-muted/20 p-3"},QO={class:"text-xs text-muted-foreground"},ZO={class:"mt-1 font-mono text-lg tabular-nums"},eP={class:"mb-2 flex items-center justify-between gap-2"},tP={class:"text-sm font-medium"},nP={key:0,class:"text-[11px] text-muted-foreground"},sP={class:"font-mono tabular-nums text-foreground"},oP={class:"rounded-lg border p-3"},rP={class:"relative pt-9"},aP={class:"flex h-40 gap-px"},lP={class:"pointer-events-none absolute bottom-full left-1/2 z-20 mb-1 hidden -translate-x-1/2 whitespace-nowrap rounded-md border bg-background px-2 py-1 text-center text-xs shadow-md group-hover:block"},iP={class:"font-medium"},uP={class:"font-mono tabular-nums"},cP={class:"text-[10px]"},dP={class:"text-emerald-600 dark:text-emerald-400"},fP={class:"text-destructive"},pP={class:"mt-1.5 flex justify-between text-[10px] text-muted-foreground"},mP={class:"grid gap-4 lg:grid-cols-2"},hP={class:"lg:col-span-2"},gP={key:1,class:"space-y-3"},vP={class:"text-sm font-medium"},yP={class:"grid gap-4 lg:grid-cols-2"},_d=160,_P=re({__name:"Stats",setup(e){const{t}=ft(),n=[{v:"24h",key:"h24"},{v:"7d",key:"d7"},{v:"30d",key:"d30"},{v:"90d",key:"d90"},{v:"all",key:"all"}],s=j(localStorage.getItem("myapikey.stats.range")||"7d");n.some(M=>M.v===s.value)||(s.value="7d"),Ie(s,M=>{try{localStorage.setItem("myapikey.stats.range",M)}catch{}});const o=j(null),a=j(!1);async function l(){a.value=!0;try{o.value=await Be("GET",`/admin/stats?range=${s.value}`)}catch{o.value=null}finally{a.value=!1}}Ie(s,l),at(l);function i(M){return M<1e3?`${M}ms`:`${(M/1e3).toFixed(1)}s`}function u(M){if(!M)return"0%";const S=Math.round(M*1e3)/10;return(S%1===0?S.toFixed(0):S.toFixed(1))+"%"}function c(M){const[S,F,D]=M.split("-").map(Number);return new Date(S,F-1,D).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const d=ae(()=>{var M;return((M=o.value)==null?void 0:M.byDay.reduce((S,F)=>Math.max(S,F.calls),0))??0});function f(M){const S=d.value||1,F=M.calls/S*_d,D=M.error/S*_d;return{success:Math.max(0,Math.round(F-D)),error:Math.round(D)}}function p(M){return M.reduce((S,F)=>Math.max(S,F.calls),0)||1}const y=ae(()=>!!o.value&&o.value.totals.calls>0),$=ae(()=>{var M,S;return(((M=o.value)==null?void 0:M.totals.cacheRead)??0)+(((S=o.value)==null?void 0:S.totals.cacheCreation)??0)}),A=ae(()=>!!o.value&&!!(o.value.totals.inputTokens||o.value.totals.outputTokens||$.value)),E=ae(()=>{var F;const M=(((F=o.value)==null?void 0:F.byProviderModel)??[]).filter(D=>D.cacheRead||D.cacheCreation),S=new Map;for(const D of M){const T=D.providerId||D.provider;let I=S.get(T);I||(I={providerId:D.providerId,provider:D.provider,models:[],cacheRead:0},S.set(T,I)),I.models.push({key:D.model,calls:D.calls,success:D.success,error:0,avgMs:0,inputTokens:D.inputTokens,outputTokens:D.outputTokens,cacheRead:D.cacheRead,cacheCreation:D.cacheCreation,cacheHitRate:D.cacheHitRate}),I.cacheRead+=D.cacheRead}return[...S.values()].sort((D,T)=>T.cacheRead-D.cacheRead)}),C=ae(()=>E.value.length>0);function k(M){return M?M<1e3?String(M):M<1e6?(M/1e3).toFixed(M<1e4?1:0).replace(/\.0$/,"")+"k":(M/1e6).toFixed(1)+"M":"0"}return(M,S)=>(h(),V(r(Vt),null,{default:g(()=>[m(r(zn),null,{default:g(()=>[x("div",yO,[m(r(Wn),{class:"flex items-center gap-2 text-base"},{default:g(()=>[m(r($m),{class:"h-4 w-4 text-primary"}),U(" "+v(r(t)("stats.title")),1)]),_:1}),x("div",_O,[x("div",bO,[(h(),N(he,null,Pe(n,F=>x("button",{key:F.v,type:"button",class:ge(["rounded-sm px-2.5 py-1 text-xs transition-colors",s.value===F.v?"bg-background font-medium shadow-sm":"text-muted-foreground hover:text-foreground"]),onClick:D=>s.value=F.v},v(r(t)(`stats.ranges.${F.key}`)),11,xO)),64))]),m(r(we),{variant:"outline",size:"sm",disabled:a.value,onClick:l},{default:g(()=>[a.value?(h(),V(r(gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),V(r(Vs),{key:1,class:"h-3.5 w-3.5"})),x("span",wO,v(r(t)("stats.refresh")),1)]),_:1},8,["disabled"])])]),m(r(Ds),null,{default:g(()=>[U(v(r(t)("stats.desc")),1)]),_:1})]),_:1}),m(r(Zt),{class:"space-y-5"},{default:g(()=>[a.value&&!o.value?(h(),N("div",kO,[m(r(gt),{class:"h-4 w-4 animate-spin"}),U(" "+v(r(t)("stats.loading")),1)])):y.value?o.value?(h(),N(he,{key:2},[x("div",SO,[x("div",$O,[x("div",TO,v(r(t)("stats.totals.calls")),1),x("div",AO,v(o.value.totals.calls),1)]),x("div",EO,[x("div",OO,v(r(t)("stats.totals.success")),1),x("div",PO,v(o.value.totals.success),1)]),x("div",MO,[x("div",IO,v(r(t)("stats.totals.error")),1),x("div",RO,v(o.value.totals.error),1)]),x("div",LO,[x("div",DO,v(r(t)("stats.totals.errorRate")),1),x("div",NO,v(u(o.value.totals.errorRate)),1)]),x("div",FO,[x("div",qO,v(r(t)("stats.totals.avgLatency")),1),x("div",BO,v(i(o.value.totals.avgMs)),1)]),x("div",VO,[x("div",UO,v(r(t)("stats.totals.p95")),1),x("div",HO,v(i(o.value.totals.p95Ms)),1)])]),A.value?(h(),N("div",jO,[x("div",zO,[x("div",WO,"↑ "+v(r(t)("stats.totals.inputTokens")),1),x("div",KO,v(k(o.value.totals.inputTokens)),1)]),x("div",GO,[x("div",YO,"↓ "+v(r(t)("stats.totals.outputTokens")),1),x("div",XO,v(k(o.value.totals.outputTokens)),1)]),x("div",JO,[x("div",QO,"⚡ "+v(r(t)("stats.totals.cache")),1),x("div",ZO,v(k($.value)),1)])])):se("",!0),x("div",null,[x("div",eP,[x("div",tP,v(r(t)("stats.byDay")),1),d.value?(h(),N("div",nP,[U(v(r(t)("stats.peak"))+" ",1),x("span",sP,v(d.value),1)])):se("",!0)]),x("div",oP,[x("div",rP,[x("div",aP,[(h(!0),N(he,null,Pe(o.value.byDay,F=>(h(),N("div",{key:F.day,class:"group relative flex min-w-0 flex-1 cursor-default flex-col justify-end"},[x("div",{style:en({height:f(F).success+"px"}),class:"w-full rounded-t-sm bg-emerald-500/70 transition-colors group-hover:bg-emerald-500"},null,4),x("div",{style:en({height:f(F).error+"px"}),class:ge(["w-full transition-colors group-hover:bg-destructive",f(F).error?"bg-destructive/70":""])},null,6),x("div",lP,[x("div",iP,v(c(F.day)),1),x("div",uP,v(F.calls)+" "+v(r(t)("stats.callsAxis")),1),x("div",cP,[x("span",dP,v(F.success),1),S[0]||(S[0]=x("span",{class:"text-muted-foreground"}," / ",-1)),x("span",fP,v(F.error),1)])])]))),128))])]),x("div",pP,[x("span",null,v(o.value.byDay.length?c(o.value.byDay[0].day):""),1),x("span",null,v(o.value.byDay.length?c(o.value.byDay[o.value.byDay.length-1].day):""),1)])])]),x("div",mP,[x("div",hP,[m(Fr,{title:r(t)("stats.byModel"),buckets:o.value.byModel,max:p(o.value.byModel),kind:"model"},null,8,["title","buckets","max"])]),m(Fr,{title:r(t)("stats.byProvider"),buckets:o.value.byProvider,max:p(o.value.byProvider),kind:"provider"},null,8,["title","buckets","max"]),m(Fr,{title:r(t)("stats.byFormat"),buckets:o.value.byFormat,max:p(o.value.byFormat),kind:"format"},null,8,["title","buckets","max"])]),C.value?(h(),N("div",gP,[x("div",vP,v(r(t)("stats.cacheBySource")),1),x("div",yP,[(h(!0),N(he,null,Pe(E.value,F=>(h(),V(Fr,{key:F.providerId||F.provider,title:F.provider,buckets:F.models,max:p(F.models),kind:"model"},null,8,["title","buckets","max"]))),128))])])):se("",!0)],64)):se("",!0):(h(),N("div",CO,v(r(t)("stats.empty")),1))]),_:1})]),_:1}))}}),bP={class:"space-y-4"},xP={class:"space-y-2"},wP={class:"min-w-0"},kP={class:"mt-0.5 truncate font-mono text-sm"},CP={class:"min-w-0"},SP={class:"mt-0.5 truncate font-mono text-sm"},$P={class:"text-xs text-muted-foreground"},TP={class:"flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 p-3"},AP={class:"min-w-0"},EP={class:"text-xs font-medium text-primary"},OP={class:"truncate font-mono text-sm"},PP={class:"flex items-center gap-1"},MP={class:"overflow-x-auto rounded-md border bg-muted/40 p-3 font-mono text-xs leading-relaxed"},IP=re({__name:"Connect",setup(e){const{t}=ft(),n={openai:"openai",anthropic:"anthropic",responses:"responses",curl:null,"curl-anthropic":"anthropic"};function s(E){const C=n[E];return C?pt[C]:null}const o=j(null),a=j(null),l=j(""),i=j(!1),u=j([]),c=ae(()=>{const E=window.location.hostname;if((E==="localhost"||E==="127.0.0.1")&&a.value){const C=window.location.port;return`${window.location.protocol}//${a.value}${C?":"+C:""}`}return window.location.origin}),d=ae(()=>`${c.value}/openai/v1`),f=ae(()=>`${c.value}/anthropic`);async function p(){o.value=(await Be("GET","/admin/api-key")).apiKey,a.value=(await Be("GET","/admin/connection")).lanIp,u.value=(await Be("GET","/admin/models").catch(()=>({models:[]}))).models}function y(E){var C;return((C=u.value.find(k=>k[E].enabled))==null?void 0:C.name)||"<model>"}async function $(E,C){await xr(C)?(l.value=E,setTimeout(()=>{l.value===E&&(l.value="")},1500)):Ue(t("connect.copyFailed"),"error")}const A=ae(()=>[{key:"openai",title:t("connect.openaiTitle"),text:`export OPENAI_BASE_URL=${d.value}
|
|
330
330
|
export OPENAI_API_KEY=${o.value??""}`},{key:"anthropic",title:t("connect.anthropicTitle"),text:`export ANTHROPIC_BASE_URL=${f.value}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
document.documentElement.classList.add("dark");
|
|
16
16
|
}
|
|
17
17
|
</script>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-u2yni_uP.js"></script>
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/index-BmLbtmEY.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|