diff --git a/changelog/unreleased/access-raw-api-toggle-placement.md b/changelog/unreleased/access-raw-api-toggle-placement.md new file mode 100644 index 00000000..52229690 --- /dev/null +++ b/changelog/unreleased/access-raw-api-toggle-placement.md @@ -0,0 +1,7 @@ +### English + +- Access page: the Show raw API control sits beside the Native API title (not far right), and uses a secondary button when collapsed so it is easier to find. + +### 中文 + +- Access 页:「展开原始 API」按钮紧挨「原生 API」标题(不再靠右),收起态使用 secondary 按钮样式,更容易发现。 diff --git a/frontend/src/components/access/RawApiPanel.tsx b/frontend/src/components/access/RawApiPanel.tsx index 9a744c4c..1aac35c0 100644 --- a/frontend/src/components/access/RawApiPanel.tsx +++ b/frontend/src/components/access/RawApiPanel.tsx @@ -42,14 +42,14 @@ export function RawApiPanel({ return (
-
-
+
+

{t('accessTabApi')}

-

{t('nativeApiHint')}

+
- +

{t('nativeApiHint')}

{open ? ( diff --git a/internal/webui/static/assets/AreaChart-CpgbhahE.js b/internal/webui/static/assets/AreaChart-BZEGDE2D.js similarity index 60% rename from internal/webui/static/assets/AreaChart-CpgbhahE.js rename to internal/webui/static/assets/AreaChart-BZEGDE2D.js index 22a2ddcf..a412f051 100644 --- a/internal/webui/static/assets/AreaChart-CpgbhahE.js +++ b/internal/webui/static/assets/AreaChart-BZEGDE2D.js @@ -1 +1 @@ -import{f as e,h as t}from"./index-A4ivp0An.js";import{L as n,t as r}from"./CartesianChart-BkZGKHVn.js";var i=t(e()),a=[`axis`],o=(0,i.forwardRef)((e,t)=>i.createElement(r,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:a,tooltipPayloadSearcher:n,categoricalChartProps:e,ref:t}));export{o as t}; \ No newline at end of file +import{f as e,h as t}from"./index-Cg5HTsPm.js";import{L as n,t as r}from"./CartesianChart-SZzrkft1.js";var i=t(e()),a=[`axis`],o=(0,i.forwardRef)((e,t)=>i.createElement(r,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:a,tooltipPayloadSearcher:n,categoricalChartProps:e,ref:t}));export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/CartesianChart-BkZGKHVn.js b/internal/webui/static/assets/CartesianChart-SZzrkft1.js similarity index 99% rename from internal/webui/static/assets/CartesianChart-BkZGKHVn.js rename to internal/webui/static/assets/CartesianChart-SZzrkft1.js index 3a07bbc5..fa130d97 100644 --- a/internal/webui/static/assets/CartesianChart-BkZGKHVn.js +++ b/internal/webui/static/assets/CartesianChart-SZzrkft1.js @@ -1,4 +1,4 @@ -import{c as e,d as t,f as n,h as r,m as i,p as a,u as o}from"./index-A4ivp0An.js";var s=r(n()),c=`dangerouslySetInnerHTML.onCopy.onCopyCapture.onCut.onCutCapture.onPaste.onPasteCapture.onCompositionEnd.onCompositionEndCapture.onCompositionStart.onCompositionStartCapture.onCompositionUpdate.onCompositionUpdateCapture.onFocus.onFocusCapture.onBlur.onBlurCapture.onChange.onChangeCapture.onBeforeInput.onBeforeInputCapture.onInput.onInputCapture.onReset.onResetCapture.onSubmit.onSubmitCapture.onInvalid.onInvalidCapture.onLoad.onLoadCapture.onError.onErrorCapture.onKeyDown.onKeyDownCapture.onKeyPress.onKeyPressCapture.onKeyUp.onKeyUpCapture.onAbort.onAbortCapture.onCanPlay.onCanPlayCapture.onCanPlayThrough.onCanPlayThroughCapture.onDurationChange.onDurationChangeCapture.onEmptied.onEmptiedCapture.onEncrypted.onEncryptedCapture.onEnded.onEndedCapture.onLoadedData.onLoadedDataCapture.onLoadedMetadata.onLoadedMetadataCapture.onLoadStart.onLoadStartCapture.onPause.onPauseCapture.onPlay.onPlayCapture.onPlaying.onPlayingCapture.onProgress.onProgressCapture.onRateChange.onRateChangeCapture.onSeeked.onSeekedCapture.onSeeking.onSeekingCapture.onStalled.onStalledCapture.onSuspend.onSuspendCapture.onTimeUpdate.onTimeUpdateCapture.onVolumeChange.onVolumeChangeCapture.onWaiting.onWaitingCapture.onAuxClick.onAuxClickCapture.onClick.onClickCapture.onContextMenu.onContextMenuCapture.onDoubleClick.onDoubleClickCapture.onDrag.onDragCapture.onDragEnd.onDragEndCapture.onDragEnter.onDragEnterCapture.onDragExit.onDragExitCapture.onDragLeave.onDragLeaveCapture.onDragOver.onDragOverCapture.onDragStart.onDragStartCapture.onDrop.onDropCapture.onMouseDown.onMouseDownCapture.onMouseEnter.onMouseLeave.onMouseMove.onMouseMoveCapture.onMouseOut.onMouseOutCapture.onMouseOver.onMouseOverCapture.onMouseUp.onMouseUpCapture.onSelect.onSelectCapture.onTouchCancel.onTouchCancelCapture.onTouchEnd.onTouchEndCapture.onTouchMove.onTouchMoveCapture.onTouchStart.onTouchStartCapture.onPointerDown.onPointerDownCapture.onPointerMove.onPointerMoveCapture.onPointerUp.onPointerUpCapture.onPointerCancel.onPointerCancelCapture.onPointerEnter.onPointerEnterCapture.onPointerLeave.onPointerLeaveCapture.onPointerOver.onPointerOverCapture.onPointerOut.onPointerOutCapture.onGotPointerCapture.onGotPointerCaptureCapture.onLostPointerCapture.onLostPointerCaptureCapture.onScroll.onScrollCapture.onWheel.onWheelCapture.onAnimationStart.onAnimationStartCapture.onAnimationEnd.onAnimationEndCapture.onAnimationIteration.onAnimationIterationCapture.onTransitionEnd.onTransitionEndCapture`.split(`.`);function l(e){return typeof e==`string`&&c.includes(e)}var u=new Set(`aria-activedescendant.aria-atomic.aria-autocomplete.aria-busy.aria-checked.aria-colcount.aria-colindex.aria-colspan.aria-controls.aria-current.aria-describedby.aria-details.aria-disabled.aria-errormessage.aria-expanded.aria-flowto.aria-haspopup.aria-hidden.aria-invalid.aria-keyshortcuts.aria-label.aria-labelledby.aria-level.aria-live.aria-modal.aria-multiline.aria-multiselectable.aria-orientation.aria-owns.aria-placeholder.aria-posinset.aria-pressed.aria-readonly.aria-relevant.aria-required.aria-roledescription.aria-rowcount.aria-rowindex.aria-rowspan.aria-selected.aria-setsize.aria-sort.aria-valuemax.aria-valuemin.aria-valuenow.aria-valuetext.className.color.height.id.lang.max.media.method.min.name.style.target.width.role.tabIndex.accentHeight.accumulate.additive.alignmentBaseline.allowReorder.alphabetic.amplitude.arabicForm.ascent.attributeName.attributeType.autoReverse.azimuth.baseFrequency.baselineShift.baseProfile.bbox.begin.bias.by.calcMode.capHeight.clip.clipPath.clipPathUnits.clipRule.colorInterpolation.colorInterpolationFilters.colorProfile.colorRendering.contentScriptType.contentStyleType.cursor.cx.cy.d.decelerate.descent.diffuseConstant.direction.display.divisor.dominantBaseline.dur.dx.dy.edgeMode.elevation.enableBackground.end.exponent.externalResourcesRequired.fill.fillOpacity.fillRule.filter.filterRes.filterUnits.floodColor.floodOpacity.focusable.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.format.from.fx.fy.g1.g2.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.glyphRef.gradientTransform.gradientUnits.hanging.horizAdvX.horizOriginX.href.ideographic.imageRendering.in2.in.intercept.k1.k2.k3.k4.k.kernelMatrix.kernelUnitLength.kerning.keyPoints.keySplines.keyTimes.lengthAdjust.letterSpacing.lightingColor.limitingConeAngle.local.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.mathematical.mode.numOctaves.offset.opacity.operator.order.orient.orientation.origin.overflow.overlinePosition.overlineThickness.paintOrder.panose1.pathLength.patternContentUnits.patternTransform.patternUnits.pointerEvents.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.r.radius.refX.refY.renderingIntent.repeatCount.repeatDur.requiredExtensions.requiredFeatures.restart.result.rotate.rx.ry.seed.shapeRendering.slope.spacing.specularConstant.specularExponent.speed.spreadMethod.startOffset.stdDeviation.stemh.stemv.stitchTiles.stopColor.stopOpacity.strikethroughPosition.strikethroughThickness.string.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.surfaceScale.systemLanguage.tableValues.targetX.targetY.textAnchor.textDecoration.textLength.textRendering.to.transform.u1.u2.underlinePosition.underlineThickness.unicode.unicodeBidi.unicodeRange.unitsPerEm.vAlphabetic.values.vectorEffect.version.vertAdvY.vertOriginX.vertOriginY.vHanging.vIdeographic.viewTarget.visibility.vMathematical.widths.wordSpacing.writingMode.x1.x2.x.xChannelSelector.xHeight.xlinkActuate.xlinkArcrole.xlinkHref.xlinkRole.xlinkShow.xlinkTitle.xlinkType.xmlBase.xmlLang.xmlns.xmlnsXlink.xmlSpace.y1.y2.y.yChannelSelector.z.zoomAndPan.ref.key.angle`.split(`.`));function d(e){return typeof e==`string`&&u.has(e)}function f(e){return typeof e==`string`&&e.startsWith(`data-`)}function p(e){if(typeof e!=`object`||!e)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(d(n)||f(n))&&(t[n]=e[n]);return t}function m(e){if(e==null)return null;if((0,s.isValidElement)(e)&&typeof e.props==`object`&&e.props!==null){var t=e.props;return p(t)}return typeof e==`object`&&!Array.isArray(e)?p(e):null}function h(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(d(n)||f(n)||l(n))&&(t[n]=e[n]);return t}function g(e){return e==null?null:(0,s.isValidElement)(e)?h(e.props):typeof e==`object`&&!Array.isArray(e)?h(e):null}var _=r(t()),v=[`children`,`width`,`height`,`viewBox`,`className`,`style`,`title`,`desc`];function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.width,i=e.height,a=e.viewBox,c=e.className,l=e.style,u=e.title,d=e.desc,f=b(e,v),p=a||{width:r,height:i,x:0,y:0},m=o(`recharts-surface`,c);return s.createElement(`svg`,y({},h(f),{className:m,width:r,height:i,style:l,viewBox:`${p.x} ${p.y} ${p.width} ${p.height}`,ref:t}),s.createElement(`title`,null,u),s.createElement(`desc`,null,d),n)}),C=[`children`,`className`];function w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.className,i=T(e,C),a=o(`recharts-layer`,r);return s.createElement(`g`,w({className:a},h(i),{ref:t}),n)});function O(e){return e===`__proto__`}var k=/\.|(\[(?:[^[\]]*|(["'])(?:(?!\2)[^\\]|\\.)*?\2)\])/;function A(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e===``||e.startsWith(`.`)||e.endsWith(`.`)?!1:k.test(e);default:return!1}}function j(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function M(e){return typeof e==`symbol`||e instanceof Symbol}function N(e){return e==null?``:ee(e)}function ee(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(ee).join(`,`);if(M(e))return e.toString();let t=e+``;return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function te(e){if(Array.isArray(e))return e.map(j);if(typeof e==`symbol`)return[e];e=N(e);let t=[],n=e.length;if(n===0)return t;let r=0,i=``,a=``,o=!1,s=!1,c=/^-?\d+(?:\.\d+)?$/;for(e.charCodeAt(0)===46&&t.push(``);r1&&arguments[1]!==void 0?arguments[1]:ie),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function oe(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+ae(i)+n},``)}var se=e=>e===0?0:e>0?1:-1,ce=e=>typeof e==`number`&&e!=+e,le=e=>typeof e==`string`&&e.length>1&&e.indexOf(`%`)===e.length-1,P=e=>(typeof e==`number`||e instanceof Number)&&!ce(e),ue=e=>P(e)||typeof e==`string`,de=0,fe=e=>{var t=++de;return`${e||``}${t}`},pe=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(!P(e)&&typeof e!=`string`)return n;var i;if(le(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return ce(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},me=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;re&&(typeof t==`function`?t(e):ne(e,t))===n)}var _e=e=>e==null,ve=e=>_e(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function ye(e){return e!=null}function be(){}function xe(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function Se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ce(e){for(var t=1;t{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,a=e.parentViewBox,o=e.clamp,s=xe(t),c=s.x,l=s.y,u=s.height,d=s.upperWidth,f=s.lowerWidth,p=c,m=c+(d-f)/2,h=(p+m)/2,g=(d+f)/2,_=p+d/2,v=u>=0?1:-1,y=v*i,b=v>0?`end`:`start`,x=v>0?`start`:`end`,S=d>=0?1:-1,C=S*i,w=S>0?`end`:`start`,T=S>0?`start`:`end`,E=a;if(n===`top`){var D={x:p+d/2,y:l-y,horizontalAnchor:`middle`,verticalAnchor:b};return o&&E&&(D.height=Math.max(l-E.y,0),D.width=d),D}if(n===`bottom`){var O={x:m+f/2,y:l+u+y,horizontalAnchor:`middle`,verticalAnchor:x};return o&&E&&(O.height=Math.max(E.y+E.height-(l+u),0),O.width=f),O}if(n===`left`){var k={x:h-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`};return o&&E&&(k.width=Math.max(k.x-E.x,0),k.height=u),k}if(n===`right`){var A={x:h+g+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`};return o&&E&&(A.width=Math.max(E.x+E.width-A.x,0),A.height=u),A}var j=o&&E?{width:g,height:u}:{};return n===`insideLeft`?Ce({x:h+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`},j):n===`insideRight`?Ce({x:h+g-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`},j):n===`insideTop`?Ce({x:p+d/2,y:l+y,horizontalAnchor:`middle`,verticalAnchor:x},j):n===`insideBottom`?Ce({x:m+f/2,y:l+u-y,horizontalAnchor:`middle`,verticalAnchor:b},j):n===`insideTopLeft`?Ce({x:p+C,y:l+y,horizontalAnchor:T,verticalAnchor:x},j):n===`insideTopRight`?Ce({x:p+d-C,y:l+y,horizontalAnchor:w,verticalAnchor:x},j):n===`insideBottomLeft`?Ce({x:m+C,y:l+u-y,horizontalAnchor:T,verticalAnchor:b},j):n===`insideBottomRight`?Ce({x:m+f-C,y:l+u-y,horizontalAnchor:w,verticalAnchor:b},j):n&&typeof n==`object`&&(P(n.x)||le(n.x))&&(P(n.y)||le(n.y))?Ce({x:c+pe(n.x,g),y:l+pe(n.y,u),horizontalAnchor:`end`,verticalAnchor:`end`},j):Ce({x:_,y:l+u/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},j)},Oe=[`top`,`left`,`right`,`bottom`];function ke(e){return e==null?!1:typeof e==`object`||Oe.includes(e)}var Ae=(0,s.createContext)(null);function F(e){return function(){return e}}var je=Math.PI,Me=2*je,Ne=1e-6,Pe=Me-Ne;function Fe(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return Fe;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;tNe){if(!(Math.abs(u*s-c*l)>Ne)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((je-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>Ne&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>Ne||Math.abs(this._y1-l)>Ne)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%Me+Me),d>Pe?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>Ne&&this._append`A${n},${n},0,${+(d>=je)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};Le.prototype;function Re(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new Le(t)}Array.prototype.slice;function ze(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Be(e){this._context=e}Be.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function Ve(e){return new Be(e)}function He(e){return e[0]}function Ue(e){return e[1]}function We(e,t){var n=F(!0),r=null,i=Ve,a=null,o=Re(s);e=typeof e==`function`?e:e===void 0?He:F(e),t=typeof t==`function`?t:t===void 0?Ue:F(t);function s(s){var c,l=(s=ze(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return We().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:F(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:F(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:F(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:F(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:F(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:F(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:F(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var Ke=class{constructor(e,t){this._context=e,this._x=t}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t)}this._x0=e,this._y0=t}};function qe(e){return new Ke(e,!0)}function Je(e){return new Ke(e,!1)}function Ye(){}function Xe(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Ze(e){this._context=e}Ze.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Xe(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Xe(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Qe(e){return new Ze(e)}function $e(e){this._context=e}$e.prototype={areaStart:Ye,areaEnd:Ye,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Xe(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function et(e){return new $e(e)}function tt(e){this._context=e}tt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Xe(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function nt(e){return new tt(e)}function rt(e){this._context=e}rt.prototype={areaStart:Ye,areaEnd:Ye,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function it(e){return new rt(e)}function at(e){return e<0?-1:1}function ot(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(at(a)+at(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function st(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function ct(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function lt(e){this._context=e}lt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:ct(this,this._t0,st(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,e!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,ct(this,st(this,n=ot(this,e,t)),n);break;default:ct(this,this._t0,n=ot(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function ut(e){this._context=new dt(e)}(ut.prototype=Object.create(lt.prototype)).point=function(e,t){lt.prototype.point.call(this,t,e)};function dt(e){this._context=e}dt.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function ft(e){return new lt(e)}function pt(e){return new ut(e)}function mt(e){this._context=e}mt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n){if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=ht(e),i=ht(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};function vt(e){return new _t(e,.5)}function yt(e){return new _t(e,0)}function bt(e){return new _t(e,1)}function xt(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n=0;)n[t]=t;return n}function Ct(e,t){return e[t]}function wt(e){let t=[];return t.key=e,t}function Tt(){var e=F([]),t=St,n=xt,r=Ct;function i(i){var a=Array.from(e.apply(this,arguments),wt),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r`radius`in e&&`startAngle`in e&&`endAngle`in e,At=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,s.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{l(e)&&typeof n[e]==`function`&&(r[e]=t||(t=>n[e](n,t)))}),r},jt=(e,t,n)=>r=>(e(t,n,r),null),Mt=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];l(i)&&typeof a==`function`&&(r||={},r[i]=jt(a,t,n))}),r};function Nt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Pt(e){for(var t=1;t(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function zt(e){return Number.isSafeInteger(e)&&e>=0}function Bt(e){return e!=null&&typeof e!=`function`&&zt(e.length)}function Vt(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function Ht(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var Ut=`[object RegExp]`,Wt=`[object String]`,Gt=`[object Number]`,Kt=`[object Boolean]`,qt=`[object Arguments]`,Jt=`[object Symbol]`,Yt=`[object Date]`,Xt=`[object Map]`,Zt=`[object Set]`,Qt=`[object Array]`,$t=`[object Function]`,en=`[object ArrayBuffer]`,tn=`[object Object]`,nn=`[object Error]`,rn=`[object DataView]`,an=`[object Uint8Array]`,on=`[object Uint8ClampedArray]`,sn=`[object Uint16Array]`,cn=`[object Uint32Array]`,ln=`[object BigUint64Array]`,un=`[object Int8Array]`,dn=`[object Int16Array]`,fn=`[object Int32Array]`,pn=`[object BigInt64Array]`,mn=`[object Float32Array]`,hn=`[object Float64Array]`,gn=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window||typeof self==`object`&&self||typeof global==`object`&&global||(function(){return this})();function _n(e){return gn.Buffer!==void 0&&gn.Buffer.isBuffer(e)}function vn(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function yn(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}var bn=/^(?:0|[1-9]\d*)$/;function xn(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e{var r=n(),i=e();function a(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var o=typeof Object.is==`function`?Object.is:a,s=i.useSyncExternalStore,c=r.useRef,l=r.useEffect,u=r.useMemo,d=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var a=c(null);if(a.current===null){var f={hasValue:!1,value:null};a.current=f}else f=a.current;a=u(function(){function e(e){if(!a){if(a=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,o(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var a=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=s(e,a[0],a[1]);return l(function(){f.hasValue=!0,f.value=p},[p]),d(p),p}})),Cn=a(((e,t)=>{t.exports=Sn()}))(),wn=(0,s.createContext)(null),Tn=e=>e,I=()=>{var e=(0,s.useContext)(wn);return e?e.store.dispatch:Tn},En=()=>{},Dn=()=>En,On=(e,t)=>e===t;function L(e){var t=(0,s.useContext)(wn),n=(0,s.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:En,[t,e]);return(0,Cn.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:Dn,t?t.store.getState:En,t?t.store.getState:En,n,On)}function kn(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function An(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var jn=e=>Array.isArray(e)?e:[e];function Mn(e){let t=Array.isArray(e[0])?e[0]:e;return An(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function Nn(e,t){let n=[],{length:r}=e;for(let i=0;i`u`?Pn:WeakRef,In=0,Ln=1;function Rn(){return{s:In,v:void 0,o:null,p:null}}function zn(e){return e instanceof Fn?e.deref():e}function Bn(e,t={}){let n=Rn(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e{n=Rn(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Vn(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),kn(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=Bn,argsMemoizeOptions:u=[]}={...n,...a},d=jn(c),f=jn(u),p=Mn(e),m=s(function(){return t++,o.apply(null,arguments)},...d),h=l(function(){r++;let e=Nn(p,arguments);return i=m.apply(null,e),i},...f);return Object.assign(h,{resultFunc:o,memoizedResultFunc:m,dependencies:p,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var R=Vn(Bn);function Hn(e,t=1){let n=[],r=Math.floor(t),i=(e,t)=>{for(let a=0;a{if(e!==t){let r=Wn(e),i=Wn(t);if(r===i&&r===0){if(et)return n===`desc`?-1:1}return n===`desc`?i-r:r-i}return 0},Kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qn=/^\w*$/;function Jn(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||M(e)?!0:typeof e==`string`&&(qn.test(e)||!Kn.test(e))||t!=null&&Object.hasOwn(t,e)}function Yn(e,t,n,r){if(e==null)return[];n=r?void 0:n,Array.isArray(e)||(e=Bt(e)?Array.from(e):Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(e=>String(e));let i=(e,t)=>{let n=e,r=0;for(;r0&&r===t.length?n:void 0},a=(e,t)=>{if(e==null)return t;if(t!=null)return typeof e==`object`&&`key`in e?Object.hasOwn(t,e.key)?t[e.key]:i(t,e.path):typeof e==`function`?e(t):Array.isArray(e)?i(t,e):t[e]},o=t.map(e=>(Array.isArray(e)&&e.length===1&&(e=e[0]),e==null||typeof e==`function`||Array.isArray(e)||Jn(e)?e:{key:e,path:te(e)}));return e.map(e=>({original:e,criteria:o.map(t=>a(t,e))})).slice().sort((e,t)=>{for(let r=0;re.original)}function Xn(e,...t){let n=t.length;return n>1&&Un(e,t[0],t[1])?t=[]:n>2&&Un(t[0],t[1],t[2])&&(t=[t[0]]),Yn(e,Hn(t),[`asc`])}var Zn=e=>e.legend.settings,Qn=e=>e.legend.size;R([e=>e.legend.payload,Zn],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?Xn(r,n):r});function z(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var $n=typeof Symbol==`function`&&Symbol.observable||`@@observable`,er=()=>Math.random().toString(36).substring(7).split(``).join(`.`),tr={INIT:`@@redux/INIT${er()}`,REPLACE:`@@redux/REPLACE${er()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${er()}`};function nr(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function rr(e,t,n){if(typeof e!=`function`)throw Error(z(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(z(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(z(1));return n(rr)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error(z(3));return i}function d(e){if(typeof e!=`function`)throw Error(z(4));if(c)throw Error(z(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error(z(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!nr(e))throw Error(z(7));if(e.type===void 0)throw Error(z(8));if(typeof e.type!=`string`)throw Error(z(17));if(c)throw Error(z(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error(z(10));r=e,f({type:tr.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error(z(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[$n](){return this}}}return f({type:tr.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[$n]:m}}function ir(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:tr.INIT})===void 0)throw Error(z(12));if(n(void 0,{type:tr.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(z(13))})}function ar(e){let t=Object.keys(e),n={};for(let r=0;re:e.length===1?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function sr(...e){return t=>(n,r)=>{let i=t(n,r),a=()=>{throw Error(z(15))},o={getState:i.getState,dispatch:(e,...t)=>a(e,...t)};return a=or(...e.map(e=>e(o)))(i.dispatch),{...i,dispatch:a}}}function cr(e){return nr(e)&&`type`in e&&typeof e.type==`string`}var lr=Symbol.for(`immer-nothing`),ur=Symbol.for(`immer-draftable`),dr=Symbol.for(`immer-state`);function fr(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var pr=Object,mr=pr.getPrototypeOf,hr=`constructor`,gr=`prototype`,_r=`configurable`,vr=`enumerable`,yr=`writable`,br=`value`,xr=e=>!!e&&!!e[dr];function Sr(e){return e?Tr(e)||Mr(e)||!!e[ur]||!!e[hr]?.[ur]||Nr(e)||Pr(e):!1}var Cr=pr[gr][hr].toString(),wr=new WeakMap;function Tr(e){if(!e||!Fr(e))return!1;let t=mr(e);if(t===null||t===pr[gr])return!0;let n=pr.hasOwnProperty.call(t,hr)&&t[hr];if(n===Object)return!0;if(!Ir(n))return!1;let r=wr.get(n);return r===void 0&&(r=Function.toString.call(n),wr.set(n,r)),r===Cr}function Er(e,t,n=!0){Dr(e)===0?(n?Reflect.ownKeys(e):pr.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Dr(e){let t=e[dr];return t?t.type_:Mr(e)?1:Nr(e)?2:Pr(e)?3:0}var Or=(e,t,n=Dr(e))=>n===2?e.has(t):pr[gr].hasOwnProperty.call(e,t),kr=(e,t,n=Dr(e))=>n===2?e.get(t):e[t],Ar=(e,t,n,r=Dr(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function jr(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Mr=Array.isArray,Nr=e=>e instanceof Map,Pr=e=>e instanceof Set,Fr=e=>typeof e==`object`,Ir=e=>typeof e==`function`,Lr=e=>typeof e==`boolean`;function Rr(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var zr=e=>e.copy_||e.base_,Br=e=>e.modified_?e.copy_:e.base_;function Vr(e,t){if(Nr(e))return new Map(e);if(Pr(e))return new Set(e);if(Mr(e))return Array[gr].slice.call(e);let n=Tr(e);if(t===!0||t===`class_only`&&!n){let t=pr.getOwnPropertyDescriptors(e);delete t[dr];let n=Reflect.ownKeys(t);for(let r=0;r1&&pr.defineProperties(e,{set:Wr,add:Wr,clear:Wr,delete:Wr}),pr.freeze(e),t&&Er(e,(e,t)=>{Hr(t,!0)},!1),e)}function Ur(){fr(2)}var Wr={[br]:Ur};function Gr(e){return e===null||!Fr(e)||pr.isFrozen(e)}var Kr=`MapSet`,qr=`Patches`,Jr=`ArrayMethods`,Yr={};function Xr(e){let t=Yr[e];return t||fr(0,e),t}var Zr=e=>!!Yr[e],Qr,$r=()=>Qr,ei=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Zr(Kr)?Xr(Kr):void 0,arrayMethodsPlugin_:Zr(Jr)?Xr(Jr):void 0});function ti(e,t){t&&(e.patchPlugin_=Xr(qr),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ni(e){ri(e),e.drafts_.forEach(ai),e.drafts_=null}function ri(e){e===Qr&&(Qr=e.parent_)}var ii=e=>Qr=ei(Qr,e);function ai(e){let t=e[dr];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function oi(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[dr].modified_&&(ni(t),fr(4)),Sr(e)&&(e=si(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[dr].base_,e,t)}else e=si(t,n);return ci(t,e,!0),ni(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===lr?void 0:e}function si(e,t){if(Gr(t))return t;let n=t[dr];if(!n)return gi(t,e.handledSet_,e);if(!ui(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);mi(n,e)}return n.copy_}function ci(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Hr(t,n)}function li(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var ui=(e,t)=>e.scope_===t,di=[];function fi(e,t,n,r){let i=zr(e),a=e.type_;if(r!==void 0&&kr(i,r,a)===t){Ar(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;Er(i,(e,n)=>{if(xr(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??di;for(let e of o)Ar(i,e,n,a)}function pi(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!ui(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Br(i);fi(e,i.draft_??i,a,n),mi(i,r)})}function mi(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}li(e)}}function hi(e,t,n){let{scope_:r}=e;if(xr(n)){let i=n[dr];ui(i,r)&&i.callbacks_.push(function(){Ti(e),fi(e,n,Br(i),t)})}else Sr(n)&&e.callbacks_.push(function(){let i=zr(e);e.type_===3?i.has(n)&&gi(n,r.handledSet_,r):kr(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&gi(kr(e.copy_,t,e.type_),r.handledSet_,r)})}function gi(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||xr(e)||t.has(e)||!Sr(e)||Gr(e)?e:(t.add(e),Er(e,(r,i)=>{if(xr(i)){let t=i[dr];ui(t,n)&&(Ar(e,r,Br(t),e.type_),li(t))}else Sr(i)&&gi(i,t,n)}),e)}function _i(e,t){let n=Mr(e),r={type_:+!!n,scope_:t?t.scope_:$r(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=vi;n&&(i=[r],a=yi);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var vi={get(e,t){if(t===dr)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=zr(e);if(!Or(i,t,e.type_))return Si(e,i,t);let a=i[t];if(e.finalized_||!Sr(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Rr(t))return a;if(a===bi(e.base_,t)||xi(e,t,a)){Ti(e);let n=e.type_===1?+t:t,r=Di(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in zr(e)},ownKeys(e){return Reflect.ownKeys(zr(e))},set(e,t,n){let r=Ci(zr(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=bi(zr(e),t),i=r?.[dr];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(jr(n,r)&&(n!==void 0||Or(e.base_,t,e.type_)))return!0;Ti(e),wi(e)}return e.copy_[t]===n&&(n!==void 0||Or(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),hi(e,t,n),!0)},deleteProperty(e,t){return Ti(e),bi(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),wi(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=zr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[yr]:!0,[_r]:e.type_!==1||t!==`length`,[vr]:r[vr],[br]:n[t]}},defineProperty(){fr(11)},getPrototypeOf(e){return mr(e.base_)},setPrototypeOf(){fr(12)}},yi={};for(let e in vi){let t=vi[e];yi[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}yi.deleteProperty=function(e,t){return yi.set.call(this,e,t,void 0)},yi.set=function(e,t,n){return vi.set.call(this,e[0],t,n,e[0])};function bi(e,t){let n=e[dr];return(n?zr(n):e)[t]}function xi(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!Sr(n)||n[dr]?!1:e.baseRefs_.has(n)}function Si(e,t,n){let r=Ci(t,n);return r?br in r?r[br]:r.get?.call(e.draft_):void 0}function Ci(e,t){if(!(t in e))return;let n=mr(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=mr(n)}}function wi(e){e.modified_||(e.modified_=!0,e.parent_&&wi(e.parent_))}function Ti(e){e.copy_||=(e.assigned_=new Map,Vr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ei=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Ir(e)&&!Ir(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Ir(t)||fr(6),n!==void 0&&!Ir(n)&&fr(7);let r;if(Sr(e)){let i=ii(this),a=Di(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?ni(i):ri(i)}return ti(i,n),oi(r,i)}if(!e||!Fr(e)){if(r=t(e),r===void 0&&(r=e),r===lr&&(r=void 0),this.autoFreeze_&&Hr(r,!0),n){let t=[],i=[];Xr(qr).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}fr(1,e)},this.produceWithPatches=(e,t)=>{if(Ir(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Lr(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Lr(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Lr(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Sr(e)||fr(8),xr(e)&&(e=Oi(e));let t=ii(this),n=Di(t,e,void 0);return n[dr].isManual_=!0,ri(t),n}finishDraft(e,t){let n=e&&e[dr];(!n||!n.isManual_)&&fr(9);let{scope_:r}=n;return ti(r,t),oi(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=Xr(qr).applyPatches_;return xr(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Di(e,t,n,r){let[i,a]=Nr(t)?Xr(Kr).proxyMap_(t,n):Pr(t)?Xr(Kr).proxySet_(t,n):_i(t,n);return(n?.scope_??$r()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?pi(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Oi(e){return xr(e)||fr(10,e),ki(e)}function ki(e){if(!Sr(e)||Gr(e))return e;let t=e[dr],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Vr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Vr(e,!0);return Er(n,(e,t)=>{Ar(n,e,ki(t))},r),t&&(t.finalized_=!1),n}globalThis.Iterator?.from;var Ai=new Ei().produce,B=e=>e;function ji(e){return({dispatch:t,getState:n})=>r=>i=>typeof i==`function`?i(t,n,e):r(i)}var Mi=ji(),Ni=ji,Pi=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]==`object`?or:or.apply(null,arguments)};typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function Fi(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw Error(Ua(0));return{type:e,payload:r.payload,...`meta`in r&&{meta:r.meta},...`error`in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>cr(t)&&t.type===e,n}var Ii=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Li(e){return Sr(e)?Ai(e,()=>{}):e}function Ri(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function zi(e){return typeof e==`boolean`}var Bi=()=>function(e){let{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{},a=new Ii;return t&&(zi(t)?a.push(Mi):a.push(Ni(t.extraArgument))),a},Vi=`RTK_autoBatch`,V=()=>e=>({payload:e,meta:{[Vi]:!0}}),Hi=e=>t=>{setTimeout(t,e)},Ui=(e,t)=>n=>{let r=!1,i=()=>{r||(r=!0,cancelAnimationFrame(a),clearTimeout(o),n())},a=e(i),o=setTimeout(i,t)},Wi=(e={type:`raf`})=>t=>(...n)=>{let r=t(...n),i=!0,a=!1,o=!1,s=new Set,c=e.type===`tick`?queueMicrotask:e.type===`raf`?typeof window<`u`&&window.requestAnimationFrame?Ui(window.requestAnimationFrame,100):Hi(10):e.type===`callback`?e.queueNotification:Hi(e.timeout),l=()=>{o=!1,a&&(a=!1,s.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){let t=r.subscribe(()=>i&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return i=!e?.meta?.[Vi],a=!i,a&&(o||(o=!0,c(l))),r.dispatch(e)}finally{i=!0}}})},Gi=e=>function(t){let{autoBatch:n=!0}=t??{},r=new Ii(e);return n&&r.push(Wi(typeof n==`object`?n:void 0)),r};function Ki(e){let t=Bi(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:a=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{},c;if(typeof n==`function`)c=n;else if(nr(n))c=ar(n);else throw Error(Ua(1));let l;l=typeof r==`function`?r(t):t();let u=or;i&&(u=Pi({trace:!1,...typeof i==`object`&&i}));let d=Gi(sr(...l)),f=typeof s==`function`?s(d):d(),p=u(...f);return rr(c,o,p)}function qi(e){let t={},n=[],r,i={addCase(e,n){let r=typeof e==`string`?e:e.type;if(!r)throw Error(Ua(28));if(r in t)throw Error(Ua(29));return t[r]=n,i},addAsyncThunk(e,r){return r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),i},addMatcher(e,t){return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){return r=e,i}};return e(i),[t,n,r]}function Ji(e){return typeof e==`function`}function Yi(e,t){let[n,r,i]=qi(t),a;if(Ji(e))a=()=>Li(e());else{let t=Li(e);a=()=>t}function o(e=a(),t){let o=[n[t.type],...r.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return o.filter(e=>!!e).length===0&&(o=[i]),o.reduce((e,n)=>{if(n){if(xr(e)){let r=n(e,t);return r===void 0?e:r}if(Sr(e))return Ai(e,e=>n(e,t));{let r=n(e,t);if(r===void 0){if(e===null)return e;throw Error(`A case reducer on a non-draftable value must not return undefined`)}return r}}return e},e)}return o.getInitialState=a,o}var Xi=`ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW`,Zi=(e=21)=>{let t=``,n=e;for(;n--;)t+=Xi[Math.random()*64|0];return t},Qi=Symbol.for(`rtk-slice-createasyncthunk`);function $i(e,t){return`${e}/${t}`}function ea({creators:e}={}){let t=e?.asyncThunk?.[Qi];return function(e){let{name:n,reducerPath:r=n}=e;if(!n)throw Error(Ua(11));let i=(typeof e.reducers==`function`?e.reducers(ra()):e.reducers)||{},a=Object.keys(i),o={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){let n=typeof e==`string`?e:e.type;if(!n)throw Error(Ua(12));if(n in o.sliceCaseReducersByType)throw Error(Ua(13));return o.sliceCaseReducersByType[n]=t,s},addMatcher(e,t){return o.sliceMatchers.push({matcher:e,reducer:t}),s},exposeAction(e,t){return o.actionCreators[e]=t,s},exposeCaseReducer(e,t){return o.sliceCaseReducersByName[e]=t,s}};a.forEach(r=>{let a=i[r],o={reducerName:r,type:$i(n,r),createNotation:typeof e.reducers==`function`};aa(a)?sa(o,a,s,t):ia(o,a,s)});function c(){let[t={},n=[],r=void 0]=typeof e.extraReducers==`function`?qi(e.extraReducers):[e.extraReducers],i={...t,...o.sliceCaseReducersByType};return Yi(e.initialState,e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}let l=e=>e,u=new Map,d=new WeakMap,f;function p(e,t){return f||=c(),f(e,t)}function m(){return f||=c(),f.getInitialState()}function h(t,n=!1){function r(e){let i=e[t];return i===void 0&&n&&(i=Ri(d,r,m)),i}function i(t=l){return Ri(Ri(u,n,()=>new WeakMap),t,()=>{let r={};for(let[i,a]of Object.entries(e.selectors??{}))r[i]=ta(a,t,()=>Ri(d,t,m),n);return r})}return{reducerPath:t,getSelectors:i,get selectors(){return i(r)},selectSlice:r}}let g={name:n,reducer:p,actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:m,...h(r),injectInto(e,{reducerPath:t,...n}={}){let i=t??r;return e.inject({reducerPath:i,reducer:p},n),{...g,...h(i,!0)}}};return g}}function ta(e,t,n,r){function i(i,...a){let o=t(i);return o===void 0&&r&&(o=n()),e(o,...a)}return i.unwrapped=e,i}var na=ea();function ra(){function e(e,t){return{_reducerDefinitionType:`asyncThunk`,payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:`reducer`})},preparedReducer(e,t){return{_reducerDefinitionType:`reducerWithPrepare`,prepare:e,reducer:t}},asyncThunk:e}}function ia({type:e,reducerName:t,createNotation:n},r,i){let a,o;if(`reducer`in r){if(n&&!oa(r))throw Error(Ua(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?Fi(e,o):Fi(e))}function aa(e){return e._reducerDefinitionType===`asyncThunk`}function oa(e){return e._reducerDefinitionType===`reducerWithPrepare`}function sa({type:e,reducerName:t},n,r,i){if(!i)throw Error(Ua(18));let{payloadCreator:a,fulfilled:o,pending:s,rejected:c,settled:l,options:u}=n,d=i(e,a,u);r.exposeAction(t,d),o&&r.addCase(d.fulfilled,o),s&&r.addCase(d.pending,s),c&&r.addCase(d.rejected,c),l&&r.addMatcher(d.settled,l),r.exposeCaseReducer(t,{fulfilled:o||ca,pending:s||ca,rejected:c||ca,settled:l||ca})}function ca(){}var la=`task`,ua=`listener`,da=`completed`,fa=`cancelled`,pa=`task-${fa}`,ma=`task-${da}`,ha=`${ua}-${fa}`,ga=`${ua}-${da}`,_a=class{constructor(e){this.code=e,this.message=`${la} ${fa} (reason: ${e})`}code;name=`TaskAbortError`;message},va=(e,t)=>{if(typeof e!=`function`)throw TypeError(Ua(32))},ya=()=>{},ba=(e,t=ya)=>(e.catch(t),e),xa=(e,t)=>(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)),Sa=e=>{if(e.aborted)throw new _a(e.reason)};function Ca(e,t){let n=ya;return new Promise((r,i)=>{let a=()=>i(new _a(e.reason));if(e.aborted){a();return}n=xa(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=ya})}var wa=async(e,t)=>{try{return await Promise.resolve(),{status:`ok`,value:await e()}}catch(e){return{status:e instanceof _a?`cancelled`:`rejected`,error:e}}finally{t?.()}},Ta=e=>t=>ba(Ca(e,t).then(t=>(Sa(e),t))),Ea=e=>{let t=Ta(e);return e=>t(new Promise(t=>setTimeout(t,e)))},{assign:Da}=Object,Oa={},ka=`listenerMiddleware`,Aa=(e,t)=>{let n=t=>xa(e,()=>t.abort(e.reason));return(r,i)=>{va(r,`taskExecutor`);let a=new AbortController;n(a);let o=wa(async()=>{Sa(e),Sa(a.signal);let t=await r({pause:Ta(a.signal),delay:Ea(a.signal),signal:a.signal});return Sa(a.signal),t},()=>a.abort(ma));return i?.autoJoin&&t.push(o.catch(ya)),{result:Ta(e)(o),cancel(){a.abort(pa)}}}},ja=(e,t)=>{let n=async(n,r)=>{Sa(t);let i=()=>{},a=[new Promise((t,r)=>{let a=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});i=()=>{a(),r()}})];r!=null&&a.push(new Promise(e=>setTimeout(e,r,null)));try{let e=await Ca(t,Promise.race(a));return Sa(t),e}finally{i()}};return((e,t)=>ba(n(e,t)))},Ma=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=Fi(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw Error(Ua(21));return va(a,`options.listener`),{predicate:i,type:t,effect:a}},Na=Da(e=>{let{type:t,predicate:n,effect:r}=Ma(e);return{id:Zi(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw Error(Ua(22))}}},{withTypes:()=>Na}),Pa=(e,t)=>{let{type:n,effect:r,predicate:i}=Ma(t);return Array.from(e.values()).find(e=>(typeof n==`string`?e.type===n:e.predicate===i)&&e.effect===r)},Fa=e=>{e.pending.forEach(e=>{e.abort(ha)})},Ia=(e,t)=>()=>{for(let e of t.keys())Fa(e);e.clear()},La=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout(()=>{throw e},0)}},Ra=Da(Fi(`${ka}/add`),{withTypes:()=>Ra}),za=Fi(`${ka}/removeAll`),Ba=Da(Fi(`${ka}/remove`),{withTypes:()=>Ba}),Va=(...e)=>{console.error(`${ka}/error`,...e)},Ha=(e={})=>{let t=new Map,n=new Map,r=e=>{let t=n.get(e)??0;n.set(e,t+1)},i=e=>{let t=n.get(e)??1;t===1?n.delete(e):n.set(e,t-1)},{extra:a,onError:o=Va}=e;va(o,`onError`);let s=e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),t?.cancelActive&&Fa(e)}),c=(e=>{let n=Pa(t,e)??Na(e);return s(n)});Da(c,{withTypes:()=>c});let l=e=>{let n=Pa(t,e);return n&&(n.unsubscribe(),e.cancelActive&&Fa(n)),!!n};Da(l,{withTypes:()=>l});let u=async(e,n,s,l)=>{let u=new AbortController,d=ja(c,u.signal),f=[];try{e.pending.add(u),r(e),await Promise.resolve(e.effect(n,Da({},s,{getOriginalState:l,condition:(e,t)=>d(e,t).then(Boolean),take:d,delay:Ea(u.signal),pause:Ta(u.signal),extra:a,signal:u.signal,fork:Aa(u.signal,f),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach((e,t,n)=>{e!==u&&(e.abort(ha),n.delete(e))})},cancel:()=>{u.abort(ha),e.pending.delete(u)},throwIfCancelled:()=>{Sa(u.signal)}})))}catch(e){e instanceof _a||La(o,e,{raisedBy:`effect`})}finally{await Promise.all(f),u.abort(ga),i(e),e.pending.delete(u)}},d=Ia(t,n);return{middleware:e=>n=>r=>{if(!cr(r))return n(r);if(Ra.match(r))return c(r.payload);if(za.match(r)){d();return}if(Ba.match(r))return l(r.payload);let i=e.getState(),a=()=>{if(i===Oa)throw Error(Ua(23));return i},s;try{if(s=n(r),t.size>0){let n=e.getState(),s=Array.from(t.values());for(let t of s){let s=!1;try{s=t.predicate(r,n,i)}catch(e){s=!1,La(o,e,{raisedBy:`predicate`})}s&&u(t,r,e,a)}}}finally{i=Oa}return s},startListening:c,stopListening:l,clearListeners:d}};function Ua(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Wa=na({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),Ga=Wa.actions,Ka=Ga.setMargin,qa=Ga.setLayout,Ja=Ga.setChartSize,Ya=Ga.setScale,Xa=Wa.reducer;function Za(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function H(e){return Number.isFinite(e)}function Qa(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function $a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eo(e){for(var t=1;t{if(t&&n){var r=n.width,i=n.height,a=t.align,o=t.verticalAlign,s=t.layout,c=t.position,l=t.offset,u=l===void 0?0:l;if(c!=null){if(ke(c)){if(c===`top`&&P(e.top))return eo(eo({},e),{},{top:e.top+(i||0)+u});if(c===`bottom`&&P(e.bottom))return eo(eo({},e),{},{bottom:e.bottom+(i||0)+u});if(c===`left`&&P(e.left))return eo(eo({},e),{},{left:e.left+(r||0)+u});if(c===`right`&&P(e.right))return eo(eo({},e),{},{right:e.right+(r||0)+u})}return e}if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&P(e[a]))return eo(eo({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&P(e[o]))return eo(eo({},e),{},{[o]:e[o]+(i||0)})}return e},ao=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,oo=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},so=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,i=e.type,a=e.range,o=e.scale,s=e.realScaleType,c=e.isCategorical,l=e.categoricalDomain,u=e.tickCount,d=e.ticks,f=e.niceTicks,p=e.axisType;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?se(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return H(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(ye):c&&l?l.map((e,t)=>{var n=o.map(e);return H(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(ye):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return H(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(ye):o.domain().map((e,t)=>{var n=o.map(e);return H(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(ye)},co={sign:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:Et,none:xt,silhouette:Dt,wiggle:Ot,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},lo=(e,t,n)=>{var r=co[n]??xt,i=Tt().keys(t).value((e,t)=>Number(U(e,t,0))).order(St).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=U(e[i],t[r],0);Array.isArray(a)&&a.length===2&&P(a[0])&&P(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function uo(e){return e==null?void 0:String(e)}function fo(e){var t=e.axis,n=e.ticks,r=e.bandSize,i=e.entry,a=e.index,o=e.dataKey;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!_e(i[t.dataKey])){var s=ge(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=U(i,_e(o)?t.dataKey:o),l=t.scale.map(c);return P(l)?l:null}var po=e=>{var t=e.flat(2).filter(P);return[Math.min(...t),Math.max(...t)]},mo=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],ho=(e,t,n)=>{if(e!=null&&Object.keys(e).length!==0)return mo(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var o=a.stackedData.reduce((e,r)=>{var i=po(Za(r,t,n));return!H(i[0])||!H(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},go=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_o=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,vo=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=Xn(t,e=>e.coordinate),a=[],o=0,s=1,c=i.length;su&&(d=Math.min(f,d));return d===1/0?0:d}return n?void 0:0};function yo(e){var t=e.tooltipEntrySettings,n=e.dataKey,r=e.payload,i=e.value,a=e.name;return eo(eo({},t),{},{dataKey:n,payload:r,value:i,name:a})}function bo(e,t){if(e!=null)return String(e);if(typeof t==`string`)return t}var xo=(e,t)=>{if(t===`horizontal`)return e.relativeX;if(t===`vertical`)return e.relativeY},So=(e,t)=>t===`centric`?e.angle:e.radius,Co=e=>e.layout.width,wo=e=>e.layout.height,To=e=>e.layout.scale,Eo=e=>e.layout.margin,Do=R(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Oo=R(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),ko=`data-recharts-item-index`;function Ao(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jo(e){for(var t=1;te.brush.height;function Io(e){return Oo(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Lo(e){return Oo(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Ro(e){return Do(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}function zo(e){return Do(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}var Bo=R([Co,wo,Eo,Fo,Io,Lo,Ro,zo,Zn,Qn],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=jo(jo({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=io(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return jo(jo({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),Vo=R(Bo,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Ho=R(Co,wo,(e,t)=>({x:0,y:0,width:e,height:t})),Uo=(0,s.createContext)(null),Wo=()=>(0,s.useContext)(Uo)!=null,Go=e=>e.brush,Ko=R([Go,Bo,Eo],(e,t,n)=>({height:e.height,x:P(e.x)?e.x:t.left,y:P(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:P(e.width)?e.width:t.width}));function qo(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}function Jo(e,t=0,n={}){typeof n!=`object`&&(n={});let{leading:r=!1,trailing:i=!0,maxWait:a}=n,o=[,,];r&&(o[0]=`leading`),i&&(o[1]=`trailing`);let s,c=null,l=qo(function(...t){s=e.apply(this,t),c=null},t,{edges:o}),u=function(...t){return a!=null&&(c===null&&(c=Date.now()),Date.now()-c>=a)?((r||i)&&(s=e.apply(this,t)),c=Date.now(),l.cancel(),l.schedule(),s):(l.apply(this,t),s)};return u.cancel=l.cancel,u.flush=()=>(l.flush(),s),u}function Yo(e,t=0,n={}){let{leading:r=!0,trailing:i=!0}=n;return Jo(e,t,{leading:r,maxWait:t,trailing:i})}var Xo=function(e,t){var n=[...arguments].slice(2);if(typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e)){if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}}},Zo={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},Qo=(e,t,n)=>{var r=n.width,i=r===void 0?Zo.width:r,a=n.height,o=a===void 0?Zo.height:a,s=n.aspect,c=n.maxHeight,l=le(i)?e:Number(i),u=le(o)?t:Number(o);return s&&s>0&&(l?u=l/s:u&&(l=u*s),c&&u!=null&&u>c&&(u=c)),{calculatedWidth:l,calculatedHeight:u}},$o={width:0,height:0,overflow:`visible`},es={width:0,overflowX:`visible`},ts={height:0,overflowY:`visible`},ns={},rs=e=>{var t=e.width,n=e.height,r=le(t),i=le(n);return r&&i?$o:r?es:i?ts:ns};function is(e){var t=e.width,n=e.height,r=e.aspect,i=t,a=n;return i===void 0&&a===void 0?(i=Zo.width,a=Zo.height):i===void 0?i=r&&r>0?void 0:Zo.width:a===void 0&&(a=r&&r>0?void 0:Zo.height),{width:i,height:a}}var as=[`aspect`,`initialDimension`,`width`,`height`,`minWidth`,`minHeight`,`maxHeight`,`children`,`debounce`,`id`,`className`,`onResize`,`style`];function os(){return os=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.width,i=e.height,a=e.viewBox,c=e.className,l=e.style,u=e.title,d=e.desc,f=b(e,v),p=a||{width:r,height:i,x:0,y:0},m=o(`recharts-surface`,c);return s.createElement(`svg`,y({},h(f),{className:m,width:r,height:i,style:l,viewBox:`${p.x} ${p.y} ${p.width} ${p.height}`,ref:t}),s.createElement(`title`,null,u),s.createElement(`desc`,null,d),n)}),C=[`children`,`className`];function w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.className,i=T(e,C),a=o(`recharts-layer`,r);return s.createElement(`g`,w({className:a},h(i),{ref:t}),n)});function O(e){return e===`__proto__`}var k=/\.|(\[(?:[^[\]]*|(["'])(?:(?!\2)[^\\]|\\.)*?\2)\])/;function A(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e===``||e.startsWith(`.`)||e.endsWith(`.`)?!1:k.test(e);default:return!1}}function j(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function M(e){return typeof e==`symbol`||e instanceof Symbol}function N(e){return e==null?``:ee(e)}function ee(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(ee).join(`,`);if(M(e))return e.toString();let t=e+``;return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function te(e){if(Array.isArray(e))return e.map(j);if(typeof e==`symbol`)return[e];e=N(e);let t=[],n=e.length;if(n===0)return t;let r=0,i=``,a=``,o=!1,s=!1,c=/^-?\d+(?:\.\d+)?$/;for(e.charCodeAt(0)===46&&t.push(``);r1&&arguments[1]!==void 0?arguments[1]:ie),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function oe(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+ae(i)+n},``)}var se=e=>e===0?0:e>0?1:-1,ce=e=>typeof e==`number`&&e!=+e,le=e=>typeof e==`string`&&e.length>1&&e.indexOf(`%`)===e.length-1,P=e=>(typeof e==`number`||e instanceof Number)&&!ce(e),ue=e=>P(e)||typeof e==`string`,de=0,fe=e=>{var t=++de;return`${e||``}${t}`},pe=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(!P(e)&&typeof e!=`string`)return n;var i;if(le(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return ce(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},me=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;re&&(typeof t==`function`?t(e):ne(e,t))===n)}var _e=e=>e==null,ve=e=>_e(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function ye(e){return e!=null}function be(){}function xe(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function Se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ce(e){for(var t=1;t{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,a=e.parentViewBox,o=e.clamp,s=xe(t),c=s.x,l=s.y,u=s.height,d=s.upperWidth,f=s.lowerWidth,p=c,m=c+(d-f)/2,h=(p+m)/2,g=(d+f)/2,_=p+d/2,v=u>=0?1:-1,y=v*i,b=v>0?`end`:`start`,x=v>0?`start`:`end`,S=d>=0?1:-1,C=S*i,w=S>0?`end`:`start`,T=S>0?`start`:`end`,E=a;if(n===`top`){var D={x:p+d/2,y:l-y,horizontalAnchor:`middle`,verticalAnchor:b};return o&&E&&(D.height=Math.max(l-E.y,0),D.width=d),D}if(n===`bottom`){var O={x:m+f/2,y:l+u+y,horizontalAnchor:`middle`,verticalAnchor:x};return o&&E&&(O.height=Math.max(E.y+E.height-(l+u),0),O.width=f),O}if(n===`left`){var k={x:h-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`};return o&&E&&(k.width=Math.max(k.x-E.x,0),k.height=u),k}if(n===`right`){var A={x:h+g+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`};return o&&E&&(A.width=Math.max(E.x+E.width-A.x,0),A.height=u),A}var j=o&&E?{width:g,height:u}:{};return n===`insideLeft`?Ce({x:h+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`},j):n===`insideRight`?Ce({x:h+g-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`},j):n===`insideTop`?Ce({x:p+d/2,y:l+y,horizontalAnchor:`middle`,verticalAnchor:x},j):n===`insideBottom`?Ce({x:m+f/2,y:l+u-y,horizontalAnchor:`middle`,verticalAnchor:b},j):n===`insideTopLeft`?Ce({x:p+C,y:l+y,horizontalAnchor:T,verticalAnchor:x},j):n===`insideTopRight`?Ce({x:p+d-C,y:l+y,horizontalAnchor:w,verticalAnchor:x},j):n===`insideBottomLeft`?Ce({x:m+C,y:l+u-y,horizontalAnchor:T,verticalAnchor:b},j):n===`insideBottomRight`?Ce({x:m+f-C,y:l+u-y,horizontalAnchor:w,verticalAnchor:b},j):n&&typeof n==`object`&&(P(n.x)||le(n.x))&&(P(n.y)||le(n.y))?Ce({x:c+pe(n.x,g),y:l+pe(n.y,u),horizontalAnchor:`end`,verticalAnchor:`end`},j):Ce({x:_,y:l+u/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},j)},Oe=[`top`,`left`,`right`,`bottom`];function ke(e){return e==null?!1:typeof e==`object`||Oe.includes(e)}var Ae=(0,s.createContext)(null);function F(e){return function(){return e}}var je=Math.PI,Me=2*je,Ne=1e-6,Pe=Me-Ne;function Fe(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return Fe;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;tNe){if(!(Math.abs(u*s-c*l)>Ne)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((je-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>Ne&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>Ne||Math.abs(this._y1-l)>Ne)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%Me+Me),d>Pe?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>Ne&&this._append`A${n},${n},0,${+(d>=je)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};Le.prototype;function Re(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new Le(t)}Array.prototype.slice;function ze(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Be(e){this._context=e}Be.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function Ve(e){return new Be(e)}function He(e){return e[0]}function Ue(e){return e[1]}function We(e,t){var n=F(!0),r=null,i=Ve,a=null,o=Re(s);e=typeof e==`function`?e:e===void 0?He:F(e),t=typeof t==`function`?t:t===void 0?Ue:F(t);function s(s){var c,l=(s=ze(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return We().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:F(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:F(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:F(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:F(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:F(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:F(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:F(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var Ke=class{constructor(e,t){this._context=e,this._x=t}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t)}this._x0=e,this._y0=t}};function qe(e){return new Ke(e,!0)}function Je(e){return new Ke(e,!1)}function Ye(){}function Xe(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Ze(e){this._context=e}Ze.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Xe(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Xe(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Qe(e){return new Ze(e)}function $e(e){this._context=e}$e.prototype={areaStart:Ye,areaEnd:Ye,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Xe(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function et(e){return new $e(e)}function tt(e){this._context=e}tt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Xe(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function nt(e){return new tt(e)}function rt(e){this._context=e}rt.prototype={areaStart:Ye,areaEnd:Ye,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function it(e){return new rt(e)}function at(e){return e<0?-1:1}function ot(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(at(a)+at(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function st(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function ct(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function lt(e){this._context=e}lt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:ct(this,this._t0,st(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,e!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,ct(this,st(this,n=ot(this,e,t)),n);break;default:ct(this,this._t0,n=ot(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function ut(e){this._context=new dt(e)}(ut.prototype=Object.create(lt.prototype)).point=function(e,t){lt.prototype.point.call(this,t,e)};function dt(e){this._context=e}dt.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function ft(e){return new lt(e)}function pt(e){return new ut(e)}function mt(e){this._context=e}mt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n){if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=ht(e),i=ht(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};function vt(e){return new _t(e,.5)}function yt(e){return new _t(e,0)}function bt(e){return new _t(e,1)}function xt(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n=0;)n[t]=t;return n}function Ct(e,t){return e[t]}function wt(e){let t=[];return t.key=e,t}function Tt(){var e=F([]),t=St,n=xt,r=Ct;function i(i){var a=Array.from(e.apply(this,arguments),wt),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r`radius`in e&&`startAngle`in e&&`endAngle`in e,At=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,s.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{l(e)&&typeof n[e]==`function`&&(r[e]=t||(t=>n[e](n,t)))}),r},jt=(e,t,n)=>r=>(e(t,n,r),null),Mt=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];l(i)&&typeof a==`function`&&(r||={},r[i]=jt(a,t,n))}),r};function Nt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Pt(e){for(var t=1;t(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function zt(e){return Number.isSafeInteger(e)&&e>=0}function Bt(e){return e!=null&&typeof e!=`function`&&zt(e.length)}function Vt(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function Ht(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var Ut=`[object RegExp]`,Wt=`[object String]`,Gt=`[object Number]`,Kt=`[object Boolean]`,qt=`[object Arguments]`,Jt=`[object Symbol]`,Yt=`[object Date]`,Xt=`[object Map]`,Zt=`[object Set]`,Qt=`[object Array]`,$t=`[object Function]`,en=`[object ArrayBuffer]`,tn=`[object Object]`,nn=`[object Error]`,rn=`[object DataView]`,an=`[object Uint8Array]`,on=`[object Uint8ClampedArray]`,sn=`[object Uint16Array]`,cn=`[object Uint32Array]`,ln=`[object BigUint64Array]`,un=`[object Int8Array]`,dn=`[object Int16Array]`,fn=`[object Int32Array]`,pn=`[object BigInt64Array]`,mn=`[object Float32Array]`,hn=`[object Float64Array]`,gn=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window||typeof self==`object`&&self||typeof global==`object`&&global||(function(){return this})();function _n(e){return gn.Buffer!==void 0&&gn.Buffer.isBuffer(e)}function vn(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function yn(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}var bn=/^(?:0|[1-9]\d*)$/;function xn(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e{var r=n(),i=e();function a(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var o=typeof Object.is==`function`?Object.is:a,s=i.useSyncExternalStore,c=r.useRef,l=r.useEffect,u=r.useMemo,d=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var a=c(null);if(a.current===null){var f={hasValue:!1,value:null};a.current=f}else f=a.current;a=u(function(){function e(e){if(!a){if(a=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,o(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var a=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=s(e,a[0],a[1]);return l(function(){f.hasValue=!0,f.value=p},[p]),d(p),p}})),Cn=a(((e,t)=>{t.exports=Sn()}))(),wn=(0,s.createContext)(null),Tn=e=>e,I=()=>{var e=(0,s.useContext)(wn);return e?e.store.dispatch:Tn},En=()=>{},Dn=()=>En,On=(e,t)=>e===t;function L(e){var t=(0,s.useContext)(wn),n=(0,s.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:En,[t,e]);return(0,Cn.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:Dn,t?t.store.getState:En,t?t.store.getState:En,n,On)}function kn(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function An(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var jn=e=>Array.isArray(e)?e:[e];function Mn(e){let t=Array.isArray(e[0])?e[0]:e;return An(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function Nn(e,t){let n=[],{length:r}=e;for(let i=0;i`u`?Pn:WeakRef,In=0,Ln=1;function Rn(){return{s:In,v:void 0,o:null,p:null}}function zn(e){return e instanceof Fn?e.deref():e}function Bn(e,t={}){let n=Rn(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e{n=Rn(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Vn(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),kn(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=Bn,argsMemoizeOptions:u=[]}={...n,...a},d=jn(c),f=jn(u),p=Mn(e),m=s(function(){return t++,o.apply(null,arguments)},...d),h=l(function(){r++;let e=Nn(p,arguments);return i=m.apply(null,e),i},...f);return Object.assign(h,{resultFunc:o,memoizedResultFunc:m,dependencies:p,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var R=Vn(Bn);function Hn(e,t=1){let n=[],r=Math.floor(t),i=(e,t)=>{for(let a=0;a{if(e!==t){let r=Wn(e),i=Wn(t);if(r===i&&r===0){if(et)return n===`desc`?-1:1}return n===`desc`?i-r:r-i}return 0},Kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qn=/^\w*$/;function Jn(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||M(e)?!0:typeof e==`string`&&(qn.test(e)||!Kn.test(e))||t!=null&&Object.hasOwn(t,e)}function Yn(e,t,n,r){if(e==null)return[];n=r?void 0:n,Array.isArray(e)||(e=Bt(e)?Array.from(e):Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(e=>String(e));let i=(e,t)=>{let n=e,r=0;for(;r0&&r===t.length?n:void 0},a=(e,t)=>{if(e==null)return t;if(t!=null)return typeof e==`object`&&`key`in e?Object.hasOwn(t,e.key)?t[e.key]:i(t,e.path):typeof e==`function`?e(t):Array.isArray(e)?i(t,e):t[e]},o=t.map(e=>(Array.isArray(e)&&e.length===1&&(e=e[0]),e==null||typeof e==`function`||Array.isArray(e)||Jn(e)?e:{key:e,path:te(e)}));return e.map(e=>({original:e,criteria:o.map(t=>a(t,e))})).slice().sort((e,t)=>{for(let r=0;re.original)}function Xn(e,...t){let n=t.length;return n>1&&Un(e,t[0],t[1])?t=[]:n>2&&Un(t[0],t[1],t[2])&&(t=[t[0]]),Yn(e,Hn(t),[`asc`])}var Zn=e=>e.legend.settings,Qn=e=>e.legend.size;R([e=>e.legend.payload,Zn],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?Xn(r,n):r});function z(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var $n=typeof Symbol==`function`&&Symbol.observable||`@@observable`,er=()=>Math.random().toString(36).substring(7).split(``).join(`.`),tr={INIT:`@@redux/INIT${er()}`,REPLACE:`@@redux/REPLACE${er()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${er()}`};function nr(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function rr(e,t,n){if(typeof e!=`function`)throw Error(z(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(z(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(z(1));return n(rr)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error(z(3));return i}function d(e){if(typeof e!=`function`)throw Error(z(4));if(c)throw Error(z(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error(z(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!nr(e))throw Error(z(7));if(e.type===void 0)throw Error(z(8));if(typeof e.type!=`string`)throw Error(z(17));if(c)throw Error(z(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error(z(10));r=e,f({type:tr.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error(z(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[$n](){return this}}}return f({type:tr.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[$n]:m}}function ir(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:tr.INIT})===void 0)throw Error(z(12));if(n(void 0,{type:tr.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(z(13))})}function ar(e){let t=Object.keys(e),n={};for(let r=0;re:e.length===1?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function sr(...e){return t=>(n,r)=>{let i=t(n,r),a=()=>{throw Error(z(15))},o={getState:i.getState,dispatch:(e,...t)=>a(e,...t)};return a=or(...e.map(e=>e(o)))(i.dispatch),{...i,dispatch:a}}}function cr(e){return nr(e)&&`type`in e&&typeof e.type==`string`}var lr=Symbol.for(`immer-nothing`),ur=Symbol.for(`immer-draftable`),dr=Symbol.for(`immer-state`);function fr(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var pr=Object,mr=pr.getPrototypeOf,hr=`constructor`,gr=`prototype`,_r=`configurable`,vr=`enumerable`,yr=`writable`,br=`value`,xr=e=>!!e&&!!e[dr];function Sr(e){return e?Tr(e)||Mr(e)||!!e[ur]||!!e[hr]?.[ur]||Nr(e)||Pr(e):!1}var Cr=pr[gr][hr].toString(),wr=new WeakMap;function Tr(e){if(!e||!Fr(e))return!1;let t=mr(e);if(t===null||t===pr[gr])return!0;let n=pr.hasOwnProperty.call(t,hr)&&t[hr];if(n===Object)return!0;if(!Ir(n))return!1;let r=wr.get(n);return r===void 0&&(r=Function.toString.call(n),wr.set(n,r)),r===Cr}function Er(e,t,n=!0){Dr(e)===0?(n?Reflect.ownKeys(e):pr.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Dr(e){let t=e[dr];return t?t.type_:Mr(e)?1:Nr(e)?2:Pr(e)?3:0}var Or=(e,t,n=Dr(e))=>n===2?e.has(t):pr[gr].hasOwnProperty.call(e,t),kr=(e,t,n=Dr(e))=>n===2?e.get(t):e[t],Ar=(e,t,n,r=Dr(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function jr(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Mr=Array.isArray,Nr=e=>e instanceof Map,Pr=e=>e instanceof Set,Fr=e=>typeof e==`object`,Ir=e=>typeof e==`function`,Lr=e=>typeof e==`boolean`;function Rr(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var zr=e=>e.copy_||e.base_,Br=e=>e.modified_?e.copy_:e.base_;function Vr(e,t){if(Nr(e))return new Map(e);if(Pr(e))return new Set(e);if(Mr(e))return Array[gr].slice.call(e);let n=Tr(e);if(t===!0||t===`class_only`&&!n){let t=pr.getOwnPropertyDescriptors(e);delete t[dr];let n=Reflect.ownKeys(t);for(let r=0;r1&&pr.defineProperties(e,{set:Wr,add:Wr,clear:Wr,delete:Wr}),pr.freeze(e),t&&Er(e,(e,t)=>{Hr(t,!0)},!1),e)}function Ur(){fr(2)}var Wr={[br]:Ur};function Gr(e){return e===null||!Fr(e)||pr.isFrozen(e)}var Kr=`MapSet`,qr=`Patches`,Jr=`ArrayMethods`,Yr={};function Xr(e){let t=Yr[e];return t||fr(0,e),t}var Zr=e=>!!Yr[e],Qr,$r=()=>Qr,ei=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Zr(Kr)?Xr(Kr):void 0,arrayMethodsPlugin_:Zr(Jr)?Xr(Jr):void 0});function ti(e,t){t&&(e.patchPlugin_=Xr(qr),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ni(e){ri(e),e.drafts_.forEach(ai),e.drafts_=null}function ri(e){e===Qr&&(Qr=e.parent_)}var ii=e=>Qr=ei(Qr,e);function ai(e){let t=e[dr];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function oi(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[dr].modified_&&(ni(t),fr(4)),Sr(e)&&(e=si(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[dr].base_,e,t)}else e=si(t,n);return ci(t,e,!0),ni(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===lr?void 0:e}function si(e,t){if(Gr(t))return t;let n=t[dr];if(!n)return gi(t,e.handledSet_,e);if(!ui(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);mi(n,e)}return n.copy_}function ci(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Hr(t,n)}function li(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var ui=(e,t)=>e.scope_===t,di=[];function fi(e,t,n,r){let i=zr(e),a=e.type_;if(r!==void 0&&kr(i,r,a)===t){Ar(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;Er(i,(e,n)=>{if(xr(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??di;for(let e of o)Ar(i,e,n,a)}function pi(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!ui(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Br(i);fi(e,i.draft_??i,a,n),mi(i,r)})}function mi(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}li(e)}}function hi(e,t,n){let{scope_:r}=e;if(xr(n)){let i=n[dr];ui(i,r)&&i.callbacks_.push(function(){Ti(e),fi(e,n,Br(i),t)})}else Sr(n)&&e.callbacks_.push(function(){let i=zr(e);e.type_===3?i.has(n)&&gi(n,r.handledSet_,r):kr(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&gi(kr(e.copy_,t,e.type_),r.handledSet_,r)})}function gi(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||xr(e)||t.has(e)||!Sr(e)||Gr(e)?e:(t.add(e),Er(e,(r,i)=>{if(xr(i)){let t=i[dr];ui(t,n)&&(Ar(e,r,Br(t),e.type_),li(t))}else Sr(i)&&gi(i,t,n)}),e)}function _i(e,t){let n=Mr(e),r={type_:+!!n,scope_:t?t.scope_:$r(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=vi;n&&(i=[r],a=yi);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var vi={get(e,t){if(t===dr)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=zr(e);if(!Or(i,t,e.type_))return Si(e,i,t);let a=i[t];if(e.finalized_||!Sr(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Rr(t))return a;if(a===bi(e.base_,t)||xi(e,t,a)){Ti(e);let n=e.type_===1?+t:t,r=Di(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in zr(e)},ownKeys(e){return Reflect.ownKeys(zr(e))},set(e,t,n){let r=Ci(zr(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=bi(zr(e),t),i=r?.[dr];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(jr(n,r)&&(n!==void 0||Or(e.base_,t,e.type_)))return!0;Ti(e),wi(e)}return e.copy_[t]===n&&(n!==void 0||Or(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),hi(e,t,n),!0)},deleteProperty(e,t){return Ti(e),bi(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),wi(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=zr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[yr]:!0,[_r]:e.type_!==1||t!==`length`,[vr]:r[vr],[br]:n[t]}},defineProperty(){fr(11)},getPrototypeOf(e){return mr(e.base_)},setPrototypeOf(){fr(12)}},yi={};for(let e in vi){let t=vi[e];yi[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}yi.deleteProperty=function(e,t){return yi.set.call(this,e,t,void 0)},yi.set=function(e,t,n){return vi.set.call(this,e[0],t,n,e[0])};function bi(e,t){let n=e[dr];return(n?zr(n):e)[t]}function xi(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!Sr(n)||n[dr]?!1:e.baseRefs_.has(n)}function Si(e,t,n){let r=Ci(t,n);return r?br in r?r[br]:r.get?.call(e.draft_):void 0}function Ci(e,t){if(!(t in e))return;let n=mr(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=mr(n)}}function wi(e){e.modified_||(e.modified_=!0,e.parent_&&wi(e.parent_))}function Ti(e){e.copy_||=(e.assigned_=new Map,Vr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ei=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Ir(e)&&!Ir(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Ir(t)||fr(6),n!==void 0&&!Ir(n)&&fr(7);let r;if(Sr(e)){let i=ii(this),a=Di(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?ni(i):ri(i)}return ti(i,n),oi(r,i)}if(!e||!Fr(e)){if(r=t(e),r===void 0&&(r=e),r===lr&&(r=void 0),this.autoFreeze_&&Hr(r,!0),n){let t=[],i=[];Xr(qr).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}fr(1,e)},this.produceWithPatches=(e,t)=>{if(Ir(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Lr(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Lr(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Lr(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Sr(e)||fr(8),xr(e)&&(e=Oi(e));let t=ii(this),n=Di(t,e,void 0);return n[dr].isManual_=!0,ri(t),n}finishDraft(e,t){let n=e&&e[dr];(!n||!n.isManual_)&&fr(9);let{scope_:r}=n;return ti(r,t),oi(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=Xr(qr).applyPatches_;return xr(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Di(e,t,n,r){let[i,a]=Nr(t)?Xr(Kr).proxyMap_(t,n):Pr(t)?Xr(Kr).proxySet_(t,n):_i(t,n);return(n?.scope_??$r()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?pi(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Oi(e){return xr(e)||fr(10,e),ki(e)}function ki(e){if(!Sr(e)||Gr(e))return e;let t=e[dr],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Vr(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Vr(e,!0);return Er(n,(e,t)=>{Ar(n,e,ki(t))},r),t&&(t.finalized_=!1),n}globalThis.Iterator?.from;var Ai=new Ei().produce,B=e=>e;function ji(e){return({dispatch:t,getState:n})=>r=>i=>typeof i==`function`?i(t,n,e):r(i)}var Mi=ji(),Ni=ji,Pi=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]==`object`?or:or.apply(null,arguments)};typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function Fi(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw Error(Ua(0));return{type:e,payload:r.payload,...`meta`in r&&{meta:r.meta},...`error`in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>cr(t)&&t.type===e,n}var Ii=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Li(e){return Sr(e)?Ai(e,()=>{}):e}function Ri(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function zi(e){return typeof e==`boolean`}var Bi=()=>function(e){let{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{},a=new Ii;return t&&(zi(t)?a.push(Mi):a.push(Ni(t.extraArgument))),a},Vi=`RTK_autoBatch`,V=()=>e=>({payload:e,meta:{[Vi]:!0}}),Hi=e=>t=>{setTimeout(t,e)},Ui=(e,t)=>n=>{let r=!1,i=()=>{r||(r=!0,cancelAnimationFrame(a),clearTimeout(o),n())},a=e(i),o=setTimeout(i,t)},Wi=(e={type:`raf`})=>t=>(...n)=>{let r=t(...n),i=!0,a=!1,o=!1,s=new Set,c=e.type===`tick`?queueMicrotask:e.type===`raf`?typeof window<`u`&&window.requestAnimationFrame?Ui(window.requestAnimationFrame,100):Hi(10):e.type===`callback`?e.queueNotification:Hi(e.timeout),l=()=>{o=!1,a&&(a=!1,s.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){let t=r.subscribe(()=>i&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return i=!e?.meta?.[Vi],a=!i,a&&(o||(o=!0,c(l))),r.dispatch(e)}finally{i=!0}}})},Gi=e=>function(t){let{autoBatch:n=!0}=t??{},r=new Ii(e);return n&&r.push(Wi(typeof n==`object`?n:void 0)),r};function Ki(e){let t=Bi(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:a=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{},c;if(typeof n==`function`)c=n;else if(nr(n))c=ar(n);else throw Error(Ua(1));let l;l=typeof r==`function`?r(t):t();let u=or;i&&(u=Pi({trace:!1,...typeof i==`object`&&i}));let d=Gi(sr(...l)),f=typeof s==`function`?s(d):d(),p=u(...f);return rr(c,o,p)}function qi(e){let t={},n=[],r,i={addCase(e,n){let r=typeof e==`string`?e:e.type;if(!r)throw Error(Ua(28));if(r in t)throw Error(Ua(29));return t[r]=n,i},addAsyncThunk(e,r){return r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),i},addMatcher(e,t){return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){return r=e,i}};return e(i),[t,n,r]}function Ji(e){return typeof e==`function`}function Yi(e,t){let[n,r,i]=qi(t),a;if(Ji(e))a=()=>Li(e());else{let t=Li(e);a=()=>t}function o(e=a(),t){let o=[n[t.type],...r.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return o.filter(e=>!!e).length===0&&(o=[i]),o.reduce((e,n)=>{if(n){if(xr(e)){let r=n(e,t);return r===void 0?e:r}if(Sr(e))return Ai(e,e=>n(e,t));{let r=n(e,t);if(r===void 0){if(e===null)return e;throw Error(`A case reducer on a non-draftable value must not return undefined`)}return r}}return e},e)}return o.getInitialState=a,o}var Xi=`ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW`,Zi=(e=21)=>{let t=``,n=e;for(;n--;)t+=Xi[Math.random()*64|0];return t},Qi=Symbol.for(`rtk-slice-createasyncthunk`);function $i(e,t){return`${e}/${t}`}function ea({creators:e}={}){let t=e?.asyncThunk?.[Qi];return function(e){let{name:n,reducerPath:r=n}=e;if(!n)throw Error(Ua(11));let i=(typeof e.reducers==`function`?e.reducers(ra()):e.reducers)||{},a=Object.keys(i),o={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){let n=typeof e==`string`?e:e.type;if(!n)throw Error(Ua(12));if(n in o.sliceCaseReducersByType)throw Error(Ua(13));return o.sliceCaseReducersByType[n]=t,s},addMatcher(e,t){return o.sliceMatchers.push({matcher:e,reducer:t}),s},exposeAction(e,t){return o.actionCreators[e]=t,s},exposeCaseReducer(e,t){return o.sliceCaseReducersByName[e]=t,s}};a.forEach(r=>{let a=i[r],o={reducerName:r,type:$i(n,r),createNotation:typeof e.reducers==`function`};aa(a)?sa(o,a,s,t):ia(o,a,s)});function c(){let[t={},n=[],r=void 0]=typeof e.extraReducers==`function`?qi(e.extraReducers):[e.extraReducers],i={...t,...o.sliceCaseReducersByType};return Yi(e.initialState,e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}let l=e=>e,u=new Map,d=new WeakMap,f;function p(e,t){return f||=c(),f(e,t)}function m(){return f||=c(),f.getInitialState()}function h(t,n=!1){function r(e){let i=e[t];return i===void 0&&n&&(i=Ri(d,r,m)),i}function i(t=l){return Ri(Ri(u,n,()=>new WeakMap),t,()=>{let r={};for(let[i,a]of Object.entries(e.selectors??{}))r[i]=ta(a,t,()=>Ri(d,t,m),n);return r})}return{reducerPath:t,getSelectors:i,get selectors(){return i(r)},selectSlice:r}}let g={name:n,reducer:p,actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:m,...h(r),injectInto(e,{reducerPath:t,...n}={}){let i=t??r;return e.inject({reducerPath:i,reducer:p},n),{...g,...h(i,!0)}}};return g}}function ta(e,t,n,r){function i(i,...a){let o=t(i);return o===void 0&&r&&(o=n()),e(o,...a)}return i.unwrapped=e,i}var na=ea();function ra(){function e(e,t){return{_reducerDefinitionType:`asyncThunk`,payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:`reducer`})},preparedReducer(e,t){return{_reducerDefinitionType:`reducerWithPrepare`,prepare:e,reducer:t}},asyncThunk:e}}function ia({type:e,reducerName:t,createNotation:n},r,i){let a,o;if(`reducer`in r){if(n&&!oa(r))throw Error(Ua(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?Fi(e,o):Fi(e))}function aa(e){return e._reducerDefinitionType===`asyncThunk`}function oa(e){return e._reducerDefinitionType===`reducerWithPrepare`}function sa({type:e,reducerName:t},n,r,i){if(!i)throw Error(Ua(18));let{payloadCreator:a,fulfilled:o,pending:s,rejected:c,settled:l,options:u}=n,d=i(e,a,u);r.exposeAction(t,d),o&&r.addCase(d.fulfilled,o),s&&r.addCase(d.pending,s),c&&r.addCase(d.rejected,c),l&&r.addMatcher(d.settled,l),r.exposeCaseReducer(t,{fulfilled:o||ca,pending:s||ca,rejected:c||ca,settled:l||ca})}function ca(){}var la=`task`,ua=`listener`,da=`completed`,fa=`cancelled`,pa=`task-${fa}`,ma=`task-${da}`,ha=`${ua}-${fa}`,ga=`${ua}-${da}`,_a=class{constructor(e){this.code=e,this.message=`${la} ${fa} (reason: ${e})`}code;name=`TaskAbortError`;message},va=(e,t)=>{if(typeof e!=`function`)throw TypeError(Ua(32))},ya=()=>{},ba=(e,t=ya)=>(e.catch(t),e),xa=(e,t)=>(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)),Sa=e=>{if(e.aborted)throw new _a(e.reason)};function Ca(e,t){let n=ya;return new Promise((r,i)=>{let a=()=>i(new _a(e.reason));if(e.aborted){a();return}n=xa(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=ya})}var wa=async(e,t)=>{try{return await Promise.resolve(),{status:`ok`,value:await e()}}catch(e){return{status:e instanceof _a?`cancelled`:`rejected`,error:e}}finally{t?.()}},Ta=e=>t=>ba(Ca(e,t).then(t=>(Sa(e),t))),Ea=e=>{let t=Ta(e);return e=>t(new Promise(t=>setTimeout(t,e)))},{assign:Da}=Object,Oa={},ka=`listenerMiddleware`,Aa=(e,t)=>{let n=t=>xa(e,()=>t.abort(e.reason));return(r,i)=>{va(r,`taskExecutor`);let a=new AbortController;n(a);let o=wa(async()=>{Sa(e),Sa(a.signal);let t=await r({pause:Ta(a.signal),delay:Ea(a.signal),signal:a.signal});return Sa(a.signal),t},()=>a.abort(ma));return i?.autoJoin&&t.push(o.catch(ya)),{result:Ta(e)(o),cancel(){a.abort(pa)}}}},ja=(e,t)=>{let n=async(n,r)=>{Sa(t);let i=()=>{},a=[new Promise((t,r)=>{let a=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});i=()=>{a(),r()}})];r!=null&&a.push(new Promise(e=>setTimeout(e,r,null)));try{let e=await Ca(t,Promise.race(a));return Sa(t),e}finally{i()}};return((e,t)=>ba(n(e,t)))},Ma=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=Fi(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw Error(Ua(21));return va(a,`options.listener`),{predicate:i,type:t,effect:a}},Na=Da(e=>{let{type:t,predicate:n,effect:r}=Ma(e);return{id:Zi(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw Error(Ua(22))}}},{withTypes:()=>Na}),Pa=(e,t)=>{let{type:n,effect:r,predicate:i}=Ma(t);return Array.from(e.values()).find(e=>(typeof n==`string`?e.type===n:e.predicate===i)&&e.effect===r)},Fa=e=>{e.pending.forEach(e=>{e.abort(ha)})},Ia=(e,t)=>()=>{for(let e of t.keys())Fa(e);e.clear()},La=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout(()=>{throw e},0)}},Ra=Da(Fi(`${ka}/add`),{withTypes:()=>Ra}),za=Fi(`${ka}/removeAll`),Ba=Da(Fi(`${ka}/remove`),{withTypes:()=>Ba}),Va=(...e)=>{console.error(`${ka}/error`,...e)},Ha=(e={})=>{let t=new Map,n=new Map,r=e=>{let t=n.get(e)??0;n.set(e,t+1)},i=e=>{let t=n.get(e)??1;t===1?n.delete(e):n.set(e,t-1)},{extra:a,onError:o=Va}=e;va(o,`onError`);let s=e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),t?.cancelActive&&Fa(e)}),c=(e=>{let n=Pa(t,e)??Na(e);return s(n)});Da(c,{withTypes:()=>c});let l=e=>{let n=Pa(t,e);return n&&(n.unsubscribe(),e.cancelActive&&Fa(n)),!!n};Da(l,{withTypes:()=>l});let u=async(e,n,s,l)=>{let u=new AbortController,d=ja(c,u.signal),f=[];try{e.pending.add(u),r(e),await Promise.resolve(e.effect(n,Da({},s,{getOriginalState:l,condition:(e,t)=>d(e,t).then(Boolean),take:d,delay:Ea(u.signal),pause:Ta(u.signal),extra:a,signal:u.signal,fork:Aa(u.signal,f),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach((e,t,n)=>{e!==u&&(e.abort(ha),n.delete(e))})},cancel:()=>{u.abort(ha),e.pending.delete(u)},throwIfCancelled:()=>{Sa(u.signal)}})))}catch(e){e instanceof _a||La(o,e,{raisedBy:`effect`})}finally{await Promise.all(f),u.abort(ga),i(e),e.pending.delete(u)}},d=Ia(t,n);return{middleware:e=>n=>r=>{if(!cr(r))return n(r);if(Ra.match(r))return c(r.payload);if(za.match(r)){d();return}if(Ba.match(r))return l(r.payload);let i=e.getState(),a=()=>{if(i===Oa)throw Error(Ua(23));return i},s;try{if(s=n(r),t.size>0){let n=e.getState(),s=Array.from(t.values());for(let t of s){let s=!1;try{s=t.predicate(r,n,i)}catch(e){s=!1,La(o,e,{raisedBy:`predicate`})}s&&u(t,r,e,a)}}}finally{i=Oa}return s},startListening:c,stopListening:l,clearListeners:d}};function Ua(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Wa=na({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),Ga=Wa.actions,Ka=Ga.setMargin,qa=Ga.setLayout,Ja=Ga.setChartSize,Ya=Ga.setScale,Xa=Wa.reducer;function Za(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function H(e){return Number.isFinite(e)}function Qa(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function $a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eo(e){for(var t=1;t{if(t&&n){var r=n.width,i=n.height,a=t.align,o=t.verticalAlign,s=t.layout,c=t.position,l=t.offset,u=l===void 0?0:l;if(c!=null){if(ke(c)){if(c===`top`&&P(e.top))return eo(eo({},e),{},{top:e.top+(i||0)+u});if(c===`bottom`&&P(e.bottom))return eo(eo({},e),{},{bottom:e.bottom+(i||0)+u});if(c===`left`&&P(e.left))return eo(eo({},e),{},{left:e.left+(r||0)+u});if(c===`right`&&P(e.right))return eo(eo({},e),{},{right:e.right+(r||0)+u})}return e}if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&P(e[a]))return eo(eo({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&P(e[o]))return eo(eo({},e),{},{[o]:e[o]+(i||0)})}return e},ao=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,oo=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},so=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,i=e.type,a=e.range,o=e.scale,s=e.realScaleType,c=e.isCategorical,l=e.categoricalDomain,u=e.tickCount,d=e.ticks,f=e.niceTicks,p=e.axisType;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?se(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return H(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(ye):c&&l?l.map((e,t)=>{var n=o.map(e);return H(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(ye):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return H(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(ye):o.domain().map((e,t)=>{var n=o.map(e);return H(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(ye)},co={sign:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:Et,none:xt,silhouette:Dt,wiggle:Ot,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},lo=(e,t,n)=>{var r=co[n]??xt,i=Tt().keys(t).value((e,t)=>Number(U(e,t,0))).order(St).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=U(e[i],t[r],0);Array.isArray(a)&&a.length===2&&P(a[0])&&P(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function uo(e){return e==null?void 0:String(e)}function fo(e){var t=e.axis,n=e.ticks,r=e.bandSize,i=e.entry,a=e.index,o=e.dataKey;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!_e(i[t.dataKey])){var s=ge(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=U(i,_e(o)?t.dataKey:o),l=t.scale.map(c);return P(l)?l:null}var po=e=>{var t=e.flat(2).filter(P);return[Math.min(...t),Math.max(...t)]},mo=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],ho=(e,t,n)=>{if(e!=null&&Object.keys(e).length!==0)return mo(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var o=a.stackedData.reduce((e,r)=>{var i=po(Za(r,t,n));return!H(i[0])||!H(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},go=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_o=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,vo=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=Xn(t,e=>e.coordinate),a=[],o=0,s=1,c=i.length;su&&(d=Math.min(f,d));return d===1/0?0:d}return n?void 0:0};function yo(e){var t=e.tooltipEntrySettings,n=e.dataKey,r=e.payload,i=e.value,a=e.name;return eo(eo({},t),{},{dataKey:n,payload:r,value:i,name:a})}function bo(e,t){if(e!=null)return String(e);if(typeof t==`string`)return t}var xo=(e,t)=>{if(t===`horizontal`)return e.relativeX;if(t===`vertical`)return e.relativeY},So=(e,t)=>t===`centric`?e.angle:e.radius,Co=e=>e.layout.width,wo=e=>e.layout.height,To=e=>e.layout.scale,Eo=e=>e.layout.margin,Do=R(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Oo=R(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),ko=`data-recharts-item-index`;function Ao(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jo(e){for(var t=1;te.brush.height;function Io(e){return Oo(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Lo(e){return Oo(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Ro(e){return Do(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}function zo(e){return Do(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}var Bo=R([Co,wo,Eo,Fo,Io,Lo,Ro,zo,Zn,Qn],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=jo(jo({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=io(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return jo(jo({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),Vo=R(Bo,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Ho=R(Co,wo,(e,t)=>({x:0,y:0,width:e,height:t})),Uo=(0,s.createContext)(null),Wo=()=>(0,s.useContext)(Uo)!=null,Go=e=>e.brush,Ko=R([Go,Bo,Eo],(e,t,n)=>({height:e.height,x:P(e.x)?e.x:t.left,y:P(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:P(e.width)?e.width:t.width}));function qo(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}function Jo(e,t=0,n={}){typeof n!=`object`&&(n={});let{leading:r=!1,trailing:i=!0,maxWait:a}=n,o=[,,];r&&(o[0]=`leading`),i&&(o[1]=`trailing`);let s,c=null,l=qo(function(...t){s=e.apply(this,t),c=null},t,{edges:o}),u=function(...t){return a!=null&&(c===null&&(c=Date.now()),Date.now()-c>=a)?((r||i)&&(s=e.apply(this,t)),c=Date.now(),l.cancel(),l.schedule(),s):(l.apply(this,t),s)};return u.cancel=l.cancel,u.flush=()=>(l.flush(),s),u}function Yo(e,t=0,n={}){let{leading:r=!0,trailing:i=!0}=n;return Jo(e,t,{leading:r,maxWait:t,trailing:i})}var Xo=function(e,t){var n=[...arguments].slice(2);if(typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e)){if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}}},Zo={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},Qo=(e,t,n)=>{var r=n.width,i=r===void 0?Zo.width:r,a=n.height,o=a===void 0?Zo.height:a,s=n.aspect,c=n.maxHeight,l=le(i)?e:Number(i),u=le(o)?t:Number(o);return s&&s>0&&(l?u=l/s:u&&(l=u*s),c&&u!=null&&u>c&&(u=c)),{calculatedWidth:l,calculatedHeight:u}},$o={width:0,height:0,overflow:`visible`},es={width:0,overflowX:`visible`},ts={height:0,overflowY:`visible`},ns={},rs=e=>{var t=e.width,n=e.height,r=le(t),i=le(n);return r&&i?$o:r?es:i?ts:ns};function is(e){var t=e.width,n=e.height,r=e.aspect,i=t,a=n;return i===void 0&&a===void 0?(i=Zo.width,a=Zo.height):i===void 0?i=r&&r>0?void 0:Zo.width:a===void 0&&(a=r&&r>0?void 0:Zo.height),{width:i,height:a}}var as=[`aspect`,`initialDimension`,`width`,`height`,`minWidth`,`minHeight`,`maxHeight`,`children`,`debounce`,`id`,`className`,`onResize`,`style`];function os(){return os=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n({width:n,height:r}),[n,r]);return xs(i)?s.createElement(bs.Provider,{value:i},t):null}var Cs=()=>(0,s.useContext)(bs),ws=(0,s.forwardRef)((e,t)=>{var n=e.aspect,r=e.initialDimension,i=r===void 0?Zo.initialDimension:r,a=e.width,c=e.height,l=e.minWidth,u=l===void 0?Zo.minWidth:l,d=e.minHeight,f=e.maxHeight,p=e.children,m=e.debounce,h=m===void 0?Zo.debounce:m,g=e.id,_=e.className,v=e.onResize,y=e.style,b=y===void 0?{}:y,x=vs(e,as),S=(0,s.useRef)(null),C=(0,s.useRef)();C.current=v,(0,s.useImperativeHandle)(t,()=>S.current);var w=fs((0,s.useState)({containerWidth:i.width,containerHeight:i.height}),2),T=w[0],E=w[1],D=(0,s.useCallback)((e,t)=>{E(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]);(0,s.useEffect)(()=>{if(S.current==null||typeof ResizeObserver>`u`)return be;var e=e=>{var t,n=e[0];if(n!=null){var r=n.contentRect,i=r.width,a=r.height;D(i,a),(t=C.current)==null||t.call(C,i,a)}};h>0&&(e=Yo(e,h,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),n=S.current.getBoundingClientRect(),r=n.width,i=n.height;return D(r,i),t.observe(S.current),()=>{t.disconnect()}},[D,h]);var O=T.containerWidth,k=T.containerHeight;Xo(!n||n>0,`The aspect(%s) must be greater than zero.`,n);var A=Qo(O,k,{width:a,height:c,aspect:n,maxHeight:f}),j=A.calculatedWidth,M=A.calculatedHeight;return Xo(O<0||k<0||j!=null&&j>0||M!=null&&M>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the diff --git a/internal/webui/static/assets/CostChart-5urt0nTO.js b/internal/webui/static/assets/CostChart-X9vZokWw.js similarity index 93% rename from internal/webui/static/assets/CostChart-5urt0nTO.js rename to internal/webui/static/assets/CostChart-X9vZokWw.js index 20d58a83..1991e566 100644 --- a/internal/webui/static/assets/CostChart-5urt0nTO.js +++ b/internal/webui/static/assets/CostChart-X9vZokWw.js @@ -1 +1 @@ -import{a as e,f as t,h as n,i as r,l as i,r as a}from"./index-A4ivp0An.js";import{i as o,n as s,wt as c}from"./CartesianChart-BkZGKHVn.js";import{n as l,r as u,t as d}from"./XAxis-BeXdNyw4.js";import{t as f}from"./AreaChart-CpgbhahE.js";var p=n(t(),1),m=i(),h=[`var(--accent)`,`var(--muted)`,`var(--success)`,`var(--warning)`];function g(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function _(e,t){return t===`credits`?e.per_model_credits??{}:t===`tokens`?e.per_model_tokens??{}:e.per_model??{}}function v(t,n){return n===`cost`?a(t):n===`tokens`?r(t):e(t)}function y(t,n){return n===`cost`?`¥${t>=10?Math.round(t):Number(t.toFixed(1))}`:n===`tokens`?r(t):e(t)}function b({active:e,payload:t,label:n,daily:r,lang:i,models:a,totalLabel:o,metric:s}){if(!e||!t?.length)return null;let c=new Map(a.map(e=>[e.id,e.label])),l=t.filter(e=>(e.value??0)>0).sort((e,t)=>t.value-e.value),u=t.reduce((e,t)=>e+(t.value??0),0);return(0,m.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,m.jsx)(`div`,{className:`mono text-muted`,children:g(String(n),r,i)}),(0,m.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[l.map(e=>(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[a.findIndex(t=>t.id===e.dataKey)%h.length]}}),c.get(e.dataKey)||e.dataKey]}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(e.value,s)})]},e.dataKey)),(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6 border-t border-separator pt-1`,children:[(0,m.jsx)(`span`,{className:`text-muted`,children:o}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(u,s)})]})]})]})}function x({series:e,models:t,lang:n,emptyLabel:r,totalLabel:i,metric:a=`credits`}){let v=(0,p.useMemo)(()=>t.map(e=>e.id),[t]),x=(0,p.useMemo)(()=>e.map(e=>{let t=_(e,a),n={at:e.at};for(let e of v){let r=Number(t[e]??0);n[e]=a===`tokens`?r:Number(r.toFixed(4))}return n}),[e,v,a]),S=Math.max(0,...x.map(e=>v.reduce((t,n)=>t+Number(e[n]??0),0)))>0,C=(x.length>1?Date.parse(x[x.length-1].at)-Date.parse(x[0].at):0)>1728e5;return!e.length||!S?(0,m.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center text-sm text-muted`,children:r}):(0,m.jsxs)(`div`,{className:`min-w-0`,children:[(0,m.jsx)(`div`,{className:`h-72 w-full`,children:(0,m.jsx)(c,{width:`100%`,height:`100%`,children:(0,m.jsxs)(f,{data:x,margin:{top:8,right:8,bottom:0,left:0},children:[(0,m.jsx)(`defs`,{children:v.map((e,t)=>(0,m.jsxs)(`linearGradient`,{id:`cost-${a}-${e}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,m.jsx)(`stop`,{offset:`0%`,stopColor:h[t%h.length],stopOpacity:.32}),(0,m.jsx)(`stop`,{offset:`100%`,stopColor:h[t%h.length],stopOpacity:.04})]},e))}),(0,m.jsx)(l,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,m.jsx)(d,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>g(e,C,n)}),(0,m.jsx)(s,{width:52,tickLine:!1,axisLine:!1,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>y(e,a)}),(0,m.jsx)(u,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,m.jsx)(b,{daily:C,lang:n,models:t,totalLabel:i,metric:a})}),v.map((e,t)=>(0,m.jsx)(o,{type:`monotone`,dataKey:e,stackId:`usage`,stroke:h[t%h.length],strokeWidth:1.5,fill:`url(#cost-${a}-${e})`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:1.2}},e))]})})}),(0,m.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[10px] text-muted`,children:t.map((e,t)=>(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[t%h.length]}}),e.label]},e.id))})]})}export{x as CostChart}; \ No newline at end of file +import{a as e,f as t,h as n,i as r,l as i,r as a}from"./index-Cg5HTsPm.js";import{i as o,n as s,wt as c}from"./CartesianChart-SZzrkft1.js";import{n as l,r as u,t as d}from"./XAxis-Frfh6e9H.js";import{t as f}from"./AreaChart-BZEGDE2D.js";var p=n(t(),1),m=i(),h=[`var(--accent)`,`var(--muted)`,`var(--success)`,`var(--warning)`];function g(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function _(e,t){return t===`credits`?e.per_model_credits??{}:t===`tokens`?e.per_model_tokens??{}:e.per_model??{}}function v(t,n){return n===`cost`?a(t):n===`tokens`?r(t):e(t)}function y(t,n){return n===`cost`?`¥${t>=10?Math.round(t):Number(t.toFixed(1))}`:n===`tokens`?r(t):e(t)}function b({active:e,payload:t,label:n,daily:r,lang:i,models:a,totalLabel:o,metric:s}){if(!e||!t?.length)return null;let c=new Map(a.map(e=>[e.id,e.label])),l=t.filter(e=>(e.value??0)>0).sort((e,t)=>t.value-e.value),u=t.reduce((e,t)=>e+(t.value??0),0);return(0,m.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,m.jsx)(`div`,{className:`mono text-muted`,children:g(String(n),r,i)}),(0,m.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[l.map(e=>(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[a.findIndex(t=>t.id===e.dataKey)%h.length]}}),c.get(e.dataKey)||e.dataKey]}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(e.value,s)})]},e.dataKey)),(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6 border-t border-separator pt-1`,children:[(0,m.jsx)(`span`,{className:`text-muted`,children:o}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(u,s)})]})]})]})}function x({series:e,models:t,lang:n,emptyLabel:r,totalLabel:i,metric:a=`credits`}){let v=(0,p.useMemo)(()=>t.map(e=>e.id),[t]),x=(0,p.useMemo)(()=>e.map(e=>{let t=_(e,a),n={at:e.at};for(let e of v){let r=Number(t[e]??0);n[e]=a===`tokens`?r:Number(r.toFixed(4))}return n}),[e,v,a]),S=Math.max(0,...x.map(e=>v.reduce((t,n)=>t+Number(e[n]??0),0)))>0,C=(x.length>1?Date.parse(x[x.length-1].at)-Date.parse(x[0].at):0)>1728e5;return!e.length||!S?(0,m.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center text-sm text-muted`,children:r}):(0,m.jsxs)(`div`,{className:`min-w-0`,children:[(0,m.jsx)(`div`,{className:`h-72 w-full`,children:(0,m.jsx)(c,{width:`100%`,height:`100%`,children:(0,m.jsxs)(f,{data:x,margin:{top:8,right:8,bottom:0,left:0},children:[(0,m.jsx)(`defs`,{children:v.map((e,t)=>(0,m.jsxs)(`linearGradient`,{id:`cost-${a}-${e}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,m.jsx)(`stop`,{offset:`0%`,stopColor:h[t%h.length],stopOpacity:.32}),(0,m.jsx)(`stop`,{offset:`100%`,stopColor:h[t%h.length],stopOpacity:.04})]},e))}),(0,m.jsx)(l,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,m.jsx)(d,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>g(e,C,n)}),(0,m.jsx)(s,{width:52,tickLine:!1,axisLine:!1,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>y(e,a)}),(0,m.jsx)(u,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,m.jsx)(b,{daily:C,lang:n,models:t,totalLabel:i,metric:a})}),v.map((e,t)=>(0,m.jsx)(o,{type:`monotone`,dataKey:e,stackId:`usage`,stroke:h[t%h.length],strokeWidth:1.5,fill:`url(#cost-${a}-${e})`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:1.2}},e))]})})}),(0,m.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[10px] text-muted`,children:t.map((e,t)=>(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[t%h.length]}}),e.label]},e.id))})]})}export{x as CostChart}; \ No newline at end of file diff --git a/internal/webui/static/assets/LiveSparkline-CiMyj7tn.js b/internal/webui/static/assets/LiveSparkline-37ksHAMS.js similarity index 73% rename from internal/webui/static/assets/LiveSparkline-CiMyj7tn.js rename to internal/webui/static/assets/LiveSparkline-37ksHAMS.js index 535bc0c9..a72ad20b 100644 --- a/internal/webui/static/assets/LiveSparkline-CiMyj7tn.js +++ b/internal/webui/static/assets/LiveSparkline-37ksHAMS.js @@ -1 +1 @@ -import{l as e}from"./index-A4ivp0An.js";import{i as t,n,wt as r}from"./CartesianChart-BkZGKHVn.js";import{t as i}from"./AreaChart-CpgbhahE.js";var a=e();function o({samples:e,capacity:o,label:s}){let c=e.length?e:[{at:0,value:0}],l=Math.max(1,o,...c.map(e=>e.value));return(0,a.jsx)(`div`,{className:`h-6 w-[120px] shrink-0`,role:`img`,"aria-label":s,children:(0,a.jsx)(r,{width:`100%`,height:`100%`,children:(0,a.jsxs)(i,{data:c,margin:{top:1,right:0,bottom:1,left:0},children:[(0,a.jsx)(n,{hide:!0,domain:[0,l]}),(0,a.jsx)(t,{type:`monotone`,dataKey:`value`,stroke:`var(--foreground)`,strokeOpacity:.7,strokeWidth:1.25,fill:`var(--foreground)`,fillOpacity:.08,isAnimationActive:!1,dot:!1})]})})})}export{o as LiveSparkline}; \ No newline at end of file +import{l as e}from"./index-Cg5HTsPm.js";import{i as t,n,wt as r}from"./CartesianChart-SZzrkft1.js";import{t as i}from"./AreaChart-BZEGDE2D.js";var a=e();function o({samples:e,capacity:o,label:s}){let c=e.length?e:[{at:0,value:0}],l=Math.max(1,o,...c.map(e=>e.value));return(0,a.jsx)(`div`,{className:`h-6 w-[120px] shrink-0`,role:`img`,"aria-label":s,children:(0,a.jsx)(r,{width:`100%`,height:`100%`,children:(0,a.jsxs)(i,{data:c,margin:{top:1,right:0,bottom:1,left:0},children:[(0,a.jsx)(n,{hide:!0,domain:[0,l]}),(0,a.jsx)(t,{type:`monotone`,dataKey:`value`,stroke:`var(--foreground)`,strokeOpacity:.7,strokeWidth:1.25,fill:`var(--foreground)`,fillOpacity:.08,isAnimationActive:!1,dot:!1})]})})})}export{o as LiveSparkline}; \ No newline at end of file diff --git a/internal/webui/static/assets/TrafficChart-DKxQTayd.js b/internal/webui/static/assets/TrafficChart-r71KB7Cg.js similarity index 98% rename from internal/webui/static/assets/TrafficChart-DKxQTayd.js rename to internal/webui/static/assets/TrafficChart-r71KB7Cg.js index 0b10250f..a37320d4 100644 --- a/internal/webui/static/assets/TrafficChart-DKxQTayd.js +++ b/internal/webui/static/assets/TrafficChart-r71KB7Cg.js @@ -1 +1 @@ -import{f as e,h as t,i as n,l as r,n as i,o as a,s as o,t as s,u as c}from"./index-A4ivp0An.js";import{A as l,An as u,C as d,Cn as f,D as p,E as m,Et as h,L as g,Lt as _,M as v,Mn as y,Mt as b,N as x,Nt as S,O as C,Ot as w,P as T,Pt as E,Q as D,Rt as O,S as k,T as A,Z as j,_t as M,a as N,bn as P,bt as ee,ct as te,d as F,et as ne,f as re,g as ie,gt as ae,h as oe,hn as I,i as se,j as ce,jn as L,k as le,kt as R,m as ue,n as de,nt as fe,o as pe,p as me,pt as he,s as ge,st as z,t as _e,vn as B,w as ve,wn as ye,wt as be,x as xe,yn as V,z as H,zt as U}from"./CartesianChart-BkZGKHVn.js";import{i as Se,n as Ce,r as we,t as Te}from"./XAxis-BeXdNyw4.js";var Ee=class{constructor(e){var t=e.x,n=e.y;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var n=t.position;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var n=t.position,r=t.fallback,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var t=e.x,n=e.y,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}},W=t(e());function G(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t{var s=o.x1,c=o.x2,l=o.y1,u=o.y2;if(i==null||a==null)return null;var d=new Ee({x:i,y:a}),f={x:e?i.map(s,{position:`start`})??null:i.rangeMin(),y:n?a.map(l,{position:`start`})??null:a.rangeMin()},p={x:t?i.map(c,{position:`end`})??null:i.rangeMax(),y:r?a.map(u,{position:`end`})??null:a.rangeMax()};return o.ifOverflow===`discard`&&(!d.isInRange(f)||!d.isInRange(p))?null:ue(f,p)},je=(e,t)=>W.isValidElement(e)?W.cloneElement(e,t):typeof e==`function`?e(t):W.createElement(Se,q({},t,{className:`recharts-reference-area-rect`}));function Me(e){var t=O();return(0,W.useEffect)(()=>(t(re(e)),()=>{t(me(e))})),null}function Ne(e){var t=e.x1,n=e.x2,r=e.y1,i=e.y2,a=e.className,o=e.shape,s=e.xAxisId,l=e.yAxisId,d=F(),f=h(),p=U(e=>j(e,`xAxis`,s,f)),m=U(e=>j(e,`yAxis`,l,f));if(p==null||m==null)return null;var g=P(t),_=P(n),v=P(r),y=P(i);if(!g&&!_&&!v&&!y&&!o)return null;var b=Ae(g,_,v,y,p,m,e);if(!b&&!o)return null;var S=e.ifOverflow===`hidden`?`url(#${d})`:void 0;return W.createElement(H,{zIndex:e.zIndex},W.createElement(u,{className:c(`recharts-reference-area`,a)},je(o,K(K({clipPath:S},L(e)),b)),b!=null&&W.createElement(x,q({},b,{lowerWidth:b.width,upperWidth:b.width}),W.createElement(T,{label:e.label}),e.children)))}var Pe={ifOverflow:`discard`,xAxisId:0,yAxisId:0,radius:0,fill:`#ccc`,label:!1,fillOpacity:.5,stroke:`none`,strokeWidth:1,zIndex:z.area};function Fe(e){var t=I(e,Pe);return W.createElement(W.Fragment,null,W.createElement(Me,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2}),W.createElement(Ne,t))}Fe.displayName=`ReferenceArea`;var Ie=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;te+t,0);if(!i)return Be(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;co){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...He(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function We(e,t,n){return e?Ue(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Be(t,n)}function Ge(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=Le(e,Ie),a=r??!1,o;if(t!=null){var s=i.pathRef;o=We(n,ze(s?.current??null),t)}else n!=null&&(o=String(n));return W.createElement(he,J({},i,{connectNulls:a,strokeDasharray:o}))}function Ke(e){var t=(0,W.useRef)(0),n=(0,W.useRef)(0),r=(0,W.useRef)(!1),i=(0,W.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,W.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(ye(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}var qe=[`children`];function Je(e,t){if(e==null)return{};var n,r,i=Ye(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function Ze(e){var t=e.children,n=Je(e,qe);return W.createElement(Xe.Provider,{value:n},t)}var Qe=(e,t,n,r)=>D(e,`xAxis`,t,r),$e=(e,t,n,r)=>ne(e,`xAxis`,t,r),et=(e,t,n,r)=>D(e,`yAxis`,n,r),tt=(e,t,n,r)=>ne(e,`yAxis`,n,r),nt=_([M,Qe,et,$e,tt],(e,t,n,r,i)=>E(e,`xAxis`)?w(t,r,!1):w(n,i,!1)),rt=(e,t,n,r,i)=>i;function it(e){return e.type===`line`}var at=_([fe,rt],(e,t)=>e.filter(it).find(e=>e.id===t)),ot=_([M,Qe,et,$e,tt,at,nt,te],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return Dt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}}),st=[`id`],ct=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],lt=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?t/n:0}var Q={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=gt(e),r=[];for(var i of e)if(i.status===`matched`)r.push(Z(Z({},i.next),{},{x:B(i.prev.x,i.next.x,t),y:B(i.prev.y,i.next.y,t)}));else if(i.status===`added`){if(i.next.x!=null){var a=i.next.x-n;r.push(Z(Z({},i.next),{},{x:B(a,i.next.x,t),y:i.next.y}))}else r.push(i.next)}else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(Z(Z({},i.prev),{},{x:B(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:m,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:Ge,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:z.line,type:`linear`},_t=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:b(n,t),payload:e}]},vt=W.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,p={dataDefinedOnItem:n,getPosition:f,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:b(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return W.createElement(C,{tooltipEntrySettings:p})});function yt(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=X(r,st),c=y(s);return W.createElement(xe,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function bt(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,W.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return W.createElement(ce,{value:t?i:void 0},n)}function xt(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,h=X(i,ct),g=Z(Z({},L(h)),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return W.createElement(W.Fragment,null,r?.length>1&&W.createElement(le,{option:p,DefaultShape:Q.shape,shapeProps:g}),W.createElement(yt,{points:r,clipPathId:t,props:i}))}function St(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,p=ht(r.current),m=A(n.onAnimationStart,n.onAnimationEnd),h=m.isAnimating,g=m.handleAnimationStart,_=m.handleAnimationEnd,y=!h,b=Ke(a),x=(0,W.useCallback)(e=>e>0&&p>0,[p]);return W.createElement(bt,{points:a,showLabels:y},n.children,W.createElement(ve,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:g,onAnimationEnd:_,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:x,layout:f},(e,i,a)=>{var o=h||i<1,s=o?b(i,p):null;return W.createElement(xt,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),W.createElement(v,{label:n.label}))}function Ct(e){var t=e.clipPathId,n=e.props,r=(0,W.useRef)(null),i=(0,W.useRef)(null);return W.createElement(St,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var wt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:S(e.payload,t)}),Tt=class extends W.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.xAxisId,o=e.yAxisId,s=e.top,d=e.left,f=e.width,p=e.height,m=e.id,h=e.needClip,g=e.zIndex;if(t)return null;var _=c(`recharts-line`,i),v=m,y=N(n),b=y.r,x=y.strokeWidth,S=l(n),C=b*2+x,w=h?`url(#clipPath-${S?``:`dots-`}${v})`:void 0;return W.createElement(H,{zIndex:g},W.createElement(u,{className:_},h&&W.createElement(`defs`,null,W.createElement(pe,{clipPathId:v,xAxisId:a,yAxisId:o}),!S&&W.createElement(`clipPath`,{id:`clipPath-dots-${v}`},W.createElement(`rect`,{x:d-C/2,y:s-C/2,width:f+C,height:p+C}))),W.createElement(Ze,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:wt,errorBarOffset:0},W.createElement(Ct,{props:this.props,clipPathId:v}))),W.createElement(oe,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:w}))}};function Et(e){var t=I(e,Q),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,p=t.xAxisId,m=t.yAxisId,g=t.id,_=X(t,lt),v=ge(p,m).needClip,y=ie(),b=ee(),x=h(),S=U(e=>ot(e,p,m,x,g));if(b!==`horizontal`&&b!==`vertical`||S==null||y==null)return null;var C=y.height,w=y.width,T=y.x,E=y.y;return W.createElement(Tt,Y({},_,{id:g,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:S,layout:b,height:C,width:w,left:T,top:E,needClip:v}))}function Dt(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=S(e,o);if(t===`horizontal`)return{x:R({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=R({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function Ot(e){var t=I(e,Q),n=h();return W.createElement(d,{id:t.id,type:`line`},e=>W.createElement(W.Fragment,null,W.createElement(p,{legendPayload:_t(t)}),W.createElement(vt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),W.createElement(k,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),W.createElement(Et,Y({},t,{id:e}))))}var kt=W.memo(Ot,ae);kt.displayName=`Line`;var At=[`axis`],jt=(0,W.forwardRef)((e,t)=>W.createElement(_e,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:At,tooltipPayloadSearcher:g,categoricalChartProps:e,ref:t})),Mt={metric:24,title:18,section:15,body:13,xs:12,caption:12},$=r();function Nt(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function Pt(e){if(e<=1)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function Ft(e){let t=Math.max(0,e.ok??e.requests-e.error),n=Math.min(Math.max(0,e.requests-t),Math.max(0,e.requests));return{...e,okCount:t,errorCount:n,inputTokens:e.prompt_tokens??0,outputTokens:e.completion_tokens??0,cacheTokens:e.cache_read_tokens??0,p50:e.latency_p50_ms??null,p95:e.latency_p95_ms??null}}function It({active:e,payload:t,daily:n,lang:r,specs:i,format:a,totalLabel:o,total:s}){if(!e||!t?.[0])return null;let c=t[0].payload;return(0,$.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,$.jsx)(`div`,{className:`mono text-muted`,children:Nt(c.at,n,r)}),(0,$.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(c[e.key])})]},String(e.key))),s&&o?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6 pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted`,children:o}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(s(c))})]}):null]})]})}function Lt({series:e,lang:t,emptyLabel:r,okLabel:c,errorLabel:l,onSelectRange:u,selectHint:d,labels:f,initialMetric:p=`requests`}){let[m,h]=(0,W.useState)(p),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),b=(0,W.useRef)(!1),x=(0,W.useRef)(null),S=(0,W.useMemo)(()=>e.map(Ft),[e]),C=S[0],w=S[S.length-1],T=(C&&w?Date.parse(w.at)-Date.parse(C.at):0)>1728e5,E=f??{requests:`Requests`,tokens:`Tokens`,latency:`p95 latency`,input:`input`,output:`output`,cacheRead:`cache read`,p50:`p50`,p95:`p95`,total:`total`},D=m===`tokens`?[{key:`inputTokens`,label:E.input,color:`var(--foreground)`,area:!0,width:1.5,opacity:.75},{key:`outputTokens`,label:E.output,color:`var(--success)`,area:!0,width:1.5},{key:`cacheTokens`,label:E.cacheRead,color:`var(--muted)`,width:1.25,opacity:.8}]:m===`latency`?[{key:`p95`,label:E.p95,color:`var(--warning)`,area:!0,width:1.75},{key:`p50`,label:E.p50,color:`var(--muted)`,width:1.25,opacity:.85}]:[{key:`okCount`,label:c,color:`var(--success)`,area:!0,width:1.75},{key:`errorCount`,label:l,color:`var(--danger)`,area:!0,width:1.25,opacity:.7}],O=e=>e==null?`—`:m===`latency`?a(e):n(e),k=m===`requests`?e=>e.requests:m===`tokens`?e=>e.inputTokens+e.outputTokens:void 0,A=S.flatMap(e=>D.map(t=>Number(e[t.key]??0))),j=m===`requests`?Math.max(0,...S.map(e=>e.requests)):Math.max(0,...A),M=Pt(j),N=S.some(e=>e.requests>0),P=S.map(e=>`${e.at}:${e.requests}:${e.error}`).join(`|`);(0,W.useLayoutEffect)(()=>{let e=x.current;if(!e||!N||b.current)return;let t=!1,n=null,r=o.context(()=>{let r=o.matchMedia(),i=()=>{let t=o.utils.toArray(`.recharts-area-area`,e),n=o.utils.toArray(`.recharts-line-curve`,e);return!t.length&&!n.length?!1:(r.add(`(prefers-reduced-motion: reduce)`,()=>{o.set(n,{clearProps:`strokeDashoffset,strokeDasharray`}),o.set(t,{clearProps:`autoAlpha`})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{o.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:.45,ease:`power2.out`,stagger:.05}),n.forEach((e,t)=>{let n=e.getTotalLength();o.fromTo(e,{strokeDasharray:n,strokeDashoffset:n},{strokeDashoffset:0,duration:.7,delay:t*.05,ease:`power2.out`})})}),!0)};if(i()){t=!0,b.current=!0;return}n=new MutationObserver(()=>{t||i()&&(t=!0,b.current=!0,n?.disconnect())}),n.observe(e,{childList:!0,subtree:!0})},e);return()=>{n?.disconnect(),r.revert()}},[N,P]);let ee=S.length>1?Date.parse(S[1].at)-Date.parse(S[0].at):36e5,te=()=>{if(g&&v&&u){let e=Date.parse(g),t=Date.parse(v);if(Number.isFinite(e)&&Number.isFinite(t)){let n=Math.min(e,t),r=Math.max(e,t)+ee;u(new Date(n).toISOString(),new Date(r).toISOString())}}_(null),y(null)},F=e=>{let t=e?.activeLabel;return t==null?null:String(t)};return!e.length||!N?(0,$.jsx)(i,{emptyLabel:r}):(0,$.jsxs)(`div`,{ref:x,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,$.jsx)(s,{value:m,onChange:e=>h(e),ariaLabel:E.requests,options:[{id:`requests`,label:E.requests},{id:`tokens`,label:E.tokens},{id:`latency`,label:E.latency}]})}),(0,$.jsx)(`div`,{className:`h-56 w-full`,children:(0,$.jsx)(be,{width:`100%`,height:`100%`,children:(0,$.jsxs)(jt,{data:S,margin:{top:8,right:8,bottom:0,left:0},style:u?{cursor:`crosshair`,userSelect:`none`}:void 0,onMouseDown:u?e=>{let t=F(e);t&&(_(t),y(t))}:void 0,onMouseMove:u?e=>{if(!g)return;let t=F(e);t&&y(t)}:void 0,onMouseUp:u?te:void 0,onMouseLeave:u?()=>{_(null),y(null)}:void 0,children:[(0,$.jsx)(`defs`,{children:D.filter(e=>e.area).map(e=>(0,$.jsxs)(`linearGradient`,{id:`traffic-fill-${String(e.key)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:e.color,stopOpacity:.22}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:e.color,stopOpacity:.02})]},String(e.key)))}),(0,$.jsx)(Ce,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,$.jsx)(Te,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:Mt.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>Nt(e,T,t)}),(0,$.jsx)(de,{width:m===`latency`?44:36,domain:[0,M],tickLine:!1,axisLine:!1,allowDecimals:!1,tick:{fill:`var(--muted)`,fontSize:Mt.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>m===`latency`?a(e):n(e)}),(0,$.jsx)(we,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,$.jsx)(It,{daily:T,lang:t,specs:D,format:O,totalLabel:E.total,total:k})}),D.filter(e=>e.area).map(e=>(0,$.jsx)(se,{type:`monotone`,dataKey:e.key,stroke:`none`,fill:`url(#traffic-fill-${String(e.key)})`,isAnimationActive:!1,activeDot:!1,dot:!1,connectNulls:!0},`area-${String(e.key)}`)),D.map(e=>(0,$.jsx)(kt,{type:`monotone`,dataKey:e.key,stroke:e.color,strokeWidth:e.width??1.5,strokeOpacity:e.opacity??1,dot:!1,isAnimationActive:!1,connectNulls:!0,activeDot:{r:4,fill:`var(--surface)`,stroke:e.color,strokeWidth:1.5}},`line-${String(e.key)}`)),g&&v?(0,$.jsx)(Fe,{x1:g,x2:v,fill:`var(--foreground)`,fillOpacity:.06,stroke:`none`,ifOverflow:`visible`}):null]})})}),(0,$.jsxs)(`div`,{className:`mt-2 flex min-h-5 items-center justify-between gap-3 text-caption text-muted`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-3`,children:D.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]},String(e.key)))}),(0,$.jsxs)(`span`,{className:`flex items-center gap-3`,children:[u&&d?(0,$.jsx)(`span`,{children:d}):null,(0,$.jsxs)(`span`,{className:`mono`,children:[O(j),` peak`]})]})]})]})}export{Lt as TrafficChart}; \ No newline at end of file +import{f as e,h as t,i as n,l as r,n as i,o as a,s as o,t as s,u as c}from"./index-Cg5HTsPm.js";import{A as l,An as u,C as d,Cn as f,D as p,E as m,Et as h,L as g,Lt as _,M as v,Mn as y,Mt as b,N as x,Nt as S,O as C,Ot as w,P as T,Pt as E,Q as D,Rt as O,S as k,T as A,Z as j,_t as M,a as N,bn as P,bt as ee,ct as te,d as F,et as ne,f as re,g as ie,gt as ae,h as oe,hn as I,i as se,j as ce,jn as L,k as le,kt as R,m as ue,n as de,nt as fe,o as pe,p as me,pt as he,s as ge,st as z,t as _e,vn as B,w as ve,wn as ye,wt as be,x as xe,yn as V,z as H,zt as U}from"./CartesianChart-SZzrkft1.js";import{i as Se,n as Ce,r as we,t as Te}from"./XAxis-Frfh6e9H.js";var Ee=class{constructor(e){var t=e.x,n=e.y;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var n=t.position;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var n=t.position,r=t.fallback,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var t=e.x,n=e.y,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}},W=t(e());function G(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t{var s=o.x1,c=o.x2,l=o.y1,u=o.y2;if(i==null||a==null)return null;var d=new Ee({x:i,y:a}),f={x:e?i.map(s,{position:`start`})??null:i.rangeMin(),y:n?a.map(l,{position:`start`})??null:a.rangeMin()},p={x:t?i.map(c,{position:`end`})??null:i.rangeMax(),y:r?a.map(u,{position:`end`})??null:a.rangeMax()};return o.ifOverflow===`discard`&&(!d.isInRange(f)||!d.isInRange(p))?null:ue(f,p)},je=(e,t)=>W.isValidElement(e)?W.cloneElement(e,t):typeof e==`function`?e(t):W.createElement(Se,q({},t,{className:`recharts-reference-area-rect`}));function Me(e){var t=O();return(0,W.useEffect)(()=>(t(re(e)),()=>{t(me(e))})),null}function Ne(e){var t=e.x1,n=e.x2,r=e.y1,i=e.y2,a=e.className,o=e.shape,s=e.xAxisId,l=e.yAxisId,d=F(),f=h(),p=U(e=>j(e,`xAxis`,s,f)),m=U(e=>j(e,`yAxis`,l,f));if(p==null||m==null)return null;var g=P(t),_=P(n),v=P(r),y=P(i);if(!g&&!_&&!v&&!y&&!o)return null;var b=Ae(g,_,v,y,p,m,e);if(!b&&!o)return null;var S=e.ifOverflow===`hidden`?`url(#${d})`:void 0;return W.createElement(H,{zIndex:e.zIndex},W.createElement(u,{className:c(`recharts-reference-area`,a)},je(o,K(K({clipPath:S},L(e)),b)),b!=null&&W.createElement(x,q({},b,{lowerWidth:b.width,upperWidth:b.width}),W.createElement(T,{label:e.label}),e.children)))}var Pe={ifOverflow:`discard`,xAxisId:0,yAxisId:0,radius:0,fill:`#ccc`,label:!1,fillOpacity:.5,stroke:`none`,strokeWidth:1,zIndex:z.area};function Fe(e){var t=I(e,Pe);return W.createElement(W.Fragment,null,W.createElement(Me,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2}),W.createElement(Ne,t))}Fe.displayName=`ReferenceArea`;var Ie=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;te+t,0);if(!i)return Be(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;co){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...He(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function We(e,t,n){return e?Ue(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Be(t,n)}function Ge(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=Le(e,Ie),a=r??!1,o;if(t!=null){var s=i.pathRef;o=We(n,ze(s?.current??null),t)}else n!=null&&(o=String(n));return W.createElement(he,J({},i,{connectNulls:a,strokeDasharray:o}))}function Ke(e){var t=(0,W.useRef)(0),n=(0,W.useRef)(0),r=(0,W.useRef)(!1),i=(0,W.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,W.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(ye(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}var qe=[`children`];function Je(e,t){if(e==null)return{};var n,r,i=Ye(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function Ze(e){var t=e.children,n=Je(e,qe);return W.createElement(Xe.Provider,{value:n},t)}var Qe=(e,t,n,r)=>D(e,`xAxis`,t,r),$e=(e,t,n,r)=>ne(e,`xAxis`,t,r),et=(e,t,n,r)=>D(e,`yAxis`,n,r),tt=(e,t,n,r)=>ne(e,`yAxis`,n,r),nt=_([M,Qe,et,$e,tt],(e,t,n,r,i)=>E(e,`xAxis`)?w(t,r,!1):w(n,i,!1)),rt=(e,t,n,r,i)=>i;function it(e){return e.type===`line`}var at=_([fe,rt],(e,t)=>e.filter(it).find(e=>e.id===t)),ot=_([M,Qe,et,$e,tt,at,nt,te],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return Dt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}}),st=[`id`],ct=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],lt=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?t/n:0}var Q={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=gt(e),r=[];for(var i of e)if(i.status===`matched`)r.push(Z(Z({},i.next),{},{x:B(i.prev.x,i.next.x,t),y:B(i.prev.y,i.next.y,t)}));else if(i.status===`added`){if(i.next.x!=null){var a=i.next.x-n;r.push(Z(Z({},i.next),{},{x:B(a,i.next.x,t),y:i.next.y}))}else r.push(i.next)}else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(Z(Z({},i.prev),{},{x:B(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:m,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:Ge,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:z.line,type:`linear`},_t=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:b(n,t),payload:e}]},vt=W.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,p={dataDefinedOnItem:n,getPosition:f,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:b(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return W.createElement(C,{tooltipEntrySettings:p})});function yt(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=X(r,st),c=y(s);return W.createElement(xe,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function bt(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,W.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return W.createElement(ce,{value:t?i:void 0},n)}function xt(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,h=X(i,ct),g=Z(Z({},L(h)),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return W.createElement(W.Fragment,null,r?.length>1&&W.createElement(le,{option:p,DefaultShape:Q.shape,shapeProps:g}),W.createElement(yt,{points:r,clipPathId:t,props:i}))}function St(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,p=ht(r.current),m=A(n.onAnimationStart,n.onAnimationEnd),h=m.isAnimating,g=m.handleAnimationStart,_=m.handleAnimationEnd,y=!h,b=Ke(a),x=(0,W.useCallback)(e=>e>0&&p>0,[p]);return W.createElement(bt,{points:a,showLabels:y},n.children,W.createElement(ve,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:g,onAnimationEnd:_,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:x,layout:f},(e,i,a)=>{var o=h||i<1,s=o?b(i,p):null;return W.createElement(xt,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),W.createElement(v,{label:n.label}))}function Ct(e){var t=e.clipPathId,n=e.props,r=(0,W.useRef)(null),i=(0,W.useRef)(null);return W.createElement(St,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var wt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:S(e.payload,t)}),Tt=class extends W.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.xAxisId,o=e.yAxisId,s=e.top,d=e.left,f=e.width,p=e.height,m=e.id,h=e.needClip,g=e.zIndex;if(t)return null;var _=c(`recharts-line`,i),v=m,y=N(n),b=y.r,x=y.strokeWidth,S=l(n),C=b*2+x,w=h?`url(#clipPath-${S?``:`dots-`}${v})`:void 0;return W.createElement(H,{zIndex:g},W.createElement(u,{className:_},h&&W.createElement(`defs`,null,W.createElement(pe,{clipPathId:v,xAxisId:a,yAxisId:o}),!S&&W.createElement(`clipPath`,{id:`clipPath-dots-${v}`},W.createElement(`rect`,{x:d-C/2,y:s-C/2,width:f+C,height:p+C}))),W.createElement(Ze,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:wt,errorBarOffset:0},W.createElement(Ct,{props:this.props,clipPathId:v}))),W.createElement(oe,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:w}))}};function Et(e){var t=I(e,Q),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,p=t.xAxisId,m=t.yAxisId,g=t.id,_=X(t,lt),v=ge(p,m).needClip,y=ie(),b=ee(),x=h(),S=U(e=>ot(e,p,m,x,g));if(b!==`horizontal`&&b!==`vertical`||S==null||y==null)return null;var C=y.height,w=y.width,T=y.x,E=y.y;return W.createElement(Tt,Y({},_,{id:g,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:S,layout:b,height:C,width:w,left:T,top:E,needClip:v}))}function Dt(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=S(e,o);if(t===`horizontal`)return{x:R({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=R({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function Ot(e){var t=I(e,Q),n=h();return W.createElement(d,{id:t.id,type:`line`},e=>W.createElement(W.Fragment,null,W.createElement(p,{legendPayload:_t(t)}),W.createElement(vt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),W.createElement(k,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),W.createElement(Et,Y({},t,{id:e}))))}var kt=W.memo(Ot,ae);kt.displayName=`Line`;var At=[`axis`],jt=(0,W.forwardRef)((e,t)=>W.createElement(_e,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:At,tooltipPayloadSearcher:g,categoricalChartProps:e,ref:t})),Mt={metric:24,title:18,section:15,body:13,xs:12,caption:12},$=r();function Nt(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function Pt(e){if(e<=1)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function Ft(e){let t=Math.max(0,e.ok??e.requests-e.error),n=Math.min(Math.max(0,e.requests-t),Math.max(0,e.requests));return{...e,okCount:t,errorCount:n,inputTokens:e.prompt_tokens??0,outputTokens:e.completion_tokens??0,cacheTokens:e.cache_read_tokens??0,p50:e.latency_p50_ms??null,p95:e.latency_p95_ms??null}}function It({active:e,payload:t,daily:n,lang:r,specs:i,format:a,totalLabel:o,total:s}){if(!e||!t?.[0])return null;let c=t[0].payload;return(0,$.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,$.jsx)(`div`,{className:`mono text-muted`,children:Nt(c.at,n,r)}),(0,$.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(c[e.key])})]},String(e.key))),s&&o?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6 pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted`,children:o}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(s(c))})]}):null]})]})}function Lt({series:e,lang:t,emptyLabel:r,okLabel:c,errorLabel:l,onSelectRange:u,selectHint:d,labels:f,initialMetric:p=`requests`}){let[m,h]=(0,W.useState)(p),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),b=(0,W.useRef)(!1),x=(0,W.useRef)(null),S=(0,W.useMemo)(()=>e.map(Ft),[e]),C=S[0],w=S[S.length-1],T=(C&&w?Date.parse(w.at)-Date.parse(C.at):0)>1728e5,E=f??{requests:`Requests`,tokens:`Tokens`,latency:`p95 latency`,input:`input`,output:`output`,cacheRead:`cache read`,p50:`p50`,p95:`p95`,total:`total`},D=m===`tokens`?[{key:`inputTokens`,label:E.input,color:`var(--foreground)`,area:!0,width:1.5,opacity:.75},{key:`outputTokens`,label:E.output,color:`var(--success)`,area:!0,width:1.5},{key:`cacheTokens`,label:E.cacheRead,color:`var(--muted)`,width:1.25,opacity:.8}]:m===`latency`?[{key:`p95`,label:E.p95,color:`var(--warning)`,area:!0,width:1.75},{key:`p50`,label:E.p50,color:`var(--muted)`,width:1.25,opacity:.85}]:[{key:`okCount`,label:c,color:`var(--success)`,area:!0,width:1.75},{key:`errorCount`,label:l,color:`var(--danger)`,area:!0,width:1.25,opacity:.7}],O=e=>e==null?`—`:m===`latency`?a(e):n(e),k=m===`requests`?e=>e.requests:m===`tokens`?e=>e.inputTokens+e.outputTokens:void 0,A=S.flatMap(e=>D.map(t=>Number(e[t.key]??0))),j=m===`requests`?Math.max(0,...S.map(e=>e.requests)):Math.max(0,...A),M=Pt(j),N=S.some(e=>e.requests>0),P=S.map(e=>`${e.at}:${e.requests}:${e.error}`).join(`|`);(0,W.useLayoutEffect)(()=>{let e=x.current;if(!e||!N||b.current)return;let t=!1,n=null,r=o.context(()=>{let r=o.matchMedia(),i=()=>{let t=o.utils.toArray(`.recharts-area-area`,e),n=o.utils.toArray(`.recharts-line-curve`,e);return!t.length&&!n.length?!1:(r.add(`(prefers-reduced-motion: reduce)`,()=>{o.set(n,{clearProps:`strokeDashoffset,strokeDasharray`}),o.set(t,{clearProps:`autoAlpha`})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{o.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:.45,ease:`power2.out`,stagger:.05}),n.forEach((e,t)=>{let n=e.getTotalLength();o.fromTo(e,{strokeDasharray:n,strokeDashoffset:n},{strokeDashoffset:0,duration:.7,delay:t*.05,ease:`power2.out`})})}),!0)};if(i()){t=!0,b.current=!0;return}n=new MutationObserver(()=>{t||i()&&(t=!0,b.current=!0,n?.disconnect())}),n.observe(e,{childList:!0,subtree:!0})},e);return()=>{n?.disconnect(),r.revert()}},[N,P]);let ee=S.length>1?Date.parse(S[1].at)-Date.parse(S[0].at):36e5,te=()=>{if(g&&v&&u){let e=Date.parse(g),t=Date.parse(v);if(Number.isFinite(e)&&Number.isFinite(t)){let n=Math.min(e,t),r=Math.max(e,t)+ee;u(new Date(n).toISOString(),new Date(r).toISOString())}}_(null),y(null)},F=e=>{let t=e?.activeLabel;return t==null?null:String(t)};return!e.length||!N?(0,$.jsx)(i,{emptyLabel:r}):(0,$.jsxs)(`div`,{ref:x,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,$.jsx)(s,{value:m,onChange:e=>h(e),ariaLabel:E.requests,options:[{id:`requests`,label:E.requests},{id:`tokens`,label:E.tokens},{id:`latency`,label:E.latency}]})}),(0,$.jsx)(`div`,{className:`h-56 w-full`,children:(0,$.jsx)(be,{width:`100%`,height:`100%`,children:(0,$.jsxs)(jt,{data:S,margin:{top:8,right:8,bottom:0,left:0},style:u?{cursor:`crosshair`,userSelect:`none`}:void 0,onMouseDown:u?e=>{let t=F(e);t&&(_(t),y(t))}:void 0,onMouseMove:u?e=>{if(!g)return;let t=F(e);t&&y(t)}:void 0,onMouseUp:u?te:void 0,onMouseLeave:u?()=>{_(null),y(null)}:void 0,children:[(0,$.jsx)(`defs`,{children:D.filter(e=>e.area).map(e=>(0,$.jsxs)(`linearGradient`,{id:`traffic-fill-${String(e.key)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:e.color,stopOpacity:.22}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:e.color,stopOpacity:.02})]},String(e.key)))}),(0,$.jsx)(Ce,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,$.jsx)(Te,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:Mt.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>Nt(e,T,t)}),(0,$.jsx)(de,{width:m===`latency`?44:36,domain:[0,M],tickLine:!1,axisLine:!1,allowDecimals:!1,tick:{fill:`var(--muted)`,fontSize:Mt.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>m===`latency`?a(e):n(e)}),(0,$.jsx)(we,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,$.jsx)(It,{daily:T,lang:t,specs:D,format:O,totalLabel:E.total,total:k})}),D.filter(e=>e.area).map(e=>(0,$.jsx)(se,{type:`monotone`,dataKey:e.key,stroke:`none`,fill:`url(#traffic-fill-${String(e.key)})`,isAnimationActive:!1,activeDot:!1,dot:!1,connectNulls:!0},`area-${String(e.key)}`)),D.map(e=>(0,$.jsx)(kt,{type:`monotone`,dataKey:e.key,stroke:e.color,strokeWidth:e.width??1.5,strokeOpacity:e.opacity??1,dot:!1,isAnimationActive:!1,connectNulls:!0,activeDot:{r:4,fill:`var(--surface)`,stroke:e.color,strokeWidth:1.5}},`line-${String(e.key)}`)),g&&v?(0,$.jsx)(Fe,{x1:g,x2:v,fill:`var(--foreground)`,fillOpacity:.06,stroke:`none`,ifOverflow:`visible`}):null]})})}),(0,$.jsxs)(`div`,{className:`mt-2 flex min-h-5 items-center justify-between gap-3 text-caption text-muted`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-3`,children:D.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]},String(e.key)))}),(0,$.jsxs)(`span`,{className:`flex items-center gap-3`,children:[u&&d?(0,$.jsx)(`span`,{children:d}):null,(0,$.jsxs)(`span`,{className:`mono`,children:[O(j),` peak`]})]})]})]})}export{Lt as TrafficChart}; \ No newline at end of file diff --git a/internal/webui/static/assets/XAxis-BeXdNyw4.js b/internal/webui/static/assets/XAxis-Frfh6e9H.js similarity index 99% rename from internal/webui/static/assets/XAxis-BeXdNyw4.js rename to internal/webui/static/assets/XAxis-Frfh6e9H.js index 2e525e75..ec5ccb6a 100644 --- a/internal/webui/static/assets/XAxis-BeXdNyw4.js +++ b/internal/webui/static/assets/XAxis-Frfh6e9H.js @@ -1,4 +1,4 @@ -import{d as e,f as t,h as n,u as r}from"./index-A4ivp0An.js";import{$ as i,$t as a,At as o,B as s,Bt as c,Ct as l,Dn as u,Dt as d,En as f,Et as p,F as m,Ft as h,G as g,Gt as _,H as v,Ht as y,I as b,It as x,J as S,Jt as C,K as w,Kt as T,Mn as E,Nn as D,On as O,Ot as k,Qt as A,R as ee,Rt as j,Sn as M,St as N,Tn as P,Tt as te,U as ne,Ut as re,V as ie,Vt as ae,W as oe,Wt as se,X as F,Xt as ce,Y as I,Yt as le,Zt as ue,_ as de,_n as L,an as fe,at as pe,b as me,bn as he,bt as ge,c as _e,cn as ve,dn as ye,dt as be,en as xe,fn as Se,ft as Ce,gn as we,hn as R,ht as Te,in as Ee,it as De,jn as Oe,jt as ke,kn as Ae,l as z,ln as je,lt as Me,mn as Ne,mt as Pe,nn as Fe,on as Ie,ot as Le,pn as Re,pt as ze,q as Be,qt as Ve,r as He,rn as Ue,rt as We,sn as Ge,st as B,tn as Ke,tt as qe,u as Je,un as Ye,ut as V,v as Xe,vn as Ze,vt as Qe,wn as H,xn as U,xt as $e,y as et,yn as tt,yt as nt,z as rt,zt as W}from"./CartesianChart-BkZGKHVn.js";function it(e,t){let n=new Map;for(let r=0;rvoid 0)}function mt(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case`object`:return ht(e,t,n,r,i);case`function`:return Object.keys(t).length>0?mt(e,{...t},n,r,i):y(e,t);default:return ae(e)&&i?typeof t!=`string`||t===``:y(e,t)}}function ht(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return _t(e,t,n,r);if(t instanceof Map)return gt(e,t,n,r);if(t instanceof Set)return vt(e,t,n,r);let a=Object.keys(t);if(e==null)return i&&a.length===0;if(i)ct(e)&&(e=Object(e));else{let t=Se(e);if(t!==`[object Object]`&&t!==`[object Arguments]`)return!1}if(a.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let i=0;ivoid 0)}function bt(e){return e=ft(e),t=>yt(t,e)}function xt(e,t){return ut(e,(n,r,i,a)=>{let o=t?.(n,r,i,a);if(o!==void 0)return o;if(typeof e==`object`){if(Se(e)===`[object Object]`&&typeof e.constructor!=`function`){let t={};return a.set(e,t),K(t,e,i,a),t}switch(Object.prototype.toString.call(e)){case Fe:case Ie:case Ve:{let t=new e.constructor(e?.valueOf());return K(t,e),t}case se:{let t={};return K(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}function St(e){return xt(e)}function Ct(e){return typeof e==`object`&&!!e&&Se(e)===`[object Arguments]`}function wt(e,t){let n;if(n=Array.isArray(t)?t:typeof t==`string`&&Ae(t)&&!(t in Object(e))?u(t):[t],n.length===0)return!1;let r=e;for(let e=0;evoid 0)}function mt(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case`object`:return ht(e,t,n,r,i);case`function`:return Object.keys(t).length>0?mt(e,{...t},n,r,i):y(e,t);default:return ae(e)&&i?typeof t!=`string`||t===``:y(e,t)}}function ht(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return _t(e,t,n,r);if(t instanceof Map)return gt(e,t,n,r);if(t instanceof Set)return vt(e,t,n,r);let a=Object.keys(t);if(e==null)return i&&a.length===0;if(i)ct(e)&&(e=Object(e));else{let t=Se(e);if(t!==`[object Object]`&&t!==`[object Arguments]`)return!1}if(a.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let i=0;ivoid 0)}function bt(e){return e=ft(e),t=>yt(t,e)}function xt(e,t){return ut(e,(n,r,i,a)=>{let o=t?.(n,r,i,a);if(o!==void 0)return o;if(typeof e==`object`){if(Se(e)===`[object Object]`&&typeof e.constructor!=`function`){let t={};return a.set(e,t),K(t,e,i,a),t}switch(Object.prototype.toString.call(e)){case Fe:case Ie:case Ve:{let t=new e.constructor(e?.valueOf());return K(t,e),t}case se:{let t={};return K(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}function St(e){return xt(e)}function Ct(e){return typeof e==`object`&&!!e&&Se(e)===`[object Arguments]`}function wt(e,t){let n;if(n=Array.isArray(t)?t:typeof t==`string`&&Ae(t)&&!(t in Object(e))?u(t):[t],n.length===0)return!1;let r=e;for(let e=0;ee.length)&&(t=e.length);for(var n=0,r=Array(t);nLt||Math.abs(e.left-t.left)>Lt||Math.abs(e.top-t.top)>Lt||Math.abs(e.width-t.width)>Lt}function zt(e){var t=e.getBoundingClientRect();return{height:t.height,left:t.left,top:t.top,width:t.width}}function Bt(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=jt((0,q.useState)({height:0,left:0,top:0,width:0}),2),n=t[0],r=t[1],i=(0,q.useRef)(null),a=(0,q.useRef)(n);a.current=n;var o=(0,q.useCallback)(e=>{if(i.current!=null&&(i.current.disconnect(),i.current=null),e!=null){var t=zt(e);if(Rt(t,a.current)&&r(t),typeof ResizeObserver<`u`){var n=new ResizeObserver(()=>{var t=zt(e);Rt(t,a.current)&&r(t)});n.observe(e),i.current=n}}},[...e]);return(0,q.useEffect)(()=>()=>{var e;(e=i.current)==null||e.disconnect()},[]),[n,o]}function Vt(){return Vt=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n{var t=e.separator,n=t===void 0?J.separator:t,i=e.contentStyle,a=e.itemStyle,o=e.labelStyle,s=o===void 0?J.labelStyle:o,c=e.payload,l=e.formatter,u=e.itemSorter,d=e.wrapperClassName,f=e.labelClassName,p=e.label,m=e.labelFormatter,h=e.accessibilityLayer,g=h===void 0?J.accessibilityLayer:h,_=()=>{if(c&&c.length){var e={padding:0,margin:0},t=en(c,u).map((e,t)=>{if(!e||e.type===`none`)return null;var r=e.formatter||l||$t,i=e.value,o=e.name,s=i,u=o;if(r){var d=r(i,o,e,t,c);if(Array.isArray(d)){var f=qt(d,2);s=f[0],u=f[1]}else if(d!=null)s=d;else return null}var p=Ut(Ut({},J.itemStyle),{},{color:e.color||J.itemStyle.color},a);return q.createElement(`li`,{className:`recharts-tooltip-item`,key:`tooltip-item-${t}`,style:p},he(u)?q.createElement(`span`,{className:`recharts-tooltip-item-name`},u):null,he(u)?q.createElement(`span`,{className:`recharts-tooltip-item-separator`},n):null,q.createElement(`span`,{className:`recharts-tooltip-item-value`},s),q.createElement(`span`,{className:`recharts-tooltip-item-unit`},e.unit||``))});return q.createElement(`ul`,{className:`recharts-tooltip-item-list`,style:e},t)}return null},v=Ut(Ut({},J.contentStyle),i),y=Ut({margin:0},s),b=!tt(p),x=b?p:``,S=r(`recharts-default-tooltip`,d),C=r(`recharts-tooltip-label`,f);b&&m&&c!=null&&(x=m(p,c));var w=g?{role:`status`,"aria-live":`assertive`}:{};return q.createElement(`div`,Vt({className:S,style:v},w),q.createElement(`p`,{className:C,style:y},q.isValidElement(x)?x:`${x}`),_())},nn=`recharts-tooltip-wrapper`,rn={visibility:`hidden`};function an(e){var t=e.coordinate,n=e.translateX,i=e.translateY;return r(nn,{[`${nn}-right`]:U(n)&&t&&U(t.x)&&n>=t.x,[`${nn}-left`]:U(n)&&t&&U(t.x)&&n=t.y,[`${nn}-top`]:U(i)&&t&&U(t.y)&&i0?i:0),d=n[r]+i;if(t[r])return o[r]?u:d;var f=c[r];return f==null?0:o[r]?Math.max(uf+l?Math.max(u,f):Math.max(d,f)}function sn(e){var t=e.translateX,n=e.translateY;return{transform:e.useTranslate3d?`translate3d(${t}px, ${n}px, 0)`:`translate(${t}px, ${n}px)`}}function cn(e){var t=e.allowEscapeViewBox,n=e.coordinate,r=e.offsetTop,i=e.offsetLeft,a=e.position,o=e.reverseDirection,s=e.tooltipBox,c=e.useTranslate3d,l=e.viewBox,u,d,f;return s&&s.height>0&&s.width>0&&n?(d=on({allowEscapeViewBox:t,coordinate:n,key:`x`,offset:i,position:a,reverseDirection:o,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=on({allowEscapeViewBox:t,coordinate:n,key:`y`,offset:r,position:a,reverseDirection:o,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),u=sn({translateX:d,translateY:f,useTranslate3d:c})):u=rn,{cssProperties:u,cssClasses:an({translateX:d,translateY:f,coordinate:n})}}function ln(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}})),2),r=n[0],i=n[1];q.useEffect(()=>{var t=t=>{t.key===`Escape`&&i({dismissed:!0,dismissedAtCoordinate:{x:e.coordinate?.x??0,y:e.coordinate?.y??0}})};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t)}},[e.coordinate?.x,e.coordinate?.y]),r.dismissed&&((e.coordinate?.x??0)!==r.dismissedAtCoordinate.x||(e.coordinate?.y??0)!==r.dismissedAtCoordinate.y)&&i(Y(Y({},r),{},{dismissed:!1}));var a=cn({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset==`number`?e.offset:e.offset.x,offsetTop:typeof e.offset==`number`?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:e.lastBoundingBox,useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),o=a.cssClasses,s=a.cssProperties,c=Y(Y({},e.hasPortalFromProps?{}:Y(Y({transition:yn({prefersReducedMotion:t,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},s),{},{pointerEvents:`none`,position:`absolute`,top:0,left:0})),{},{visibility:!r.dismissed&&e.active&&e.hasPayload?`visible`:`hidden`},e.wrapperStyle);return q.createElement(`div`,{xmlns:`http://www.w3.org/1999/xhtml`,tabIndex:-1,className:o,style:c,ref:e.innerRef},e.children)}var xn=q.memo(bn),Sn=[`x`,`y`,`top`,`left`,`width`,`height`,`className`];function Cn(){return Cn=Object.assign?Object.assign.bind():function(e){for(var t=1;t`M${e},${i}v${r}M${a},${t}h${n}`,Mn=e=>{var t=e.x,n=t===void 0?0:t,i=e.y,a=i===void 0?0:i,o=e.top,s=o===void 0?0:o,c=e.left,l=c===void 0?0:c,u=e.width,d=u===void 0?0:u,f=e.height,p=f===void 0?0:f,m=e.className,h=kn(e,Sn),g=Tn({x:n,y:a,top:s,left:l,width:d,height:p},h);return!U(n)||!U(a)||!U(d)||!U(p)||!U(s)||!U(l)?null:q.createElement(`path`,Cn({},Oe(g),{className:r(`recharts-cross`,m),d:jn(n,a,d,p,s,l)}))};function Nn(e,t,n,r){var i=r/2;return{stroke:`none`,fill:`#ccc`,x:e===`horizontal`?t.x-i:n.left+.5,y:e===`horizontal`?n.top+.5:t.y-i,width:e===`horizontal`?r:n.width-1,height:e===`horizontal`?n.height-1:r}}var Pn=e=>e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`),Fn=(e,t,n)=>e.map(e=>`${Pn(e)} ${t}ms ${n}`).join(`,`),In=[`radius`],Ln=[`radius`],Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn;function Jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yn(e){for(var t=1;ti.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LiveSparkline-37ksHAMS.js","assets/CartesianChart-SZzrkft1.js","assets/AreaChart-BZEGDE2D.js","assets/TrafficChart-r71KB7Cg.js","assets/XAxis-Frfh6e9H.js","assets/CostChart-X9vZokWw.js"])))=>i.map(i=>d[i]); var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1R||(e.current=te[R],te[R]=null,R--)}function ne(e,t){R++,te[R]=e.current,e.current=t}var re=z(null),ie=z(null),V=z(null),ae=z(null);function oe(e,t){switch(ne(V,t),ne(ie,e),ne(re,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jd(t),e=Yd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(re),ne(re,e)}function se(){B(re),B(ie),B(V)}function ce(e){e.memoizedState!==null&&ne(ae,e);var t=re.current,n=Yd(t,e.type);t!==n&&(ne(ie,e),ne(re,n))}function le(e){ie.current===e&&(B(re),B(ie)),ae.current===e&&(B(ae),ip._currentValue=L)}var ue,de;function fe(e){if(ue===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ue=t&&t[1]||``,de=-1)`:-1 to !!TX(e)).sort(([e],[t])=>e.localeCompare(t))}function DX(e){return e.enabled?e.status===`quota_exhausted`||e.quota?.exceeded?`quota_exhausted`:e.status===`cooling`||TX(e.down_until||e.cooldown_until)?`cooling`:e.status===`dead`||e.runtime_state===`dead`?`dead`:e.status===`auth_failed`||e.runtime_state===`auth_failed`?`auth_failed`:e.status===`login_required`?`login`:(e.status===`starting`||e.runtime_state===`starting`)&&!e.hot&&!e.ready?e.quota?`starting`:`loading`:e.status===`ready`?e.hot?`hot`:`ready`:e.hot?`hot`:e.ready?`ready`:(e.status===`error`||e.status,`unavailable`):`disabled`}function OX(e){return e===`hot`?12:e===`ready`?9:e===`cooling`?5:e===`login`?3:e===`loading`||e===`starting`?6:e===`unavailable`?2:e===`auth_failed`?3:e===`dead`?2:1}function kX(e){return e===`hot`||e===`ready`?`ok`:e===`cooling`||e===`quota_exhausted`||e===`loading`||e===`starting`?`warn`:e===`auth_failed`||e===`unavailable`||e===`dead`||e===`login`?`danger`:`muted`}function AX(e){return e==null||!Number.isFinite(e)?`—`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(Math.round(e*100)/100)}function jX(e){let t=e.percentage??0;return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):0}function MX(e){let t=e.percentage??0;return e.exceeded?`danger`:t>=80?`warn`:`ok`}function NX(e){return(e.windows??[]).filter(e=>!!e.id)}var PX={free:`Free`,go:`Go`,plus:`Plus`,pro:`Pro`,prolite:`Pro Lite`,promax:`Pro Max`,team:`Team`,business:`Business`,enterprise:`Enterprise`,edu:`Edu`,edu_plus:`Edu Plus`,edu_pro:`Edu Pro`,education:`Education`};function FX(e){let t=e?.trim().toLowerCase()??``;return!t||t===`unknown`||t===`guest`?``:PX[t]??t.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function IX(e,t){return e.id===`daily`?t(`quotaDaily`):e.id===`weekly`?t(`quotaWeekly`):e.id===`monthly`?t(`quotaMonthly`):e.id===`fiveHour`?t(`quotaFiveHour`):e.id===`weeklyLimit`?t(`quotaWeeklyLimit`):e.id===`monthlyLimit`?t(`quotaMonthlyLimit`):e.label||t(`quota`)}function LX(e,t){if(!e)return``;let n=Date.parse(e)-Date.now();if(!Number.isFinite(n)||n<=0)return t(`quotaResetsSoon`);let r=Math.max(1,Math.ceil(n/6e4));return r<60?t(`quotaResetsInMinutes`,{n:r}):t(`quotaResetsInHours`,{n:Math.round(r/60)})}function RX(e,t){if(!e.expires_at||e.expires_at<=0||!Number.isFinite(e.expires_at))return``;let n=new Date(e.expires_at*1e3);if(Number.isNaN(n.getTime()))return``;let r=`${n.getFullYear()}/${n.getMonth()+1}/${n.getDate()}`;return t(`quotaExpiresOn`,{amount:e.expiring_remain&&e.expiring_remain>0?`${AX(e.expiring_remain)} `:``,unit:e.unit||`credits`,date:r})}var zX=864e5,BX=8;function VX(e){return`var(--chart-${e%BX+1})`}function HX(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function UX(e){return e<10?`0${e}`:String(e)}function WX(e){let t=new Date(e);return`${t.getFullYear()}-${UX(t.getMonth()+1)}-${UX(t.getDate())}`}function GX({accounts:e,t}){let[n,r]=(0,v.useState)(!1),{buckets:i,rows:a,todayStart:o,maxTotal:s}=(0,v.useMemo)(()=>{let t=HX(new Date),n=new Map;e.forEach((e,t)=>n.set(e.id,VX(t)));let r=new Map,i=[];for(let a of e){let e=a.quota?.packages??[],o=n.get(a.id)||VX(0),s=a.name||a.id,c=e.filter(e=>(e.remain??0)>0&&(e.ends_at??0)>0),l=0,u=0,d=0,f=0;for(let e of c){let n=e.ends_at*1e3,i=e.remain??0;d+=i;let c=HX(new Date(n)),u=c{let e=new Date(c);return{day:p,label:`${e.getMonth()+1}/${e.getDate()}`,ts:c,segments:[],total:0}})(),r.set(p,m));let h=m.segments.find(e=>e.id===a.id);h?h.remain+=i:m.segments.push({id:a.id,name:s,color:o,remain:i}),m.total+=i}if(l){let e=WX(HX(new Date(l)));for(let t of c)WX(HX(new Date(t.ends_at*1e3)))===e&&(u+=t.remain??0)}let p=l?Math.max(0,Math.round((HX(new Date(l))-t)/zX)):-1;i.push({id:a.id,name:s,color:o,remain:d,expiredRemain:f,soonest:l?Math.floor(l/1e3):0,soonestRemain:u,daysLeft:p,dailyBurn:l?u/Math.max(p,1):0,packs:c.length})}i.sort((e,t)=>e.soonest&&t.soonest?e.soonest-t.soonest:e.soonest?-1:t.soonest?1:t.remain-e.remain);let a=[...r.values()].sort((e,t)=>e.ts-t.ts);return{buckets:a,rows:i,todayStart:t,maxTotal:a.reduce((e,t)=>Math.max(e,t.total),0)}},[e]);if(!a.some(e=>e.packs>0))return null;let c=n?i:i.slice(0,8);return(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-4 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`expiryDistTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`expiryDistHint`)})]}),i.length>8?(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:()=>r(e=>!e),children:n?t(`expiryDistCollapse`):t(`expiryDistExpand`,{n:i.length})}):null]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4 sm:space-y-3 sm:p-5`,children:[(0,G.jsx)(`div`,{className:`space-y-2.5 sm:space-y-1.5`,children:c.map(e=>{let n=e.ts===o,r=s>0?e.total/s*100:0;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:grid sm:grid-cols-[52px_minmax(0,1fr)_auto] sm:items-center sm:gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 sm:contents`,children:[(0,G.jsx)(`span`,{className:`mono text-caption ${e.day===`__expired__`?`font-semibold text-danger`:n?`font-semibold text-foreground`:`text-muted`}`,children:e.day===`__expired__`?t(`expiryDistExpired`):e.label}),(0,G.jsx)(`span`,{className:`mono text-caption text-foreground sm:hidden`,children:AX(e.total)})]}),(0,G.jsx)(`div`,{className:`h-2.5 w-full rounded-full bg-surface-tertiary`,role:`img`,"aria-label":`${e.day} ${t(`expiryDistDayTotal`,{n:AX(e.total)})}`,title:e.day,children:(0,G.jsx)(`div`,{className:`flex h-full items-stretch overflow-hidden rounded-full`,style:{width:`${r}%`},children:e.segments.map(t=>(0,G.jsx)(`span`,{style:{width:`${t.remain/e.total*100}%`,backgroundColor:t.color},title:`${t.name} · ${AX(t.remain)}`},t.id))})}),(0,G.jsx)(`span`,{className:`mono hidden text-caption text-foreground sm:inline`,children:AX(e.total)})]},e.day)})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1.5 pt-1`,children:a.filter(e=>e.remain>0).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(`i`,{className:`size-2 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.id))}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:a.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null,a=e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`,o=e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`;return(0,G.jsxs)(`article`,{className:`space-y-3 py-3.5`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`truncate text-body font-medium text-foreground`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColSoonest`)}),(0,G.jsx)(`div`,{className:`mono text-body text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaysLeft`)}),(0,G.jsx)(`div`,{className:`mono text-body ${a}`,children:o})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColBatch`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:AX(e.soonestRemain)})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaily`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:e.soonest?AX(e.dailyBurn):`—`})]})]})]},e.id)})}),(0,G.jsx)(Q,{"aria-label":t(`expiryDistTitle`),className:`hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{className:`min-w-[32rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:t(`expiryDistColAccount`)}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColSoonest`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaysLeft`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColBatch`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaily`)})})]}),(0,G.jsx)(Q.Body,{children:a.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null;return(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[150px] truncate text-foreground`,children:e.name})]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center ${e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`}`,children:e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:AX(e.soonestRemain)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:e.soonest?AX(e.dailyBurn):`—`})})]},e.id)})})]})})}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:t(`expiryDistFoot`)})]})]})}var KX={"--toggle-button-bg-selected":`transparent`,"--toggle-button-bg-selected-hover":`transparent`,"--toggle-button-bg-selected-pressed":`transparent`};function qX({value:e,onChange:t,options:n,ariaLabel:r,className:i}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(!1);return(0,v.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=n=>{let r=e.querySelector(`[data-selected="true"]`);if(!r){eY.set(t,{autoAlpha:0});return}let i=e.getBoundingClientRect(),a=r.getBoundingClientRect();eY.to(t,{x:a.left-i.left,y:a.top-i.top,width:a.width,height:a.height,autoAlpha:1,duration:n?aY(tY.base):0,ease:nY.out,overwrite:!0})};n(s.current),s.current=!0;let r=new ResizeObserver(()=>n(!1));return r.observe(e),()=>{r.disconnect(),eY.killTweensOf(t)}},[e,n]),(0,G.jsxs)(`div`,{ref:a,className:`filter-toggle relative inline-flex ${i??``}`,children:[(0,G.jsx)(`span`,{ref:o,"aria-hidden":!0,className:`filter-toggle__pill pointer-events-none absolute left-0 top-0 opacity-0`}),(0,G.jsx)(wI,{"aria-label":r,size:`sm`,selectionMode:`single`,disallowEmptySelection:!0,selectedKeys:new Set([e]),onSelectionChange:n=>{let r=[...n][0];typeof r==`string`&&r!==e&&t(r)},children:n.map(e=>(0,G.jsxs)(QP,{id:e.id,className:`relative z-[1]`,style:KX,children:[e.icon,e.label]},e.id))})]})}function JX(e,t){let n=e.toFixed(t);return n.includes(`.`)?n.replace(/0+$/,``).replace(/\.$/,``):n}function YX(e){let t=Number(e||0);return Number.isFinite(t)?t>=1e9?`${JX(t/1e9,2)}B`:t>=1e6?`${JX(t/1e6,2)}M`:t>=1e3?`${JX(t/1e3,1)}k`:String(Math.round(t)):`—`}function XX(e){let t=Number(e||0);return Number.isFinite(t)?JX(t,2):`—`}function ZX(e,t,n){if(!t||!n)return`—`;let r=Number(e||0);return Number.isFinite(r)?`${JX(r,4)} / 1M`:`—`}function QX(e){let t=Number(e||0);return t?t>=1e3?`${JX(t/1e3,2)}s`:`${Math.round(t)}ms`:`—`}function $X(e){if(e==null)return`—`;let t=Number(e);return!Number.isFinite(t)||t<0?`—`:`x${JX(t,2)}`}function eZ(e){let t=(e||``).trim().toLowerCase().replace(/\s*credits?$/,``).replace(/^x/,``);if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:null}function tZ(e,t){if(!e.length||!t)return null;let n=t.indexOf(`/`),r=n>=0?t.slice(0,n).toLowerCase():``,i=n>=0?t.slice(n+1):t,a=e.filter(e=>e.id===t||e.id===i||e.native_model===i);if(!a.length)return null;let o=a.map(e=>({rate:eZ(e.credits),cn:/credits?\s*$/i.test((e.credits||``).trim())})),s=o,c=r.includes(`cn`)?!0:!/(^|[-_])(gl|global|intl)([-_]|$)/.test(r)&&null;if(c!==null){let e=o.filter(e=>e.cn===c);e.length&&(s=e)}let l=s.map(e=>e.rate).filter(e=>e!==null);if(!l.length)return null;let u=l.filter(e=>e>0);return u.length?Math.max(...u):l[0]}function nZ(e,t){let n=Number(e||0),r=n+Number(t||0);return r?n/r*100:null}function rZ({hit:e,miss:t}){let n=nZ(e,t);return n==null?(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:`—`}):(0,G.jsxs)(`div`,{className:`mono text-right ${n>=90?`text-success`:n>=80?`text-warning`:`text-danger`}`,title:`${YX(e)} / ${YX(e+t)}`,children:[JX(n,1),`%`]})}function iZ(e){let t=Number(e||0);return Number.isFinite(t)?t:0}function aZ(e,t){let n=e.slice(),r=e=>iZ(String(t===`requests`?e.requests:t===`errors`?e.errors:t===`latency`?e.avg_latency_ms??0:e.total_tokens));return n.sort((e,t)=>r(t)-r(e)),n}function oZ(e,t){return e.find(e=>e.id===t)?.name||t.slice(0,8)}function sZ({usage:e,accounts:t,loading:n,t:r}){let[i,a]=(0,v.useState)(`account`),[o,s]=(0,v.useState)(`total`),c=(0,v.useMemo)(()=>e?aZ((i===`model`?e.by_model:i===`realm`?e.by_realm:e.by_account)||[],o):[],[e,i,o]),l=i===`account`,u=l?8:7;return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,"data-skeleton-swap":`stats`,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:r(`usageDetailTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:r(`usageDetailHint`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(qX,{value:i,onChange:e=>a(e),ariaLabel:r(`usageDetailTitle`),options:[{id:`account`,label:r(`usageDimAccount`)},{id:`model`,label:r(`usageDimModel`)},{id:`realm`,label:r(`usageDimRealm`)}]}),(0,G.jsx)(qX,{value:o,onChange:e=>s(e),ariaLabel:r(`usageDetailHint`),options:[{id:`total`,label:r(`usageSortTotal`)},{id:`requests`,label:r(`usageSortRequests`)},{id:`errors`,label:r(`usageSortErrors`)},{id:`latency`,label:r(`usageSortLatency`)}]})]})]}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:n?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)($,{className:`h-4 w-32`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)($,{className:`h-3 w-12`}),(0,G.jsx)($,{className:`h-4 w-16`})]},t))})]},`skeleton-${t}`)):c.length===0?(0,G.jsx)(`div`,{className:`px-5 py-8 text-body text-muted`,children:r(`usageEmpty`)}):c.map(e=>{let n=i===`account`?oZ(t,e.key):e.key||`—`,a=i===`account`?e.realm:``,o=[{label:r(`usageColRequests`),value:YX(e.requests)},{label:r(`usageColErrors`),value:e.errors?YX(e.errors):`—`,tone:e.errors?`text-warning`:`text-muted`},{label:r(`usageColPrompt`),value:YX(e.prompt_tokens),tone:`text-muted`},{label:r(`usageColCacheHit`),value:nZ(e.cache_hit_tokens,e.cache_miss_tokens)==null?`—`:`${JX(nZ(e.cache_hit_tokens,e.cache_miss_tokens),1)}%`},{label:r(`usageColCompletion`),value:YX(e.completion_tokens),tone:`text-muted`},{label:r(`usageColTotal`),value:YX(e.total_tokens)}];return l&&o.push({label:r(`usageColAvgLatency`),value:QX(e.avg_latency_ms),tone:`text-muted`}),(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:n}),a?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:a}):null]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:o.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value})]},e.label))})]},e.key)})}),(0,G.jsx)(Q,{"aria-label":r(`usageDetailTitle`),className:`hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{className:`min-w-[44rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:r(i===`model`?`usageColModel`:i===`realm`?`usageColRealm`:`usageColAccount`)}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColRequests`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColErrors`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColPrompt`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColCacheHit`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColCompletion`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColTotal`)})}),l?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColAvgLatency`)})})}):null]}),(0,G.jsx)(Q.Body,{children:n?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`h-4 w-32`})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`ml-auto h-4 w-12`})},t))]},`skeleton-${t}`)):c.length===0?(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-body text-muted`,children:r(`usageEmpty`)})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:null},t))]}):c.map(e=>{let n=i===`account`?oZ(t,e.key):e.key||`—`,r=i===`account`?e.realm:``;return(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-foreground`,children:n}),r?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:r}):null]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:YX(e.requests)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right ${e.errors?`text-warning`:`text-muted`}`,children:e.errors?YX(e.errors):`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:YX(e.prompt_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(rZ,{hit:e.cache_hit_tokens,miss:e.cache_miss_tokens})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:YX(e.completion_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:YX(e.total_tokens)})}),l?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:QX(e.avg_latency_ms)})})}):null]},e.key)})})]})})}),(0,G.jsx)(`p`,{className:`px-5 py-3 text-caption text-muted`,children:r(`usageDimNote`,{n:c.length})})]})}function cZ({label:e,value:t,sub:n,tone:r}){return(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-tertiary px-3 py-2.5`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`div`,{className:`mono mt-1 text-body font-semibold ${r??`text-foreground`}`,children:t}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,title:n,children:n})]})}function lZ({usage:e,accounts:t,models:n,loading:r,t:i}){let[a,o]=(0,v.useState)(`account`),s=e?.totals,c=(0,v.useMemo)(()=>e&&(a===`model`?e.credit_by_model:e.credit_by_account)||[],[e,a]),l=a===`model`,u=l?7:6;return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,"data-skeleton-swap":`stats`,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:i(`usageCreditTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:i(`usageCreditHint`)})]}),(0,G.jsx)(qX,{value:a,onChange:e=>o(e),ariaLabel:i(`usageCreditTitle`),options:[{id:`account`,label:i(`usageDimAccount`)},{id:`model`,label:i(`usageDimModel`)}]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-separator px-5 py-4 sm:grid-cols-3 sm:gap-2.5 xl:grid-cols-5`,children:r||!s?Array.from({length:5}).map((e,t)=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-tertiary px-3 py-2.5`,children:[(0,G.jsx)($,{className:`h-3 w-16`}),(0,G.jsx)($,{className:`mt-2 h-5 w-20`})]},t)):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(cZ,{label:i(`usageCreditKpiCredits`),value:XX(s.credits),sub:i(`usageCreditKpiCreditsSub`)}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiTokens`),value:YX(s.credit_tokens),sub:i(`usageCreditKpiTokensSub`)}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiAvg`),value:ZX(s.credits_per_1m_tokens,s.credit_samples,s.credit_tokens),sub:i(`usageCreditKpiAvgSub`),tone:`text-success`}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiSamples`),value:String(s.credit_samples||0),sub:i(`usageCreditKpiSamplesSub`)}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiCache`),value:nZ(s.cache_hit_tokens,s.cache_miss_tokens)==null?`—`:`${JX(nZ(s.cache_hit_tokens,s.cache_miss_tokens),1)}%`,sub:i(`usageCreditKpiCacheSub`)})]})}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:r?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)($,{className:`h-4 w-32`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)($,{className:`h-3 w-12`}),(0,G.jsx)($,{className:`h-4 w-16`})]},t))})]},`skeleton-${t}`)):c.length===0?(0,G.jsx)(`div`,{className:`px-5 py-8 text-body text-muted`,children:i(`usageCreditEmpty`)}):c.map(e=>{let r=l?e.key||`—`:oZ(t,e.key),a=!l&&e.realm?e.realm:``,o=[];return l&&o.push({label:i(`usageCreditColRate`),value:$X(e.rate??tZ(n,e.key)),tone:`text-muted`}),o.push({label:i(`usageColRequests`),value:YX(e.requests)},{label:i(`usageCreditColCredits`),value:XX(e.credits)},{label:i(`usageCreditColSampleTokens`),value:YX(e.credit_tokens),tone:`text-muted`},{label:i(`usageCreditColPer1M`),value:ZX(e.credits_per_1m_tokens,e.credit_samples,e.credit_tokens),tone:`text-muted`},{label:i(`usageColCacheHit`),value:nZ(e.cache_hit_tokens,e.cache_miss_tokens)==null?`—`:`${JX(nZ(e.cache_hit_tokens,e.cache_miss_tokens),1)}%`}),(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:r}),a?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:a}):null]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:o.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value})]},e.label))})]},e.key)})}),(0,G.jsx)(Q,{"aria-label":i(`usageCreditTitle`),className:`hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{className:`min-w-[40rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:i(l?`usageColModel`:`usageColAccount`)}),l?(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColRate`)})}):null,(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageColRequests`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColCredits`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColSampleTokens`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColPer1M`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageColCacheHit`)})})]}),(0,G.jsx)(Q.Body,{children:r?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`h-4 w-32`})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`ml-auto h-4 w-12`})},t))]},`skeleton-${t}`)):c.length===0?(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-body text-muted`,children:i(`usageCreditEmpty`)})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:null},t))]}):c.map(e=>{let r=l?e.key||`—`:oZ(t,e.key),i=!l&&e.realm?e.realm:``;return(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-foreground`,children:r}),i?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:i}):null]}),l?(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:$X(e.rate??tZ(n,e.key))})}):null,(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:YX(e.requests)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:XX(e.credits)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:YX(e.credit_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:ZX(e.credits_per_1m_tokens,e.credit_samples,e.credit_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(rZ,{hit:e.cache_hit_tokens,miss:e.cache_miss_tokens})})]},e.key)})})]})})}),(0,G.jsx)(`p`,{className:`px-5 py-3 text-caption text-muted`,children:i(`usageCreditNote`,{accounts:e?.credit_by_account?.length??0,models:e?.credit_by_model?.length??0})})]})}function uZ(e,t=!1){if(!e)return;let n=e.toDate(SD());if(Number.isFinite(n.getTime()))return t&&n.setSeconds(59,999),n.toISOString()}function dZ(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return JD(jO(new Date(t).toISOString()))}catch{return null}}function fZ({value:e,onChange:t,ariaLabel:n,fromLabel:r,toLabel:i,className:a}){return(0,G.jsx)(hP,{className:a,granularity:`minute`,hourCycle:24,shouldForceLeadingZeros:!0,value:e,onChange:e=>t(e),"aria-label":n,children:({state:e})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(AM.Group,{className:`w-full min-w-0`,variant:`secondary`,children:[(0,G.jsx)(AM.Input,{className:`min-w-0`,slot:`start`,"aria-label":r,children:e=>(0,G.jsx)(AM.Segment,{segment:e})}),(0,G.jsx)(hP.RangeSeparator,{}),(0,G.jsx)(AM.Input,{className:`min-w-0`,slot:`end`,"aria-label":i,children:e=>(0,G.jsx)(AM.Segment,{segment:e})}),(0,G.jsx)(AM.Suffix,{children:(0,G.jsx)(hP.Trigger,{children:(0,G.jsx)(hP.TriggerIndicator,{})})})]}),(0,G.jsxs)(hP.Popover,{className:`flex w-[20.5rem] max-w-[calc(100vw-2rem)] flex-col gap-3 p-3`,children:[(0,G.jsxs)(xH,{"aria-label":n,children:[(0,G.jsxs)(xH.Header,{children:[(0,G.jsxs)(xH.YearPickerTrigger,{children:[(0,G.jsx)(xH.YearPickerTriggerHeading,{}),(0,G.jsx)(xH.YearPickerTriggerIndicator,{})]}),(0,G.jsx)(xH.NavButton,{slot:`previous`}),(0,G.jsx)(xH.NavButton,{slot:`next`})]}),(0,G.jsxs)(xH.Grid,{children:[(0,G.jsx)(xH.GridHeader,{children:e=>(0,G.jsx)(xH.HeaderCell,{children:e})}),(0,G.jsx)(xH.GridBody,{children:e=>(0,G.jsx)(xH.Cell,{date:e})})]}),(0,G.jsx)(xH.YearPickerGrid,{children:(0,G.jsx)(xH.YearPickerGridBody,{children:({year:e})=>(0,G.jsx)(xH.YearPickerCell,{year:e})})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(sR,{className:`text-xs`,children:r}),(0,G.jsx)(LP,{"aria-label":r,granularity:`minute`,hourCycle:24,value:e.timeRange?.start??null,onChange:t=>e.setTimeRange({start:t,end:e.timeRange?.end}),children:(0,G.jsx)(LP.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LP.Input,{children:e=>(0,G.jsx)(LP.Segment,{segment:e})})})})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(sR,{className:`text-xs`,children:i}),(0,G.jsx)(LP,{"aria-label":i,granularity:`minute`,hourCycle:24,value:e.timeRange?.end??null,onChange:t=>e.setTimeRange({start:e.timeRange?.start,end:t}),children:(0,G.jsx)(LP.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LP.Input,{children:e=>(0,G.jsx)(LP.Segment,{segment:e})})})})]})]})]})]})})}var pZ={today:`statsWindowToday`,1:`statsWindow1h`,24:`statsWindow24h`,168:`statsWindow7d`,720:`statsWindow30d`,custom:`statsWindowCustom`};function mZ(e,t){if(e===`today`){let e=new Date;return e.setHours(0,0,0,0),{from:e.toISOString()}}if(e===`custom`){let e=uZ(t?.start),n=uZ(t?.end,!0);return e&&n?{from:e,to:n}:null}if(e===`720`){let e=new Date;return{from:new Date(e.getTime()-2592e6).toISOString(),to:e.toISOString()}}return{hours:Number(e)}}function hZ({value:e,onChange:t,custom:n,onCustomChange:r,onBusy:i,t:a}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qX,{value:e,onChange:r=>{let a=r;e!==a&&((a!==`custom`||n)&&i?.(),t(a))},ariaLabel:a(`statsTraffic`),options:Object.keys(pZ).map(e=>({id:e,label:a(pZ[e])}))}),e===`custom`?(0,G.jsx)(fZ,{className:`w-[min(100%,24rem)]`,value:n,onChange:e=>{e&&i?.(),r(e)},ariaLabel:a(`statsWindowCustom`),fromLabel:a(`logsTimeFrom`),toLabel:a(`logsTimeTo`)}):null]})}function gZ(e,t,n){let r=new URLSearchParams;for(let[t,n]of Object.entries(e))n&&r.set(t,n);let i=Date.parse(t),a=Date.parse(n);return Number.isFinite(i)&&Number.isFinite(a)&&(r.set(`from`,new Date(Math.floor(i/6e4)*6e4).toISOString()),r.set(`to`,new Date(Math.ceil(a/6e4)*6e4-6e4).toISOString())),`/logs?${r}`}function _Z(e){let t=String(e||``).toLowerCase();return!t||t===`qoder`||t===`qoder-global`||t===`qoder-cn`}function vZ(e){return String(e||``).toLowerCase()===`workbuddy`}function yZ(e){return String(e||``).toLowerCase()===`trae`}function bZ(e){return String(e||``).toLowerCase()===`devin`}function xZ(e){return String(e||``).toLowerCase()===`command`}function SZ(e){return String(e||``).toLowerCase()===`zhipu`}function CZ(e){return String(e||``).toLowerCase()===`qwenwork`}function wZ(e){return String(e||``).toLowerCase()===`kimi`}function TZ(e,t){let n=String(e||``).toLowerCase();return vZ(n)?`WorkBuddy`:yZ(n)?`Trae`:bZ(n)?`Devin`:xZ(n)?`Command Code`:SZ(n)?`Zhipu GLM`:CZ(n)?`QwenWork`:wZ(n)?`Kimi Code`:_Z(n)?`Qoder`:e||t(`account`)}function EZ(e,t,n){let r=String(e||``).toLowerCase(),i=String(t||``).toLowerCase();return vZ(r)?n(i===`global`?`accountTypeWorkBuddyGlobal`:`accountTypeWorkBuddyCN`):yZ(r)?n(`accountTypeTraeCN`):bZ(r)?n(`accountTypeDevinGlobal`):xZ(r)?n(`accountTypeCommandGlobal`):SZ(r)?n(`accountTypeZhipuCN`):CZ(r)?n(i===`cn`?`accountTypeQwenworkCN`:`accountTypeQwenworkGlobal`):wZ(r)?n(`accountTypeKimiCN`):_Z(r)?n(i===`cn`?`accountTypeQoderCN`:`accountTypeQoderGlobal`):e||n(`account`)}function DZ(e,t){let n=t??!!e.max_mode,r=e.catalog_context_length||e.default_context_length||e.context_length||0,i=e.catalog_context_length_max||0;return n&&i>0?{context_length:i,prompt_max_tokens:e.prompt_max_tokens_max||e.prompt_max_tokens,max_output_tokens:e.max_output_tokens_max||e.max_output_tokens}:{context_length:r,prompt_max_tokens:e.prompt_max_tokens,max_output_tokens:e.max_output_tokens}}function OZ({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#0a84ff] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`C`})}function kZ({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.086.457a6.1 6.1 0 0 1 3.046-.415q2 .23 3.564 1.7a.12.12 0 0 0 .107.029q2.112-.519 4.061.366l.063.03l.154.076q2.036 1.055 2.918 3.198a5.6 5.6 0 0 1 .421 2.126 5.7 5.7 0 0 1-.18 1.631.17.17 0 0 0 .04.155 6 6 0 0 1 1.578 2.891q.577 2.852-1.183 5.14l-.182.22a6.06 6.06 0 0 1-2.934 1.851.16.16 0 0 0-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451q-2.374-.012-4.21-1.736a.14.14 0 0 0-.14-.032 5.9 5.9 0 0 1-1.604-.185 5.9 5.9 0 0 1-2.595-.622 6.06 6.06 0 0 1-2.146-1.781c-.203-.269-.404-.522-.551-.821a8 8 0 0 1-.495-1.283 6.1 6.1 0 0 1-.017-3.064.2.2 0 0 0 .008-.074.1.1 0 0 0-.037-.064 6 6 0 0 1-1.38-2.202 5.2 5.2 0 0 1-.333-1.589 6.9 6.9 0 0 1 .188-2.132q.675-2.226 2.577-3.493.424-.282.802-.438.429-.179.861-.304a.13.13 0 0 0 .087-.087A6 6 0 0 1 5.635 2.31Q6.655 1.04 8.086.457m-.804 7.85a.848.848 0 0 0-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 0 0 1.46.864l1.94-3.272a.85.85 0 0 0 .007-.854zm5.446 6.24a.849.849 0 0 0 0 1.695h4.848a.849.849 0 0 0 0-1.696z`})})}function AZ({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`D`})}function jZ({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,d:`M21 12.79A9 9 0 1 1 11.21 3a7 7 0 0 0 9.79 9.79Z`})})}var MZ=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAJ5ElEQVR42u2dXUxUZxrH/wKDDDCM4CJBZJZNxMpGDMGYXsAWeikapF6Jqc02kUhWTWsTIQHjNk22yWCyN5INrk22rbsc71ZNpXfb0sJ+Gcxmma2mNpt1XMsaLd2ZoY7D5164btfiBx8zzDnv+f1uiWeG9/x8eN7neT9WFRaunROAIWQwBIDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAA35LFEDyZ6uotKi8PqL6+ToFAuQoK/PL7/fL7CyRJ4fBNRaMRhcM3FQ6HFQqFNDoaUiQSYfDSxCqO031U4Lq6OjU1Nam6eov8fv+inxGJRDQ6GtLAwIAs6xxyI/TK0tTUpJ07d6iurk6BQCCpz45EIurrO62+vtOIjdCpIxAIqLPzWEokRmyEXjHq6+vU0dGh+vq6tHw+YiN00iJyb++ptImM2Aid1NSitbXVlt8vEomoq+u4LMvCRIR+Oq2trersPLYiOfJyCYfD6u4+rkuXBjASoZ0VlZ/G0NCwenp6NDQ0jJkI/aCOfPbs+46IyogtWt9Po739oAYHP3a8zNKDaszFixd08eIF20xkidArSGdnhzo7O4x9SZZlKRg8qXA4jLGmC/322z9Te/tBV7ysvr7TCgZ7KPWZKnRv7ynt29fqqhdGDdtQod0oM2IbKrSb0gzEXhyZXm/um06bAL7++muY/F9ycnJUX1+nPXteUiQSVSgUIkI75cvu29eq3t5TWKyndx0PHz7i2hq2Y4QOBAIaHPxoSYvu3YhbmzOOENrv92tw8CMjmiaILTqFnZ0dyKzldx2rq7cQoe3yQkB0HZ0uNKlG6ggGe4ws9dlaaOrNSyM2e0+3pu4oOntPX07dnffzzasDKvMUazY2ZVwN27ZCV1dv0eDgx9i5AK4lbuhy/Joux6/q1vRdXUvcWNC/K8sq1nbvZpXeX6N/9X+m3/zyrOPFtq3QLJ18egT+c/yqfjcx8j+Jk8GmyfWaOPOFRt4bRGgmgqnnfPRTnY99osvxayn9nJmxuKI/v6r7g7cRmuicXG5N3dEvxn+b1Ei8UCZHxvXvt/6qmbE4QhOdkyPy+dinaf0ec7Fpxd65rm+sf4jDGpdAR0eH3L4Ww7LO6Z2KQWVvK0p/xPNlqeBolTLyPYqduS46hVpc3dnNqYZlWWpublEw2GO775bftlFrTmwlQmuRG13dGpWDwZO2P3DGu6tMM2NxW0dqhE4zo6Mh7d//imNa0fltGyXJtlJn2Gky6LalocFgjxoaGh23riK/baMt8ntbC93U1OQqmbu6um2ZKy+UNSe2KsPnQWg98Sy6vXLLHsD9+19RX99pR/8emaVe5R/YiNB6wm4UN6QbkUhEzc27jTmUMa+1QpmlXoSen27scI3Mo6NmbWL1tVUitB6zss50TJRZelDKs1OUtoXQdXVmN1MOHz5ipMwPyWksQWj9X3fQ5B0pwWCP+vvNPqE/b28FQn87ISw39kX391uOLs1pERUPz6YChJak8vKAse3s7u7jcgvZtUUIbWqEflhrdtNZczkNJQj9MIc2MW82eRL4OEg5DBV6aGjY8V1ALXHddOZ6L0L7/QUyrUTnVrJKcxHatFTDzfeg2KHBgtBJPng8aS/GhivZENpl0TmZVY1VviwGFaGVtpqzGyeCRGiZe91a0l9MvoeBRej05M6WdS65L8XnIeVA6PRF52R3BO22aB6hSTdkQtcNoeW++0tSsV4ja5OPwUVopeGko3MyeV0EQrtsMjgwkJrNrp5KhEboFWZ4ODXpRva2IiocCJ2e/DkVrK5dy+Ai9MozMPBhSp5r1yO2EFpmt7pTsaouw+exzVYmhHYRoVDI+N3TCE3+LFP25SG061KOmynJnWmoILQxKYfdzohDaLmrqaIkL0ZiMojQxghNdDZI6Egk6riSXbKjs3dXGSaaI3TE1S9gzU+3YiFCm0H2tiJyZ9OETkUJzEkX74BhQkej7ozQvrZKtlqZKLTbDjWUHizgf3iBJRiYQ7tJ6gyfR/4T1Zhnch06FBp1zYDnt21ki5XpQg8N/d4Vg+3dVcaKOjcIPTw8LDfkzf6jP8Q4NwgdDodTtuFUNjnzrfBkLXsF3bSW49KlD42VeW3f85To3Ca0ZVnGHRaOzC5fbRcMnkRmMEdoU6I0MiO0MVEamRF6XpS2LGfejZ3XWqHiX9cjM0LPj9JOSz0K3qhSwdEqSnMIrcfWpZubWxyxVjqz1Kt1FxrpACL0QqTebWupfW2VWnehkRQDobXgpaXd3cdtJ3Xurg1ad6GRJaAIvXj6+y01N++2TU6dWeqV/0Q1URmhlxepm5tbUnYEFyB02nLqrq5u1+8UB4MOmunrO62amtqkX0UMCK10btsKBnvSInZBZh7WIHRqxW5oeHHFuou+jFysQejU59eHDh1RTU3tikwcN6/+PuYg9MpNHJubd6dU7LKs72EOQmtFT9hPpdjPrQ5gDkKbI/Z2bxXmIHT6xT506EhSOo5V5NAILZusta6pqV12c8aXkavt3s3Yg9AypjnT4nsBexBaxjRniNAI7QixF0qZp1gtvh9hEELbX+yFdh1/UvQSA4fQckTXsaGh8ZmlPqI0QjuGB2uwn13DJkojtExqzpR5ipEaoZ0t9nebM4eK9rC+Q9LMWByhnSh2TU3tvK7jr8q6XC+1HYTO9Hpz30RTLekCe8s6p0QioerqLSrOLdJ2b5U+nPijJuembP3d52LTWrU6I+nPjAT/prnJWYR2KolEQsPDw3r33feUSCT0Yk29NuSV6HL8qm2ljn9wS18f/4vuf3JbWaW5ylyfnN3r37z/dyX+cCftv9+qwsK1c6iZHPx+v9rbD6rx1R16baJXsdl7tkoHIm+NKjHylb57m63vQKWytxUt69l3Xx7WbGwKoU0V++U3XtVnLfd1LXEj7SJPnPlC9z745zPPG8ndtUF5eysWdT7fzFhcXx+7oqnPo7YYe4ROIYUb1ir/QKWmmwpX/LMnR8YVv3TrmSI/7h7FvL0VCxJ7Ziyur9r/ZIvJIEKvID94/jlFf7xmWX/WFxotJ0fGFTtzfdmSZfg88u4sU05DiTybCh6Re6n/WRDaMLK3FSmnoUS5Ozck7djdyZFx3R+8rckr4yn9s/9w8jjzZdzWY4zQSs/1yFmbfMppKFHOCyULrjTMxaY19XlUU9ejmhwZ1+SVcVtMxBAa5gmeWepVZqlXGT7PIz+bjU1pbmJa02P3bB8dERqA1jcAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQgNABCAyA0AEIDIDQgNABCAyA0AEIDLIj/ABWOKFxbGBRBAAAAAElFTkSuQmCC`;function NZ({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:MZ,alt:``,width:e,height:e,className:`block shrink-0 rounded-[22%] ${t}`.trim(),draggable:!1})}function PZ({size:e=16,className:t=``}){let n=Math.max(2,Math.round(e*.14));return(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-baseline justify-center rounded-[22%] bg-[#18181B] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.5)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:[(0,G.jsx)(`span`,{style:{alignSelf:`center`},children:`Q`}),(0,G.jsx)(`span`,{style:{alignSelf:`center`,width:n,height:n,marginLeft:Math.max(0,Math.round(e*.03)),borderRadius:`50%`,background:`#22D3EE`}})]})}function FZ({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`T`})}var IZ=`/assets/workbuddy-mark-D1Gu2IKl.svg`;function LZ({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:IZ,alt:``,width:e,height:e,className:`block shrink-0 ${t}`.trim(),draggable:!1})}function RZ({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M11.991 23.503a.24.24 0 0 0-.244.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.22-.247zM9.671 5.365a1.697 1.697 0 0 1 1.099 2.132l-.071.172l-.016.04l-.018.054c-.07.16-.104.32-.104.498c-.035.71.47 1.279 1.186 1.314h.366c1.309.053 2.338 1.173 2.286 2.523c-.052 1.332-1.152 2.38-2.478 2.327h-.174c-.715.018-1.274.64-1.239 1.368c0 .124.018.23.053.337c.209.373.54.658.96.8c.75.23 1.517-.125 1.9-.782l.018-.035c.402-.64 1.17-.96 1.92-.711c.854.284 1.378 1.226 1.099 2.167a1.66 1.66 0 0 1-2.077 1.102a1.7 1.7 0 0 1-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646 1.646 0 0 0-1.954.746a1.66 1.66 0 0 1-1.065.764a1.677 1.677 0 0 1-1.989-1.279c-.209-.906.332-1.83 1.257-2.043a1.5 1.5 0 0 1 .296-.035h.018c.68-.071 1.151-.622 1.116-1.333a1.3 1.3 0 0 0-.227-.693a2.5 2.5 0 0 1-.366-1.403a2.4 2.4 0 0 1 .366-1.208c.14-.195.21-.444.227-.693c.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.4 1.4 0 0 1-.299-.07l-.05-.019a1.7 1.7 0 0 1-1.047-2.114a1.68 1.68 0 0 1 2.094-1.101m-5.575 10.11c.26-.264.639-.367.994-.27s.633.379.728.74c.095.362-.007.748-.267 1.013c-.402.41-1.053.41-1.455 0a1.06 1.06 0 0 1 0-1.482zm14.845-.294c.359-.09.738.024.992.297c.254.274.344.665.237 1.025s-.396.634-.756.718c-.551.128-1.1-.22-1.23-.781a1.05 1.05 0 0 1 .757-1.26zm-.064-4.39c.314.32.49.753.49 1.206s-.176.886-.49 1.206c-.315.32-.74.5-1.185.5c-.444 0-.87-.18-1.184-.5a1.727 1.727 0 0 1 0-2.412a1.654 1.654 0 0 1 2.369 0m-11.243.163c.364.484.447 1.128.218 1.691a1.665 1.665 0 0 1-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68 1.68 0 0 1 1.33-1.038a1.66 1.66 0 0 1 1.547.652m11.545-4.221c.368 0 .708.2.892.524s.184.724 0 1.048a1.03 1.03 0 0 1-.892.524a1.04 1.04 0 0 1-1.03-1.048a1.04 1.04 0 0 1 1.03-1.048m-14.358 0c.368 0 .707.2.891.524s.184.724 0 1.048a1.03 1.03 0 0 1-.891.524a1.04 1.04 0 0 1-1.03-1.048c0-.579.461-1.048 1.03-1.048m10.031-1.475c.925 0 1.675.764 1.675 1.706s-.75 1.705-1.675 1.705s-1.674-.763-1.674-1.705s.75-1.706 1.674-1.706m-2.626-.684c.362-.082.653-.356.761-.718a1.06 1.06 0 0 0-.238-1.028a1.02 1.02 0 0 0-.996-.294c-.547.14-.881.7-.752 1.257c.13.558.675.907 1.225.783m0 16.876c.359-.087.644-.36.75-.72a1.06 1.06 0 0 0-.237-1.019a1.02 1.02 0 0 0-.985-.301a1.04 1.04 0 0 0-.762.717c-.108.361-.017.754.239 1.028c.245.263.606.377.953.305zM17.19 3.5a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64a.63.63 0 0 0-.628.64c0 .355.28.64.628.64m-10.38 0a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64a.63.63 0 0 0-.628.64c0 .355.279.64.628.64m-5.182 7.852a.63.63 0 0 0-.628.64c0 .354.28.639.628.639a.63.63 0 0 0 .627-.606l.001-.034a.62.62 0 0 0-.628-.64zm5.182 9.13a.63.63 0 0 0-.628.64c0 .355.279.64.628.64a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64m10.38.018a.63.63 0 0 0-.628.64c0 .355.28.64.628.64a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64m5.182-9.148a.63.63 0 0 0-.628.64c0 .354.279.639.628.639a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24 0 0 0 .244-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249c0 .142.122.249.244.249M11.991.497a.24.24 0 0 0 .245-.248A.24.24 0 0 0 11.99 0a.24.24 0 0 0-.244.249c0 .133.108.236.223.247zM2.011 6.36a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249a.24.24 0 0 0 .244.249zm0 11.263a.24.24 0 0 0-.243.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .244-.249a.25.25 0 0 0-.244-.248zm19.995-.018a.24.24 0 0 0-.245.248a.24.24 0 0 0 .245.25a.24.24 0 0 0 .244-.25a.25.25 0 0 0-.244-.248z`})})}function zZ({provider:e,size:t=16,className:n=``}){let r=String(e||``).toLowerCase();return r===`workbuddy`?(0,G.jsx)(LZ,{size:t,className:n}):r===`trae`?(0,G.jsx)(FZ,{size:t,className:n}):r===`devin`?(0,G.jsx)(AZ,{size:t,className:n}):r===`command`?(0,G.jsx)(OZ,{size:t,className:n}):r===`codex`?(0,G.jsx)(kZ,{size:t,className:n}):r===`zhipu`?(0,G.jsx)(RZ,{size:t,className:n}):r===`qwenwork`?(0,G.jsx)(PZ,{size:t,className:n}):r===`kimi`?(0,G.jsx)(jZ,{size:t,className:n}):(0,G.jsx)(NZ,{size:t,className:n})}var BZ=(0,v.lazy)(()=>C(()=>import(`./LiveSparkline-CiMyj7tn.js`).then(e=>({default:e.LiveSparkline})),__vite__mapDeps([0,1,2])));function VZ({live:e,samples:t,t:n}){let r=e?.in_flight??null,i=e?.capacity??0,a=r!=null&&i>0?r/i:0,o=i>0&&r!=null&&r>=i;return(0,G.jsxs)(`div`,{"data-testid":`live-strip`,className:`flex min-h-11 flex-wrap items-center gap-x-5 gap-y-2 overflow-hidden rounded-lg bg-surface-secondary px-4 py-2.5 text-caption text-muted sm:h-11 sm:gap-x-6 sm:gap-y-1 sm:py-0`,children:[(0,G.jsx)(`span`,{className:`inline-flex items-center`,children:(0,G.jsx)(`span`,{className:`status-dot`,"data-state":r==null?``:o?`warn`:r>0?`ok`:``})}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveConcurrency`),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono tabular text-body font-semibold ${o?`text-warning`:`text-foreground`}`,children:[r??`—`,(0,G.jsxs)(`span`,{className:`font-normal text-muted`,children:[`/`,e?i:`—`]})]}),(0,G.jsx)(`span`,{className:`inline-block h-[3px] w-12 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${o?`bg-warning`:`bg-foreground/60`}`,style:{width:`${Math.min(100,a*100)}%`}})})]})]}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveRpm`),(0,G.jsx)(`span`,{className:`mono tabular text-body font-semibold text-foreground`,children:e?.rpm??`—`})]}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveTrace`),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`span`,{className:`inline-block h-6 w-[120px]`}),children:(0,G.jsx)(BZ,{samples:t,capacity:i,label:n(`liveTrace`)})})]})]})}var HZ=2500;Math.round(6e4/HZ);function UZ(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=!1,n=null,i=()=>{document.hidden||OY().then(n=>{e||(t(n),r(e=>[...e,{at:Date.now(),value:n.in_flight}].slice(-24)))}).catch(()=>{})},a=()=>{n||document.hidden||(i(),n=setInterval(i,HZ))},o=()=>{n&&clearInterval(n),n=null},s=()=>document.hidden?o():a();return a(),document.addEventListener(`visibilitychange`,s),()=>{e=!0,o(),document.removeEventListener(`visibilitychange`,s)}},[]),{live:e,samples:n}}var WZ=(0,v.lazy)(()=>C(()=>import(`./TrafficChart-DKxQTayd.js`).then(e=>({default:e.TrafficChart})),__vite__mapDeps([3,1,4]))),GZ=3e4,KZ={window:{from:``,to:``,hours:24},totals:{requests:0,ok:0,incomplete:0,error:0,canceled:0,streaming:0,success_rate:0},latency:{},tokens:{prompt:0,completion:0,cache_read:0,total:0},status:[],errors:[],models:[],accounts:[],providers:[],series:[]};function qZ(e,t){return!e||e===`(unknown)`?t(`statsUnknown`):TZ(e,t)}function JZ(e,t,n){return!t||t===`(unassigned)`?n:e.find(e=>e.id===t)?.name||t}var YZ=new Set([`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`]);function XZ(e,t){let n={quota:`logsKindQuota`,rate_limit:`logsKindRateLimit`,auth:`logsKindAuth`,not_ready:`logsKindNotReady`,unavailable:`logsKindUnavailable`,invalid_request:`logsKindInvalidRequest`,model_not_available:`logsKindModelNotAvailable`};return n[e]?t(n[e]):e}var ZZ=[`ok`,`incomplete`,`error`,`canceled`],QZ={ok:`bg-success`,incomplete:`bg-warning`,error:`bg-danger`,canceled:`bg-muted`},$Z={ok:`logsFilterOk`,incomplete:`logsFilterIncomplete`,error:`logsFilterError`,canceled:`logsFilterCanceled`};function eQ(e,t){return t>0?e/t:null}function tQ(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(0,Math.round((n-t)/1e3));if(r<=0)return null;let i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return i?`${i}h ${a}m`:a?`${a}m ${String(o).padStart(2,`0`)}s`:`${o}s`}function nQ(e,t){let n=[e.down_until,e.cooldown_until].filter(e=>!!e).filter(e=>Date.parse(e)>t);return n.length?n.reduce((e,t)=>Date.parse(e)>=Date.parse(t)?e:t):null}function rQ(e,t){return t?`danger`:(e??0)>=80?`warning`:`ok`}function iQ(){let{lang:e,t}=DH(),{overview:n,loading:r,error:i}=dU(),[a,o]=(0,v.useState)(`today`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=ot(),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!0),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(``),[C,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)([]),[D,O]=(0,v.useState)(!0),[k,A]=(0,v.useState)(0),[j,M]=(0,v.useState)([]),[N,P]=(0,v.useState)(null),[ee,F]=(0,v.useState)(()=>Date.now()),{live:I,samples:L}=UZ(),te=new Map((I?.accounts??[]).map(e=>[e.id,e])),R=!!n?.proxy?.ok,z=!!n?.worker?.ok,B=n?.worker?.ready_count??0,ne=n?.worker?.hot_count??0,re=n?.worker?.cooling_count??0,ie=I?.in_flight??n?.worker?.in_flight??0,V=f??KZ,ae=n?.routing?.session_affinity,oe=(ae?.hits??0)+(ae?.misses??0),se=eQ(ae?.hits??0,oe),ce=T.map(e=>({account:e,until:nQ(e,ee)})).filter(e=>e.until!=null),le=ce.length>0;(0,v.useEffect)(()=>{if(!le)return;let e=setInterval(()=>F(Date.now()),1e3);return()=>clearInterval(e)},[le]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([LH(!1),GH(),GH(void 0,!1,`regional`)]).then(([t,n,r])=>{e||(t.status===`fulfilled`&&E(t.value.data||[]),n.status===`fulfilled`&&A((n.value.data||[]).length),r.status===`fulfilled`&&M(r.value.data||[]))}).finally(()=>{e||O(!1)}),()=>{e=!0}},[]);let ue=s?.start?.toString()??``,de=s?.end?.toString()??``,fe=(0,v.useRef)(0),pe=(0,v.useCallback)(e=>{let t=mZ(a,s);if(!t){_(!1);return}let n=++fe.current;tX(t).then(e=>{n===fe.current&&(p(e),h(``))}).catch(t=>{n!==fe.current||e||(p(null),h(t instanceof Error?t.message:String(t)))}).finally(()=>{n===fe.current&&_(!1)})},[a,ue,de]);(0,v.useEffect)(()=>(pe(!1),()=>{fe.current++}),[pe]);let me=(0,v.useRef)(0),he=(0,v.useCallback)(e=>{let t=mZ(a,s)??{},n=++me.current;nX(t).then(e=>{n===me.current&&(b(e),S(``))}).catch(t=>{n!==me.current||e||(b(null),S(t instanceof Error?t.message:String(t)))}).finally(()=>{n===me.current&&w(!1)})},[a,ue,de]);(0,v.useEffect)(()=>(he(!1),()=>{me.current++}),[he]),(0,v.useEffect)(()=>{if(l)return;let e=Date.now(),t=()=>{document.hidden||(e=Date.now(),pe(!0),he(!0))},n=setInterval(t,GZ),r=()=>{!document.hidden&&Date.now()-e>=GZ&&t()};return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,r)}},[l,pe,he]),(0,v.useEffect)(()=>{let e=!1,t=()=>{OU().then(t=>{e||P(t)}).catch(()=>{})};t();let n=setInterval(t,5e3);return()=>{e=!0,clearInterval(n)}},[]);let ge=Math.floor(V.series.length/2),_e=(e,t)=>e.reduce((e,n)=>e+n[t],0),ve=V.series.slice(0,ge),ye=V.series.slice(ge),be=((e,t)=>e>0?(t-e)/e:null)(_e(ve,`requests`),_e(ye,`requests`)),xe=_e(ve,`requests`)?_e(ve,`ok`)/_e(ve,`requests`):null,Se=_e(ye,`requests`)?_e(ye,`ok`)/_e(ye,`requests`):null,Ce=xe!=null&&Se!=null?Se-xe:null,we=[{label:t(`metricRequests`),value:V.totals.requests,kind:`compact`,detail:t(`statsWindowHint`,{window:t(pZ[a])}),ok:V.totals.requests>0,trend:be},{label:t(`metricSuccess`),value:V.totals.success_rate,kind:`percent`,detail:`${V.totals.ok} ${t(`logsFilterOk`)} · ${V.totals.incomplete} ${t(`logsFilterIncomplete`)} · ${V.totals.error} ${t(`logsFilterError`)}`,ok:V.totals.requests===0||V.totals.success_rate>=.9,trend:Ce},{label:t(`metricLatency`),value:V.latency.p95_ms??V.latency.avg_ms,kind:`ms`,detail:`p50 ${cX(V.latency.p50_ms)} · avg ${cX(V.latency.avg_ms)}`,ok:V.latency.p95_ms==null||V.latency.p95_ms<8e3,trend:null},{label:t(`metricTokens`),value:V.tokens.total,kind:`compact`,detail:`${sX(V.tokens.prompt)} / ${sX(V.tokens.completion)}`,ok:!0,trend:null}],Te=eQ(V.tokens.cache_read,V.tokens.prompt),Ee=eQ(V.totals.streaming,V.totals.requests),De=[{label:t(`metricCacheHit`),value:Te,kind:`percent`,detail:t(`metricCacheHitDetail`,{read:sX(V.tokens.cache_read),prompt:sX(V.tokens.prompt)})},{label:t(`metricStreaming`),value:Ee,kind:`percent`,detail:t(`metricStreamingDetail`,{count:V.totals.streaming,total:V.totals.requests})},{label:t(`metricCanceled`),value:V.totals.canceled,kind:`int`,detail:t(`metricCanceledDetail`,{rate:uX(eQ(V.totals.canceled,V.totals.requests)??0)})}],Oe=ZZ.map(e=>({key:e,count:V.status.find(t=>t.key===e)?.count??V.totals[e]??0})),ke=e=>gZ(e,V.window.from,V.window.to);return r&&!n?(0,G.jsx)(mY,{}):(0,G.jsxs)(`div`,{className:`space-y-5 sm:space-y-4`,children:[(0,G.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:t(`homeDisplay`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:t(`homeLead`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(hZ,{value:a,onChange:o,custom:s,onCustomChange:c,onBusy:()=>{_(!0),w(!0)},t}),(0,G.jsxs)(eL,{delay:300,children:[(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(l?`statsRefreshResume`:`statsRefreshPause`),"aria-pressed":l,onPress:()=>u(e=>!e),children:l?(0,G.jsx)(Sa,{size:14}):(0,G.jsx)(va,{size:14})}),(0,G.jsx)(eL.Content,{children:t(l?`statsRefreshPaused`:`statsRefreshAuto`)})]}),(0,G.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:n?.time||`—`}),(0,G.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-2 text-body font-medium`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":R&&z?`ok`:`danger`}),t(R&&z?`running`:`degraded`)]})]})]})]}),i?(0,G.jsx)(bU,{title:t(`failedOverview`,{msg:i})}):null,(0,G.jsx)(VZ,{live:I,samples:L,t}),(0,G.jsx)(`section`,{"data-gsap-reveal":!0,className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:we.map(e=>(0,G.jsxs)(zw,{className:`gap-0 p-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`span`,{className:`status-dot`,"data-state":e.ok?`ok`:`danger`})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`tabular text-metric font-medium leading-none`,children:g?(0,G.jsx)($,{className:`h-7 w-24`}):e.value==null?`—`:(0,G.jsx)(SX,{value:e.value,kind:e.kind})}),!g&&e.trend!=null?(0,G.jsx)(cQ,{value:e.trend,hint:t(`trendHalfHint`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-2 truncate text-caption text-muted`,children:g?(0,G.jsx)($,{className:`h-3 w-28`}):e.detail})]},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:De.map(e=>(0,G.jsx)(zw,{className:`gap-0 p-3.5`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:g?(0,G.jsx)($,{className:`h-3 w-28`}):e.detail})]}),(0,G.jsx)(`div`,{className:`tabular text-section font-semibold sm:shrink-0`,children:g?(0,G.jsx)($,{className:`h-5 w-12`}):e.value==null?`—`:(0,G.jsx)(SX,{value:e.value,kind:e.kind})})]})},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3`,children:(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTraffic`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTrafficHint`)})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:V.totals.error?`warning`:`success`,children:uX(V.totals.success_rate)})]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[m?(0,G.jsx)(`div`,{className:`text-body text-danger`,children:t(`failedStats`,{msg:m})}):g?(0,G.jsx)(fY,{}):V.series.some(e=>e.requests>0)?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(fY,{}),children:(0,G.jsx)(WZ,{series:V.series,lang:e,emptyLabel:t(`statsEmptyTraffic`),okLabel:t(`logsFilterOk`),errorLabel:t(`logsFilterError`),selectHint:t(`statsDragHint`),labels:{requests:t(`chartMetricRequests`),tokens:t(`chartMetricTokens`),latency:t(`chartMetricLatency`),input:t(`chartInput`),output:t(`chartOutput`),cacheRead:t(`chartCacheRead`),p50:t(`statsLatencyP50`),p95:t(`statsLatencyP95`),total:t(`chartTotal`)},onSelectRange:(e,t)=>d(gZ({},e,t))})}):(0,G.jsx)(wX,{emptyLabel:t(`statsEmptyTraffic`)}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-4 pt-3 sm:grid-cols-4 sm:gap-3`,children:[[t(`statsLatencyP50`),cX(V.latency.p50_ms)],[t(`statsLatencyP95`),cX(V.latency.p95_ms)],[t(`statsLatencyAvg`),cX(V.latency.avg_ms)],[t(`statsTTFB`),cX(V.latency.ttfb_avg_ms)]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`div`,{className:`mono mt-1 text-body font-medium`,children:g?(0,G.jsx)($,{className:`h-4 w-16`}):t})]},String(e)))})]})]})}),(0,G.jsx)(GX,{accounts:T,t}),(0,G.jsx)(sZ,{usage:y,accounts:T,loading:C,t}),x?(0,G.jsx)(bU,{title:t(`failedStats`,{msg:x})}):null,(0,G.jsx)(lZ,{usage:y,accounts:T,models:j,loading:C,t}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,.85fr)]`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsPool`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsPoolHint`)})]}),(0,G.jsxs)(Cn,{to:`/accounts`,className:`inline-flex items-center gap-1 text-caption font-medium text-muted hover:text-foreground`,children:[t(`navAccounts`),(0,G.jsx)(ei,{size:12})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-y-1 border-b border-separator sm:grid-cols-4 sm:gap-y-0`,children:[[t(`ready`),B,`ok`],[t(`hot`),ne,ne?`ok`:``],[t(`inFlight`),ie,ie?`ok`:``],[t(`statsAffinityHit`),se==null?`—`:uX(se),``,ae?t(`statsAffinityHint`,{hits:ae.hits??0,misses:ae.misses??0,bindings:ae.bindings??0}):``]].map(([e,t,n,r])=>(0,G.jsxs)(`div`,{className:`px-4 py-3 sm:py-2.5`,title:r?String(r):void 0,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 sm:mt-1`,children:[(0,G.jsx)(`span`,{className:`mono text-section font-semibold`,children:t}),n?(0,G.jsx)(`span`,{className:`status-dot`,"data-state":n}):null]})]},String(e)))}),!D&&ce.length?(0,G.jsxs)(`div`,{className:`border-b border-separator px-4 py-2.5`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`statsCoolingDetails`)}),(0,G.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:ce.map(({account:e,until:n})=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-caption sm:flex-row sm:items-center sm:gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":`warn`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pl-4 sm:contents sm:pl-0`,children:[(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted`,children:e.last_error_kind?XZ(e.last_error_kind,t):t(`statsUnknown`)}),(0,G.jsx)(`span`,{className:`mono shrink-0 tabular sm:w-16 sm:text-right`,children:tQ(n,ee)??`—`}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted sm:w-12 sm:text-right`,title:t(`statsBackoffLevel`),children:e.restart_backoff_level?`L${e.restart_backoff_level}`:`—`})]})]},e.id))})]}):null,(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:D?(0,G.jsx)(dY,{}):T.length===0?(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`noAccounts`)}):T.slice(0,6).map(e=>{let n=e.quota,r=rQ(n?.percentage,n?.exceeded),i=te.get(e.id),a=i?.in_flight??e.in_flight??e.inFlight??0,o=i?.max_inflight||e.max_inflight||4,s=a>=o;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-3 sm:py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 sm:items-center`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0 sm:mt-0`,"data-state":e.ready?`ok`:`danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(zZ,{provider:e.provider,size:14}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:[EZ(e.provider,e.region,t),` · `,e.hot?t(`hot`):e.ready?t(`ready`):t(`degraded`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 pl-6 sm:shrink-0 sm:pl-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(s?`liveSaturated`:`inFlight`),"data-testid":`account-inflight`,children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`inFlight`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular ${s?`text-warning`:`text-muted`}`,children:[a,`/`,o]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/50`}`,style:{width:`${Math.min(100,a/o*100)}%`}})})]}),n?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(`quota`),children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`quota`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular text-muted`,children:[Math.round(n.percentage??0),`%`]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${r===`danger`?`bg-danger`:r===`warning`?`bg-warning`:`bg-success`}`,style:{width:`${Math.min(100,Math.max(0,n.percentage??0))}%`}})})]}):null]})]},e.id)})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{children:[t(`metricModels`),` `,k]}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[[`qoder`,`workbuddy`,`trae`].map(e=>{let t=T.filter(t=>String(t.provider||`qoder`).toLowerCase()===e).length;return t?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(zZ,{provider:e,size:11}),t]},e):null}),(0,G.jsx)(`span`,{children:re?`${re} ${t(`statsCooling`)}`:`${T.length} ${t(`accountCount`)}`})]})]})]}),(0,G.jsx)(oQ,{resources:N,t})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-2 2xl:grid-cols-3`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopProviders`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTopProvidersHint`)})]})}),g?(0,G.jsx)(dY,{}):(0,G.jsx)(sQ,{empty:t(`statsNoProviders`),items:(V.providers||[]).map(e=>({key:e.key,label:qZ(e.key,t),count:e.count,meta:`${e.ok}/${e.count}`,mark:e.key===`(unknown)`?void 0:e.key,href:e.key===`(unknown)`?void 0:ke({provider:e.key})}))})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`providerCatalog`)})]})}),g?(0,G.jsx)(dY,{rows:4}):(0,G.jsx)(sQ,{empty:t(`statsNoModels`),items:V.models.map(e=>({key:e.key,label:e.key===`(unknown)`?t(`statsUnknown`):e.key,count:e.count,href:e.key===`(unknown)`?void 0:ke({model:e.key}),meta:e.latency_avg_ms==null?`${e.ok}/${e.count}`:cX(e.latency_avg_ms)}))})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsStatusMix`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsStatusMixHint`)})]})}),g?(0,G.jsx)(dY,{rows:4}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(lQ,{items:Oe,t}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsErrorMix`)}),(0,G.jsx)(sQ,{empty:t(`statsNoErrors`),danger:!0,items:V.errors.map(e=>({key:e.key,label:XZ(e.key,t),count:e.count,href:YZ.has(e.key)?ke({error_kind:e.key}):void 0}))}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsTopAccounts`)}),(0,G.jsx)(sQ,{empty:t(`statsNoAccounts`),items:V.accounts.slice(0,5).map(e=>({key:e.key,label:JZ(T,e.key,t(`statsUnassigned`)),count:e.count,href:!e.key||e.key===`(unassigned)`?void 0:ke({account:e.key}),meta:`${e.ok}/${e.count}`}))})]})]})]})]})}function aQ(e,t){return e>=2147483648||t>=200?`danger`:e>=1073741824||t>=100?`warning`:`ok`}function oQ({resources:e,t}){let n=[...e?.workers??[]].sort((e,t)=>t.rss_bytes-e.rss_bytes),r=e?.server;return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`resTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`resHint`)})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:e?`success`:`default`,children:e?lX(e.total_rss_bytes):`—`})]}),(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":aQ(r?.rss_bytes??0,r?.cpu_percent??0)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:t(`resServer`)}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,r?.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[lX(r?.rss_bytes),` · `,(r?.cpu_percent??0).toFixed(1),`%`]})]})}),n.length===0?(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`resEmpty`)}):n.map(e=>(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":aQ(e.rss_bytes,e.cpu_percent)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label||e.account_id}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,e.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[lX(e.rss_bytes),` · `,e.cpu_percent.toFixed(1),`%`]})]})},e.pid))]}):(0,G.jsx)(dY,{rows:3})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{className:`mono`,children:[r?.goroutines??0,` `,t(`resGoroutines`)]}),(0,G.jsx)(`span`,{className:`mono`,children:e?.sampled_at?new Date(e.sampled_at).toLocaleTimeString():`—`})]})]})}function sQ({items:e,empty:t,danger:n}){let r=(0,v.useRef)(null),i=Math.max(1,...e.map(e=>e.count)),a=e.map(e=>`${e.key}:${e.count}`).join(`|`);return(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=eY.context(()=>{let e=eY.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(`[data-rank-fill]`,{clearProps:`transform`})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=eY.utils.toArray(`[data-rank-fill]`);e.length&&eY.fromTo(e,{scaleX:0},{scaleX:1,duration:.38,ease:`power2.out`,stagger:.05,transformOrigin:`0% 50%`})})},e);return()=>t.revert()},[a]),e.length?(0,G.jsx)(`div`,{ref:r,className:`divide-y divide-separator`,children:e.map(e=>{let t=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.mark?(0,G.jsx)(zZ,{provider:e.mark,size:14}):null,(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label})]}),(0,G.jsx)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:e.meta?`${e.count} · ${e.meta}`:e.count})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.jsx)(`div`,{"data-rank-fill":!0,className:`h-full origin-left rounded-[2px] ${n?`bg-danger`:`bg-success`}`,style:{width:`${Math.max(6,e.count/i*100)}%`}})})]});return e.href?(0,G.jsx)(Cn,{to:e.href,className:`rank-row block px-4 py-2.5`,title:e.label,children:t},e.key):(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:t},e.key)})}):(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t})}function cQ({value:e,hint:t}){let n=Math.abs(e)<.005?`flat`:e>0?`up`:`down`;return(0,G.jsxs)(`span`,{className:`trend-chip`,"data-tone":n,title:t,children:[(0,G.jsx)(n===`down`?Xa:n===`up`?Qa:gi,{size:12,weight:`bold`}),e>0?`+`:``,(e*100).toFixed(1),`%`]})}function lQ({items:e,t}){let n=e.reduce((e,t)=>e+t.count,0);return n?(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`flex h-2 gap-px overflow-hidden rounded-[3px] bg-separator`,role:`img`,"aria-label":e.map(e=>`${t($Z[e.key])} ${e.count}`).join(`, `),children:e.filter(e=>e.count>0).map(e=>(0,G.jsx)(`div`,{className:QZ[e.key],style:{width:`${e.count/n*100}%`,minWidth:2}},e.key))}),(0,G.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-1.5`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(`span`,{className:`inline-block size-2 shrink-0 rounded-[2px] ${QZ[e.key]}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted`,children:t($Z[e.key])}),(0,G.jsx)(`span`,{className:`mono tabular`,children:e.count}),(0,G.jsx)(`span`,{className:`mono w-10 text-right tabular text-muted`,children:uX(e.count/n)})]},e.key))})]}):(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`statsEmptyTraffic`)})}function uQ(e){return e?e>=1e6?`${(e/1e6).toString().replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e):`—`}function dQ({model:e,t,onClose:n}){if(!e)return null;let r=e.reasoning_options||[],i=e.catalog_context_length||e.default_context_length||e.context_length,a=e.catalog_context_length_max,o=fX(e),s=pX(e),c=String(e.provider||e.owned_by||`qoder`).trim().toLowerCase(),l=EZ(c,String(e.region||e.regions?.[0]||``).trim().toLowerCase()||void 0,t),u=c===`trae`?DZ(e):void 0;return(0,G.jsx)(Z.Root,{isOpen:!0,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`md`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`text-section`,children:e.display_name||e.id}),s?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:e.id}),(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[l,o?` · ${o}`:``]})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-4 px-5 pb-5`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`contextWindowCol`)}),(0,G.jsxs)(`div`,{className:`mt-1 text-body`,children:[uQ(i),a&&a!==i?` → ${uQ(a)}`:``]}),e.supports_max_mode?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(c===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,!e.supports_max_mode&&a&&a!==i?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`workbuddyContextHint`)}):null,u?u.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,uQ(u.prompt_max_tokens)]}):null:e.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,uQ(e.prompt_max_tokens)]}):null,u?u.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,uQ(u.max_output_tokens)]}):null:e.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,uQ(e.max_output_tokens)]}):null]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`reasoningLevels`)}),r.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`reasoningHint`)}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:r.map(n=>{let r=`reasoningLevel_${n}`,i=t(r);return(0,G.jsxs)(lT,{size:`sm`,variant:`soft`,color:n===(e.reasoning_effort||e.reasoning_default)?`success`:`default`,children:[i===r?n:i,n===e.reasoning_default?` · ${t(`defaultValue`)}`:``,n===e.reasoning_effort&&n!==e.reasoning_default?` · ${t(`custom`)}`:``]},n)})})]}):(0,G.jsx)(`div`,{className:`mt-1 text-body text-muted`,children:e.reasoning_type?t(`reasoningFixed`,{type:e.reasoning_type}):t(`noReasoningLevels`)})]})]})]})})})})}function fQ({isSelected:e,isDisabled:t,ariaLabel:n,label:r,size:i=`sm`,onChange:a}){return(0,G.jsx)(dF,{size:i,isSelected:e,isDisabled:t,onChange:a,children:(0,G.jsxs)(dF.Content,{children:[(0,G.jsx)(dF.Control,{children:(0,G.jsx)(dF.Thumb,{})}),r?(0,G.jsx)(sR,{children:r}):(0,G.jsx)(`span`,{className:`sr-only`,children:n})]})})}function pQ({title:e,hint:t,action:n,icon:r,className:i}){return(0,G.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center ${i||``}`,children:(0,G.jsxs)(`div`,{className:`max-w-sm`,children:[r?(0,G.jsx)(`div`,{className:`mb-3 flex justify-center text-muted`,children:r}):null,(0,G.jsx)(dR,{className:`p-0 text-body font-medium text-foreground`,children:e}),t?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t}):null,n?(0,G.jsx)(`div`,{className:`mt-5 flex justify-center`,children:n}):null]})})}var mQ=`__all__`;function hQ({value:e,onChange:t,ariaLabel:n,options:r,className:i}){let a=r.map(e=>({id:e.id||mQ,label:e.label})),o=e||mQ,s=a.find(e=>e.id===o);return(0,G.jsxs)(SV,{className:i??`w-fit min-w-36`,"aria-label":n,value:o,onChange:e=>{typeof e==`string`&&t(e===mQ?``:e)},children:[(0,G.jsxs)(SV.Trigger,{className:`min-w-0 w-full items-center`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t||!s?e:(0,G.jsx)(`span`,{className:`truncate`,children:s.label})}),(0,G.jsx)(SV.Indicator,{})]}),(0,G.jsx)(SV.Popover,{className:`max-h-72 min-w-36`,children:(0,G.jsx)(GB,{children:a.map(e=>(0,G.jsxs)(GB.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(sR,{className:`block truncate`,children:e.label}),(0,G.jsx)(GB.ItemIndicator,{})]},e.id))})})]})}var gQ=[20,50,100],_Q=[20,50,100];function vQ(e,t){if(t<=7)return Array.from({length:t},(e,t)=>t+1);let n=[1];e>3&&n.push(`gap`);let r=Math.max(2,e-1),i=Math.min(t-1,e+1);for(let e=r;e<=i;e++)n.push(e);return e{let t=Number([...e][0]);d.includes(t)&&u(t)},"aria-label":a,children:d.map(e=>(0,G.jsx)(QP,{id:String(e),children:e},e))})]}),(0,G.jsxs)(yV,{size:`sm`,className:`w-fit`,children:[(0,G.jsx)(yV.Summary,{className:`mono text-caption`,children:o}),(0,G.jsxs)(yV.Content,{children:[(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Previous,{isDisabled:i||t<=1,onPress:()=>l(Math.max(1,t-1)),"aria-label":s,children:(0,G.jsx)(yV.PreviousIcon,{})})}),f.map((e,n)=>e===`gap`?(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Ellipsis,{})},`gap-${n}`):(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Link,{isActive:e===t,isDisabled:i,onPress:()=>l(e),children:e})},e)),(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Next,{isDisabled:i||t>=n,onPress:()=>l(Math.min(n,t+1)),"aria-label":c,children:(0,G.jsx)(yV.NextIcon,{})})})]})]})]})}function bQ({value:e,onChange:t,placeholder:n,ariaLabel:r,className:i}){return(0,G.jsx)(aR,{"aria-label":r,value:e,onChange:t,className:i,children:(0,G.jsxs)(aR.Group,{children:[(0,G.jsx)(aR.SearchIcon,{}),(0,G.jsx)(aR.Input,{placeholder:n}),(0,G.jsx)(aR.ClearButton,{})]})})}function xQ(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id});return t}function SQ(e){return e.settings_key||e.id}function CQ(e){return String(e.provider||e.owned_by||`qoder`).trim().toLowerCase()}function wQ(e){let t=String(e.region||``).trim().toLowerCase();if(t)return t;let n=e.regions||[];return String(n[0]||``).trim().toLowerCase()}function TQ(e){return`${CQ(e)}:${wQ(e)||`any`}:${e.settings_key||e.id}:${e.native_model||e.mapped_key||``}`}function EQ(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function DQ(e,t){let n=`reasoningLevel_${t}`,r=e(n);return r===n?t:r}function OQ({label:e,hint:t}){return(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`span`,{className:`cursor-help text-caption text-muted`,children:e})}),(0,G.jsx)(eL.Content,{children:(0,G.jsx)(`p`,{className:`max-w-xs text-caption leading-5`,children:t})})]})}function kQ({model:e,saving:t,t:n,variant:r=`table`,onToggleTraeMax:i,onReasoningChange:a}){let o=CQ(e),s=r===`card`,c=s?`w-full min-w-0`:`w-full max-w-[7.5rem] min-w-0`;return(0,G.jsxs)(`div`,{className:s?`flex min-w-0 flex-col gap-3`:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[uQ(e.catalog_context_length||e.context_length),e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?` → ${uQ(e.catalog_context_length_max)}`:``]}),o===`workbuddy`&&e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?(0,G.jsx)(OQ,{label:n(`catalogWindow`),hint:n(`workbuddyContextHint`)}):null]}),(o===`trae`||o===`qoder`)&&e.supports_max_mode?(0,G.jsxs)(`div`,{className:s?`flex flex-col gap-1.5`:`flex items-center gap-2`,children:[s?(0,G.jsx)(OQ,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${uQ(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(fQ,{isSelected:!!e.max_mode,isDisabled:t,ariaLabel:`${e.id} ${n(`maxMode`)}`,onChange:t=>i(e,t)}),s?null:(0,G.jsx)(OQ,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${uQ(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)})]})]}):null,(e.reasoning_options||[]).length>1?(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsx)(OQ,{label:n(`reasoningLevels`),hint:n(`reasoningHint`)}),(0,G.jsx)(hQ,{className:c,ariaLabel:`${e.id} ${n(`reasoningLevels`)}`,value:e.reasoning_effort||e.reasoning_default||e.reasoning_options?.[0]||``,onChange:t=>{t&&a(e,t)},options:(e.reasoning_options||[]).map(e=>({id:e,label:DQ(n,e)}))})]}):(e.reasoning_options||[]).length===1?(0,G.jsx)(OQ,{label:`${n(`reasoningLevels`)} ${DQ(n,e.reasoning_options[0])}`,hint:n(`reasoningHint`)}):e.reasoning_type?(0,G.jsx)(`span`,{className:`text-caption text-muted`,children:n(`reasoningFixed`,{type:e.reasoning_type})}):o===`trae`&&!e.supports_max_mode?(0,G.jsx)(OQ,{label:n(`catalogWindow`),hint:n(`catalogWindowHint`)}):null]})}function AQ({model:e,t,onDetails:n}){return(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>n(e),children:[(0,G.jsx)(ea,{size:14}),t(`modelDetails`)]})}function jQ(){let{t:e}=DH(),{overview:t,loading:n}=dU(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(1),[d,f]=(0,v.useState)(50),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)(!0);(0,v.useEffect)(()=>{let e=!1;return KH(void 0,`regional`).then(t=>{e||T(t.data||[])}).catch(()=>void 0).finally(()=>{e||D(!1)}),tU().then(t=>{e||c(xQ(t.data||[]))}).catch(()=>void 0),()=>{e=!0}},[]);let O=(0,v.useMemo)(()=>{let t=r.trim().toLowerCase(),[n,i]=a.includes(`:`)?a.split(`:`,2):[a,``];return w.filter(r=>{let a=CQ(r),o=wQ(r);if(n&&a!==n||i&&o!==i)return!1;if(!t)return!0;let s=EZ(a,o||void 0,e);return`${r.display_name||``} ${r.id} ${r.mapped_key||``} ${a} ${s} ${r.owned_by||``} ${o} ${r.credits||``} ${r.free?`free`:``}`.toLowerCase().includes(t)})},[r,w,a,e]),k=[r,a,d].join(`\0`),[A,j]=(0,v.useState)(k);A!==k&&(j(k),u(1));let M=Math.max(1,Math.ceil(O.length/d)),N=Math.min(A===k?Math.max(1,l):1,M);l!==N&&u(N);let P=(0,v.useMemo)(()=>{let e=(N-1)*d;return O.slice(e,e+d)},[N,O,d]),ee=O.length===0?0:(N-1)*d+1,F=Math.min(O.length,N*d),I=O.length?e(`logsShownTotal`,{shown:`${ee}–${F}`,total:O.length}):e(`shownTotal`,{shown:0,total:w.length});if(n&&!t||E)return(0,G.jsx)(vY,{});function L(e,t){let n=SQ(e),r=CQ(e),i=w.map(e=>{if(SQ(e)!==n||CQ(e)!==r)return e;let i=e.reasoning_effort||e.reasoning_default||``,a=e.catalog_context_length||e.default_context_length||e.context_length||0,o=e.catalog_context_length_max||0;return{...e,max_mode:t,context_length:t&&o?o:a,default_context_length:a,context_custom:r===`qoder`?t:t||!!(i&&i!==e.reasoning_default)}});T(i)}function te(e,t){let n=SQ(e),r=CQ(e),i=w.map(e=>SQ(e)!==n||CQ(e)!==r?e:{...e,reasoning_effort:t,context_custom:!!e.max_mode||!!(t&&t!==e.reasoning_default)});T(i)}async function R(){m(!0),y(``),x(!1);try{let e=await qH(void 0,`regional`);T(e.data||[])}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function z(t,n){let r=CQ(t);if(r!==`trae`&&r!==`workbuddy`&&r!==`kimi`)return;let i=SQ(t);g(i),y(``),x(!1);try{await YH(r,i,n),te(t,n),y(e(`reasoningSaved`,{model:t.id,level:DQ(e,n)}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}async function B(t,n){if(!t.supports_max_mode){x(!0),y(e(`contextMaxUnavailable`));return}let r=SQ(t),i=CQ(t);g(r),y(``),x(!1);try{await JH(i,r,n,t.catalog_context_length_max),L(t,n),y(e(n?`contextMaxOn`:`contextMaxOff`,{model:t.id}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`grid gap-5 pb-6 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`availableModels`)}),(0,G.jsx)(`p`,{className:`mt-1 text-body text-muted`,children:w.length?I:e(`noModelsYet`)})]}),(0,G.jsxs)(`div`,{"data-gsap-reveal":!0,className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,G.jsx)(bQ,{className:`w-full min-w-0 sm:w-72`,value:r,onChange:i,placeholder:e(`filterPh`),ariaLabel:e(`filter`)}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(hQ,{ariaLabel:e(`providerCol`),value:a,onChange:o,options:[{id:``,label:e(`providerFilterAll`)},...s.map(t=>({id:t.value,label:EZ(t.provider,t.region,e)}))]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:p,onPress:()=>void R(),children:[(0,G.jsx)(Jr,{size:14}),e(p?`refreshing`:`refresh`)]})]})]})]}),_?(0,G.jsx)(bU,{status:b?`danger`:`success`,title:_}):null,(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-separator px-4 py-4 sm:items-center sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(Mi,{size:16})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:e(`providerCatalog`)}),(0,G.jsx)(`div`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:e(`contextConfigHint`)})]})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,className:`shrink-0`,children:O.length})]}),p||n?(0,G.jsx)(pY,{}):O.length===0?(0,G.jsx)(pQ,{icon:(0,G.jsx)(ua,{size:22}),title:w.length?e(`noModelsMatch`):e(`noProviders`),hint:w.length?r||a||e(`noModelsMatch`):e(`noModelsYet`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:P.map(t=>{let n=SQ(t),r=h===n,i=CQ(t),a=EZ(i,wQ(t)||void 0,e),o=fX(t),s=pX(t);return(0,G.jsxs)(`article`,{className:`space-y-3 px-4 py-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:t.id}),EQ(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:EQ(t)})}):null]})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-caption`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(zZ,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`font-medium`,children:a})]}),(0,G.jsx)(`span`,{className:`mono break-all text-muted`,children:t.mapped_key||t.native_model||t.id})]}),(0,G.jsx)(kQ,{model:t,saving:r,t:e,variant:`card`,onToggleTraeMax:(e,t)=>void B(e,t),onReasoningChange:(e,t)=>void z(e,t)}),(0,G.jsx)(AQ,{model:t,t:e,onDetails:C})]},TQ(t))})}),(0,G.jsx)(Q,{className:`hidden min-w-0 lg:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{"aria-label":e(`availableModels`),className:`min-w-[68rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`modelCol`)}),(0,G.jsx)(Q.Column,{children:e(`requestIdCol`)}),(0,G.jsx)(Q.Column,{children:e(`providerCol`)}),(0,G.jsx)(Q.Column,{children:e(`qoderKeyCol`)}),(0,G.jsx)(Q.Column,{children:e(`modelDefaultsCol`)}),(0,G.jsx)(Q.Column,{children:e(`stateCol`)}),(0,G.jsx)(Q.Column,{children:e(`actions`)})]}),(0,G.jsx)(Q.Body,{children:P.map(t=>{let n=SQ(t),r=h===n,i=CQ(t),a=EZ(i,wQ(t)||void 0,e),o=fX(t),s=pX(t);return(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),EQ(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:EQ(t)})}):null]})]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption font-medium`,children:t.id})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zZ,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`text-caption font-medium`,children:a})]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t.mapped_key||t.native_model||t.id})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(kQ,{model:t,saving:r,t:e,variant:`table`,onToggleTraeMax:(e,t)=>void B(e,t),onReasoningChange:(e,t)=>void z(e,t)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(AQ,{model:t,t:e,onDetails:C})})]},TQ(t))})})]})})})]})]}),(0,G.jsx)(dQ,{model:S?w.find(e=>SQ(e)===SQ(S))||S:null,t:e,onClose:()=>C(null)}),(0,G.jsx)(yQ,{total:O.length,page:N,pageCount:M,pageSize:d,loading:p,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:N,pages:M}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:u,onPageSize:f})]})}function MQ({copied:e,size:t=14,className:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(!0);return(0,v.useLayoutEffect)(()=>{let t=e?i.current:r.current,n=e?r.current:i.current;if(!t||!n)return;let o={autoAlpha:1,scale:1,filter:`blur(0px)`},s={autoAlpha:0,scale:.5,filter:`blur(4px)`};if(a.current||iY()){a.current=!1,eY.set(t,o),eY.set(n,s);return}eY.to(n,{...s,duration:tY.fast,ease:nY.out,overwrite:!0}),eY.fromTo(t,s,{...o,duration:tY.base,ease:nY.soft,delay:tY.instant/2,overwrite:!0})},[e]),(0,G.jsxs)(`span`,{className:`relative inline-grid place-items-center ${n??``}`,style:{width:t,height:t},children:[(0,G.jsx)(`span`,{ref:r,className:`col-start-1 row-start-1 inline-flex`,children:(0,G.jsx)(Oi,{size:t})}),(0,G.jsx)(`span`,{ref:i,className:`col-start-1 row-start-1 inline-flex text-success`,children:(0,G.jsx)(vi,{size:t})})]})}async function NQ(e){if(!e)return!1;try{if(typeof navigator<`u`&&navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function PQ(){return`${location.protocol}//${location.host}`}function FQ(e){return e?/^https?:\/\//i.test(e)?e:e.startsWith(`/`)?`${PQ()}${e}`:`${PQ()}/${e}`:PQ()}function IQ({access:e}){let{t}=DH(),[n,r]=(0,v.useState)(``),i=FQ(e?.openai_base_url||`/v1`),a=(0,v.useMemo)(()=>[{name:t(`endpointOpenAI`),url:i,method:`BASE`,hint:t(`endpointBaseHint`),icon:(0,G.jsx)(oi,{size:15})},{name:t(`endpointChat`),url:FQ(e?.chat_completions||`${i}/chat/completions`),method:`POST`,hint:t(`endpointChatHint`),icon:(0,G.jsx)(ga,{size:15})},{name:t(`endpointMessages`),url:FQ(e?.messages||`${i}/messages`),method:`POST`,hint:t(`endpointMessagesHint`),icon:(0,G.jsx)(ga,{size:15})},{name:t(`endpointResponses`),url:FQ(e?.responses||`${i}/responses`),method:`POST`,hint:t(`endpointResponsesHint`),icon:(0,G.jsx)(ga,{size:15})},{name:t(`endpointModels`),url:FQ(e?.models||`${i}/models`),method:`GET`,hint:t(`endpointModelsHint`),icon:(0,G.jsx)(ca,{size:15})},{name:t(`endpointHealth`),url:FQ(e?.health||`/health`),method:`GET`,hint:t(`endpointHealthHint`),icon:(0,G.jsx)(Qi,{size:15})}],[e,i,t]);return(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4 px-5 py-4 sm:px-6`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`endpoints`)}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:t(`endpointCount`,{count:a.length-1})})]}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`routesHint`)})]})}),(0,G.jsx)(`div`,{className:`grid gap-2 px-3 pb-3 sm:grid-cols-2 sm:px-4 sm:pb-4 lg:grid-cols-3`,children:a.map(e=>(0,G.jsxs)(`div`,{className:`group min-w-0 rounded-xl bg-surface-secondary/40 p-3 transition-colors hover:bg-surface-secondary/70`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface text-muted`,children:e.icon}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.name}),(0,G.jsx)(`code`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.url})]})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:e.method})]}),(0,G.jsx)(`p`,{className:`mt-2 text-caption leading-5 text-muted`,children:e.hint}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:e.method===`BASE`?t(`endpointBaseLabel`):t(`endpointAuthLabel`)}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`copy`),onPress:()=>{NQ(e.url),r(e.name),window.setTimeout(()=>r(``),1100)},children:(0,G.jsx)(MQ,{copied:n===e.name})}),(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`open`),onPress:()=>window.open(e.url,`_blank`,`noopener,noreferrer`),children:(0,G.jsx)(Qr,{size:14})})]})]})]},e.name))})]})}var LQ=new Set(`txt.md.markdown.json.csv.tsv.yml.yaml.toml.xml.html.htm.css.scss.js.jsx.ts.tsx.mjs.cjs.py.go.rs.java.kt.swift.c.h.cpp.hpp.sh.bash.zsh.sql.graphql.env.ini.conf.log.rst.tex`.split(`.`)),RQ=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function zQ(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}function BQ(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function VQ(e){let t=zQ(e.name),n=e.type||`application/octet-stream`,r=`${e.name}-${e.size}-${e.lastModified}-${Math.random().toString(36).slice(2,8)}`;if(RQ.has(n)||[`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(t)){let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error||Error(`read failed`)),r.readAsDataURL(e)});return{id:r,name:e.name,mime:n,kind:`image`,dataUrl:t,size:e.size}}if(LQ.has(t)||n.startsWith(`text/`)||n===`application/json`){let t=await e.text();return{id:r,name:e.name,mime:n,kind:`text`,text:t,size:e.size}}return null}function HQ({ariaLabel:e,value:t,onChange:n,placeholder:r,isDisabled:i,options:a,className:o,tone:s=`default`}){let c=a.find(e=>e.id===t),l=s===`muted`?`text-muted hover:text-foreground`:`text-foreground`;return(0,G.jsxs)(SV,{className:o??`w-auto max-w-[11rem] min-w-0`,"aria-label":e,value:t||null,placeholder:r,isDisabled:i,onChange:e=>{typeof e==`string`&&e&&n(e)},children:[(0,G.jsxs)(SV.Trigger,{className:`h-7 min-h-7 gap-1 rounded-md border-0 bg-transparent px-1.5 shadow-none items-center hover:bg-surface data-[focus-visible=true]:bg-surface ${l}`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate text-caption font-medium`,children:({defaultChildren:e,isPlaceholder:t})=>t||!c?e:(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[c.icon?(0,G.jsx)(`span`,{className:`grid size-3.5 shrink-0 place-items-center opacity-80`,children:c.icon}):null,(0,G.jsx)(`span`,{className:`truncate`,children:c.label})]})}),(0,G.jsx)(SV.Indicator,{className:`size-2.5 opacity-50`})]}),(0,G.jsx)(SV.Popover,{placement:`top end`,className:`max-h-72 min-w-48`,children:(0,G.jsx)(GB,{children:a.map(e=>(0,G.jsxs)(GB.Item,{id:e.id,textValue:e.textValue,className:`gap-2`,children:[e.icon?(0,G.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:e.icon}):null,(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(sR,{className:`block truncate text-caption`,children:e.label}),e.hint?(0,G.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),(0,G.jsx)(GB.ItemIndicator,{})]},e.id))})})]})}function UQ({value:e,onChange:t,attachments:n,onAttachmentsChange:r,disabled:i,streaming:a,canSend:o,onSend:s,onStop:c,accountValue:l,onAccountChange:u,accountOptions:d,modelValue:f,onModelChange:p,modelOptions:m,modelsLoading:h}){let{t:g}=DH(),_=(0,v.useRef)(null);async function y(e){if(!e?.length)return;let t=[],i=[];for(let n of Array.from(e))try{let e=await VQ(n);e?t.push(e):i.push(n.name)}catch{i.push(n.name)}t.length&&r([...n,...t]),i.length&&window.alert(g(`chatAttachUnsupported`,{names:i.join(`, `)})),_.current&&(_.current.value=``)}function b(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!a&&o&&s())}return(0,G.jsxs)(`div`,{className:`border-t border-separator/60 p-3 sm:p-4`,children:[(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-surface-secondary/80`,children:[n.length?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:n.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex max-w-[14rem] items-center gap-2 rounded-xl bg-surface px-1.5 py-1.5 text-caption text-foreground`,children:[e.kind===`image`&&e.dataUrl?(0,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-8 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(Wi,{size:14})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,G.jsx)(`span`,{className:`mono text-muted`,children:BQ(e.size)})]}),(0,G.jsx)(`button`,{type:`button`,className:`grid size-6 shrink-0 place-items-center rounded-md text-muted hover:bg-surface-secondary hover:text-foreground`,"aria-label":g(`chatAttachRemove`),onClick:()=>r(n.filter(t=>t.id!==e.id)),children:(0,G.jsx)(oo,{size:12})})]},e.id))}):null,(0,G.jsx)(mL,{fullWidth:!0,rows:3,className:`min-h-20 resize-none border-0 bg-transparent px-3.5 py-3 text-body leading-[1.65] shadow-none focus-visible:ring-0`,value:e,onChange:e=>t(e.target.value),onKeyDown:b,placeholder:g(`promptPlaceholder`),"aria-label":g(`prompt`),disabled:i||a}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pb-2 pt-0.5`,children:[(0,G.jsx)(`input`,{ref:_,type:`file`,className:`hidden`,multiple:!0,accept:`.txt,.md,.json,.csv,.yml,.yaml,.toml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.go,.rs,.sh,.sql,.png,.jpg,.jpeg,.gif,.webp,text/*,image/png,image/jpeg,image/gif,image/webp,application/json`,onChange:e=>void y(e.target.files)}),(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-7 min-w-7 shrink-0`,"aria-label":g(`chatAttach`),isDisabled:i||a,onPress:()=>_.current?.click(),children:(0,G.jsx)(wa,{size:15})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,G.jsx)(HQ,{ariaLabel:g(`account`),value:l,onChange:u,options:d,isDisabled:i||a,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,G.jsx)(HQ,{ariaLabel:g(`model`),value:f,onChange:p,placeholder:g(h?`requesting`:`model`),options:m,isDisabled:i||a||h||!m.length,className:`w-auto max-w-[10.5rem] min-w-0`}),a?(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`secondary`,className:`size-7 shrink-0 rounded-full`,"aria-label":g(`chatTryStop`),onPress:c,children:(0,G.jsx)(Ha,{size:13,weight:`fill`})}):(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,className:`size-7 shrink-0 rounded-full transition-transform active:scale-95 disabled:active:scale-100`,"aria-label":g(`chatTrySend`),isDisabled:!o||i,onPress:s,children:(0,G.jsx)(ga,{size:13,weight:`fill`})})]})]}),(0,G.jsx)(`p`,{className:`mt-2 px-1 text-caption leading-5 text-muted`,children:g(`chatTryHelper`)})]})}function WQ({text:e,streaming:t,defaultOpen:n}){let{t:r}=DH(),[i,a]=(0,v.useState)(!!n),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(0);if((0,v.useEffect)(()=>{t?a(!1):n!=null&&a(!!n)},[t,n]),(0,v.useEffect)(()=>{if(!t)return;let e=Date.now();s(0);let n=window.setInterval(()=>{let t=Math.floor((Date.now()-e)/1e3);s(t),c.current=t},250);return()=>window.clearInterval(n)},[t]),(0,v.useEffect)(()=>{!t&&o===0&&c.current>0&&s(c.current)},[t,o]),!e&&!t)return null;let l=iY(),u=t?o:o||c.current;return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl`,children:[(0,G.jsx)(`button`,{type:`button`,className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-surface-secondary px-2.5 py-1 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(wi,{size:12,className:`shrink-0 text-muted ${l?``:`animate-spin`}`}),(0,G.jsx)(`span`,{className:l?``:`access-thinking-shimmer`,children:r(`thinkingWorking`)}),(0,G.jsxs)(`span`,{className:`mono text-muted/80`,children:[o,`s`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fi,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{children:r(`thinkingDone`)}),u>0?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingElapsed`,{n:u})}):null,!u&&e?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingChars`,{count:e.length})}):null]})}),i&&e?(0,G.jsx)(`div`,{className:`mt-1.5`,children:(0,G.jsx)(`pre`,{className:`max-h-52 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-surface-secondary/80 px-3 py-2 text-caption leading-5 text-muted`,children:e})}):null]})}function GQ(e,t){return t(e===`running`?`toolCallRunning`:e===`error`?`toolCallError`:`toolCallSuccess`)}function KQ({status:e}){return e===`running`?(0,G.jsx)(Ia,{size:12,className:`animate-spin text-muted`}):e===`error`?(0,G.jsx)(io,{size:12,weight:`fill`,className:`text-danger`}):(0,G.jsx)(bi,{size:12,weight:`fill`,className:`text-success`})}function qQ(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function JQ({call:e,forceOpen:t}){let{t:n}=DH(),[r,i]=(0,v.useState)(e.status===`error`||!!t),[a,o]=(0,v.useState)(!1),s=(0,v.useMemo)(()=>qQ(e.arguments||``),[e.arguments]);(0,v.useEffect)(()=>{e.status===`error`&&i(!0)},[e.status]),(0,v.useEffect)(()=>{t&&i(!0)},[t]);async function c(){s&&(await NQ(s),o(!0),window.setTimeout(()=>o(!1),1200))}return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2 py-1.5 text-left`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,G.jsx)(fi,{size:11,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-caption font-medium text-foreground`,children:e.name||n(`toolCallUntitled`)}),(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted`,children:[(0,G.jsx)(KQ,{status:e.status}),GQ(e.status,n)]})]}),r?(0,G.jsxs)(`div`,{className:`space-y-1.5 px-2 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:n(`toolCallArgs`)}),(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-caption text-muted hover:bg-surface-secondary hover:text-foreground`,onClick:e=>{e.stopPropagation(),c()},children:[(0,G.jsx)(Ai,{size:12}),n(a?`copied`:`copy`)]})]}),(0,G.jsx)(`pre`,{className:`mono max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary/80 px-2.5 py-2 text-caption leading-5 text-muted`,children:s||n(`toolCallArgsEmpty`)})]}):null]})}function YQ({calls:e}){let{t}=DH(),n=e.some(e=>e.status===`error`),r=e.some(e=>e.status===`running`),[i,a]=(0,v.useState)(n||r||e.length===1);return(0,v.useEffect)(()=>{(n||r)&&a(!0)},[n,r]),e.length?e.length===1?(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary/70`,children:(0,G.jsx)(JQ,{call:e[0],forceOpen:e[0].status===`error`})}):(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-secondary/70`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,G.jsx)(fi,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(`toolCallGroup`,{n:e.length})}),r?(0,G.jsx)(Ia,{size:12,className:`animate-spin`}):null]}),i?(0,G.jsx)(`div`,{className:`space-y-0.5 border-t border-separator/40 px-0.5 py-1`,children:e.map(e=>(0,G.jsx)(JQ,{call:e},`${e.index}-${e.id||e.name}`))}):null]}):null}function XQ({message:e}){return e.attachments?.length?(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.attachments.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-xl bg-surface/70 px-1.5 py-1 text-caption text-muted`,children:[e.kind===`image`&&e.dataUrl?(0,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-7 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface`,children:(0,G.jsx)(Wi,{size:12})}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))}):null}function ZQ({message:e}){let{t}=DH(),n=e.usage;if(!n||n.credits==null)return null;let r=n.prompt_tokens,i=n.completion_tokens,a=typeof r==`number`||typeof i==`number`?t(`chatTryUsageTokens`,{prompt:sX(r??0),completion:sX(i??0)}):``;return(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`chatTryUsageFoot`,{tokens:a,amount:_X(n.credits)}):t(`chatTryCreditsUsed`,{amount:_X(n.credits)})})}function QQ({message:e}){let{t}=DH(),[n,r]=(0,v.useState)(!1);if(e.role===`user`)return(0,G.jsx)(`div`,{className:`ml-auto max-w-[92%] sm:max-w-[78%]`,children:(0,G.jsxs)(`div`,{className:`rounded-2xl rounded-br-md bg-surface-secondary/90 px-3.5 py-2.5`,children:[e.content?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground`,children:e.content}):null,(0,G.jsx)(XQ,{message:e})]})});let i=e.status===`streaming`&&!e.content&&!e.reasoning&&!e.toolCalls?.length,a=!!e.content&&e.status===`done`;async function o(){e.content&&(await NQ(e.content),r(!0),window.setTimeout(()=>r(!1),1200))}return(0,G.jsxs)(`div`,{className:`max-w-[96%] space-y-2 sm:max-w-[88%]`,children:[e.reasoning||e.status===`streaming`?(0,G.jsx)(WQ,{text:e.reasoning||``,streaming:e.status===`streaming`&&(!e.content||!!e.reasoning),defaultOpen:e.reasoningOpen}):null,e.toolCalls?.length?(0,G.jsx)(YQ,{calls:e.toolCalls}):null,e.status===`error`?(0,G.jsx)(bU,{status:`danger`,title:t(`requestFailed`),description:e.error||``}):i?(0,G.jsxs)(`div`,{className:`space-y-2.5 pt-0.5`,children:[(0,G.jsx)(qP,{className:`h-3 w-28 rounded-md`}),(0,G.jsx)(qP,{className:`h-3 w-full rounded-md`}),(0,G.jsx)(qP,{className:`h-3 w-[86%] rounded-md`}),(0,G.jsx)(qP,{className:`h-3 w-[68%] rounded-md`})]}):e.content?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words rounded-2xl rounded-tl-md bg-surface-secondary/50 px-3.5 py-2.5 text-body leading-[1.65] text-foreground`,children:e.content}):null,a||e.usage&&e.usage.credits!=null?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-0.5`,children:[a?(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-caption text-muted hover:text-foreground`,onClick:()=>void o(),children:[(0,G.jsx)(Ai,{size:12}),t(n?`copied`:`copy`)]}):null,(0,G.jsx)(ZQ,{message:e})]}):null]})}function $Q({messages:e,busy:t,onLoadDemo:n}){let{t:r}=DH(),i=(0,v.useRef)(null);return(0,v.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[e,t]),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-5 sm:px-6 sm:py-6`,"aria-live":`polite`,"aria-busy":t,children:[e.length?(0,G.jsx)(`div`,{className:`space-y-5`,children:e.map(e=>(0,G.jsx)(QQ,{message:e},e.id))}):(0,G.jsx)(pQ,{className:`min-h-64`,title:r(`chatTryEmptyTitle`),hint:r(`chatTryEmptyHint`),action:n?(0,G.jsx)(`button`,{type:`button`,className:`rounded-lg bg-surface-secondary px-3 py-1.5 text-caption font-medium text-foreground hover:bg-surface-tertiary`,onClick:n,children:r(`chatDemoLoad`)}):void 0}),(0,G.jsx)(`div`,{ref:i})]})}function e$({open:e,onOpenChange:t,chatPath:n,prompt:r,onPromptChange:i,onTest:a,requestState:o,elapsedMs:s,output:c,responseStatus:l,curl:u,copiedCurl:d,onCopyCurl:f,canSend:p}){let{t:m}=DH();return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-body font-semibold`,children:m(`accessTabApi`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:m(`nativeApiHint`)})]}),(0,G.jsx)(X,{size:`sm`,variant:e?`secondary`:`ghost`,onPress:()=>t(!e),children:m(e?`rawApiHide`:`rawApiShow`)})]}),e?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:(0,G.jsxs)(`div`,{className:`grid xl:grid-cols-[minmax(440px,.92fr)_minmax(0,1.08fr)]`,children:[(0,G.jsxs)(`div`,{className:`xl:border-r xl:border-separator`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 sm:px-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:m(`requestBuilder`)}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-caption text-muted`,children:[`POST `,n]})]}),(0,G.jsxs)(`div`,{className:`space-y-5 px-5 pb-5 sm:px-6 sm:pb-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:m(`prompt`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:r.length})]}),(0,G.jsx)(mL,{fullWidth:!0,rows:9,className:`min-h-56 resize-y px-4 py-3 text-body leading-6`,value:r,onChange:e=>i(e.target.value),placeholder:m(`promptPlaceholder`),"aria-label":m(`prompt`)}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:m(`promptHelper`)})]}),(0,G.jsxs)(X,{fullWidth:!0,isPending:o===`loading`,isDisabled:!p,onPress:a,children:[(0,G.jsx)(ga,{size:16}),m(o===`loading`?`requesting`:`sendRequest`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex min-h-[480px] min-w-0 flex-col bg-surface-secondary/40`,"aria-live":`polite`,"aria-busy":o===`loading`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-4 px-5 py-3.5 sm:px-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:m(`responseInspector`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:m(`responseInspectorHint`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s===null?null:(0,G.jsxs)(`span`,{className:`mono flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(Ei,{size:12}),s,` ms`]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:o===`success`?`success`:o===`error`?`danger`:void 0,children:l})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-5 pb-5 sm:px-6 sm:pb-6`,children:o===`idle`?(0,G.jsx)(pQ,{className:`min-h-72`,icon:(0,G.jsx)(oi,{size:21}),title:m(`responseEmptyTitle`),hint:m(`responseEmptyHint`)}):o===`loading`?(0,G.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,G.jsx)(qP,{className:`h-3 w-32 rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-full rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-[88%] rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-[72%] rounded-lg`}),(0,G.jsx)(qP,{className:`mt-7 h-3 w-[92%] rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-[64%] rounded-lg`})]}):o===`error`?(0,G.jsx)(`div`,{className:`space-y-3`,children:(0,G.jsx)(bU,{status:`danger`,title:m(`requestFailed`),description:c})}):(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-caption font-medium text-success`,children:[(0,G.jsx)(bi,{size:15,weight:`fill`}),m(`responseReceived`)]}),(0,G.jsx)(`pre`,{className:`mono overflow-x-auto whitespace-pre-wrap break-words text-caption leading-6 text-muted`,children:c})]})})]})]})}),(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-3.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:m(`curlExample`)}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,children:m(`curlGeneratedHint`)})]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:f,children:[(0,G.jsx)(MQ,{copied:d}),m(d?`copied`:`copy`)]})]}),(0,G.jsx)(`pre`,{className:`mono max-h-80 overflow-auto whitespace-pre-wrap px-5 pb-5 text-caption leading-6 text-muted`,children:u})]})]}):null]})}function t$(e,t){let n=t.filter(e=>e.kind===`text`),r=t.filter(e=>e.kind===`image`&&e.dataUrl),i=e.trim();for(let e of n){let t=e.text??``;i=`${i}${i?` +`;function wX({emptyLabel:e}){return(0,G.jsx)(`div`,{className:`grid min-h-56 place-items-center rounded-lg bg-surface-secondary px-4 text-body text-muted`,children:e})}function TX(e){if(!e)return``;let t=Date.parse(e)-Date.now();if(!Number.isFinite(t)||t<=0)return``;let n=Math.ceil(t/1e3);return n<60?`${n}s`:`${Math.ceil(n/60)}m`}function EX(e){return Object.entries(e.model_cooldowns??{}).filter(([,e])=>!!TX(e)).sort(([e],[t])=>e.localeCompare(t))}function DX(e){return e.enabled?e.status===`quota_exhausted`||e.quota?.exceeded?`quota_exhausted`:e.status===`cooling`||TX(e.down_until||e.cooldown_until)?`cooling`:e.status===`dead`||e.runtime_state===`dead`?`dead`:e.status===`auth_failed`||e.runtime_state===`auth_failed`?`auth_failed`:e.status===`login_required`?`login`:(e.status===`starting`||e.runtime_state===`starting`)&&!e.hot&&!e.ready?e.quota?`starting`:`loading`:e.status===`ready`?e.hot?`hot`:`ready`:e.hot?`hot`:e.ready?`ready`:(e.status===`error`||e.status,`unavailable`):`disabled`}function OX(e){return e===`hot`?12:e===`ready`?9:e===`cooling`?5:e===`login`?3:e===`loading`||e===`starting`?6:e===`unavailable`?2:e===`auth_failed`?3:e===`dead`?2:1}function kX(e){return e===`hot`||e===`ready`?`ok`:e===`cooling`||e===`quota_exhausted`||e===`loading`||e===`starting`?`warn`:e===`auth_failed`||e===`unavailable`||e===`dead`||e===`login`?`danger`:`muted`}function AX(e){return e==null||!Number.isFinite(e)?`—`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(Math.round(e*100)/100)}function jX(e){let t=e.percentage??0;return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):0}function MX(e){let t=e.percentage??0;return e.exceeded?`danger`:t>=80?`warn`:`ok`}function NX(e){return(e.windows??[]).filter(e=>!!e.id)}var PX={free:`Free`,go:`Go`,plus:`Plus`,pro:`Pro`,prolite:`Pro Lite`,promax:`Pro Max`,team:`Team`,business:`Business`,enterprise:`Enterprise`,edu:`Edu`,edu_plus:`Edu Plus`,edu_pro:`Edu Pro`,education:`Education`};function FX(e){let t=e?.trim().toLowerCase()??``;return!t||t===`unknown`||t===`guest`?``:PX[t]??t.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function IX(e,t){return e.id===`daily`?t(`quotaDaily`):e.id===`weekly`?t(`quotaWeekly`):e.id===`monthly`?t(`quotaMonthly`):e.id===`fiveHour`?t(`quotaFiveHour`):e.id===`weeklyLimit`?t(`quotaWeeklyLimit`):e.id===`monthlyLimit`?t(`quotaMonthlyLimit`):e.label||t(`quota`)}function LX(e,t){if(!e)return``;let n=Date.parse(e)-Date.now();if(!Number.isFinite(n)||n<=0)return t(`quotaResetsSoon`);let r=Math.max(1,Math.ceil(n/6e4));return r<60?t(`quotaResetsInMinutes`,{n:r}):t(`quotaResetsInHours`,{n:Math.round(r/60)})}function RX(e,t){if(!e.expires_at||e.expires_at<=0||!Number.isFinite(e.expires_at))return``;let n=new Date(e.expires_at*1e3);if(Number.isNaN(n.getTime()))return``;let r=`${n.getFullYear()}/${n.getMonth()+1}/${n.getDate()}`;return t(`quotaExpiresOn`,{amount:e.expiring_remain&&e.expiring_remain>0?`${AX(e.expiring_remain)} `:``,unit:e.unit||`credits`,date:r})}var zX=864e5,BX=8;function VX(e){return`var(--chart-${e%BX+1})`}function HX(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function UX(e){return e<10?`0${e}`:String(e)}function WX(e){let t=new Date(e);return`${t.getFullYear()}-${UX(t.getMonth()+1)}-${UX(t.getDate())}`}function GX({accounts:e,t}){let[n,r]=(0,v.useState)(!1),{buckets:i,rows:a,todayStart:o,maxTotal:s}=(0,v.useMemo)(()=>{let t=HX(new Date),n=new Map;e.forEach((e,t)=>n.set(e.id,VX(t)));let r=new Map,i=[];for(let a of e){let e=a.quota?.packages??[],o=n.get(a.id)||VX(0),s=a.name||a.id,c=e.filter(e=>(e.remain??0)>0&&(e.ends_at??0)>0),l=0,u=0,d=0,f=0;for(let e of c){let n=e.ends_at*1e3,i=e.remain??0;d+=i;let c=HX(new Date(n)),u=c{let e=new Date(c);return{day:p,label:`${e.getMonth()+1}/${e.getDate()}`,ts:c,segments:[],total:0}})(),r.set(p,m));let h=m.segments.find(e=>e.id===a.id);h?h.remain+=i:m.segments.push({id:a.id,name:s,color:o,remain:i}),m.total+=i}if(l){let e=WX(HX(new Date(l)));for(let t of c)WX(HX(new Date(t.ends_at*1e3)))===e&&(u+=t.remain??0)}let p=l?Math.max(0,Math.round((HX(new Date(l))-t)/zX)):-1;i.push({id:a.id,name:s,color:o,remain:d,expiredRemain:f,soonest:l?Math.floor(l/1e3):0,soonestRemain:u,daysLeft:p,dailyBurn:l?u/Math.max(p,1):0,packs:c.length})}i.sort((e,t)=>e.soonest&&t.soonest?e.soonest-t.soonest:e.soonest?-1:t.soonest?1:t.remain-e.remain);let a=[...r.values()].sort((e,t)=>e.ts-t.ts);return{buckets:a,rows:i,todayStart:t,maxTotal:a.reduce((e,t)=>Math.max(e,t.total),0)}},[e]);if(!a.some(e=>e.packs>0))return null;let c=n?i:i.slice(0,8);return(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-4 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`expiryDistTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`expiryDistHint`)})]}),i.length>8?(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:()=>r(e=>!e),children:n?t(`expiryDistCollapse`):t(`expiryDistExpand`,{n:i.length})}):null]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4 sm:space-y-3 sm:p-5`,children:[(0,G.jsx)(`div`,{className:`space-y-2.5 sm:space-y-1.5`,children:c.map(e=>{let n=e.ts===o,r=s>0?e.total/s*100:0;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:grid sm:grid-cols-[52px_minmax(0,1fr)_auto] sm:items-center sm:gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 sm:contents`,children:[(0,G.jsx)(`span`,{className:`mono text-caption ${e.day===`__expired__`?`font-semibold text-danger`:n?`font-semibold text-foreground`:`text-muted`}`,children:e.day===`__expired__`?t(`expiryDistExpired`):e.label}),(0,G.jsx)(`span`,{className:`mono text-caption text-foreground sm:hidden`,children:AX(e.total)})]}),(0,G.jsx)(`div`,{className:`h-2.5 w-full rounded-full bg-surface-tertiary`,role:`img`,"aria-label":`${e.day} ${t(`expiryDistDayTotal`,{n:AX(e.total)})}`,title:e.day,children:(0,G.jsx)(`div`,{className:`flex h-full items-stretch overflow-hidden rounded-full`,style:{width:`${r}%`},children:e.segments.map(t=>(0,G.jsx)(`span`,{style:{width:`${t.remain/e.total*100}%`,backgroundColor:t.color},title:`${t.name} · ${AX(t.remain)}`},t.id))})}),(0,G.jsx)(`span`,{className:`mono hidden text-caption text-foreground sm:inline`,children:AX(e.total)})]},e.day)})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1.5 pt-1`,children:a.filter(e=>e.remain>0).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(`i`,{className:`size-2 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.id))}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:a.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null,a=e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`,o=e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`;return(0,G.jsxs)(`article`,{className:`space-y-3 py-3.5`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`truncate text-body font-medium text-foreground`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColSoonest`)}),(0,G.jsx)(`div`,{className:`mono text-body text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaysLeft`)}),(0,G.jsx)(`div`,{className:`mono text-body ${a}`,children:o})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColBatch`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:AX(e.soonestRemain)})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaily`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:e.soonest?AX(e.dailyBurn):`—`})]})]})]},e.id)})}),(0,G.jsx)(Q,{"aria-label":t(`expiryDistTitle`),className:`hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{className:`min-w-[32rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:t(`expiryDistColAccount`)}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColSoonest`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaysLeft`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColBatch`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaily`)})})]}),(0,G.jsx)(Q.Body,{children:a.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null;return(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[150px] truncate text-foreground`,children:e.name})]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center ${e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`}`,children:e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:AX(e.soonestRemain)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:e.soonest?AX(e.dailyBurn):`—`})})]},e.id)})})]})})}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:t(`expiryDistFoot`)})]})]})}var KX={"--toggle-button-bg-selected":`transparent`,"--toggle-button-bg-selected-hover":`transparent`,"--toggle-button-bg-selected-pressed":`transparent`};function qX({value:e,onChange:t,options:n,ariaLabel:r,className:i}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(!1);return(0,v.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=n=>{let r=e.querySelector(`[data-selected="true"]`);if(!r){eY.set(t,{autoAlpha:0});return}let i=e.getBoundingClientRect(),a=r.getBoundingClientRect();eY.to(t,{x:a.left-i.left,y:a.top-i.top,width:a.width,height:a.height,autoAlpha:1,duration:n?aY(tY.base):0,ease:nY.out,overwrite:!0})};n(s.current),s.current=!0;let r=new ResizeObserver(()=>n(!1));return r.observe(e),()=>{r.disconnect(),eY.killTweensOf(t)}},[e,n]),(0,G.jsxs)(`div`,{ref:a,className:`filter-toggle relative inline-flex ${i??``}`,children:[(0,G.jsx)(`span`,{ref:o,"aria-hidden":!0,className:`filter-toggle__pill pointer-events-none absolute left-0 top-0 opacity-0`}),(0,G.jsx)(wI,{"aria-label":r,size:`sm`,selectionMode:`single`,disallowEmptySelection:!0,selectedKeys:new Set([e]),onSelectionChange:n=>{let r=[...n][0];typeof r==`string`&&r!==e&&t(r)},children:n.map(e=>(0,G.jsxs)(QP,{id:e.id,className:`relative z-[1]`,style:KX,children:[e.icon,e.label]},e.id))})]})}function JX(e,t){let n=e.toFixed(t);return n.includes(`.`)?n.replace(/0+$/,``).replace(/\.$/,``):n}function YX(e){let t=Number(e||0);return Number.isFinite(t)?t>=1e9?`${JX(t/1e9,2)}B`:t>=1e6?`${JX(t/1e6,2)}M`:t>=1e3?`${JX(t/1e3,1)}k`:String(Math.round(t)):`—`}function XX(e){let t=Number(e||0);return Number.isFinite(t)?JX(t,2):`—`}function ZX(e,t,n){if(!t||!n)return`—`;let r=Number(e||0);return Number.isFinite(r)?`${JX(r,4)} / 1M`:`—`}function QX(e){let t=Number(e||0);return t?t>=1e3?`${JX(t/1e3,2)}s`:`${Math.round(t)}ms`:`—`}function $X(e){if(e==null)return`—`;let t=Number(e);return!Number.isFinite(t)||t<0?`—`:`x${JX(t,2)}`}function eZ(e){let t=(e||``).trim().toLowerCase().replace(/\s*credits?$/,``).replace(/^x/,``);if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:null}function tZ(e,t){if(!e.length||!t)return null;let n=t.indexOf(`/`),r=n>=0?t.slice(0,n).toLowerCase():``,i=n>=0?t.slice(n+1):t,a=e.filter(e=>e.id===t||e.id===i||e.native_model===i);if(!a.length)return null;let o=a.map(e=>({rate:eZ(e.credits),cn:/credits?\s*$/i.test((e.credits||``).trim())})),s=o,c=r.includes(`cn`)?!0:!/(^|[-_])(gl|global|intl)([-_]|$)/.test(r)&&null;if(c!==null){let e=o.filter(e=>e.cn===c);e.length&&(s=e)}let l=s.map(e=>e.rate).filter(e=>e!==null);if(!l.length)return null;let u=l.filter(e=>e>0);return u.length?Math.max(...u):l[0]}function nZ(e,t){let n=Number(e||0),r=n+Number(t||0);return r?n/r*100:null}function rZ({hit:e,miss:t}){let n=nZ(e,t);return n==null?(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:`—`}):(0,G.jsxs)(`div`,{className:`mono text-right ${n>=90?`text-success`:n>=80?`text-warning`:`text-danger`}`,title:`${YX(e)} / ${YX(e+t)}`,children:[JX(n,1),`%`]})}function iZ(e){let t=Number(e||0);return Number.isFinite(t)?t:0}function aZ(e,t){let n=e.slice(),r=e=>iZ(String(t===`requests`?e.requests:t===`errors`?e.errors:t===`latency`?e.avg_latency_ms??0:e.total_tokens));return n.sort((e,t)=>r(t)-r(e)),n}function oZ(e,t){return e.find(e=>e.id===t)?.name||t.slice(0,8)}function sZ({usage:e,accounts:t,loading:n,t:r}){let[i,a]=(0,v.useState)(`account`),[o,s]=(0,v.useState)(`total`),c=(0,v.useMemo)(()=>e?aZ((i===`model`?e.by_model:i===`realm`?e.by_realm:e.by_account)||[],o):[],[e,i,o]),l=i===`account`,u=l?8:7;return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,"data-skeleton-swap":`stats`,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:r(`usageDetailTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:r(`usageDetailHint`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(qX,{value:i,onChange:e=>a(e),ariaLabel:r(`usageDetailTitle`),options:[{id:`account`,label:r(`usageDimAccount`)},{id:`model`,label:r(`usageDimModel`)},{id:`realm`,label:r(`usageDimRealm`)}]}),(0,G.jsx)(qX,{value:o,onChange:e=>s(e),ariaLabel:r(`usageDetailHint`),options:[{id:`total`,label:r(`usageSortTotal`)},{id:`requests`,label:r(`usageSortRequests`)},{id:`errors`,label:r(`usageSortErrors`)},{id:`latency`,label:r(`usageSortLatency`)}]})]})]}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:n?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)($,{className:`h-4 w-32`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)($,{className:`h-3 w-12`}),(0,G.jsx)($,{className:`h-4 w-16`})]},t))})]},`skeleton-${t}`)):c.length===0?(0,G.jsx)(`div`,{className:`px-5 py-8 text-body text-muted`,children:r(`usageEmpty`)}):c.map(e=>{let n=i===`account`?oZ(t,e.key):e.key||`—`,a=i===`account`?e.realm:``,o=[{label:r(`usageColRequests`),value:YX(e.requests)},{label:r(`usageColErrors`),value:e.errors?YX(e.errors):`—`,tone:e.errors?`text-warning`:`text-muted`},{label:r(`usageColPrompt`),value:YX(e.prompt_tokens),tone:`text-muted`},{label:r(`usageColCacheHit`),value:nZ(e.cache_hit_tokens,e.cache_miss_tokens)==null?`—`:`${JX(nZ(e.cache_hit_tokens,e.cache_miss_tokens),1)}%`},{label:r(`usageColCompletion`),value:YX(e.completion_tokens),tone:`text-muted`},{label:r(`usageColTotal`),value:YX(e.total_tokens)}];return l&&o.push({label:r(`usageColAvgLatency`),value:QX(e.avg_latency_ms),tone:`text-muted`}),(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:n}),a?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:a}):null]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:o.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value})]},e.label))})]},e.key)})}),(0,G.jsx)(Q,{"aria-label":r(`usageDetailTitle`),className:`hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{className:`min-w-[44rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:r(i===`model`?`usageColModel`:i===`realm`?`usageColRealm`:`usageColAccount`)}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColRequests`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColErrors`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColPrompt`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColCacheHit`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColCompletion`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColTotal`)})}),l?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:r(`usageColAvgLatency`)})})}):null]}),(0,G.jsx)(Q.Body,{children:n?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`h-4 w-32`})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`ml-auto h-4 w-12`})},t))]},`skeleton-${t}`)):c.length===0?(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-body text-muted`,children:r(`usageEmpty`)})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:null},t))]}):c.map(e=>{let n=i===`account`?oZ(t,e.key):e.key||`—`,r=i===`account`?e.realm:``;return(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-foreground`,children:n}),r?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:r}):null]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:YX(e.requests)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right ${e.errors?`text-warning`:`text-muted`}`,children:e.errors?YX(e.errors):`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:YX(e.prompt_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(rZ,{hit:e.cache_hit_tokens,miss:e.cache_miss_tokens})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:YX(e.completion_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:YX(e.total_tokens)})}),l?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:QX(e.avg_latency_ms)})})}):null]},e.key)})})]})})}),(0,G.jsx)(`p`,{className:`px-5 py-3 text-caption text-muted`,children:r(`usageDimNote`,{n:c.length})})]})}function cZ({label:e,value:t,sub:n,tone:r}){return(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-tertiary px-3 py-2.5`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`div`,{className:`mono mt-1 text-body font-semibold ${r??`text-foreground`}`,children:t}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,title:n,children:n})]})}function lZ({usage:e,accounts:t,models:n,loading:r,t:i}){let[a,o]=(0,v.useState)(`account`),s=e?.totals,c=(0,v.useMemo)(()=>e&&(a===`model`?e.credit_by_model:e.credit_by_account)||[],[e,a]),l=a===`model`,u=l?7:6;return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,"data-skeleton-swap":`stats`,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:i(`usageCreditTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:i(`usageCreditHint`)})]}),(0,G.jsx)(qX,{value:a,onChange:e=>o(e),ariaLabel:i(`usageCreditTitle`),options:[{id:`account`,label:i(`usageDimAccount`)},{id:`model`,label:i(`usageDimModel`)}]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-separator px-5 py-4 sm:grid-cols-3 sm:gap-2.5 xl:grid-cols-5`,children:r||!s?Array.from({length:5}).map((e,t)=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-tertiary px-3 py-2.5`,children:[(0,G.jsx)($,{className:`h-3 w-16`}),(0,G.jsx)($,{className:`mt-2 h-5 w-20`})]},t)):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(cZ,{label:i(`usageCreditKpiCredits`),value:XX(s.credits),sub:i(`usageCreditKpiCreditsSub`)}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiTokens`),value:YX(s.credit_tokens),sub:i(`usageCreditKpiTokensSub`)}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiAvg`),value:ZX(s.credits_per_1m_tokens,s.credit_samples,s.credit_tokens),sub:i(`usageCreditKpiAvgSub`),tone:`text-success`}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiSamples`),value:String(s.credit_samples||0),sub:i(`usageCreditKpiSamplesSub`)}),(0,G.jsx)(cZ,{label:i(`usageCreditKpiCache`),value:nZ(s.cache_hit_tokens,s.cache_miss_tokens)==null?`—`:`${JX(nZ(s.cache_hit_tokens,s.cache_miss_tokens),1)}%`,sub:i(`usageCreditKpiCacheSub`)})]})}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:r?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)($,{className:`h-4 w-32`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4}).map((e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)($,{className:`h-3 w-12`}),(0,G.jsx)($,{className:`h-4 w-16`})]},t))})]},`skeleton-${t}`)):c.length===0?(0,G.jsx)(`div`,{className:`px-5 py-8 text-body text-muted`,children:i(`usageCreditEmpty`)}):c.map(e=>{let r=l?e.key||`—`:oZ(t,e.key),a=!l&&e.realm?e.realm:``,o=[];return l&&o.push({label:i(`usageCreditColRate`),value:$X(e.rate??tZ(n,e.key)),tone:`text-muted`}),o.push({label:i(`usageColRequests`),value:YX(e.requests)},{label:i(`usageCreditColCredits`),value:XX(e.credits)},{label:i(`usageCreditColSampleTokens`),value:YX(e.credit_tokens),tone:`text-muted`},{label:i(`usageCreditColPer1M`),value:ZX(e.credits_per_1m_tokens,e.credit_samples,e.credit_tokens),tone:`text-muted`},{label:i(`usageColCacheHit`),value:nZ(e.cache_hit_tokens,e.cache_miss_tokens)==null?`—`:`${JX(nZ(e.cache_hit_tokens,e.cache_miss_tokens),1)}%`}),(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:r}),a?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:a}):null]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:o.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value})]},e.label))})]},e.key)})}),(0,G.jsx)(Q,{"aria-label":i(`usageCreditTitle`),className:`hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{className:`min-w-[40rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:i(l?`usageColModel`:`usageColAccount`)}),l?(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColRate`)})}):null,(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageColRequests`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColCredits`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColSampleTokens`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageCreditColPer1M`)})}),(0,G.jsx)(Q.Column,{children:(0,G.jsx)(`div`,{className:`text-right`,children:i(`usageColCacheHit`)})})]}),(0,G.jsx)(Q.Body,{children:r?Array.from({length:4}).map((e,t)=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`h-4 w-32`})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:(0,G.jsx)($,{className:`ml-auto h-4 w-12`})},t))]},`skeleton-${t}`)):c.length===0?(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-body text-muted`,children:i(`usageCreditEmpty`)})}),Array.from({length:u-1}).map((e,t)=>(0,G.jsx)(Q.Cell,{children:null},t))]}):c.map(e=>{let r=l?e.key||`—`:oZ(t,e.key),i=!l&&e.realm?e.realm:``;return(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-foreground`,children:r}),i?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:i}):null]}),l?(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:$X(e.rate??tZ(n,e.key))})}):null,(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:YX(e.requests)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-foreground`,children:XX(e.credits)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:YX(e.credit_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-right text-muted`,children:ZX(e.credits_per_1m_tokens,e.credit_samples,e.credit_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(rZ,{hit:e.cache_hit_tokens,miss:e.cache_miss_tokens})})]},e.key)})})]})})}),(0,G.jsx)(`p`,{className:`px-5 py-3 text-caption text-muted`,children:i(`usageCreditNote`,{accounts:e?.credit_by_account?.length??0,models:e?.credit_by_model?.length??0})})]})}function uZ(e,t=!1){if(!e)return;let n=e.toDate(SD());if(Number.isFinite(n.getTime()))return t&&n.setSeconds(59,999),n.toISOString()}function dZ(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return JD(jO(new Date(t).toISOString()))}catch{return null}}function fZ({value:e,onChange:t,ariaLabel:n,fromLabel:r,toLabel:i,className:a}){return(0,G.jsx)(hP,{className:a,granularity:`minute`,hourCycle:24,shouldForceLeadingZeros:!0,value:e,onChange:e=>t(e),"aria-label":n,children:({state:e})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(AM.Group,{className:`w-full min-w-0`,variant:`secondary`,children:[(0,G.jsx)(AM.Input,{className:`min-w-0`,slot:`start`,"aria-label":r,children:e=>(0,G.jsx)(AM.Segment,{segment:e})}),(0,G.jsx)(hP.RangeSeparator,{}),(0,G.jsx)(AM.Input,{className:`min-w-0`,slot:`end`,"aria-label":i,children:e=>(0,G.jsx)(AM.Segment,{segment:e})}),(0,G.jsx)(AM.Suffix,{children:(0,G.jsx)(hP.Trigger,{children:(0,G.jsx)(hP.TriggerIndicator,{})})})]}),(0,G.jsxs)(hP.Popover,{className:`flex w-[20.5rem] max-w-[calc(100vw-2rem)] flex-col gap-3 p-3`,children:[(0,G.jsxs)(xH,{"aria-label":n,children:[(0,G.jsxs)(xH.Header,{children:[(0,G.jsxs)(xH.YearPickerTrigger,{children:[(0,G.jsx)(xH.YearPickerTriggerHeading,{}),(0,G.jsx)(xH.YearPickerTriggerIndicator,{})]}),(0,G.jsx)(xH.NavButton,{slot:`previous`}),(0,G.jsx)(xH.NavButton,{slot:`next`})]}),(0,G.jsxs)(xH.Grid,{children:[(0,G.jsx)(xH.GridHeader,{children:e=>(0,G.jsx)(xH.HeaderCell,{children:e})}),(0,G.jsx)(xH.GridBody,{children:e=>(0,G.jsx)(xH.Cell,{date:e})})]}),(0,G.jsx)(xH.YearPickerGrid,{children:(0,G.jsx)(xH.YearPickerGridBody,{children:({year:e})=>(0,G.jsx)(xH.YearPickerCell,{year:e})})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(sR,{className:`text-xs`,children:r}),(0,G.jsx)(LP,{"aria-label":r,granularity:`minute`,hourCycle:24,value:e.timeRange?.start??null,onChange:t=>e.setTimeRange({start:t,end:e.timeRange?.end}),children:(0,G.jsx)(LP.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LP.Input,{children:e=>(0,G.jsx)(LP.Segment,{segment:e})})})})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(sR,{className:`text-xs`,children:i}),(0,G.jsx)(LP,{"aria-label":i,granularity:`minute`,hourCycle:24,value:e.timeRange?.end??null,onChange:t=>e.setTimeRange({start:e.timeRange?.start,end:t}),children:(0,G.jsx)(LP.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LP.Input,{children:e=>(0,G.jsx)(LP.Segment,{segment:e})})})})]})]})]})]})})}var pZ={today:`statsWindowToday`,1:`statsWindow1h`,24:`statsWindow24h`,168:`statsWindow7d`,720:`statsWindow30d`,custom:`statsWindowCustom`};function mZ(e,t){if(e===`today`){let e=new Date;return e.setHours(0,0,0,0),{from:e.toISOString()}}if(e===`custom`){let e=uZ(t?.start),n=uZ(t?.end,!0);return e&&n?{from:e,to:n}:null}if(e===`720`){let e=new Date;return{from:new Date(e.getTime()-2592e6).toISOString(),to:e.toISOString()}}return{hours:Number(e)}}function hZ({value:e,onChange:t,custom:n,onCustomChange:r,onBusy:i,t:a}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qX,{value:e,onChange:r=>{let a=r;e!==a&&((a!==`custom`||n)&&i?.(),t(a))},ariaLabel:a(`statsTraffic`),options:Object.keys(pZ).map(e=>({id:e,label:a(pZ[e])}))}),e===`custom`?(0,G.jsx)(fZ,{className:`w-[min(100%,24rem)]`,value:n,onChange:e=>{e&&i?.(),r(e)},ariaLabel:a(`statsWindowCustom`),fromLabel:a(`logsTimeFrom`),toLabel:a(`logsTimeTo`)}):null]})}function gZ(e,t,n){let r=new URLSearchParams;for(let[t,n]of Object.entries(e))n&&r.set(t,n);let i=Date.parse(t),a=Date.parse(n);return Number.isFinite(i)&&Number.isFinite(a)&&(r.set(`from`,new Date(Math.floor(i/6e4)*6e4).toISOString()),r.set(`to`,new Date(Math.ceil(a/6e4)*6e4-6e4).toISOString())),`/logs?${r}`}function _Z(e){let t=String(e||``).toLowerCase();return!t||t===`qoder`||t===`qoder-global`||t===`qoder-cn`}function vZ(e){return String(e||``).toLowerCase()===`workbuddy`}function yZ(e){return String(e||``).toLowerCase()===`trae`}function bZ(e){return String(e||``).toLowerCase()===`devin`}function xZ(e){return String(e||``).toLowerCase()===`command`}function SZ(e){return String(e||``).toLowerCase()===`zhipu`}function CZ(e){return String(e||``).toLowerCase()===`qwenwork`}function wZ(e){return String(e||``).toLowerCase()===`kimi`}function TZ(e,t){let n=String(e||``).toLowerCase();return vZ(n)?`WorkBuddy`:yZ(n)?`Trae`:bZ(n)?`Devin`:xZ(n)?`Command Code`:SZ(n)?`Zhipu GLM`:CZ(n)?`QwenWork`:wZ(n)?`Kimi Code`:_Z(n)?`Qoder`:e||t(`account`)}function EZ(e,t,n){let r=String(e||``).toLowerCase(),i=String(t||``).toLowerCase();return vZ(r)?n(i===`global`?`accountTypeWorkBuddyGlobal`:`accountTypeWorkBuddyCN`):yZ(r)?n(`accountTypeTraeCN`):bZ(r)?n(`accountTypeDevinGlobal`):xZ(r)?n(`accountTypeCommandGlobal`):SZ(r)?n(`accountTypeZhipuCN`):CZ(r)?n(i===`cn`?`accountTypeQwenworkCN`:`accountTypeQwenworkGlobal`):wZ(r)?n(`accountTypeKimiCN`):_Z(r)?n(i===`cn`?`accountTypeQoderCN`:`accountTypeQoderGlobal`):e||n(`account`)}function DZ(e,t){let n=t??!!e.max_mode,r=e.catalog_context_length||e.default_context_length||e.context_length||0,i=e.catalog_context_length_max||0;return n&&i>0?{context_length:i,prompt_max_tokens:e.prompt_max_tokens_max||e.prompt_max_tokens,max_output_tokens:e.max_output_tokens_max||e.max_output_tokens}:{context_length:r,prompt_max_tokens:e.prompt_max_tokens,max_output_tokens:e.max_output_tokens}}function OZ({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#0a84ff] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`C`})}function kZ({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.086.457a6.1 6.1 0 0 1 3.046-.415q2 .23 3.564 1.7a.12.12 0 0 0 .107.029q2.112-.519 4.061.366l.063.03l.154.076q2.036 1.055 2.918 3.198a5.6 5.6 0 0 1 .421 2.126 5.7 5.7 0 0 1-.18 1.631.17.17 0 0 0 .04.155 6 6 0 0 1 1.578 2.891q.577 2.852-1.183 5.14l-.182.22a6.06 6.06 0 0 1-2.934 1.851.16.16 0 0 0-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451q-2.374-.012-4.21-1.736a.14.14 0 0 0-.14-.032 5.9 5.9 0 0 1-1.604-.185 5.9 5.9 0 0 1-2.595-.622 6.06 6.06 0 0 1-2.146-1.781c-.203-.269-.404-.522-.551-.821a8 8 0 0 1-.495-1.283 6.1 6.1 0 0 1-.017-3.064.2.2 0 0 0 .008-.074.1.1 0 0 0-.037-.064 6 6 0 0 1-1.38-2.202 5.2 5.2 0 0 1-.333-1.589 6.9 6.9 0 0 1 .188-2.132q.675-2.226 2.577-3.493.424-.282.802-.438.429-.179.861-.304a.13.13 0 0 0 .087-.087A6 6 0 0 1 5.635 2.31Q6.655 1.04 8.086.457m-.804 7.85a.848.848 0 0 0-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 0 0 1.46.864l1.94-3.272a.85.85 0 0 0 .007-.854zm5.446 6.24a.849.849 0 0 0 0 1.695h4.848a.849.849 0 0 0 0-1.696z`})})}function AZ({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`D`})}function jZ({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,d:`M21 12.79A9 9 0 1 1 11.21 3a7 7 0 0 0 9.79 9.79Z`})})}var MZ=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAJ5ElEQVR42u2dXUxUZxrH/wKDDDCM4CJBZJZNxMpGDMGYXsAWeikapF6Jqc02kUhWTWsTIQHjNk22yWCyN5INrk22rbsc71ZNpXfb0sJ+Gcxmma2mNpt1XMsaLd2ZoY7D5164btfiBx8zzDnv+f1uiWeG9/x8eN7neT9WFRaunROAIWQwBIDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAA35LFEDyZ6uotKi8PqL6+ToFAuQoK/PL7/fL7CyRJ4fBNRaMRhcM3FQ6HFQqFNDoaUiQSYfDSxCqO031U4Lq6OjU1Nam6eov8fv+inxGJRDQ6GtLAwIAs6xxyI/TK0tTUpJ07d6iurk6BQCCpz45EIurrO62+vtOIjdCpIxAIqLPzWEokRmyEXjHq6+vU0dGh+vq6tHw+YiN00iJyb++ptImM2Aid1NSitbXVlt8vEomoq+u4LMvCRIR+Oq2trersPLYiOfJyCYfD6u4+rkuXBjASoZ0VlZ/G0NCwenp6NDQ0jJkI/aCOfPbs+46IyogtWt9Po739oAYHP3a8zNKDaszFixd08eIF20xkidArSGdnhzo7O4x9SZZlKRg8qXA4jLGmC/322z9Te/tBV7ysvr7TCgZ7KPWZKnRv7ynt29fqqhdGDdtQod0oM2IbKrSb0gzEXhyZXm/um06bAL7++muY/F9ycnJUX1+nPXteUiQSVSgUIkI75cvu29eq3t5TWKyndx0PHz7i2hq2Y4QOBAIaHPxoSYvu3YhbmzOOENrv92tw8CMjmiaILTqFnZ0dyKzldx2rq7cQoe3yQkB0HZ0uNKlG6ggGe4ws9dlaaOrNSyM2e0+3pu4oOntPX07dnffzzasDKvMUazY2ZVwN27ZCV1dv0eDgx9i5AK4lbuhy/Joux6/q1vRdXUvcWNC/K8sq1nbvZpXeX6N/9X+m3/zyrOPFtq3QLJ18egT+c/yqfjcx8j+Jk8GmyfWaOPOFRt4bRGgmgqnnfPRTnY99osvxayn9nJmxuKI/v6r7g7cRmuicXG5N3dEvxn+b1Ei8UCZHxvXvt/6qmbE4QhOdkyPy+dinaf0ec7Fpxd65rm+sf4jDGpdAR0eH3L4Ww7LO6Z2KQWVvK0p/xPNlqeBolTLyPYqduS46hVpc3dnNqYZlWWpublEw2GO775bftlFrTmwlQmuRG13dGpWDwZO2P3DGu6tMM2NxW0dqhE4zo6Mh7d//imNa0fltGyXJtlJn2Gky6LalocFgjxoaGh23riK/baMt8ntbC93U1OQqmbu6um2ZKy+UNSe2KsPnQWg98Sy6vXLLHsD9+19RX99pR/8emaVe5R/YiNB6wm4UN6QbkUhEzc27jTmUMa+1QpmlXoSen27scI3Mo6NmbWL1tVUitB6zss50TJRZelDKs1OUtoXQdXVmN1MOHz5ipMwPyWksQWj9X3fQ5B0pwWCP+vvNPqE/b28FQn87ISw39kX391uOLs1pERUPz6YChJak8vKAse3s7u7jcgvZtUUIbWqEflhrdtNZczkNJQj9MIc2MW82eRL4OEg5DBV6aGjY8V1ALXHddOZ6L0L7/QUyrUTnVrJKcxHatFTDzfeg2KHBgtBJPng8aS/GhivZENpl0TmZVY1VviwGFaGVtpqzGyeCRGiZe91a0l9MvoeBRej05M6WdS65L8XnIeVA6PRF52R3BO22aB6hSTdkQtcNoeW++0tSsV4ja5OPwUVopeGko3MyeV0EQrtsMjgwkJrNrp5KhEboFWZ4ODXpRva2IiocCJ2e/DkVrK5dy+Ai9MozMPBhSp5r1yO2EFpmt7pTsaouw+exzVYmhHYRoVDI+N3TCE3+LFP25SG061KOmynJnWmoILQxKYfdzohDaLmrqaIkL0ZiMojQxghNdDZI6Egk6riSXbKjs3dXGSaaI3TE1S9gzU+3YiFCm0H2tiJyZ9OETkUJzEkX74BhQkej7ozQvrZKtlqZKLTbDjWUHizgf3iBJRiYQ7tJ6gyfR/4T1Zhnch06FBp1zYDnt21ki5XpQg8N/d4Vg+3dVcaKOjcIPTw8LDfkzf6jP8Q4NwgdDodTtuFUNjnzrfBkLXsF3bSW49KlD42VeW3f85To3Ca0ZVnGHRaOzC5fbRcMnkRmMEdoU6I0MiO0MVEamRF6XpS2LGfejZ3XWqHiX9cjM0LPj9JOSz0K3qhSwdEqSnMIrcfWpZubWxyxVjqz1Kt1FxrpACL0QqTebWupfW2VWnehkRQDobXgpaXd3cdtJ3Xurg1ad6GRJaAIvXj6+y01N++2TU6dWeqV/0Q1URmhlxepm5tbUnYEFyB02nLqrq5u1+8UB4MOmunrO62amtqkX0UMCK10btsKBnvSInZBZh7WIHRqxW5oeHHFuou+jFysQejU59eHDh1RTU3tikwcN6/+PuYg9MpNHJubd6dU7LKs72EOQmtFT9hPpdjPrQ5gDkKbI/Z2bxXmIHT6xT506EhSOo5V5NAILZusta6pqV12c8aXkavt3s3Yg9AypjnT4nsBexBaxjRniNAI7QixF0qZp1gtvh9hEELbX+yFdh1/UvQSA4fQckTXsaGh8ZmlPqI0QjuGB2uwn13DJkojtExqzpR5ipEaoZ0t9nebM4eK9rC+Q9LMWByhnSh2TU3tvK7jr8q6XC+1HYTO9Hpz30RTLekCe8s6p0QioerqLSrOLdJ2b5U+nPijJuembP3d52LTWrU6I+nPjAT/prnJWYR2KolEQsPDw3r33feUSCT0Yk29NuSV6HL8qm2ljn9wS18f/4vuf3JbWaW5ylyfnN3r37z/dyX+cCftv9+qwsK1c6iZHPx+v9rbD6rx1R16baJXsdl7tkoHIm+NKjHylb57m63vQKWytxUt69l3Xx7WbGwKoU0V++U3XtVnLfd1LXEj7SJPnPlC9z745zPPG8ndtUF5eysWdT7fzFhcXx+7oqnPo7YYe4ROIYUb1ir/QKWmmwpX/LMnR8YVv3TrmSI/7h7FvL0VCxJ7Ziyur9r/ZIvJIEKvID94/jlFf7xmWX/WFxotJ0fGFTtzfdmSZfg88u4sU05DiTybCh6Re6n/WRDaMLK3FSmnoUS5Ozck7djdyZFx3R+8rckr4yn9s/9w8jjzZdzWY4zQSs/1yFmbfMppKFHOCyULrjTMxaY19XlUU9ejmhwZ1+SVcVtMxBAa5gmeWepVZqlXGT7PIz+bjU1pbmJa02P3bB8dERqA1jcAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQgNABCAyA0AEIDIDQgNABCAyA0AEIDLIj/ABWOKFxbGBRBAAAAAElFTkSuQmCC`;function NZ({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:MZ,alt:``,width:e,height:e,className:`block shrink-0 rounded-[22%] ${t}`.trim(),draggable:!1})}function PZ({size:e=16,className:t=``}){let n=Math.max(2,Math.round(e*.14));return(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-baseline justify-center rounded-[22%] bg-[#18181B] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.5)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:[(0,G.jsx)(`span`,{style:{alignSelf:`center`},children:`Q`}),(0,G.jsx)(`span`,{style:{alignSelf:`center`,width:n,height:n,marginLeft:Math.max(0,Math.round(e*.03)),borderRadius:`50%`,background:`#22D3EE`}})]})}function FZ({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`T`})}var IZ=`/assets/workbuddy-mark-D1Gu2IKl.svg`;function LZ({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:IZ,alt:``,width:e,height:e,className:`block shrink-0 ${t}`.trim(),draggable:!1})}function RZ({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M11.991 23.503a.24.24 0 0 0-.244.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.22-.247zM9.671 5.365a1.697 1.697 0 0 1 1.099 2.132l-.071.172l-.016.04l-.018.054c-.07.16-.104.32-.104.498c-.035.71.47 1.279 1.186 1.314h.366c1.309.053 2.338 1.173 2.286 2.523c-.052 1.332-1.152 2.38-2.478 2.327h-.174c-.715.018-1.274.64-1.239 1.368c0 .124.018.23.053.337c.209.373.54.658.96.8c.75.23 1.517-.125 1.9-.782l.018-.035c.402-.64 1.17-.96 1.92-.711c.854.284 1.378 1.226 1.099 2.167a1.66 1.66 0 0 1-2.077 1.102a1.7 1.7 0 0 1-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646 1.646 0 0 0-1.954.746a1.66 1.66 0 0 1-1.065.764a1.677 1.677 0 0 1-1.989-1.279c-.209-.906.332-1.83 1.257-2.043a1.5 1.5 0 0 1 .296-.035h.018c.68-.071 1.151-.622 1.116-1.333a1.3 1.3 0 0 0-.227-.693a2.5 2.5 0 0 1-.366-1.403a2.4 2.4 0 0 1 .366-1.208c.14-.195.21-.444.227-.693c.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.4 1.4 0 0 1-.299-.07l-.05-.019a1.7 1.7 0 0 1-1.047-2.114a1.68 1.68 0 0 1 2.094-1.101m-5.575 10.11c.26-.264.639-.367.994-.27s.633.379.728.74c.095.362-.007.748-.267 1.013c-.402.41-1.053.41-1.455 0a1.06 1.06 0 0 1 0-1.482zm14.845-.294c.359-.09.738.024.992.297c.254.274.344.665.237 1.025s-.396.634-.756.718c-.551.128-1.1-.22-1.23-.781a1.05 1.05 0 0 1 .757-1.26zm-.064-4.39c.314.32.49.753.49 1.206s-.176.886-.49 1.206c-.315.32-.74.5-1.185.5c-.444 0-.87-.18-1.184-.5a1.727 1.727 0 0 1 0-2.412a1.654 1.654 0 0 1 2.369 0m-11.243.163c.364.484.447 1.128.218 1.691a1.665 1.665 0 0 1-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68 1.68 0 0 1 1.33-1.038a1.66 1.66 0 0 1 1.547.652m11.545-4.221c.368 0 .708.2.892.524s.184.724 0 1.048a1.03 1.03 0 0 1-.892.524a1.04 1.04 0 0 1-1.03-1.048a1.04 1.04 0 0 1 1.03-1.048m-14.358 0c.368 0 .707.2.891.524s.184.724 0 1.048a1.03 1.03 0 0 1-.891.524a1.04 1.04 0 0 1-1.03-1.048c0-.579.461-1.048 1.03-1.048m10.031-1.475c.925 0 1.675.764 1.675 1.706s-.75 1.705-1.675 1.705s-1.674-.763-1.674-1.705s.75-1.706 1.674-1.706m-2.626-.684c.362-.082.653-.356.761-.718a1.06 1.06 0 0 0-.238-1.028a1.02 1.02 0 0 0-.996-.294c-.547.14-.881.7-.752 1.257c.13.558.675.907 1.225.783m0 16.876c.359-.087.644-.36.75-.72a1.06 1.06 0 0 0-.237-1.019a1.02 1.02 0 0 0-.985-.301a1.04 1.04 0 0 0-.762.717c-.108.361-.017.754.239 1.028c.245.263.606.377.953.305zM17.19 3.5a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64a.63.63 0 0 0-.628.64c0 .355.28.64.628.64m-10.38 0a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64a.63.63 0 0 0-.628.64c0 .355.279.64.628.64m-5.182 7.852a.63.63 0 0 0-.628.64c0 .354.28.639.628.639a.63.63 0 0 0 .627-.606l.001-.034a.62.62 0 0 0-.628-.64zm5.182 9.13a.63.63 0 0 0-.628.64c0 .355.279.64.628.64a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64m10.38.018a.63.63 0 0 0-.628.64c0 .355.28.64.628.64a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64m5.182-9.148a.63.63 0 0 0-.628.64c0 .354.279.639.628.639a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24 0 0 0 .244-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249c0 .142.122.249.244.249M11.991.497a.24.24 0 0 0 .245-.248A.24.24 0 0 0 11.99 0a.24.24 0 0 0-.244.249c0 .133.108.236.223.247zM2.011 6.36a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249a.24.24 0 0 0 .244.249zm0 11.263a.24.24 0 0 0-.243.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .244-.249a.25.25 0 0 0-.244-.248zm19.995-.018a.24.24 0 0 0-.245.248a.24.24 0 0 0 .245.25a.24.24 0 0 0 .244-.25a.25.25 0 0 0-.244-.248z`})})}function zZ({provider:e,size:t=16,className:n=``}){let r=String(e||``).toLowerCase();return r===`workbuddy`?(0,G.jsx)(LZ,{size:t,className:n}):r===`trae`?(0,G.jsx)(FZ,{size:t,className:n}):r===`devin`?(0,G.jsx)(AZ,{size:t,className:n}):r===`command`?(0,G.jsx)(OZ,{size:t,className:n}):r===`codex`?(0,G.jsx)(kZ,{size:t,className:n}):r===`zhipu`?(0,G.jsx)(RZ,{size:t,className:n}):r===`qwenwork`?(0,G.jsx)(PZ,{size:t,className:n}):r===`kimi`?(0,G.jsx)(jZ,{size:t,className:n}):(0,G.jsx)(NZ,{size:t,className:n})}var BZ=(0,v.lazy)(()=>C(()=>import(`./LiveSparkline-37ksHAMS.js`).then(e=>({default:e.LiveSparkline})),__vite__mapDeps([0,1,2])));function VZ({live:e,samples:t,t:n}){let r=e?.in_flight??null,i=e?.capacity??0,a=r!=null&&i>0?r/i:0,o=i>0&&r!=null&&r>=i;return(0,G.jsxs)(`div`,{"data-testid":`live-strip`,className:`flex min-h-11 flex-wrap items-center gap-x-5 gap-y-2 overflow-hidden rounded-lg bg-surface-secondary px-4 py-2.5 text-caption text-muted sm:h-11 sm:gap-x-6 sm:gap-y-1 sm:py-0`,children:[(0,G.jsx)(`span`,{className:`inline-flex items-center`,children:(0,G.jsx)(`span`,{className:`status-dot`,"data-state":r==null?``:o?`warn`:r>0?`ok`:``})}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveConcurrency`),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono tabular text-body font-semibold ${o?`text-warning`:`text-foreground`}`,children:[r??`—`,(0,G.jsxs)(`span`,{className:`font-normal text-muted`,children:[`/`,e?i:`—`]})]}),(0,G.jsx)(`span`,{className:`inline-block h-[3px] w-12 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${o?`bg-warning`:`bg-foreground/60`}`,style:{width:`${Math.min(100,a*100)}%`}})})]})]}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveRpm`),(0,G.jsx)(`span`,{className:`mono tabular text-body font-semibold text-foreground`,children:e?.rpm??`—`})]}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveTrace`),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`span`,{className:`inline-block h-6 w-[120px]`}),children:(0,G.jsx)(BZ,{samples:t,capacity:i,label:n(`liveTrace`)})})]})]})}var HZ=2500;Math.round(6e4/HZ);function UZ(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=!1,n=null,i=()=>{document.hidden||OY().then(n=>{e||(t(n),r(e=>[...e,{at:Date.now(),value:n.in_flight}].slice(-24)))}).catch(()=>{})},a=()=>{n||document.hidden||(i(),n=setInterval(i,HZ))},o=()=>{n&&clearInterval(n),n=null},s=()=>document.hidden?o():a();return a(),document.addEventListener(`visibilitychange`,s),()=>{e=!0,o(),document.removeEventListener(`visibilitychange`,s)}},[]),{live:e,samples:n}}var WZ=(0,v.lazy)(()=>C(()=>import(`./TrafficChart-r71KB7Cg.js`).then(e=>({default:e.TrafficChart})),__vite__mapDeps([3,1,4]))),GZ=3e4,KZ={window:{from:``,to:``,hours:24},totals:{requests:0,ok:0,incomplete:0,error:0,canceled:0,streaming:0,success_rate:0},latency:{},tokens:{prompt:0,completion:0,cache_read:0,total:0},status:[],errors:[],models:[],accounts:[],providers:[],series:[]};function qZ(e,t){return!e||e===`(unknown)`?t(`statsUnknown`):TZ(e,t)}function JZ(e,t,n){return!t||t===`(unassigned)`?n:e.find(e=>e.id===t)?.name||t}var YZ=new Set([`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`]);function XZ(e,t){let n={quota:`logsKindQuota`,rate_limit:`logsKindRateLimit`,auth:`logsKindAuth`,not_ready:`logsKindNotReady`,unavailable:`logsKindUnavailable`,invalid_request:`logsKindInvalidRequest`,model_not_available:`logsKindModelNotAvailable`};return n[e]?t(n[e]):e}var ZZ=[`ok`,`incomplete`,`error`,`canceled`],QZ={ok:`bg-success`,incomplete:`bg-warning`,error:`bg-danger`,canceled:`bg-muted`},$Z={ok:`logsFilterOk`,incomplete:`logsFilterIncomplete`,error:`logsFilterError`,canceled:`logsFilterCanceled`};function eQ(e,t){return t>0?e/t:null}function tQ(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(0,Math.round((n-t)/1e3));if(r<=0)return null;let i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return i?`${i}h ${a}m`:a?`${a}m ${String(o).padStart(2,`0`)}s`:`${o}s`}function nQ(e,t){let n=[e.down_until,e.cooldown_until].filter(e=>!!e).filter(e=>Date.parse(e)>t);return n.length?n.reduce((e,t)=>Date.parse(e)>=Date.parse(t)?e:t):null}function rQ(e,t){return t?`danger`:(e??0)>=80?`warning`:`ok`}function iQ(){let{lang:e,t}=DH(),{overview:n,loading:r,error:i}=dU(),[a,o]=(0,v.useState)(`today`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=ot(),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!0),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(``),[C,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)([]),[D,O]=(0,v.useState)(!0),[k,A]=(0,v.useState)(0),[j,M]=(0,v.useState)([]),[N,P]=(0,v.useState)(null),[ee,F]=(0,v.useState)(()=>Date.now()),{live:I,samples:L}=UZ(),te=new Map((I?.accounts??[]).map(e=>[e.id,e])),R=!!n?.proxy?.ok,z=!!n?.worker?.ok,B=n?.worker?.ready_count??0,ne=n?.worker?.hot_count??0,re=n?.worker?.cooling_count??0,ie=I?.in_flight??n?.worker?.in_flight??0,V=f??KZ,ae=n?.routing?.session_affinity,oe=(ae?.hits??0)+(ae?.misses??0),se=eQ(ae?.hits??0,oe),ce=T.map(e=>({account:e,until:nQ(e,ee)})).filter(e=>e.until!=null),le=ce.length>0;(0,v.useEffect)(()=>{if(!le)return;let e=setInterval(()=>F(Date.now()),1e3);return()=>clearInterval(e)},[le]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([LH(!1),GH(),GH(void 0,!1,`regional`)]).then(([t,n,r])=>{e||(t.status===`fulfilled`&&E(t.value.data||[]),n.status===`fulfilled`&&A((n.value.data||[]).length),r.status===`fulfilled`&&M(r.value.data||[]))}).finally(()=>{e||O(!1)}),()=>{e=!0}},[]);let ue=s?.start?.toString()??``,de=s?.end?.toString()??``,fe=(0,v.useRef)(0),pe=(0,v.useCallback)(e=>{let t=mZ(a,s);if(!t){_(!1);return}let n=++fe.current;tX(t).then(e=>{n===fe.current&&(p(e),h(``))}).catch(t=>{n!==fe.current||e||(p(null),h(t instanceof Error?t.message:String(t)))}).finally(()=>{n===fe.current&&_(!1)})},[a,ue,de]);(0,v.useEffect)(()=>(pe(!1),()=>{fe.current++}),[pe]);let me=(0,v.useRef)(0),he=(0,v.useCallback)(e=>{let t=mZ(a,s)??{},n=++me.current;nX(t).then(e=>{n===me.current&&(b(e),S(``))}).catch(t=>{n!==me.current||e||(b(null),S(t instanceof Error?t.message:String(t)))}).finally(()=>{n===me.current&&w(!1)})},[a,ue,de]);(0,v.useEffect)(()=>(he(!1),()=>{me.current++}),[he]),(0,v.useEffect)(()=>{if(l)return;let e=Date.now(),t=()=>{document.hidden||(e=Date.now(),pe(!0),he(!0))},n=setInterval(t,GZ),r=()=>{!document.hidden&&Date.now()-e>=GZ&&t()};return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,r)}},[l,pe,he]),(0,v.useEffect)(()=>{let e=!1,t=()=>{OU().then(t=>{e||P(t)}).catch(()=>{})};t();let n=setInterval(t,5e3);return()=>{e=!0,clearInterval(n)}},[]);let ge=Math.floor(V.series.length/2),_e=(e,t)=>e.reduce((e,n)=>e+n[t],0),ve=V.series.slice(0,ge),ye=V.series.slice(ge),be=((e,t)=>e>0?(t-e)/e:null)(_e(ve,`requests`),_e(ye,`requests`)),xe=_e(ve,`requests`)?_e(ve,`ok`)/_e(ve,`requests`):null,Se=_e(ye,`requests`)?_e(ye,`ok`)/_e(ye,`requests`):null,Ce=xe!=null&&Se!=null?Se-xe:null,we=[{label:t(`metricRequests`),value:V.totals.requests,kind:`compact`,detail:t(`statsWindowHint`,{window:t(pZ[a])}),ok:V.totals.requests>0,trend:be},{label:t(`metricSuccess`),value:V.totals.success_rate,kind:`percent`,detail:`${V.totals.ok} ${t(`logsFilterOk`)} · ${V.totals.incomplete} ${t(`logsFilterIncomplete`)} · ${V.totals.error} ${t(`logsFilterError`)}`,ok:V.totals.requests===0||V.totals.success_rate>=.9,trend:Ce},{label:t(`metricLatency`),value:V.latency.p95_ms??V.latency.avg_ms,kind:`ms`,detail:`p50 ${cX(V.latency.p50_ms)} · avg ${cX(V.latency.avg_ms)}`,ok:V.latency.p95_ms==null||V.latency.p95_ms<8e3,trend:null},{label:t(`metricTokens`),value:V.tokens.total,kind:`compact`,detail:`${sX(V.tokens.prompt)} / ${sX(V.tokens.completion)}`,ok:!0,trend:null}],Te=eQ(V.tokens.cache_read,V.tokens.prompt),Ee=eQ(V.totals.streaming,V.totals.requests),De=[{label:t(`metricCacheHit`),value:Te,kind:`percent`,detail:t(`metricCacheHitDetail`,{read:sX(V.tokens.cache_read),prompt:sX(V.tokens.prompt)})},{label:t(`metricStreaming`),value:Ee,kind:`percent`,detail:t(`metricStreamingDetail`,{count:V.totals.streaming,total:V.totals.requests})},{label:t(`metricCanceled`),value:V.totals.canceled,kind:`int`,detail:t(`metricCanceledDetail`,{rate:uX(eQ(V.totals.canceled,V.totals.requests)??0)})}],Oe=ZZ.map(e=>({key:e,count:V.status.find(t=>t.key===e)?.count??V.totals[e]??0})),ke=e=>gZ(e,V.window.from,V.window.to);return r&&!n?(0,G.jsx)(mY,{}):(0,G.jsxs)(`div`,{className:`space-y-5 sm:space-y-4`,children:[(0,G.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:t(`homeDisplay`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:t(`homeLead`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(hZ,{value:a,onChange:o,custom:s,onCustomChange:c,onBusy:()=>{_(!0),w(!0)},t}),(0,G.jsxs)(eL,{delay:300,children:[(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(l?`statsRefreshResume`:`statsRefreshPause`),"aria-pressed":l,onPress:()=>u(e=>!e),children:l?(0,G.jsx)(Sa,{size:14}):(0,G.jsx)(va,{size:14})}),(0,G.jsx)(eL.Content,{children:t(l?`statsRefreshPaused`:`statsRefreshAuto`)})]}),(0,G.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:n?.time||`—`}),(0,G.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-2 text-body font-medium`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":R&&z?`ok`:`danger`}),t(R&&z?`running`:`degraded`)]})]})]})]}),i?(0,G.jsx)(bU,{title:t(`failedOverview`,{msg:i})}):null,(0,G.jsx)(VZ,{live:I,samples:L,t}),(0,G.jsx)(`section`,{"data-gsap-reveal":!0,className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:we.map(e=>(0,G.jsxs)(zw,{className:`gap-0 p-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`span`,{className:`status-dot`,"data-state":e.ok?`ok`:`danger`})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`tabular text-metric font-medium leading-none`,children:g?(0,G.jsx)($,{className:`h-7 w-24`}):e.value==null?`—`:(0,G.jsx)(SX,{value:e.value,kind:e.kind})}),!g&&e.trend!=null?(0,G.jsx)(cQ,{value:e.trend,hint:t(`trendHalfHint`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-2 truncate text-caption text-muted`,children:g?(0,G.jsx)($,{className:`h-3 w-28`}):e.detail})]},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:De.map(e=>(0,G.jsx)(zw,{className:`gap-0 p-3.5`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:g?(0,G.jsx)($,{className:`h-3 w-28`}):e.detail})]}),(0,G.jsx)(`div`,{className:`tabular text-section font-semibold sm:shrink-0`,children:g?(0,G.jsx)($,{className:`h-5 w-12`}):e.value==null?`—`:(0,G.jsx)(SX,{value:e.value,kind:e.kind})})]})},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3`,children:(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTraffic`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTrafficHint`)})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:V.totals.error?`warning`:`success`,children:uX(V.totals.success_rate)})]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[m?(0,G.jsx)(`div`,{className:`text-body text-danger`,children:t(`failedStats`,{msg:m})}):g?(0,G.jsx)(fY,{}):V.series.some(e=>e.requests>0)?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(fY,{}),children:(0,G.jsx)(WZ,{series:V.series,lang:e,emptyLabel:t(`statsEmptyTraffic`),okLabel:t(`logsFilterOk`),errorLabel:t(`logsFilterError`),selectHint:t(`statsDragHint`),labels:{requests:t(`chartMetricRequests`),tokens:t(`chartMetricTokens`),latency:t(`chartMetricLatency`),input:t(`chartInput`),output:t(`chartOutput`),cacheRead:t(`chartCacheRead`),p50:t(`statsLatencyP50`),p95:t(`statsLatencyP95`),total:t(`chartTotal`)},onSelectRange:(e,t)=>d(gZ({},e,t))})}):(0,G.jsx)(wX,{emptyLabel:t(`statsEmptyTraffic`)}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-4 pt-3 sm:grid-cols-4 sm:gap-3`,children:[[t(`statsLatencyP50`),cX(V.latency.p50_ms)],[t(`statsLatencyP95`),cX(V.latency.p95_ms)],[t(`statsLatencyAvg`),cX(V.latency.avg_ms)],[t(`statsTTFB`),cX(V.latency.ttfb_avg_ms)]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`div`,{className:`mono mt-1 text-body font-medium`,children:g?(0,G.jsx)($,{className:`h-4 w-16`}):t})]},String(e)))})]})]})}),(0,G.jsx)(GX,{accounts:T,t}),(0,G.jsx)(sZ,{usage:y,accounts:T,loading:C,t}),x?(0,G.jsx)(bU,{title:t(`failedStats`,{msg:x})}):null,(0,G.jsx)(lZ,{usage:y,accounts:T,models:j,loading:C,t}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,.85fr)]`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsPool`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsPoolHint`)})]}),(0,G.jsxs)(Cn,{to:`/accounts`,className:`inline-flex items-center gap-1 text-caption font-medium text-muted hover:text-foreground`,children:[t(`navAccounts`),(0,G.jsx)(ei,{size:12})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-y-1 border-b border-separator sm:grid-cols-4 sm:gap-y-0`,children:[[t(`ready`),B,`ok`],[t(`hot`),ne,ne?`ok`:``],[t(`inFlight`),ie,ie?`ok`:``],[t(`statsAffinityHit`),se==null?`—`:uX(se),``,ae?t(`statsAffinityHint`,{hits:ae.hits??0,misses:ae.misses??0,bindings:ae.bindings??0}):``]].map(([e,t,n,r])=>(0,G.jsxs)(`div`,{className:`px-4 py-3 sm:py-2.5`,title:r?String(r):void 0,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 sm:mt-1`,children:[(0,G.jsx)(`span`,{className:`mono text-section font-semibold`,children:t}),n?(0,G.jsx)(`span`,{className:`status-dot`,"data-state":n}):null]})]},String(e)))}),!D&&ce.length?(0,G.jsxs)(`div`,{className:`border-b border-separator px-4 py-2.5`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`statsCoolingDetails`)}),(0,G.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:ce.map(({account:e,until:n})=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-caption sm:flex-row sm:items-center sm:gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":`warn`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pl-4 sm:contents sm:pl-0`,children:[(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted`,children:e.last_error_kind?XZ(e.last_error_kind,t):t(`statsUnknown`)}),(0,G.jsx)(`span`,{className:`mono shrink-0 tabular sm:w-16 sm:text-right`,children:tQ(n,ee)??`—`}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted sm:w-12 sm:text-right`,title:t(`statsBackoffLevel`),children:e.restart_backoff_level?`L${e.restart_backoff_level}`:`—`})]})]},e.id))})]}):null,(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:D?(0,G.jsx)(dY,{}):T.length===0?(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`noAccounts`)}):T.slice(0,6).map(e=>{let n=e.quota,r=rQ(n?.percentage,n?.exceeded),i=te.get(e.id),a=i?.in_flight??e.in_flight??e.inFlight??0,o=i?.max_inflight||e.max_inflight||4,s=a>=o;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-3 sm:py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 sm:items-center`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0 sm:mt-0`,"data-state":e.ready?`ok`:`danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(zZ,{provider:e.provider,size:14}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:[EZ(e.provider,e.region,t),` · `,e.hot?t(`hot`):e.ready?t(`ready`):t(`degraded`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 pl-6 sm:shrink-0 sm:pl-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(s?`liveSaturated`:`inFlight`),"data-testid":`account-inflight`,children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`inFlight`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular ${s?`text-warning`:`text-muted`}`,children:[a,`/`,o]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/50`}`,style:{width:`${Math.min(100,a/o*100)}%`}})})]}),n?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(`quota`),children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`quota`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular text-muted`,children:[Math.round(n.percentage??0),`%`]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${r===`danger`?`bg-danger`:r===`warning`?`bg-warning`:`bg-success`}`,style:{width:`${Math.min(100,Math.max(0,n.percentage??0))}%`}})})]}):null]})]},e.id)})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{children:[t(`metricModels`),` `,k]}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[[`qoder`,`workbuddy`,`trae`].map(e=>{let t=T.filter(t=>String(t.provider||`qoder`).toLowerCase()===e).length;return t?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(zZ,{provider:e,size:11}),t]},e):null}),(0,G.jsx)(`span`,{children:re?`${re} ${t(`statsCooling`)}`:`${T.length} ${t(`accountCount`)}`})]})]})]}),(0,G.jsx)(oQ,{resources:N,t})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-2 2xl:grid-cols-3`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopProviders`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTopProvidersHint`)})]})}),g?(0,G.jsx)(dY,{}):(0,G.jsx)(sQ,{empty:t(`statsNoProviders`),items:(V.providers||[]).map(e=>({key:e.key,label:qZ(e.key,t),count:e.count,meta:`${e.ok}/${e.count}`,mark:e.key===`(unknown)`?void 0:e.key,href:e.key===`(unknown)`?void 0:ke({provider:e.key})}))})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`providerCatalog`)})]})}),g?(0,G.jsx)(dY,{rows:4}):(0,G.jsx)(sQ,{empty:t(`statsNoModels`),items:V.models.map(e=>({key:e.key,label:e.key===`(unknown)`?t(`statsUnknown`):e.key,count:e.count,href:e.key===`(unknown)`?void 0:ke({model:e.key}),meta:e.latency_avg_ms==null?`${e.ok}/${e.count}`:cX(e.latency_avg_ms)}))})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsStatusMix`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsStatusMixHint`)})]})}),g?(0,G.jsx)(dY,{rows:4}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(lQ,{items:Oe,t}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsErrorMix`)}),(0,G.jsx)(sQ,{empty:t(`statsNoErrors`),danger:!0,items:V.errors.map(e=>({key:e.key,label:XZ(e.key,t),count:e.count,href:YZ.has(e.key)?ke({error_kind:e.key}):void 0}))}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsTopAccounts`)}),(0,G.jsx)(sQ,{empty:t(`statsNoAccounts`),items:V.accounts.slice(0,5).map(e=>({key:e.key,label:JZ(T,e.key,t(`statsUnassigned`)),count:e.count,href:!e.key||e.key===`(unassigned)`?void 0:ke({account:e.key}),meta:`${e.ok}/${e.count}`}))})]})]})]})]})}function aQ(e,t){return e>=2147483648||t>=200?`danger`:e>=1073741824||t>=100?`warning`:`ok`}function oQ({resources:e,t}){let n=[...e?.workers??[]].sort((e,t)=>t.rss_bytes-e.rss_bytes),r=e?.server;return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`resTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`resHint`)})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:e?`success`:`default`,children:e?lX(e.total_rss_bytes):`—`})]}),(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":aQ(r?.rss_bytes??0,r?.cpu_percent??0)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:t(`resServer`)}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,r?.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[lX(r?.rss_bytes),` · `,(r?.cpu_percent??0).toFixed(1),`%`]})]})}),n.length===0?(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`resEmpty`)}):n.map(e=>(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":aQ(e.rss_bytes,e.cpu_percent)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label||e.account_id}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,e.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[lX(e.rss_bytes),` · `,e.cpu_percent.toFixed(1),`%`]})]})},e.pid))]}):(0,G.jsx)(dY,{rows:3})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{className:`mono`,children:[r?.goroutines??0,` `,t(`resGoroutines`)]}),(0,G.jsx)(`span`,{className:`mono`,children:e?.sampled_at?new Date(e.sampled_at).toLocaleTimeString():`—`})]})]})}function sQ({items:e,empty:t,danger:n}){let r=(0,v.useRef)(null),i=Math.max(1,...e.map(e=>e.count)),a=e.map(e=>`${e.key}:${e.count}`).join(`|`);return(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=eY.context(()=>{let e=eY.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(`[data-rank-fill]`,{clearProps:`transform`})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=eY.utils.toArray(`[data-rank-fill]`);e.length&&eY.fromTo(e,{scaleX:0},{scaleX:1,duration:.38,ease:`power2.out`,stagger:.05,transformOrigin:`0% 50%`})})},e);return()=>t.revert()},[a]),e.length?(0,G.jsx)(`div`,{ref:r,className:`divide-y divide-separator`,children:e.map(e=>{let t=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.mark?(0,G.jsx)(zZ,{provider:e.mark,size:14}):null,(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label})]}),(0,G.jsx)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:e.meta?`${e.count} · ${e.meta}`:e.count})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.jsx)(`div`,{"data-rank-fill":!0,className:`h-full origin-left rounded-[2px] ${n?`bg-danger`:`bg-success`}`,style:{width:`${Math.max(6,e.count/i*100)}%`}})})]});return e.href?(0,G.jsx)(Cn,{to:e.href,className:`rank-row block px-4 py-2.5`,title:e.label,children:t},e.key):(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:t},e.key)})}):(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t})}function cQ({value:e,hint:t}){let n=Math.abs(e)<.005?`flat`:e>0?`up`:`down`;return(0,G.jsxs)(`span`,{className:`trend-chip`,"data-tone":n,title:t,children:[(0,G.jsx)(n===`down`?Xa:n===`up`?Qa:gi,{size:12,weight:`bold`}),e>0?`+`:``,(e*100).toFixed(1),`%`]})}function lQ({items:e,t}){let n=e.reduce((e,t)=>e+t.count,0);return n?(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`flex h-2 gap-px overflow-hidden rounded-[3px] bg-separator`,role:`img`,"aria-label":e.map(e=>`${t($Z[e.key])} ${e.count}`).join(`, `),children:e.filter(e=>e.count>0).map(e=>(0,G.jsx)(`div`,{className:QZ[e.key],style:{width:`${e.count/n*100}%`,minWidth:2}},e.key))}),(0,G.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-1.5`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(`span`,{className:`inline-block size-2 shrink-0 rounded-[2px] ${QZ[e.key]}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted`,children:t($Z[e.key])}),(0,G.jsx)(`span`,{className:`mono tabular`,children:e.count}),(0,G.jsx)(`span`,{className:`mono w-10 text-right tabular text-muted`,children:uX(e.count/n)})]},e.key))})]}):(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`statsEmptyTraffic`)})}function uQ(e){return e?e>=1e6?`${(e/1e6).toString().replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e):`—`}function dQ({model:e,t,onClose:n}){if(!e)return null;let r=e.reasoning_options||[],i=e.catalog_context_length||e.default_context_length||e.context_length,a=e.catalog_context_length_max,o=fX(e),s=pX(e),c=String(e.provider||e.owned_by||`qoder`).trim().toLowerCase(),l=EZ(c,String(e.region||e.regions?.[0]||``).trim().toLowerCase()||void 0,t),u=c===`trae`?DZ(e):void 0;return(0,G.jsx)(Z.Root,{isOpen:!0,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`md`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`text-section`,children:e.display_name||e.id}),s?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:e.id}),(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[l,o?` · ${o}`:``]})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-4 px-5 pb-5`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`contextWindowCol`)}),(0,G.jsxs)(`div`,{className:`mt-1 text-body`,children:[uQ(i),a&&a!==i?` → ${uQ(a)}`:``]}),e.supports_max_mode?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(c===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,!e.supports_max_mode&&a&&a!==i?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`workbuddyContextHint`)}):null,u?u.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,uQ(u.prompt_max_tokens)]}):null:e.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,uQ(e.prompt_max_tokens)]}):null,u?u.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,uQ(u.max_output_tokens)]}):null:e.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,uQ(e.max_output_tokens)]}):null]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`reasoningLevels`)}),r.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`reasoningHint`)}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:r.map(n=>{let r=`reasoningLevel_${n}`,i=t(r);return(0,G.jsxs)(lT,{size:`sm`,variant:`soft`,color:n===(e.reasoning_effort||e.reasoning_default)?`success`:`default`,children:[i===r?n:i,n===e.reasoning_default?` · ${t(`defaultValue`)}`:``,n===e.reasoning_effort&&n!==e.reasoning_default?` · ${t(`custom`)}`:``]},n)})})]}):(0,G.jsx)(`div`,{className:`mt-1 text-body text-muted`,children:e.reasoning_type?t(`reasoningFixed`,{type:e.reasoning_type}):t(`noReasoningLevels`)})]})]})]})})})})}function fQ({isSelected:e,isDisabled:t,ariaLabel:n,label:r,size:i=`sm`,onChange:a}){return(0,G.jsx)(dF,{size:i,isSelected:e,isDisabled:t,onChange:a,children:(0,G.jsxs)(dF.Content,{children:[(0,G.jsx)(dF.Control,{children:(0,G.jsx)(dF.Thumb,{})}),r?(0,G.jsx)(sR,{children:r}):(0,G.jsx)(`span`,{className:`sr-only`,children:n})]})})}function pQ({title:e,hint:t,action:n,icon:r,className:i}){return(0,G.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center ${i||``}`,children:(0,G.jsxs)(`div`,{className:`max-w-sm`,children:[r?(0,G.jsx)(`div`,{className:`mb-3 flex justify-center text-muted`,children:r}):null,(0,G.jsx)(dR,{className:`p-0 text-body font-medium text-foreground`,children:e}),t?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t}):null,n?(0,G.jsx)(`div`,{className:`mt-5 flex justify-center`,children:n}):null]})})}var mQ=`__all__`;function hQ({value:e,onChange:t,ariaLabel:n,options:r,className:i}){let a=r.map(e=>({id:e.id||mQ,label:e.label})),o=e||mQ,s=a.find(e=>e.id===o);return(0,G.jsxs)(SV,{className:i??`w-fit min-w-36`,"aria-label":n,value:o,onChange:e=>{typeof e==`string`&&t(e===mQ?``:e)},children:[(0,G.jsxs)(SV.Trigger,{className:`min-w-0 w-full items-center`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t||!s?e:(0,G.jsx)(`span`,{className:`truncate`,children:s.label})}),(0,G.jsx)(SV.Indicator,{})]}),(0,G.jsx)(SV.Popover,{className:`max-h-72 min-w-36`,children:(0,G.jsx)(GB,{children:a.map(e=>(0,G.jsxs)(GB.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(sR,{className:`block truncate`,children:e.label}),(0,G.jsx)(GB.ItemIndicator,{})]},e.id))})})]})}var gQ=[20,50,100],_Q=[20,50,100];function vQ(e,t){if(t<=7)return Array.from({length:t},(e,t)=>t+1);let n=[1];e>3&&n.push(`gap`);let r=Math.max(2,e-1),i=Math.min(t-1,e+1);for(let e=r;e<=i;e++)n.push(e);return e{let t=Number([...e][0]);d.includes(t)&&u(t)},"aria-label":a,children:d.map(e=>(0,G.jsx)(QP,{id:String(e),children:e},e))})]}),(0,G.jsxs)(yV,{size:`sm`,className:`w-fit`,children:[(0,G.jsx)(yV.Summary,{className:`mono text-caption`,children:o}),(0,G.jsxs)(yV.Content,{children:[(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Previous,{isDisabled:i||t<=1,onPress:()=>l(Math.max(1,t-1)),"aria-label":s,children:(0,G.jsx)(yV.PreviousIcon,{})})}),f.map((e,n)=>e===`gap`?(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Ellipsis,{})},`gap-${n}`):(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Link,{isActive:e===t,isDisabled:i,onPress:()=>l(e),children:e})},e)),(0,G.jsx)(yV.Item,{children:(0,G.jsx)(yV.Next,{isDisabled:i||t>=n,onPress:()=>l(Math.min(n,t+1)),"aria-label":c,children:(0,G.jsx)(yV.NextIcon,{})})})]})]})]})}function bQ({value:e,onChange:t,placeholder:n,ariaLabel:r,className:i}){return(0,G.jsx)(aR,{"aria-label":r,value:e,onChange:t,className:i,children:(0,G.jsxs)(aR.Group,{children:[(0,G.jsx)(aR.SearchIcon,{}),(0,G.jsx)(aR.Input,{placeholder:n}),(0,G.jsx)(aR.ClearButton,{})]})})}function xQ(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id});return t}function SQ(e){return e.settings_key||e.id}function CQ(e){return String(e.provider||e.owned_by||`qoder`).trim().toLowerCase()}function wQ(e){let t=String(e.region||``).trim().toLowerCase();if(t)return t;let n=e.regions||[];return String(n[0]||``).trim().toLowerCase()}function TQ(e){return`${CQ(e)}:${wQ(e)||`any`}:${e.settings_key||e.id}:${e.native_model||e.mapped_key||``}`}function EQ(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function DQ(e,t){let n=`reasoningLevel_${t}`,r=e(n);return r===n?t:r}function OQ({label:e,hint:t}){return(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`span`,{className:`cursor-help text-caption text-muted`,children:e})}),(0,G.jsx)(eL.Content,{children:(0,G.jsx)(`p`,{className:`max-w-xs text-caption leading-5`,children:t})})]})}function kQ({model:e,saving:t,t:n,variant:r=`table`,onToggleTraeMax:i,onReasoningChange:a}){let o=CQ(e),s=r===`card`,c=s?`w-full min-w-0`:`w-full max-w-[7.5rem] min-w-0`;return(0,G.jsxs)(`div`,{className:s?`flex min-w-0 flex-col gap-3`:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[uQ(e.catalog_context_length||e.context_length),e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?` → ${uQ(e.catalog_context_length_max)}`:``]}),o===`workbuddy`&&e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?(0,G.jsx)(OQ,{label:n(`catalogWindow`),hint:n(`workbuddyContextHint`)}):null]}),(o===`trae`||o===`qoder`)&&e.supports_max_mode?(0,G.jsxs)(`div`,{className:s?`flex flex-col gap-1.5`:`flex items-center gap-2`,children:[s?(0,G.jsx)(OQ,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${uQ(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(fQ,{isSelected:!!e.max_mode,isDisabled:t,ariaLabel:`${e.id} ${n(`maxMode`)}`,onChange:t=>i(e,t)}),s?null:(0,G.jsx)(OQ,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${uQ(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)})]})]}):null,(e.reasoning_options||[]).length>1?(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsx)(OQ,{label:n(`reasoningLevels`),hint:n(`reasoningHint`)}),(0,G.jsx)(hQ,{className:c,ariaLabel:`${e.id} ${n(`reasoningLevels`)}`,value:e.reasoning_effort||e.reasoning_default||e.reasoning_options?.[0]||``,onChange:t=>{t&&a(e,t)},options:(e.reasoning_options||[]).map(e=>({id:e,label:DQ(n,e)}))})]}):(e.reasoning_options||[]).length===1?(0,G.jsx)(OQ,{label:`${n(`reasoningLevels`)} ${DQ(n,e.reasoning_options[0])}`,hint:n(`reasoningHint`)}):e.reasoning_type?(0,G.jsx)(`span`,{className:`text-caption text-muted`,children:n(`reasoningFixed`,{type:e.reasoning_type})}):o===`trae`&&!e.supports_max_mode?(0,G.jsx)(OQ,{label:n(`catalogWindow`),hint:n(`catalogWindowHint`)}):null]})}function AQ({model:e,t,onDetails:n}){return(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>n(e),children:[(0,G.jsx)(ea,{size:14}),t(`modelDetails`)]})}function jQ(){let{t:e}=DH(),{overview:t,loading:n}=dU(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(1),[d,f]=(0,v.useState)(50),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)(!0);(0,v.useEffect)(()=>{let e=!1;return KH(void 0,`regional`).then(t=>{e||T(t.data||[])}).catch(()=>void 0).finally(()=>{e||D(!1)}),tU().then(t=>{e||c(xQ(t.data||[]))}).catch(()=>void 0),()=>{e=!0}},[]);let O=(0,v.useMemo)(()=>{let t=r.trim().toLowerCase(),[n,i]=a.includes(`:`)?a.split(`:`,2):[a,``];return w.filter(r=>{let a=CQ(r),o=wQ(r);if(n&&a!==n||i&&o!==i)return!1;if(!t)return!0;let s=EZ(a,o||void 0,e);return`${r.display_name||``} ${r.id} ${r.mapped_key||``} ${a} ${s} ${r.owned_by||``} ${o} ${r.credits||``} ${r.free?`free`:``}`.toLowerCase().includes(t)})},[r,w,a,e]),k=[r,a,d].join(`\0`),[A,j]=(0,v.useState)(k);A!==k&&(j(k),u(1));let M=Math.max(1,Math.ceil(O.length/d)),N=Math.min(A===k?Math.max(1,l):1,M);l!==N&&u(N);let P=(0,v.useMemo)(()=>{let e=(N-1)*d;return O.slice(e,e+d)},[N,O,d]),ee=O.length===0?0:(N-1)*d+1,F=Math.min(O.length,N*d),I=O.length?e(`logsShownTotal`,{shown:`${ee}–${F}`,total:O.length}):e(`shownTotal`,{shown:0,total:w.length});if(n&&!t||E)return(0,G.jsx)(vY,{});function L(e,t){let n=SQ(e),r=CQ(e),i=w.map(e=>{if(SQ(e)!==n||CQ(e)!==r)return e;let i=e.reasoning_effort||e.reasoning_default||``,a=e.catalog_context_length||e.default_context_length||e.context_length||0,o=e.catalog_context_length_max||0;return{...e,max_mode:t,context_length:t&&o?o:a,default_context_length:a,context_custom:r===`qoder`?t:t||!!(i&&i!==e.reasoning_default)}});T(i)}function te(e,t){let n=SQ(e),r=CQ(e),i=w.map(e=>SQ(e)!==n||CQ(e)!==r?e:{...e,reasoning_effort:t,context_custom:!!e.max_mode||!!(t&&t!==e.reasoning_default)});T(i)}async function R(){m(!0),y(``),x(!1);try{let e=await qH(void 0,`regional`);T(e.data||[])}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function z(t,n){let r=CQ(t);if(r!==`trae`&&r!==`workbuddy`&&r!==`kimi`)return;let i=SQ(t);g(i),y(``),x(!1);try{await YH(r,i,n),te(t,n),y(e(`reasoningSaved`,{model:t.id,level:DQ(e,n)}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}async function B(t,n){if(!t.supports_max_mode){x(!0),y(e(`contextMaxUnavailable`));return}let r=SQ(t),i=CQ(t);g(r),y(``),x(!1);try{await JH(i,r,n,t.catalog_context_length_max),L(t,n),y(e(n?`contextMaxOn`:`contextMaxOff`,{model:t.id}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`grid gap-5 pb-6 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`availableModels`)}),(0,G.jsx)(`p`,{className:`mt-1 text-body text-muted`,children:w.length?I:e(`noModelsYet`)})]}),(0,G.jsxs)(`div`,{"data-gsap-reveal":!0,className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,G.jsx)(bQ,{className:`w-full min-w-0 sm:w-72`,value:r,onChange:i,placeholder:e(`filterPh`),ariaLabel:e(`filter`)}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(hQ,{ariaLabel:e(`providerCol`),value:a,onChange:o,options:[{id:``,label:e(`providerFilterAll`)},...s.map(t=>({id:t.value,label:EZ(t.provider,t.region,e)}))]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:p,onPress:()=>void R(),children:[(0,G.jsx)(Jr,{size:14}),e(p?`refreshing`:`refresh`)]})]})]})]}),_?(0,G.jsx)(bU,{status:b?`danger`:`success`,title:_}):null,(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-separator px-4 py-4 sm:items-center sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(Mi,{size:16})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:e(`providerCatalog`)}),(0,G.jsx)(`div`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:e(`contextConfigHint`)})]})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,className:`shrink-0`,children:O.length})]}),p||n?(0,G.jsx)(pY,{}):O.length===0?(0,G.jsx)(pQ,{icon:(0,G.jsx)(ua,{size:22}),title:w.length?e(`noModelsMatch`):e(`noProviders`),hint:w.length?r||a||e(`noModelsMatch`):e(`noModelsYet`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:P.map(t=>{let n=SQ(t),r=h===n,i=CQ(t),a=EZ(i,wQ(t)||void 0,e),o=fX(t),s=pX(t);return(0,G.jsxs)(`article`,{className:`space-y-3 px-4 py-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:t.id}),EQ(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:EQ(t)})}):null]})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-caption`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(zZ,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`font-medium`,children:a})]}),(0,G.jsx)(`span`,{className:`mono break-all text-muted`,children:t.mapped_key||t.native_model||t.id})]}),(0,G.jsx)(kQ,{model:t,saving:r,t:e,variant:`card`,onToggleTraeMax:(e,t)=>void B(e,t),onReasoningChange:(e,t)=>void z(e,t)}),(0,G.jsx)(AQ,{model:t,t:e,onDetails:C})]},TQ(t))})}),(0,G.jsx)(Q,{className:`hidden min-w-0 lg:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{"aria-label":e(`availableModels`),className:`min-w-[68rem]`,children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`modelCol`)}),(0,G.jsx)(Q.Column,{children:e(`requestIdCol`)}),(0,G.jsx)(Q.Column,{children:e(`providerCol`)}),(0,G.jsx)(Q.Column,{children:e(`qoderKeyCol`)}),(0,G.jsx)(Q.Column,{children:e(`modelDefaultsCol`)}),(0,G.jsx)(Q.Column,{children:e(`stateCol`)}),(0,G.jsx)(Q.Column,{children:e(`actions`)})]}),(0,G.jsx)(Q.Body,{children:P.map(t=>{let n=SQ(t),r=h===n,i=CQ(t),a=EZ(i,wQ(t)||void 0,e),o=fX(t),s=pX(t);return(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),EQ(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:EQ(t)})}):null]})]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption font-medium`,children:t.id})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zZ,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`text-caption font-medium`,children:a})]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t.mapped_key||t.native_model||t.id})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(kQ,{model:t,saving:r,t:e,variant:`table`,onToggleTraeMax:(e,t)=>void B(e,t),onReasoningChange:(e,t)=>void z(e,t)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(AQ,{model:t,t:e,onDetails:C})})]},TQ(t))})})]})})})]})]}),(0,G.jsx)(dQ,{model:S?w.find(e=>SQ(e)===SQ(S))||S:null,t:e,onClose:()=>C(null)}),(0,G.jsx)(yQ,{total:O.length,page:N,pageCount:M,pageSize:d,loading:p,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:N,pages:M}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:u,onPageSize:f})]})}function MQ({copied:e,size:t=14,className:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(!0);return(0,v.useLayoutEffect)(()=>{let t=e?i.current:r.current,n=e?r.current:i.current;if(!t||!n)return;let o={autoAlpha:1,scale:1,filter:`blur(0px)`},s={autoAlpha:0,scale:.5,filter:`blur(4px)`};if(a.current||iY()){a.current=!1,eY.set(t,o),eY.set(n,s);return}eY.to(n,{...s,duration:tY.fast,ease:nY.out,overwrite:!0}),eY.fromTo(t,s,{...o,duration:tY.base,ease:nY.soft,delay:tY.instant/2,overwrite:!0})},[e]),(0,G.jsxs)(`span`,{className:`relative inline-grid place-items-center ${n??``}`,style:{width:t,height:t},children:[(0,G.jsx)(`span`,{ref:r,className:`col-start-1 row-start-1 inline-flex`,children:(0,G.jsx)(Oi,{size:t})}),(0,G.jsx)(`span`,{ref:i,className:`col-start-1 row-start-1 inline-flex text-success`,children:(0,G.jsx)(vi,{size:t})})]})}async function NQ(e){if(!e)return!1;try{if(typeof navigator<`u`&&navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function PQ(){return`${location.protocol}//${location.host}`}function FQ(e){return e?/^https?:\/\//i.test(e)?e:e.startsWith(`/`)?`${PQ()}${e}`:`${PQ()}/${e}`:PQ()}function IQ({access:e}){let{t}=DH(),[n,r]=(0,v.useState)(``),i=FQ(e?.openai_base_url||`/v1`),a=(0,v.useMemo)(()=>[{name:t(`endpointOpenAI`),url:i,method:`BASE`,hint:t(`endpointBaseHint`),icon:(0,G.jsx)(oi,{size:15})},{name:t(`endpointChat`),url:FQ(e?.chat_completions||`${i}/chat/completions`),method:`POST`,hint:t(`endpointChatHint`),icon:(0,G.jsx)(ga,{size:15})},{name:t(`endpointMessages`),url:FQ(e?.messages||`${i}/messages`),method:`POST`,hint:t(`endpointMessagesHint`),icon:(0,G.jsx)(ga,{size:15})},{name:t(`endpointResponses`),url:FQ(e?.responses||`${i}/responses`),method:`POST`,hint:t(`endpointResponsesHint`),icon:(0,G.jsx)(ga,{size:15})},{name:t(`endpointModels`),url:FQ(e?.models||`${i}/models`),method:`GET`,hint:t(`endpointModelsHint`),icon:(0,G.jsx)(ca,{size:15})},{name:t(`endpointHealth`),url:FQ(e?.health||`/health`),method:`GET`,hint:t(`endpointHealthHint`),icon:(0,G.jsx)(Qi,{size:15})}],[e,i,t]);return(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4 px-5 py-4 sm:px-6`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`endpoints`)}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:t(`endpointCount`,{count:a.length-1})})]}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`routesHint`)})]})}),(0,G.jsx)(`div`,{className:`grid gap-2 px-3 pb-3 sm:grid-cols-2 sm:px-4 sm:pb-4 lg:grid-cols-3`,children:a.map(e=>(0,G.jsxs)(`div`,{className:`group min-w-0 rounded-xl bg-surface-secondary/40 p-3 transition-colors hover:bg-surface-secondary/70`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface text-muted`,children:e.icon}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.name}),(0,G.jsx)(`code`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.url})]})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:e.method})]}),(0,G.jsx)(`p`,{className:`mt-2 text-caption leading-5 text-muted`,children:e.hint}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:e.method===`BASE`?t(`endpointBaseLabel`):t(`endpointAuthLabel`)}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`copy`),onPress:()=>{NQ(e.url),r(e.name),window.setTimeout(()=>r(``),1100)},children:(0,G.jsx)(MQ,{copied:n===e.name})}),(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`open`),onPress:()=>window.open(e.url,`_blank`,`noopener,noreferrer`),children:(0,G.jsx)(Qr,{size:14})})]})]})]},e.name))})]})}var LQ=new Set(`txt.md.markdown.json.csv.tsv.yml.yaml.toml.xml.html.htm.css.scss.js.jsx.ts.tsx.mjs.cjs.py.go.rs.java.kt.swift.c.h.cpp.hpp.sh.bash.zsh.sql.graphql.env.ini.conf.log.rst.tex`.split(`.`)),RQ=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function zQ(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}function BQ(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function VQ(e){let t=zQ(e.name),n=e.type||`application/octet-stream`,r=`${e.name}-${e.size}-${e.lastModified}-${Math.random().toString(36).slice(2,8)}`;if(RQ.has(n)||[`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(t)){let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error||Error(`read failed`)),r.readAsDataURL(e)});return{id:r,name:e.name,mime:n,kind:`image`,dataUrl:t,size:e.size}}if(LQ.has(t)||n.startsWith(`text/`)||n===`application/json`){let t=await e.text();return{id:r,name:e.name,mime:n,kind:`text`,text:t,size:e.size}}return null}function HQ({ariaLabel:e,value:t,onChange:n,placeholder:r,isDisabled:i,options:a,className:o,tone:s=`default`}){let c=a.find(e=>e.id===t),l=s===`muted`?`text-muted hover:text-foreground`:`text-foreground`;return(0,G.jsxs)(SV,{className:o??`w-auto max-w-[11rem] min-w-0`,"aria-label":e,value:t||null,placeholder:r,isDisabled:i,onChange:e=>{typeof e==`string`&&e&&n(e)},children:[(0,G.jsxs)(SV.Trigger,{className:`h-7 min-h-7 gap-1 rounded-md border-0 bg-transparent px-1.5 shadow-none items-center hover:bg-surface data-[focus-visible=true]:bg-surface ${l}`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate text-caption font-medium`,children:({defaultChildren:e,isPlaceholder:t})=>t||!c?e:(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[c.icon?(0,G.jsx)(`span`,{className:`grid size-3.5 shrink-0 place-items-center opacity-80`,children:c.icon}):null,(0,G.jsx)(`span`,{className:`truncate`,children:c.label})]})}),(0,G.jsx)(SV.Indicator,{className:`size-2.5 opacity-50`})]}),(0,G.jsx)(SV.Popover,{placement:`top end`,className:`max-h-72 min-w-48`,children:(0,G.jsx)(GB,{children:a.map(e=>(0,G.jsxs)(GB.Item,{id:e.id,textValue:e.textValue,className:`gap-2`,children:[e.icon?(0,G.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:e.icon}):null,(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(sR,{className:`block truncate text-caption`,children:e.label}),e.hint?(0,G.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),(0,G.jsx)(GB.ItemIndicator,{})]},e.id))})})]})}function UQ({value:e,onChange:t,attachments:n,onAttachmentsChange:r,disabled:i,streaming:a,canSend:o,onSend:s,onStop:c,accountValue:l,onAccountChange:u,accountOptions:d,modelValue:f,onModelChange:p,modelOptions:m,modelsLoading:h}){let{t:g}=DH(),_=(0,v.useRef)(null);async function y(e){if(!e?.length)return;let t=[],i=[];for(let n of Array.from(e))try{let e=await VQ(n);e?t.push(e):i.push(n.name)}catch{i.push(n.name)}t.length&&r([...n,...t]),i.length&&window.alert(g(`chatAttachUnsupported`,{names:i.join(`, `)})),_.current&&(_.current.value=``)}function b(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!a&&o&&s())}return(0,G.jsxs)(`div`,{className:`border-t border-separator/60 p-3 sm:p-4`,children:[(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-surface-secondary/80`,children:[n.length?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:n.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex max-w-[14rem] items-center gap-2 rounded-xl bg-surface px-1.5 py-1.5 text-caption text-foreground`,children:[e.kind===`image`&&e.dataUrl?(0,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-8 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(Wi,{size:14})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,G.jsx)(`span`,{className:`mono text-muted`,children:BQ(e.size)})]}),(0,G.jsx)(`button`,{type:`button`,className:`grid size-6 shrink-0 place-items-center rounded-md text-muted hover:bg-surface-secondary hover:text-foreground`,"aria-label":g(`chatAttachRemove`),onClick:()=>r(n.filter(t=>t.id!==e.id)),children:(0,G.jsx)(oo,{size:12})})]},e.id))}):null,(0,G.jsx)(mL,{fullWidth:!0,rows:3,className:`min-h-20 resize-none border-0 bg-transparent px-3.5 py-3 text-body leading-[1.65] shadow-none focus-visible:ring-0`,value:e,onChange:e=>t(e.target.value),onKeyDown:b,placeholder:g(`promptPlaceholder`),"aria-label":g(`prompt`),disabled:i||a}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pb-2 pt-0.5`,children:[(0,G.jsx)(`input`,{ref:_,type:`file`,className:`hidden`,multiple:!0,accept:`.txt,.md,.json,.csv,.yml,.yaml,.toml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.go,.rs,.sh,.sql,.png,.jpg,.jpeg,.gif,.webp,text/*,image/png,image/jpeg,image/gif,image/webp,application/json`,onChange:e=>void y(e.target.files)}),(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-7 min-w-7 shrink-0`,"aria-label":g(`chatAttach`),isDisabled:i||a,onPress:()=>_.current?.click(),children:(0,G.jsx)(wa,{size:15})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,G.jsx)(HQ,{ariaLabel:g(`account`),value:l,onChange:u,options:d,isDisabled:i||a,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,G.jsx)(HQ,{ariaLabel:g(`model`),value:f,onChange:p,placeholder:g(h?`requesting`:`model`),options:m,isDisabled:i||a||h||!m.length,className:`w-auto max-w-[10.5rem] min-w-0`}),a?(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`secondary`,className:`size-7 shrink-0 rounded-full`,"aria-label":g(`chatTryStop`),onPress:c,children:(0,G.jsx)(Ha,{size:13,weight:`fill`})}):(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,className:`size-7 shrink-0 rounded-full transition-transform active:scale-95 disabled:active:scale-100`,"aria-label":g(`chatTrySend`),isDisabled:!o||i,onPress:s,children:(0,G.jsx)(ga,{size:13,weight:`fill`})})]})]}),(0,G.jsx)(`p`,{className:`mt-2 px-1 text-caption leading-5 text-muted`,children:g(`chatTryHelper`)})]})}function WQ({text:e,streaming:t,defaultOpen:n}){let{t:r}=DH(),[i,a]=(0,v.useState)(!!n),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(0);if((0,v.useEffect)(()=>{t?a(!1):n!=null&&a(!!n)},[t,n]),(0,v.useEffect)(()=>{if(!t)return;let e=Date.now();s(0);let n=window.setInterval(()=>{let t=Math.floor((Date.now()-e)/1e3);s(t),c.current=t},250);return()=>window.clearInterval(n)},[t]),(0,v.useEffect)(()=>{!t&&o===0&&c.current>0&&s(c.current)},[t,o]),!e&&!t)return null;let l=iY(),u=t?o:o||c.current;return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl`,children:[(0,G.jsx)(`button`,{type:`button`,className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-surface-secondary px-2.5 py-1 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(wi,{size:12,className:`shrink-0 text-muted ${l?``:`animate-spin`}`}),(0,G.jsx)(`span`,{className:l?``:`access-thinking-shimmer`,children:r(`thinkingWorking`)}),(0,G.jsxs)(`span`,{className:`mono text-muted/80`,children:[o,`s`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fi,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{children:r(`thinkingDone`)}),u>0?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingElapsed`,{n:u})}):null,!u&&e?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingChars`,{count:e.length})}):null]})}),i&&e?(0,G.jsx)(`div`,{className:`mt-1.5`,children:(0,G.jsx)(`pre`,{className:`max-h-52 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-surface-secondary/80 px-3 py-2 text-caption leading-5 text-muted`,children:e})}):null]})}function GQ(e,t){return t(e===`running`?`toolCallRunning`:e===`error`?`toolCallError`:`toolCallSuccess`)}function KQ({status:e}){return e===`running`?(0,G.jsx)(Ia,{size:12,className:`animate-spin text-muted`}):e===`error`?(0,G.jsx)(io,{size:12,weight:`fill`,className:`text-danger`}):(0,G.jsx)(bi,{size:12,weight:`fill`,className:`text-success`})}function qQ(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function JQ({call:e,forceOpen:t}){let{t:n}=DH(),[r,i]=(0,v.useState)(e.status===`error`||!!t),[a,o]=(0,v.useState)(!1),s=(0,v.useMemo)(()=>qQ(e.arguments||``),[e.arguments]);(0,v.useEffect)(()=>{e.status===`error`&&i(!0)},[e.status]),(0,v.useEffect)(()=>{t&&i(!0)},[t]);async function c(){s&&(await NQ(s),o(!0),window.setTimeout(()=>o(!1),1200))}return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2 py-1.5 text-left`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,G.jsx)(fi,{size:11,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-caption font-medium text-foreground`,children:e.name||n(`toolCallUntitled`)}),(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted`,children:[(0,G.jsx)(KQ,{status:e.status}),GQ(e.status,n)]})]}),r?(0,G.jsxs)(`div`,{className:`space-y-1.5 px-2 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:n(`toolCallArgs`)}),(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-caption text-muted hover:bg-surface-secondary hover:text-foreground`,onClick:e=>{e.stopPropagation(),c()},children:[(0,G.jsx)(Ai,{size:12}),n(a?`copied`:`copy`)]})]}),(0,G.jsx)(`pre`,{className:`mono max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary/80 px-2.5 py-2 text-caption leading-5 text-muted`,children:s||n(`toolCallArgsEmpty`)})]}):null]})}function YQ({calls:e}){let{t}=DH(),n=e.some(e=>e.status===`error`),r=e.some(e=>e.status===`running`),[i,a]=(0,v.useState)(n||r||e.length===1);return(0,v.useEffect)(()=>{(n||r)&&a(!0)},[n,r]),e.length?e.length===1?(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary/70`,children:(0,G.jsx)(JQ,{call:e[0],forceOpen:e[0].status===`error`})}):(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-secondary/70`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,G.jsx)(fi,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(`toolCallGroup`,{n:e.length})}),r?(0,G.jsx)(Ia,{size:12,className:`animate-spin`}):null]}),i?(0,G.jsx)(`div`,{className:`space-y-0.5 border-t border-separator/40 px-0.5 py-1`,children:e.map(e=>(0,G.jsx)(JQ,{call:e},`${e.index}-${e.id||e.name}`))}):null]}):null}function XQ({message:e}){return e.attachments?.length?(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.attachments.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-xl bg-surface/70 px-1.5 py-1 text-caption text-muted`,children:[e.kind===`image`&&e.dataUrl?(0,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-7 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface`,children:(0,G.jsx)(Wi,{size:12})}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))}):null}function ZQ({message:e}){let{t}=DH(),n=e.usage;if(!n||n.credits==null)return null;let r=n.prompt_tokens,i=n.completion_tokens,a=typeof r==`number`||typeof i==`number`?t(`chatTryUsageTokens`,{prompt:sX(r??0),completion:sX(i??0)}):``;return(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`chatTryUsageFoot`,{tokens:a,amount:_X(n.credits)}):t(`chatTryCreditsUsed`,{amount:_X(n.credits)})})}function QQ({message:e}){let{t}=DH(),[n,r]=(0,v.useState)(!1);if(e.role===`user`)return(0,G.jsx)(`div`,{className:`ml-auto max-w-[92%] sm:max-w-[78%]`,children:(0,G.jsxs)(`div`,{className:`rounded-2xl rounded-br-md bg-surface-secondary/90 px-3.5 py-2.5`,children:[e.content?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground`,children:e.content}):null,(0,G.jsx)(XQ,{message:e})]})});let i=e.status===`streaming`&&!e.content&&!e.reasoning&&!e.toolCalls?.length,a=!!e.content&&e.status===`done`;async function o(){e.content&&(await NQ(e.content),r(!0),window.setTimeout(()=>r(!1),1200))}return(0,G.jsxs)(`div`,{className:`max-w-[96%] space-y-2 sm:max-w-[88%]`,children:[e.reasoning||e.status===`streaming`?(0,G.jsx)(WQ,{text:e.reasoning||``,streaming:e.status===`streaming`&&(!e.content||!!e.reasoning),defaultOpen:e.reasoningOpen}):null,e.toolCalls?.length?(0,G.jsx)(YQ,{calls:e.toolCalls}):null,e.status===`error`?(0,G.jsx)(bU,{status:`danger`,title:t(`requestFailed`),description:e.error||``}):i?(0,G.jsxs)(`div`,{className:`space-y-2.5 pt-0.5`,children:[(0,G.jsx)(qP,{className:`h-3 w-28 rounded-md`}),(0,G.jsx)(qP,{className:`h-3 w-full rounded-md`}),(0,G.jsx)(qP,{className:`h-3 w-[86%] rounded-md`}),(0,G.jsx)(qP,{className:`h-3 w-[68%] rounded-md`})]}):e.content?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words rounded-2xl rounded-tl-md bg-surface-secondary/50 px-3.5 py-2.5 text-body leading-[1.65] text-foreground`,children:e.content}):null,a||e.usage&&e.usage.credits!=null?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-0.5`,children:[a?(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-caption text-muted hover:text-foreground`,onClick:()=>void o(),children:[(0,G.jsx)(Ai,{size:12}),t(n?`copied`:`copy`)]}):null,(0,G.jsx)(ZQ,{message:e})]}):null]})}function $Q({messages:e,busy:t,onLoadDemo:n}){let{t:r}=DH(),i=(0,v.useRef)(null);return(0,v.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[e,t]),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-5 sm:px-6 sm:py-6`,"aria-live":`polite`,"aria-busy":t,children:[e.length?(0,G.jsx)(`div`,{className:`space-y-5`,children:e.map(e=>(0,G.jsx)(QQ,{message:e},e.id))}):(0,G.jsx)(pQ,{className:`min-h-64`,title:r(`chatTryEmptyTitle`),hint:r(`chatTryEmptyHint`),action:n?(0,G.jsx)(`button`,{type:`button`,className:`rounded-lg bg-surface-secondary px-3 py-1.5 text-caption font-medium text-foreground hover:bg-surface-tertiary`,onClick:n,children:r(`chatDemoLoad`)}):void 0}),(0,G.jsx)(`div`,{ref:i})]})}function e$({open:e,onOpenChange:t,chatPath:n,prompt:r,onPromptChange:i,onTest:a,requestState:o,elapsedMs:s,output:c,responseStatus:l,curl:u,copiedCurl:d,onCopyCurl:f,canSend:p}){let{t:m}=DH();return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,G.jsx)(`h3`,{className:`text-body font-semibold`,children:m(`accessTabApi`)}),(0,G.jsx)(X,{size:`sm`,variant:e?`ghost`:`secondary`,onPress:()=>t(!e),children:m(e?`rawApiHide`:`rawApiShow`)})]}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:m(`nativeApiHint`)})]}),e?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:(0,G.jsxs)(`div`,{className:`grid xl:grid-cols-[minmax(440px,.92fr)_minmax(0,1.08fr)]`,children:[(0,G.jsxs)(`div`,{className:`xl:border-r xl:border-separator`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 sm:px-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:m(`requestBuilder`)}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-caption text-muted`,children:[`POST `,n]})]}),(0,G.jsxs)(`div`,{className:`space-y-5 px-5 pb-5 sm:px-6 sm:pb-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:m(`prompt`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:r.length})]}),(0,G.jsx)(mL,{fullWidth:!0,rows:9,className:`min-h-56 resize-y px-4 py-3 text-body leading-6`,value:r,onChange:e=>i(e.target.value),placeholder:m(`promptPlaceholder`),"aria-label":m(`prompt`)}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:m(`promptHelper`)})]}),(0,G.jsxs)(X,{fullWidth:!0,isPending:o===`loading`,isDisabled:!p,onPress:a,children:[(0,G.jsx)(ga,{size:16}),m(o===`loading`?`requesting`:`sendRequest`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex min-h-[480px] min-w-0 flex-col bg-surface-secondary/40`,"aria-live":`polite`,"aria-busy":o===`loading`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-4 px-5 py-3.5 sm:px-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:m(`responseInspector`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:m(`responseInspectorHint`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s===null?null:(0,G.jsxs)(`span`,{className:`mono flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(Ei,{size:12}),s,` ms`]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:o===`success`?`success`:o===`error`?`danger`:void 0,children:l})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-5 pb-5 sm:px-6 sm:pb-6`,children:o===`idle`?(0,G.jsx)(pQ,{className:`min-h-72`,icon:(0,G.jsx)(oi,{size:21}),title:m(`responseEmptyTitle`),hint:m(`responseEmptyHint`)}):o===`loading`?(0,G.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,G.jsx)(qP,{className:`h-3 w-32 rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-full rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-[88%] rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-[72%] rounded-lg`}),(0,G.jsx)(qP,{className:`mt-7 h-3 w-[92%] rounded-lg`}),(0,G.jsx)(qP,{className:`h-3 w-[64%] rounded-lg`})]}):o===`error`?(0,G.jsx)(`div`,{className:`space-y-3`,children:(0,G.jsx)(bU,{status:`danger`,title:m(`requestFailed`),description:c})}):(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-caption font-medium text-success`,children:[(0,G.jsx)(bi,{size:15,weight:`fill`}),m(`responseReceived`)]}),(0,G.jsx)(`pre`,{className:`mono overflow-x-auto whitespace-pre-wrap break-words text-caption leading-6 text-muted`,children:c})]})})]})]})}),(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-3.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:m(`curlExample`)}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,children:m(`curlGeneratedHint`)})]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:f,children:[(0,G.jsx)(MQ,{copied:d}),m(d?`copied`:`copy`)]})]}),(0,G.jsx)(`pre`,{className:`mono max-h-80 overflow-auto whitespace-pre-wrap px-5 pb-5 text-caption leading-6 text-muted`,children:u})]})]}):null]})}function t$(e,t){let n=t.filter(e=>e.kind===`text`),r=t.filter(e=>e.kind===`image`&&e.dataUrl),i=e.trim();for(let e of n){let t=e.text??``;i=`${i}${i?` `:``}--- file: ${e.name} ---\n${t}`}if(!r.length)return i;let a=[];i&&a.push({type:`text`,text:i});for(let e of r)a.push({type:`image_url`,image_url:{url:e.dataUrl}});return a}function n$(e,t){let n=[];for(let t of e)if(!(t.status===`error`&&t.role===`assistant`&&!t.content)){if(t.role===`user`){n.push({role:`user`,content:t$(t.content,t.attachments||[])});continue}t.content&&n.push({role:`assistant`,content:t.content})}return[...n,t]}var r$=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNkYPhfz0AEYBxVSF+FABJADveWkH6aAAAAAElFTkSuQmCC`;function i$(){return[{id:`demo-user-1`,role:`user`,content:`Summarize the attached screenshot and look up the endpoint.`,attachments:[{id:`demo-img-1`,name:`screenshot.png`,mime:`image/png`,kind:`image`,dataUrl:r$,size:2048},{id:`demo-txt-1`,name:`notes.md`,mime:`text/markdown`,kind:`text`,text:`# notes placeholder`,size:128}],status:`done`},{id:`demo-assistant-1`,role:`assistant`,content:`The screenshot shows the Access playground. I looked up the chat completions route and drafted a short summary below.`,reasoning:`User attached a UI screenshot and a notes file. @@ -93,4 +93,4 @@ Keep the reply short and ops-console toned.`,toolCalls:[{index:0,id:`call_demo_l -H "Authorization: Bearer $CLI2API_API_KEY" \\ -H ${o$(`Content-Type: application/json`)}${L?` \\ -H ${o$(`X-Qoder-Account: ${L}`)}`:``} \\ - -d ${o$(JSON.stringify(V))}`,[d,V,L]);if(n&&!t)return(0,G.jsx)(bY,{});async function oe(e,t){await NQ(e),I(t),window.setTimeout(()=>I(``),1100)}async function se(){let e=performance.now();N(`loading`),ee(null),j(``);try{let e=await ZH(V.model,V.messages[0].content,L||void 0);j(JSON.stringify(e,null,2)),N(`success`)}catch(e){j(e instanceof Error?e.message:String(e)),N(`error`)}finally{ee(Math.round(performance.now()-e))}}function ce(){k.current?.abort(),k.current=null}function le(e,t){E(n=>n.map(n=>{if(n.id!==e)return n;let r=typeof t==`function`?t(n):t;return{...n,...r}}))}async function ue(){let e=x.trim();if(!e&&!C.length||!re||z||D===`loading`)return;ce();let t=new AbortController;k.current=t;let n=C,r={id:s$(`user`),role:`user`,content:e,attachments:n,status:`done`},i=s$(`assistant`),a={id:i,role:`assistant`,content:``,status:`streaming`},o=T;E([...o,r,a]),S(``),w([]),O(`loading`);let s=n$(o,{role:`user`,content:t$(e,n)});try{await eU(re,s,L||void 0,{signal:t.signal,onContent:(e,t)=>le(i,{content:t}),onReasoning:(e,t)=>le(i,{reasoning:t}),onToolCalls:e=>le(i,{toolCalls:c$(e,!0)}),onUsage:e=>le(i,{usage:e})}),le(i,e=>({status:`done`,toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),O(`success`)}catch(e){if(t.signal.aborted){le(i,e=>({status:`done`,toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),O(`success`);return}le(i,{status:`error`,error:e instanceof Error?e.message:String(e)}),O(`error`)}finally{k.current===t&&(k.current=null)}}let de=e(M===`success`?`requestComplete`:M===`error`?`requestFailed`:M===`loading`?`requesting`:`requestIdle`),fe=l$()!=null,pe=[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ni,{size:14,className:`text-muted`})},...s.map(t=>({id:t.id,textValue:`${t.name||t.id} ${EZ(t.provider,t.region,e)}`,label:t.name||t.id,hint:EZ(t.provider,t.region,e),icon:(0,G.jsx)(zZ,{provider:t.provider,size:14})}))],me=s.length||!fe?pe:[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ni,{size:14,className:`text-muted`})},{id:`demo-wb`,textValue:`wb-demo WorkBuddy`,label:`wb-demo`,hint:`WorkBuddy`}],he=R.map(t=>{let n=fX(t),r=pX(t),i=t.display_name||t.id,a=r?e(`modelFree`):n,o=t.provider||t.owned_by||``;return{id:t.id,textValue:`${i} ${t.id} ${o} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,o,a].filter(Boolean).join(` · `)}}),ge=he.length||!fe?he:d$.map(t=>{let n=fX(t),r=pX(t),i=t.display_name||t.id,a=r?e(`modelFree`):n;return{id:t.id,textValue:`${i} ${t.id} ${t.provider} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,t.provider,a].filter(Boolean).join(` · `)}}),_e=!!((x.trim()||C.length)&&re&&!z&&(s.length||fe));function ve(){E(i$()),O(`idle`)}return(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`apiPlayground`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`apiPlaygroundHint`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":ie.length?`ok`:void 0}),(0,G.jsx)(`span`,{children:e(`readyAccounts`,{ready:ie.length,total:s.length})})]})]}),(0,G.jsx)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3 sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:e(`baseUrl`)}),(0,G.jsx)(`code`,{className:`mono mt-0.5 block truncate text-body font-medium text-foreground`,children:l})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e(`copyBaseUrl`),onPress:()=>void oe(l,`base`),children:(0,G.jsx)(MQ,{copied:F===`base`,size:15})}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:ie.length?`success`:`warning`,children:ie.length?e(`endpointReady`):e(`degraded`)})]})]})}),s.length?null:(0,G.jsx)(`p`,{className:`px-1 text-caption text-muted`,children:e(`noAccountsForTest`)}),B?(0,G.jsx)(`p`,{className:`px-1 text-caption text-danger`,children:B}):null,(0,G.jsx)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:(0,G.jsxs)(`div`,{className:`flex min-h-[640px] flex-col md:min-h-[72vh]`,children:[(0,G.jsx)($Q,{messages:T,busy:D===`loading`,onLoadDemo:ve}),(0,G.jsx)(UQ,{value:x,onChange:S,attachments:C,onAttachmentsChange:w,disabled:!s.length&&l$()==null,streaming:D===`loading`,canSend:_e,onSend:()=>void ue(),onStop:ce,accountValue:L||`auto`,onAccountChange:e=>h(e===`auto`?``:e),accountOptions:me,modelValue:re,onModelChange:p,modelOptions:ge,modelsLoading:z})]})}),(0,G.jsx)(e$,{open:r,onOpenChange:i,chatPath:u,prompt:y,onPromptChange:b,onTest:()=>void se(),requestState:M,elapsedMs:P,output:A,responseStatus:de,curl:ae,copiedCurl:F===`curl`,onCopyCurl:()=>void oe(ae,`curl`),canSend:!!(y.trim()&&re&&!z)}),(0,G.jsx)(IQ,{access:t?.access})]})}function p$(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=eY.context(()=>{eY.matchMedia().add(`(prefers-reduced-motion: no-preference)`,()=>{let e=eY.utils.toArray(`.meter__fill`);e.length&&eY.from(e,{scaleX:0,transformOrigin:`left center`,duration:tY.calm,ease:nY.emphasized,stagger:rY.base,clearProps:`transform,transformOrigin`})})},t);return()=>n.revert()},[e])}function m$(e,t,n,r,i,a){return[e.has_add_on&&e.add_on_available!==!1?`${n} ${AX(e.add_on_used)} / ${AX(e.add_on_total)} ${e.add_on_unit||`credits`}`:``,e.has_resource_package&&e.resource_package_available!==!1?`${r} ${t} ${AX(e.resource_package_remaining)} ${e.resource_package_unit||`credits`}`:``,a===`workbuddy`?RX(e,i):``].filter(Boolean)}function h$({window:e,t,extra:n}){let r=Math.round(e.percentage??0),i=IX(e,t),a=t(`quotaUsedPercent`,{n:r}),o=LX(e.reset_at,t),s=`${i} · ${a}${o?` · ${o}`:``}`,c=jX(e),l=MX(e),u=l===`danger`?`danger`:l===`warn`?`warning`:`success`;return(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{className:`block w-full min-w-0`,children:(0,G.jsxs)(`div`,{className:`w-full min-w-0 cursor-help`,children:[(0,G.jsxs)(OV,{className:`account-meter account-meter--window w-full`,color:u,size:`md`,minValue:0,maxValue:100,value:Math.round(c*100),"aria-label":i,valueLabel:s,children:[(0,G.jsxs)(OV.Output,{className:`flex w-full items-baseline justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:i}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-foreground/70`,children:a})]}),(0,G.jsx)(OV.Track,{children:(0,G.jsx)(OV.Fill,{})})]}),o?(0,G.jsx)(`div`,{className:`mt-1 text-caption leading-4 text-muted`,children:o}):null]})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`div`,{children:s}),n?.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function g$({quota:e,t,label:n,usedLabel:r,remainingLabel:i,addOnLabel:a,resourcePackageLabel:o,exceededLabel:s,provider:c}){let l=e.unit||`credits`,u=`${AX(e.used)} / ${AX(e.total)}`,d=`${AX(e.remaining)}`,f=m$(e,i,a,o,t,c),p=NX(e),m=c===`codex`?FX(e.plan):``,h=jX(e),g=MX(e),_=g===`danger`?`danger`:g===`warn`?`warning`:`success`,y=(0,v.useRef)(null);p$(y);let b=`${r} ${u} ${l} · ${i} ${d} ${l}${f.length?` · ${f.join(` · `)}`:``}`;return p.length>0?(0,G.jsxs)(`div`,{ref:y,className:`account-quota-windows flex w-full min-w-0 flex-col gap-3`,children:[m?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`text-muted`,children:t(`quotaPlan`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}):null,p.map((e,n)=>(0,G.jsx)(`div`,{className:`w-full min-w-0`,children:(0,G.jsx)(h$,{window:e,t,extra:n===0?f:void 0})},e.id||String(n)))]}):(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`div`,{ref:y,className:`w-full cursor-help`,children:(0,G.jsxs)(OV,{className:`account-meter w-full`,color:_,size:`md`,minValue:0,maxValue:100,value:Math.round(h*100),"aria-label":n,valueLabel:b,children:[(0,G.jsxs)(OV.Output,{className:`flex w-full items-baseline justify-between text-caption`,children:[(0,G.jsxs)(`span`,{className:`text-body font-semibold leading-5 text-foreground tabular-nums`,children:[e.exceeded?(0,G.jsx)(`span`,{className:`mr-1.5 text-danger`,children:s}):null,d,(0,G.jsx)(`span`,{className:`ml-1 text-caption font-normal text-foreground/60`,children:l})]}),(0,G.jsxs)(`span`,{className:`mono text-foreground/55`,children:[r,` `,u]})]}),(0,G.jsx)(OV.Track,{children:(0,G.jsx)(OV.Fill,{})})]})})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsxs)(`div`,{children:[r,` `,u,` `,l]}),(0,G.jsxs)(`div`,{children:[i,` `,d,` `,l]}),f.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function _$({state:e,stateCopy:t,t:n}){let r=(0,v.useRef)(null),i=OX(e),a=kX(e);return(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=eY.context(()=>{let e=eY.utils.toArray(`[data-runtime-seg]`),t=e.filter((e,t)=>tt>=i),r=eY.matchMedia();r.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(t,{scaleY:1,autoAlpha:1}),eY.set(n,{scaleY:.32,autoAlpha:.45})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.set(e,{transformOrigin:`center bottom`}),eY.to(n,{scaleY:.32,autoAlpha:.45,duration:tY.fast,ease:nY.out,overwrite:!0}),eY.to(t,{scaleY:1,autoAlpha:1,duration:tY.base,ease:nY.out,stagger:{amount:.08,from:`start`},overwrite:!0})})},e);return()=>t.revert()},[i,e]),(0,G.jsxs)(`div`,{ref:r,className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-caption font-medium text-foreground/75`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":a===`muted`?void 0:a===`warn`?`warn`:a}),(0,G.jsx)(`span`,{children:n(`runtimeState`)})]}),(0,G.jsx)(`div`,{className:`runtime-meter min-w-[80px] flex-1`,role:`meter`,"aria-label":n(`runtimeState`),"aria-valuemin":0,"aria-valuemax":12,"aria-valuenow":i,"aria-valuetext":t,children:Array.from({length:12},(e,t)=>(0,G.jsx)(`span`,{"data-runtime-seg":!0,"data-on":t{if(!M&&!N&&P.length===0)return;let e=window.setInterval(()=>A(e=>e+1),1e3);return()=>window.clearInterval(e)},[M,N,P.length]);let ee=v$(j,j===`dead`?N:M,o),F=j===`hot`||j===`ready`?`success`:j===`cooling`?`warning`:j===`quota_exhausted`||j===`login`||j===`unavailable`||j===`dead`||j===`auth_failed`?`danger`:void 0,I=e.last_error||e.lastError,L=e.last_error_kind||e.kind,te=EZ(e.provider,e.region,o),R=e.last_checkin_status,z=R===`success`?`checkinRecordSuccess`:R===`already`?`checkinRecordAlready`:R===`skipped`?`checkinRecordSkipped`:R===`error`?`checkinRecordFailed`:`lastCheckinNone`;return(0,v.useLayoutEffect)(()=>{let e=T.current;if(!e)return;let t=k.current;if(k.current=j,!t||t===j)return;let n=eY.context(()=>{let t=eY.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(e,{scale:1,autoAlpha:1})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.fromTo(e,{scale:.94,autoAlpha:.65},{scale:1,autoAlpha:1,duration:.2,ease:`power2.out`,overwrite:!0})})},e);return()=>n.revert()},[j]),(0,v.useLayoutEffect)(()=>{let e=E.current;if(!e||!n)return;let t=eY.context(()=>{let t=eY.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(e,{autoAlpha:1,y:0})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.fromTo(e,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:.2,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[n]),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,"data-state":j,className:`account-card overflow-hidden p-0`,children:[(0,G.jsxs)(zw.Header,{className:`flex-row items-start justify-between gap-2.5 px-4 pt-3.5 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary`,children:(0,G.jsx)(zZ,{provider:e.provider,size:20})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(zw.Title,{className:`truncate text-body leading-5`,children:e.name||e.id}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted`,children:te})]}),(0,G.jsx)(zw.Description,{className:`mono truncate text-caption leading-4 text-foreground/60`,title:`${e.id}${e.remote_uid?` · UID ${e.remote_uid}`:``}`,children:e.remote_uid?`UID ${e.remote_uid}`:e.id})]})]}),(0,G.jsxs)(`div`,{className:`flex max-w-[48%] shrink-0 flex-wrap justify-end gap-1.5`,children:[(0,G.jsx)(`span`,{ref:T,children:P.length&&j===`cooling`?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:F,children:ee})})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:TX(t)})]},e))]})})]}):(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:F,children:ee})}),P.length&&j!==`cooling`?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`warning`,children:o(`partialCooling`)})})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:TX(t)})]},e))]})})]}):null]})]}),(0,G.jsxs)(zw.Content,{className:`gap-1.5 px-4 pb-3`,children:[(0,G.jsx)(_$,{state:j,stateCopy:ee,t:o}),e.quota?(0,G.jsx)(g$,{quota:e.quota,t:o,label:o(`quota`),usedLabel:o(`quotaUsed`),remainingLabel:o(`quotaRemaining`),addOnLabel:o(`quotaAddOn`),resourcePackageLabel:o(`quotaResourcePackage`),exceededLabel:o(`quotaExceeded`),provider:e.provider}):(0,G.jsx)(`span`,{className:`text-caption text-foreground/65`,children:o(j===`hot`||j===`ready`||j===`loading`||j===`starting`?`quotaLoading`:`quotaUnavailable`)}),I?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(`div`,{className:`flex w-full cursor-help gap-2 rounded-lg bg-surface-secondary p-2 text-left text-caption leading-5 text-foreground`,children:[(0,G.jsx)(io,{size:14,className:`mt-0.5 shrink-0 text-danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[L?(0,G.jsx)(`div`,{className:`mono mb-0.5 truncate text-caption opacity-75`,children:L}):null,(0,G.jsx)(`p`,{className:`break-words line-clamp-3`,children:I})]})]})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`max-w-md whitespace-pre-wrap break-words`,children:[L?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption opacity-75`,children:L}):null,I]})})]}):null]}),n&&e.enabled?(0,G.jsxs)(`section`,{ref:E,className:`grid gap-3 bg-surface-secondary/55 px-3 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`oauthDeviceFlow`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:e.provider===`codex`?o(`wizardCodexBrowserLead`):o(`qoderLoginHint`)}),(0,G.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.provider===`codex`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(X,{size:`sm`,isPending:t===`device`,onPress:()=>c(`cli`),children:[(0,G.jsx)(Oa,{size:14}),o(`startCodexCliLogin`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>c(`chatgpt`),children:[(0,G.jsx)(Oa,{size:14}),o(`startCodexChatGPTLogin`)]})]}):(0,G.jsxs)(X,{size:`sm`,isPending:t===`device`,onPress:()=>c(),children:[(0,G.jsx)(Oa,{size:14}),o(`startBrowserLogin`)]})}),(e.provider===`trae`||e.provider===`codex`||e.provider===`devin`)&&f&&d?(0,G.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:o(`wizardCallbackLead`)}),(0,G.jsx)(mL,{className:`h-24 w-full resize-none font-mono text-caption leading-5`,value:u||``,onChange:e=>d(e.target.value),placeholder:o(`wizardCallbackPh`),"aria-label":o(`wizardCallbackPh`)}),(0,G.jsx)(X,{size:`sm`,variant:`secondary`,isPending:t===`callback`,onPress:f,children:o(`wizardSubmitCallback`)})]}):null]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`patFallback`)}),(0,G.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,G.jsxs)(hL,{className:`flex-1`,type:`password`,value:a,onChange:s,children:[(0,G.jsx)(sR,{className:`sr-only`,children:o(`pat`)}),(0,G.jsx)(lL,{placeholder:o(`pasteToken`),"aria-label":o(`pat`)})]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:l,children:[(0,G.jsx)(na,{size:14}),o(`usePat`)]})]})]}),r||i?(0,G.jsxs)(`div`,{className:`text-caption`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:o(`authUrl`)}),(0,G.jsx)(`code`,{className:`mono block break-all text-foreground`,children:r}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:()=>window.open(r,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Qr,{size:14}),o(`openAuthUrl`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>{NQ(r).then(e=>{e&&(O(!0),window.setTimeout(()=>O(!1),1100))})},children:[(0,G.jsx)(MQ,{copied:D}),o(D?`copied`:`copy`)]})]})]}):null,i?(0,G.jsx)(`p`,{className:`mt-1 text-muted`,children:i}):null]}):null]}):null,b?(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-t border-separator px-4 py-2 text-caption text-muted`,children:[(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`lastCheckin`)}),(0,G.jsx)(`span`,{className:R===`error`?`text-danger`:``,children:o(z)})]})}),(0,G.jsxs)(eL.Content,{children:[e.last_checkin_at?new Date(e.last_checkin_at).toLocaleString():o(`lastCheckinNone`),e.last_checkin_msg?` · ${e.last_checkin_msg}`:``]})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`autoCheckin`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-foreground/55`,children:e.checkin_time||_}),(0,G.jsx)(fQ,{isSelected:!!e.auto_checkin,isDisabled:!!t,ariaLabel:o(`autoCheckin`),onChange:e=>y?.(e)})]})}),(0,G.jsx)(eL.Content,{children:e.checkin_time?o(`checkinCustom`):o(`checkinInherit`)})]})]}):null,(0,G.jsxs)(zw.Footer,{className:`flex flex-wrap items-center gap-1.5 bg-surface-secondary px-4 py-2`,children:[m?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`secondary`,isPending:t===`refresh`,onPress:m,"aria-label":o(`refreshAccount`),children:(0,G.jsx)(Jr,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`refreshAccount`)})]}):null,(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:n?`secondary`:`ghost`,isDisabled:!e.enabled,onPress:C,"aria-label":o(`authentication`),children:(0,G.jsx)(na,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`authentication`)})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:w,"aria-label":o(`accountModels`),children:(0,G.jsx)(Mi,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`accountModels`)})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:S,"aria-label":o(`editAccount`),children:(0,G.jsx)(ba,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`editAccount`)})]}),b?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:!e.enabled||!!t,isPending:t===`checkin`,onPress:b,"aria-label":o(`checkinNow`),children:(0,G.jsx)(ci,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`checkinNow`)})]}):null,(0,G.jsxs)(nV,{children:[(0,G.jsx)(nV.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`secondary`,"aria-label":o(`more`),children:(0,G.jsx)(Ii,{size:16})})}),(0,G.jsx)(nV.Popover,{placement:`bottom end`,children:(0,G.jsxs)(nV.Menu,{"aria-label":o(`more`),onAction:e=>{e===`export`&&p(),e===`checkin-records`&&x?.(),e===`delete`&&h()},children:[e.auth_type===`none`?null:(0,G.jsxs)(nV.Item,{id:`export`,textValue:o(`export`),children:[(0,G.jsx)(Oi,{size:15}),o(`export`)]}),x?(0,G.jsxs)(nV.Item,{id:`checkin-records`,textValue:o(`checkinRecords`),children:[(0,G.jsx)(ca,{size:15}),o(`checkinRecords`)]}):null,(0,G.jsxs)(nV.Item,{id:`delete`,textValue:o(`delete`),className:`text-danger`,children:[(0,G.jsx)(Ja,{size:15}),o(`delete`)]})]})})]}),(0,G.jsx)(`div`,{className:`ml-auto flex shrink-0 flex-nowrap items-center gap-3 whitespace-nowrap`,children:(0,G.jsx)(fQ,{isSelected:!!e.enabled,isDisabled:t===`toggle`,ariaLabel:e.enabled?o(`disable`):o(`enable`),label:e.enabled?o(`enabledState`):o(`disabled`),onChange:g})})]})]})}function b$(e,t){return e.status===`success`?{label:t(`checkinRecordSuccess`),color:`success`}:e.status===`already`?{label:t(`checkinRecordAlready`),color:`warning`}:e.status===`skipped`?{label:t(`checkinRecordSkipped`),color:`default`}:{label:t(`checkinRecordFailed`),color:`danger`}}function x$(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function S$({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.useState)(``),l=e?.id||``,u=t(`checkinRecordsTitle`,{name:e?.name||e?.id||``});async function d(){if(l){o(!0),c(``);try{let e=await iU(l);i(e.data||[])}catch(e){i([]),c(e instanceof Error?e.message:String(e))}finally{o(!1)}}}return(0,v.useEffect)(()=>{l&&d()},[l]),(0,G.jsx)(Z.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:u}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`checkinRecordsHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`px-5 pb-2`,children:[s?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(bU,{title:s})}):null,a?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)($,{className:`h-16 w-full`}),(0,G.jsx)($,{className:`h-16 w-full`}),(0,G.jsx)($,{className:`h-16 w-full`})]}):r.length?(0,G.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(e=>{let n=b$(e,t);return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0`,"data-state":e.status===`error`?`warn`:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:n.color,children:n.label}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:x$(e.created_at)})]}),(0,G.jsx)(`p`,{className:`mt-1 break-words text-caption leading-5 text-foreground/75`,children:e.message||`—`})]})]},e.id)})}):(0,G.jsx)(pQ,{className:`min-h-44 rounded-3xl bg-surface-secondary`,title:t(`checkinRecordsEmpty`),hint:t(`checkinRecordsHint`)})]}),(0,G.jsxs)(Z.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t(`checkinRecordsCount`,{count:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:a,onPress:()=>void d(),children:[(0,G.jsx)(Jr,{size:14}),t(`refresh`)]})]})]})]})})})})}function C$(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function w$({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=e?.id||``,f=t(`accountModelsTitle`,{name:e?.name||e?.id||``}),p=e?EZ(e.provider,e.region,t):``;async function m(e=!1){if(d){e?c(!0):(o(!0),i([])),u(``);try{let t=await(e?qH(d):GH(d));i(t.data||[])}catch(e){i([]),u(e instanceof Error?e.message:String(e))}finally{o(!1),c(!1)}}}return(0,v.useEffect)(()=>{if(!d)return;let e=!1;return GH(d).then(t=>{e||(i(t.data||[]),u(``),o(!1))}).catch(t=>{e||(i([]),u(t instanceof Error?t.message:String(t)),o(!1))}),()=>{e=!0}},[d]),(0,G.jsx)(Z.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:f}),(0,G.jsx)(`p`,{className:`mt-1 text-caption font-normal leading-5 text-muted`,children:t(`accountModelsHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(zZ,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:p}),(0,G.jsx)(`span`,{className:`text-border`,children:`·`}),(0,G.jsx)(`span`,{className:`mono`,children:e.id})]}):null]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`px-5 pb-2`,children:[l?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(bU,{title:t(`accountModelsError`,{msg:l})})}):null,a||s?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)($,{className:`h-14 w-full`}),(0,G.jsx)($,{className:`h-14 w-full`}),(0,G.jsx)($,{className:`h-14 w-full`})]}):r.length?(0,G.jsx)(`ul`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(n=>{let r=n.provider||n.owned_by||e?.provider||`qoder`,i=C$(n),a=fX(n),o=pX(n);return(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":n.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.display_name||n.id}),o?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,a?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a}):null,n.stale?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`warning`,children:t(`fallback`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:n.id}),i?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:i})}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5 text-caption text-muted`,children:[(0,G.jsx)(zZ,{provider:r,size:12}),(0,G.jsx)(`span`,{children:r})]})]},n.id)})}):(0,G.jsx)(pQ,{className:`min-h-48 rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(Mi,{size:22}),title:t(`accountModelsEmpty`),hint:t(`noModelsYet`)})]}),(0,G.jsxs)(Z.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`refreshing`):t(`shownTotal`,{shown:r.length,total:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:s,onPress:()=>void m(!0),children:[(0,G.jsx)(Jr,{size:14}),t(s?`refreshing`:`refresh`)]})]})]})]})})})})}var T$=`w-28`;function E$({label:e,hint:t,labelWidthClass:n=T$,htmlFor:r,align:i=`center`,children:a}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex gap-3 ${i===`start`?`items-start`:`items-center`}`,children:[(0,G.jsx)(sR,{htmlFor:r,className:`${n} shrink-0 ${i===`start`?`pt-2`:``} text-body font-medium text-foreground`,children:e}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 [&_[data-slot=input]]:w-full [&_[data-slot=textarea]]:w-full`,children:a})]}),t?(0,G.jsx)(`p`,{className:`mt-1.5 pl-[7.75rem] text-caption leading-5 text-muted`,children:t}):null]})}function D$({catalog:e,selected:t,onChange:n,isDisabled:r,t:i}){let[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(t),l=(0,v.useMemo)(()=>new Set(t),[t]),u=(0,v.useMemo)(()=>{let t=new Set(s),n=a.trim().toLowerCase(),r=(e||[]).filter(e=>!n||e.toLowerCase().includes(n));return[...r.filter(e=>t.has(e)),...r.filter(e=>!t.has(e))]},[e,a,s]),d=(0,v.useMemo)(()=>{if(!e)return[];let n=new Set(e);return t.filter(e=>!n.has(e))},[e,t]),f=e?.length??0,p=t.filter(e=>!d.includes(e)).length;function m(e){o(e),c(t)}function h(e,r){n(r?[...t,e]:t.filter(t=>t!==e))}function g(){let e=new Set(t);u.forEach(t=>e.add(t)),n([...e])}function _(){let e=new Set(u);n(t.filter(t=>!e.has(t)))}return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(aR,{"aria-label":i(`modelPickerSearch`),value:a,onChange:m,isDisabled:r,className:`min-w-0 flex-1 basis-48`,children:(0,G.jsxs)(aR.Group,{children:[(0,G.jsx)(aR.SearchIcon,{}),(0,G.jsx)(aR.Input,{placeholder:i(`modelPickerSearch`)}),(0,G.jsx)(aR.ClearButton,{})]})}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-caption text-muted`,children:i(`modelPickerCount`,{selected:p,total:f})}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,isDisabled:r||u.length===0,onPress:g,children:[(0,G.jsx)(Si,{size:14}),i(`modelPickerSelectAll`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,isDisabled:r||t.length===0,onPress:_,children:[(0,G.jsx)(Ra,{size:14}),i(`modelPickerClear`)]})]})]}),(0,G.jsxs)(`div`,{className:`max-h-[300px] overflow-y-auto overscroll-contain rounded-lg bg-surface-secondary p-1`,children:[e===null?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(`refreshing`)}):null,d.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md px-2.5 py-1.5`,children:[(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-body text-muted line-through`,children:e}),(0,G.jsx)(`span`,{className:`shrink-0 text-caption text-warning`,children:i(`modelPickerOffline`)}),(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:r,"aria-label":i(`modelPickerRemove`,{model:e}),onPress:()=>h(e,!1),children:(0,G.jsx)(oo,{size:14})})]},`offline-${e}`)),u.map(e=>(0,G.jsx)(aT,{isSelected:l.has(e),isDisabled:r,onChange:t=>h(e,t),className:`flex w-full cursor-pointer rounded-md px-2.5 py-1.5 transition-colors hover:bg-default`,children:(0,G.jsxs)(aT.Content,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,G.jsx)(aT.Control,{children:(0,G.jsx)(aT.Indicator,{})}),(0,G.jsx)(`span`,{className:`mono min-w-0 truncate text-body text-foreground`,children:e})]})},e)),e!==null&&u.length===0?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(f===0?`noAccountModels`:`modelPickerNoMatch`)}):null]})]})}function O$(e){let[t,n]=(0,v.useState)(e);e&&!t&&n(!0);let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(e);return(0,v.useLayoutEffect)(()=>{let t=r.current,o=i.current;if(!t||!o)return;if(a.current){a.current=!1;return}eY.killTweensOf([t,o]);let s=t.getBoundingClientRect().height;if(e){eY.set(t,{overflow:`hidden`});let e=t.scrollHeight;eY.fromTo(t,{height:s===e?0:s},{height:e,duration:aY(tY.base),ease:nY.out,onComplete:()=>eY.set(t,{clearProps:`height,overflow`})}),eY.fromTo(o,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:aY(tY.base),ease:nY.out})}else eY.set(t,{overflow:`hidden`,height:s}),eY.to(o,{autoAlpha:0,y:-4,duration:aY(tY.fast),ease:nY.inOut}),eY.to(t,{height:0,duration:aY(tY.fast+.04),ease:nY.inOut,onComplete:()=>n(!1)});return()=>{eY.killTweensOf([t,o])}},[e,t]),{mounted:t,outerRef:r,innerRef:i}}function k$({account:e,checkinDefaultTime:t,checkinTimezone:n,busy:r,t:i,onClose:a,onSave:o}){let[s,c]=(0,v.useState)(e?.name||``),[l,u]=(0,v.useState)(e?.max_inflight??4),[d,f]=(0,v.useState)(e?.priority??50),[p,m]=(0,v.useState)(e?.proxy_url||``),[h,g]=(0,v.useState)(!!e?.drop_system_prompt),[_,y]=(0,v.useState)(Object.entries(e?.model_aliases||{}).map(([e,t])=>({alias:e,model:t}))),[b,x]=(0,v.useState)({alias:``,model:``}),[S,C]=(0,v.useState)(!!e?.models_restricted),[w,T]=(0,v.useState)(e?.enabled_models||[]),{mounted:E,outerRef:D,innerRef:O}=O$(S),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!e?.checkin_time),[N,P]=(0,v.useState)(e?.checkin_time||null),[ee,F]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!e?.id)return;let t=!1;return GH(e.id).then(e=>{t||A(e.data||[])}).catch(()=>{t||A([])}),()=>{t=!0}},[e?.id]);let I=i(`editAccountTitle`,{name:e?.name||e?.id||``}),L=e?EZ(e.provider,e.region,i):``;async function te(n){n?.preventDefault();let r=s.trim();if(!r){F(i(`accountNameRequired`));return}if(!Number.isInteger(l)||l<1||l>32){F(i(`maxInflightInvalid`));return}if(!Number.isInteger(d)||d<1||d>100){F(i(`priorityInvalid`));return}if(t!==void 0&&!j&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(N??t)){F(i(`checkinTimeInvalid`));return}F(``);try{await o({name:r,max_inflight:l,priority:d,proxy_url:p.trim(),checkin_time:t===void 0?void 0:j?``:N??t,drop_system_prompt:e?.provider===`workbuddy`?h:void 0,model_aliases:Object.fromEntries(_.filter(e=>e.alias.trim()&&e.model.trim()).map(e=>[e.alias.trim(),e.model.trim()])),enabled_models:S?w:[],set_model_routing:!0}),a()}catch(e){F(e instanceof Error?e.message:String(e))}}return(0,G.jsx)(Z.Root,{isOpen:!!e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:I}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:i(`editAccountHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(zZ,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:L})]})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.id})]}):null]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsxs)(Z.Body,{className:`px-6 pb-2 pt-1`,children:[ee?(0,G.jsxs)(RB,{status:`danger`,className:`mb-4`,children:[(0,G.jsx)(RB.Indicator,{}),(0,G.jsx)(RB.Content,{children:(0,G.jsx)(RB.Title,{children:ee})})]}):null,(0,G.jsxs)(FB,{className:`space-y-4`,onSubmit:e=>void te(e),children:[(0,G.jsx)(E$,{label:i(`accountName`),children:(0,G.jsx)(lL,{value:s,onChange:e=>c(e.target.value),placeholder:i(`wizardNamePh`),"aria-label":i(`accountName`),disabled:r,autoFocus:!0})}),(0,G.jsx)(E$,{label:i(`maxInflight`),hint:i(`maxInflightHint`),children:(0,G.jsx)(sV,{value:l,onChange:e=>u(e??4),minValue:1,maxValue:32,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":i(`maxInflight`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:i(`priority`),hint:i(`priorityHint`),children:(0,G.jsx)(sV,{value:d,onChange:e=>f(e??50),minValue:1,maxValue:100,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":i(`priority`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:i(`proxyUrl`),hint:i(`proxyUrlHint`),children:(0,G.jsx)(lL,{value:p,onChange:e=>m(e.target.value),placeholder:i(`proxyUrlPlaceholder`),"aria-label":i(`proxyUrl`),disabled:r})}),e?.provider===`workbuddy`?(0,G.jsx)(E$,{label:i(`dropSystemPrompt`),hint:i(`dropSystemPromptHint`),children:(0,G.jsx)(fQ,{isSelected:h,isDisabled:r,ariaLabel:i(`dropSystemPrompt`),onChange:g})}):null,(0,G.jsx)(E$,{align:`start`,label:i(`accountModelAliases`),hint:i(`accountModelAliasesHint`),children:(0,G.jsxs)(`div`,{className:`space-y-2`,children:[_.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono min-w-0 truncate text-body`,children:[e.alias,` → `,e.model]}),(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:r,onPress:()=>y(t=>t.filter(t=>t.alias!==e.alias)),children:i(`modelAliasRemove`)})]},e.alias)),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,G.jsx)(lL,{"aria-label":i(`modelAliasName`),value:b.alias,onChange:e=>x(t=>({...t,alias:e.target.value})),placeholder:i(`modelAliasPlaceholder`),disabled:r}),(0,G.jsx)(lL,{"aria-label":i(`modelAliasTarget`),value:b.model,onChange:e=>x(t=>({...t,model:e.target.value})),placeholder:i(`accountModelAliasTargetPlaceholder`),disabled:r}),(0,G.jsx)(X,{size:`sm`,variant:`secondary`,isDisabled:r||!b.alias.trim()||!b.model.trim(),onPress:()=>{y(e=>[...e.filter(e=>e.alias!==b.alias.trim()),{alias:b.alias.trim(),model:b.model.trim()}]),x({alias:``,model:``})},children:i(`modelAliasAdd`)})]})]})}),(0,G.jsxs)(`section`,{className:`space-y-3 pt-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:i(`enabledModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:i(`enabledModelsHint`)})]}),(0,G.jsx)(fQ,{isSelected:S,isDisabled:r,ariaLabel:i(`restrictModels`),label:i(S?`restrictModels`:`allModels`),onChange:C})]}),E?(0,G.jsx)(`div`,{ref:D,children:(0,G.jsx)(`div`,{ref:O,children:(0,G.jsx)(D$,{catalog:k?k.map(e=>e.id):null,selected:w,onChange:T,isDisabled:r,t:i})})}):null]}),t===void 0?null:(0,G.jsx)(E$,{label:i(`autoCheckinTime`),hint:i(`checkinScheduleHint`),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(fQ,{isSelected:j,isDisabled:r,onChange:M,ariaLabel:i(`checkinInherit`),label:i(`checkinInherit`)}),(0,G.jsxs)(`p`,{className:`text-caption text-muted`,children:[i(`checkinDefaultValue`,{time:t}),` · `,(0,G.jsx)(`span`,{className:`mono`,children:n})]}),j?null:(0,G.jsx)(lL,{type:`time`,value:N??t,onChange:e=>P(e.target.value),"aria-label":i(`autoCheckinTime`),disabled:r,required:!0})]})})]})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,G.jsx)(X,{variant:`ghost`,isDisabled:r,onPress:a,children:i(`cancel`)}),(0,G.jsx)(X,{isPending:r,onPress:()=>void te(),children:i(`save`)})]})]})})})})}var A$={1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-3`};function j$({options:e,value:t,onChange:n,ariaLabel:r,columns:i=2,className:a=``}){let o=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=eY.context(()=>{let e=eY.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(`[data-option-tile]`,{autoAlpha:1,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.fromTo(`[data-option-tile]`,{autoAlpha:0,y:8},{autoAlpha:1,y:0,duration:.32,stagger:.035,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[e.length]),(0,G.jsx)(`div`,{ref:o,role:`radiogroup`,"aria-label":r,className:`grid gap-3 ${A$[i]} ${a}`.trim(),children:e.map(e=>{let r=e.value===t;return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-option-tile":``,"data-selected":r||void 0,disabled:e.disabled,title:e.hint,onClick:()=>n(e.value),className:`flex h-16 min-w-0 items-center gap-3 rounded-xl bg-surface shadow-surface px-4 text-left transition-colors hover:bg-surface-secondary disabled:cursor-not-allowed disabled:opacity-50 data-selected:border-accent data-selected:bg-accent-soft`,children:[e.icon?(0,G.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground [&_svg]:size-[18px]`,children:e.icon}):null,(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body font-medium leading-5 text-foreground`,children:e.label})]},e.value)})})}function M$(e,t){let n={...e},r=n.format===`workbuddy-accounts`||Array.isArray(n.accounts);return n.format?r&&(n.format=`workbuddy-accounts`):n.format=r?`workbuddy-accounts`:`workbuddy-oauth-v1`,{...n,name:t.name?.trim()||n.name,enabled:t.enabled??!0,provider:`workbuddy`,region:t.region,max_inflight:t.max_inflight??4,priority:t.priority??50,drop_system_prompt:t.drop_system_prompt??!0,...t.proxy_url!=null&&t.proxy_url!==``?{proxy_url:t.proxy_url}:{}}}function N$(e,t){let n=typeof e?.succeeded==`number`?e.succeeded:e?.id||e?1:0,r=typeof e?.failed==`number`?e.failed:0,i=(e?.errors||[]).slice(0,3).map(e=>e.message||`index ${e.index}`).filter(Boolean).join(`; `),a;return a=r>0?t(`accountImportPartial`).replace(`{ok}`,String(n)).replace(`{fail}`,String(r))+(i?` — ${i}`:``):n>1?t(`accountImportBatch`).replace(`{n}`,String(n)):t(`accountImported`),{succeeded:n,failed:r,message:a}}async function P$(e,t){return sU(M$(e,t))}var F$={global:`Global`,cn:`CN`},I$={"qoder-global":`accountTypeQoderGlobal`,"qoder-cn":`accountTypeQoderCN`,"workbuddy-cn":`accountTypeWorkBuddyCN`,"workbuddy-global":`accountTypeWorkBuddyGlobal`,"trae-cn":`accountTypeTraeCN`,"devin-global":`accountTypeDevinGlobal`,"command-global":`accountTypeCommandGlobal`,"codex-global":`accountTypeCodexGlobal`,"zhipu-cn":`accountTypeZhipuCN`,"qwenwork-global":`accountTypeQwenworkGlobal`,"qwenwork-cn":`accountTypeQwenworkCN`,"kimi-cn":`accountTypeKimiCN`},L$={"qoder-global":`accountTypeQoderGlobalHint`,"qoder-cn":`accountTypeQoderCNHint`,"workbuddy-cn":`accountTypeWorkBuddyCNHint`,"workbuddy-global":`accountTypeWorkBuddyGlobalHint`,"trae-cn":`accountTypeTraeCNHint`,"devin-global":`accountTypeDevinGlobalHint`,"command-global":`accountTypeCommandGlobalHint`,"codex-global":`accountTypeCodexGlobalHint`,"zhipu-cn":`accountTypeZhipuCNHint`,"qwenwork-global":`accountTypeQwenworkGlobalHint`,"qwenwork-cn":`accountTypeQwenworkCNHint`,"kimi-cn":`accountTypeKimiCNHint`};function R$({ariaLabel:e}){return(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,"aria-busy":`true`,"aria-label":e,children:Array.from({length:6},(e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-xl bg-surface-secondary px-3 py-2.5`,children:[(0,G.jsx)(qP,{className:`size-7 shrink-0 rounded-lg`}),(0,G.jsx)(qP,{className:`h-4 w-20 rounded-lg`})]},t))})}async function z$(){let e=(await tU().catch(()=>null))?.data||[],t=[];for(let n of e)for(let e of n.regions)t.push({id:`${n.id}-${e.id}`,provider:n.id,region:e.id,descriptor:n});return t}function B$(e,t){let n=I$[e.id];if(n){let e=t(n);if(e!==n)return e}let r=e.descriptor.regions.find(t=>t.id===e.region)?.label||F$[e.region]||``,i=e.descriptor.regions.length>1&&r?` ${r}`:``;return`${e.descriptor.label}${i}`.trim()}function V$(e,t){if(!e)return``;let n=L$[e.id];if(!n)return``;let r=t(n);return r===n?``:r}function H$({phase:e,busy:t,tab:n,forTab:r}){return e===`done`?(0,G.jsx)(bi,{size:16,className:`text-success`}):t&&n===r?(0,G.jsx)(uY,{size:16,loading:!0}):null}var U$=90,W$=2e3;function G$({isOpen:e,onClose:t,onAdded:n}){let{t:r}=DH(),[i,a]=(0,v.useState)(`method`),[o,s]=(0,v.useState)(`browser`),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(4),[x,S]=(0,v.useState)(50),[C,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(`payg`),[N,P]=(0,v.useState)(``),[ee,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(``),[te,R]=(0,v.useState)(`idle`),[z,B]=(0,v.useState)(``),[ne,re]=(0,v.useState)(``),[ie,V]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(``),[se,ce]=(0,v.useState)(`cli`),le=(0,v.useRef)(null),ue=(0,v.useRef)(null),de=(0,v.useRef)(null),fe=(0,v.useRef)(``),pe=(0,v.useRef)(null),me=(0,v.useRef)(null);function he(){pe.current!==null&&(window.clearTimeout(pe.current),pe.current=null)}(0,v.useEffect)(()=>()=>he(),[]),(0,v.useEffect)(()=>{if(!e)return;let t=!1;return p(!0),d([]),l(``),z$().then(e=>{t||(d(e),l(e[0]?.id||``),s(`browser`))}).finally(()=>{t||p(!1)}),()=>{t=!0}},[e]);let ge=u.find(e=>e.id===c),_e=!!ge&&!f,ve=ge?.descriptor.capabilities?.pat_login!==!1,ye=ge?.descriptor.capabilities?.import_export!==!1,be=ge?.descriptor.capabilities?.browser_login!==!1,xe=ge?.provider===`workbuddy`,Se=ge?.provider===`trae`||ge?.provider===`devin`||ge?.provider===`codex`,Ce=te===`busy`||te===`polling`,we=!!fe.current||Ce,Te=te===`done`,Ee=V$(ge,r);(0,v.useEffect)(()=>{o===`pat`&&!ve&&s(`browser`),o===`import`&&!ye&&s(`browser`)},[ye,ve,o]),(0,v.useEffect)(()=>{be||(ve?s(`pat`):ye&&s(`import`))},[be,ye,ve]);function De(){return!Number.isInteger(y)||y<1||y>32?4:y}function Oe(){return!Number.isInteger(x)||x<1||x>100?50:x}function ke(){return{max_inflight:De(),priority:Oe(),drop_system_prompt:xe?C:ge?.provider!==`kimi`,proxy_url:T.trim()}}function Ae(){he(),a(`method`),s(`browser`),l(``),d([]),p(!1),_(``),b(4),S(50),w(!0),E(``),O(``),A(``),M(`payg`),P(``),F(``),L(``),h(!1),R(`idle`),B(``),re(``),V(!1),oe(``),ce(`cli`),fe.current=``}function je(){Ce||(Ae(),t())}function Me(){Ae(),t()}(0,v.useLayoutEffect)(()=>{let t=le.current;if(e||(de.current=null),!t||!e)return;let n=eY.context(()=>{let e=eY.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(t,{autoAlpha:1,x:0,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=de.current,n=e&&e!==i?i===`login`?1:-1:0;eY.fromTo(t,{autoAlpha:0,x:20*n,y:n?0:12},{autoAlpha:1,x:0,y:0,duration:tY.slow,ease:nY.out,overwrite:!0}),n&&ue.current&&eY.fromTo(ue.current,{autoAlpha:0,y:6},{autoAlpha:1,y:0,duration:tY.base,ease:nY.out,overwrite:!0})})},t);return de.current=i,()=>n.revert()},[e,i]);function Ne(e){if(Ce||!_e)return;let t=u.find(t=>t.id===e);l(e),s(t?.provider===`zhipu`?`pat`:`browser`),B(``),a(`login`)}async function Pe(){if(fe.current)return fe.current;if(!ge)throw Error(r(`accountTypeHint`));let e=ke(),t=await nU(g.trim()||r(`account`),ge.provider,ge.region,e),n=t?.id||t?.data?.id;if(!n)throw Error(`create account returned no id`);return fe.current=n,n}async function Fe(){B(``),re(``);try{R(`busy`);let e=await Pe();B(r(`wizardStartingSession`)),R(`polling`);let t=await RH(e,ge?.provider===`codex`?se:void 0);t.authUrl&&re(t.authUrl),B(r(`wizardWaitingBrowser`));for(let t=0;t{pe.current=window.setTimeout(e,W$)});let n=(await zH(e)).login||{};if(n.message&&B(n.message),n.status===`ok`)break;if(n.status===`error`)throw Error(n.message||`login failed`);if(t===89)throw Error(r(`wizardLoginTimeout`))}R(`done`),B(r(`wizardAccountReady`)),n(),window.setTimeout(Me,900)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}async function Ie(){let e=ae.trim();if(!e){B(r(`wizardCallbackPh`));return}try{R(`busy`);let t=await Pe();he(),await BH(t,e),R(`done`),B(r(`wizardAccountReady`)),n(),window.setTimeout(Me,900)}catch(e){R(`polling`),B(e instanceof Error?e.message:String(e))}}async function Le(){let e=N.trim();if(!e){B(r(`zhipuKeyRequired`));return}if(!ge){B(r(`accountTypeHint`));return}B(``);try{R(`busy`);let t=ke();await sU({format:`zhipu-key-v1`,api_key:e,mode:j,organization:j===`coding`?ee.trim():``,project:j===`coding`?I.trim():``,name:g.trim()||r(`accountTypeZhipuCN`),enabled:!0,provider:ge.provider,region:ge.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}),R(`done`),B(r(`wizardAccountReady`)),n(),window.setTimeout(Me,700)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}async function Re(){let e=D.trim();if(!e){B(r(`pastePatFirst`));return}B(``);try{R(`busy`);let t=await Pe();B(r(`wizardStartingSession`)),await VH(e,t),R(`done`),B(r(`patDone`)),n(),window.setTimeout(Me,700)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}async function ze(){B(``);let e;try{e=JSON.parse(k)}catch{B(r(`wizardBadJson`));return}if(!e||typeof e!=`object`){B(r(`wizardBadJson`));return}if(!ge){B(r(`accountTypeHint`));return}if(ge.provider===`qoder`&&(typeof e.user_blob!=`string`||typeof e.machine_id!=`string`)){B(r(`wizardBadJson`));return}let t=ke(),i;ge.provider===`workbuddy`?i=M$(e,{region:ge.region===`global`?`global`:`cn`,name:g.trim()||void 0,enabled:!0,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}):(e.format||(ge.descriptor.id===`trae`?e.format=`trae-oauth-v1`:ge.descriptor.id===`devin`?e.format=`devin-session-v1`:ge.descriptor.id===`command`?e.format=`command-key-v1`:ge.descriptor.id===`qwenwork`?e.format=`qwenwork-oauth-v1`:e.format=`qoder-native-v1`),i={...e,name:g.trim()||e.name,enabled:!0,provider:ge.provider,region:ge.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt});try{R(`busy`);let{failed:e,message:t}=N$(await sU(i),r);R(`done`),B(t),n(),window.setTimeout(Me,e>0?1600:700)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}function Be(){me.current?.click()}function Ve(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>A(String(n.result||``)),n.readAsText(t),e.target.value=``}let He=e=>Ce&&o===e,Ue=u.map(e=>({value:e.id,label:B$(e,r),hint:V$(e,r),icon:(0,G.jsx)(zZ,{provider:e.provider,size:18}),disabled:we})),We=ge?.provider===`zhipu`,Ge=[ge?.descriptor.capabilities?.browser_login===!1?null:{value:`browser`,label:r(`tabBrowser`),icon:(0,G.jsx)(Oa,{size:16})},ve?{value:`pat`,label:r(`tabPat`),icon:(0,G.jsx)(na,{size:16})}:null,ye?{value:`import`,label:r(`tabImport`),icon:(0,G.jsx)(Hi,{size:16})}:null].filter(Boolean),Ke=r(o===`browser`?ge?.provider===`codex`?`wizardCodexBrowserLead`:`wizardBrowserLead`:o===`pat`?ge?.provider===`command`?`wizardPatLeadCommand`:ge?.region===`cn`&&ge?.provider===`qoder`?`wizardPatLeadCN`:`wizardPatLead`:`wizardImportLead`);return(0,G.jsx)(Z.Root,{isOpen:e,onOpenChange:e=>{e||je()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,isDismissable:!Ce,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,className:`sm:max-w-4xl`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`relative items-center justify-center px-12 pt-5 text-center`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:r(`addAccountTitle`)}),(0,G.jsx)(`p`,{ref:ue,className:`mt-1 text-caption font-normal leading-5 text-muted`,children:i===`method`?r(`addAccountDesc`):Ee||r(`addAccountDesc`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":r(`close`),className:`absolute right-4 top-4 grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsx)(Z.Body,{className:`px-6 pb-2`,children:(0,G.jsx)(`div`,{ref:le,children:i===`method`?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(`section`,{className:`space-y-2.5`,children:f?(0,G.jsx)(R$,{ariaLabel:r(`accountType`)}):_e?(0,G.jsx)(j$,{ariaLabel:r(`accountType`),columns:2,value:``,onChange:Ne,options:Ue}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:r(`accountTypeHint`)})})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-surface-secondary/45 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:(0,G.jsx)(zZ,{provider:ge?.provider,size:18})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-medium text-foreground`,children:ge?B$(ge,r):r(`accountType`)}),(0,G.jsx)(`div`,{className:`truncate text-caption text-muted`,children:Ee})]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>a(`method`),isDisabled:Ce||!!fe.current,children:[(0,G.jsx)(ui,{size:12}),r(`wizardBack`)]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,G.jsx)(E$,{label:r(`accountName`),children:(0,G.jsx)(lL,{value:g,onChange:e=>_(e.target.value),placeholder:r(`wizardNamePh`),"aria-label":r(`accountName`),disabled:we,autoFocus:!0})}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-expanded":m,className:`inline-flex items-center gap-1 text-caption font-medium text-muted transition-colors hover:text-foreground`,children:[(0,G.jsx)(fi,{size:12,className:`transition-transform duration-200 ${m?`rotate-90`:``}`}),r(`wizardAdvanced`)]}),m?(0,G.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-secondary px-3.5 py-3.5`,children:[(0,G.jsx)(E$,{label:r(`maxInflight`),hint:r(`maxInflightHint`),children:(0,G.jsx)(sV,{value:y,onChange:e=>b(e??4),minValue:1,maxValue:32,isDisabled:we,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":r(`maxInflight`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:r(`priority`),hint:r(`priorityHint`),children:(0,G.jsx)(sV,{value:x,onChange:e=>S(e??50),minValue:1,maxValue:100,isDisabled:we,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":r(`priority`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:r(`proxyUrl`),hint:r(`proxyUrlHint`),children:(0,G.jsx)(lL,{value:T,onChange:e=>E(e.target.value),placeholder:r(`proxyUrlPlaceholder`),"aria-label":r(`proxyUrl`),disabled:we})}),xe?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:r(`dropSystemPrompt`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:r(`dropSystemPromptCreateHint`)})]}),(0,G.jsx)(fQ,{isSelected:C,isDisabled:we,ariaLabel:r(`dropSystemPrompt`),onChange:w})]}):null]}):null]}),We?(0,G.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-body font-medium text-muted`,children:r(`zhipuAccountMode`)}),(0,G.jsx)(j$,{ariaLabel:r(`zhipuAccountMode`),columns:2,value:j,onChange:e=>{Ce||M(e)},options:[{value:`payg`,label:r(`zhipuModePayg`),hint:r(`zhipuModePaygHint`),disabled:Ce},{value:`coding`,label:r(`zhipuModeCoding`),hint:r(`zhipuModeCodingHint`),disabled:Ce}]})]}),(0,G.jsx)(E$,{label:r(`zhipuApiKey`),children:(0,G.jsx)(lL,{type:`password`,value:N,onChange:e=>P(e.target.value),placeholder:r(`zhipuApiKeyPh`),"aria-label":r(`zhipuApiKey`),disabled:Ce})}),j===`coding`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E$,{label:r(`zhipuOrganization`),children:(0,G.jsx)(lL,{value:ee,onChange:e=>F(e.target.value),placeholder:r(`zhipuOrganizationPh`),"aria-label":r(`zhipuOrganization`),disabled:Ce})}),(0,G.jsx)(E$,{label:r(`zhipuProject`),children:(0,G.jsx)(lL,{value:I,onChange:e=>L(e.target.value),placeholder:r(`zhipuProjectPh`),"aria-label":r(`zhipuProject`),disabled:Ce})})]}):null,z?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:te===`busy`,onPress:()=>void Le(),isDisabled:Te,children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(na,{size:15}),r(`zhipuCreate`)]})})]}):null,We?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qX,{className:`mt-3`,value:o,onChange:e=>{!Ce&&e!==o&&(s(e),B(``),re(``),V(!1))},ariaLabel:r(`authentication`),options:Ge.map(e=>({id:e.value,label:e.label,icon:e.icon}))}),(0,G.jsx)(`p`,{className:`mt-2 min-h-5 text-caption leading-5 text-muted`,children:Ke}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-col gap-4`,children:o===`browser`?(0,G.jsxs)(G.Fragment,{children:[ge?.provider===`codex`?(0,G.jsx)(j$,{ariaLabel:r(`codexLoginMethod`),columns:2,value:se,onChange:e=>{Ce||ce(e)},options:[{value:`cli`,label:r(`codexLoginCli`),hint:r(`codexLoginCliHint`),disabled:Ce||!!fe.current},{value:`chatgpt`,label:r(`codexLoginChatGPT`),hint:r(`codexLoginChatGPTHint`),disabled:Ce||!!fe.current}]}):null,ne?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(H$,{phase:te,busy:Ce,tab:o,forTab:`browser`}),(0,G.jsx)(`span`,{className:`text-muted`,children:z||r(`loginOpenMsg`)})]}),(0,G.jsx)(`code`,{className:`mono mt-2 block break-all text-caption leading-5 text-foreground`,children:ne}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:()=>window.open(ne,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Qr,{size:14}),r(`openAuthUrl`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>{NQ(ne).then(e=>{e&&(V(!0),window.setTimeout(()=>V(!1),1100))})},children:[(0,G.jsx)(MQ,{copied:ie}),r(ie?`copied`:`copy`)]})]})]}):null,z&&!ne?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,Se?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:r(`wizardCallbackLead`)}),(0,G.jsx)(mL,{className:`h-28 w-full resize-none font-mono text-caption leading-5`,value:ae,onChange:e=>oe(e.target.value),placeholder:r(`wizardCallbackPh`),"aria-label":r(`wizardCallbackPh`),disabled:Te}),(0,G.jsx)(X,{className:`w-full`,variant:`secondary`,isPending:te===`busy`&&!!ae.trim(),onPress:()=>void Ie(),isDisabled:Te,children:r(`wizardSubmitCallback`)})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:He(`browser`),onPress:()=>void Fe(),children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Oa,{size:15}),r(`wizardStartBrowser`)]})})]}):o===`pat`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E$,{label:r(`tabPat`),children:(0,G.jsx)(lL,{type:`password`,value:D,onChange:e=>O(e.target.value),placeholder:r(`wizardPatPh`),"aria-label":r(`wizardPatPh`),disabled:Ce})}),z?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:He(`pat`),onPress:()=>void Re(),children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`patDone`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(na,{size:15}),r(`wizardCreateAndLogin`)]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:`JSON`}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:Be,isDisabled:Ce,children:[(0,G.jsx)(Hi,{size:13}),r(`wizardChooseFile`)]}),(0,G.jsx)(`input`,{ref:me,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:Ve})]}),(0,G.jsx)(mL,{className:`min-h-32 font-mono text-caption`,value:k,onChange:e=>A(e.target.value),placeholder:r(`wizardImportPh`),"aria-label":r(`tabImport`),disabled:Ce}),z?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:He(`import`),onPress:()=>void ze(),children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`accountImported`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Hi,{size:15}),r(`importCredential`)]})})]})})]})]})})}),(0,G.jsx)(Z.Footer,{className:`justify-end px-5 pb-5`,children:(0,G.jsx)(X,{variant:`ghost`,onPress:je,isDisabled:Ce,children:r(`cancel`)})})]})})})})}function K$({isOpen:e,title:t,description:n,confirmLabel:r,cancelLabel:i,closeLabel:a,isPending:o,status:s=`danger`,confirmVariant:c=`danger`,onClose:l,onConfirm:u}){return(0,G.jsx)(wS.Root,{isOpen:e,onOpenChange:e=>{!e&&!o&&l()},children:(0,G.jsx)(wS.Backdrop,{variant:`blur`,isDismissable:!o,children:(0,G.jsx)(wS.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(wS.Dialog,{children:[(0,G.jsxs)(wS.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(wS.Icon,{status:s}),(0,G.jsx)(`div`,{children:(0,G.jsx)(wS.Heading,{children:t})})]}),(0,G.jsx)(wS.CloseTrigger,{isDisabled:o,"aria-label":a})]}),(0,G.jsx)(wS.Body,{children:(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:n})}),(0,G.jsxs)(wS.Footer,{children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:l,children:i}),(0,G.jsx)(X,{size:`sm`,variant:c,isPending:o,onPress:u,children:r})]})]})})})})}function q$(e,t){return e===`region_mixed`?t(`batchImportRegionMixed`):e===`region_unknown`?t(`batchImportRegionUnknown`):e===`unknown_format`?t(`batchImportUnknownFormat`):``}function J$({isOpen:e,detection:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let[s,c]=(0,v.useState)(`cn`);(0,v.useEffect)(()=>{t&&(t.region===`cn`||t.region===`global`?c(t.region):c(`cn`))},[t]);let l=!!t?.batchImportSupported,u=t?.provider,d=t?.format||i(`batchImportFormatUnknown`),f=u?TZ(u,i):i(`batchImportProviderUnknown`),p=(t?.warnings||[]).map(e=>q$(e,i)).filter(Boolean);return(0,G.jsx)(Z.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`sm`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,24rem)] sm:mx-0`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:i(`batchImportConfirmTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`batchImportConfirmHint`,{file:n}):i(`batchImportConfirmHintNoFile`)})]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-4 px-5 pb-2`,children:[(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[u?(0,G.jsx)(zZ,{provider:u,size:18}):null,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:f}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:d})]})]})}),l?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:i(`batchImportRegion`)}),(0,G.jsx)(qX,{value:s,onChange:e=>{(e===`cn`||e===`global`)&&c(e)},ariaLabel:i(`batchImportRegion`),options:[{id:`cn`,label:i(`accountTypeWorkBuddyCN`)},{id:`global`,label:i(`accountTypeWorkBuddyGlobal`)}]}),t?.regionAmbiguous?(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(`batchImportRegionPickHint`)}):null]}):(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`batchImportProviderUnsupported`)}),p.length?(0,G.jsx)(`ul`,{className:`space-y-1 text-caption leading-5 text-muted`,children:p.map(e=>(0,G.jsx)(`li`,{children:e},e))}):null]}),(0,G.jsxs)(Z.Footer,{className:`flex-col-reverse gap-2 px-5 pb-5 sm:flex-row sm:justify-end`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(l?`cancel`:`close`)}),l?(0,G.jsx)(X,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,onPress:()=>o(s),children:i(`batchImportConfirmAction`)}):null]})]})})})})}var Y$={"workbuddy-accounts":`workbuddy`,"workbuddy-oauth-v1":`workbuddy`,"qoder-native-v1":`qoder`,"trae-oauth-v1":`trae`,"devin-session-v1":`devin`,"command-key-v1":`command`,"codex-oauth-v1":`codex`,"zhipu-key-v1":`zhipu`,"qwenwork-oauth-v1":`qwenwork`},X$=[`codebuddy.cn`],Z$=[`workbuddy.ai`,`workbuddy.com`];function Q$(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $$(e){let t=[],n=e=>{typeof e==`string`&&e.trim()&&t.push(e.trim().toLowerCase())};if(n(e.domain),Q$(e.account)&&n(e.account.domain),Array.isArray(e.accounts))for(let t of e.accounts)Q$(t)&&n(t.domain);return t}function e1(e){return X$.some(t=>e.includes(t))}function t1(e){return Z$.some(t=>e.includes(t))}function n1(e){return typeof e.accessToken==`string`||typeof e.access_token==`string`||typeof e.refreshToken==`string`||typeof e.refresh_token==`string`}function r1(e){return Q$(e)?n1(e)||typeof e.domain==`string`||typeof e.uid==`string`:!1}function i1(e){let t=$$(e);if(t.length===0)return{region:`cn`,ambiguous:!0,warning:`region_unknown`};let n=t.some(e1),r=t.some(t1);return n&&r?{region:null,ambiguous:!0,warning:`region_mixed`}:n?{region:`cn`,ambiguous:!1}:r?{region:`global`,ambiguous:!1}:{region:`cn`,ambiguous:!0,warning:`region_unknown`}}function a1(e){return Array.isArray(e.accounts)&&e.accounts.some(r1)?{format:`workbuddy-accounts`,provider:`workbuddy`,confidence:`medium`}:(typeof e.user_blob==`string`||typeof e.userBlob==`string`)&&(typeof e.machine_id==`string`||typeof e.machineId==`string`)?{format:`qoder-native-v1`,provider:`qoder`,confidence:`medium`}:typeof e.session_token==`string`||typeof e.sessionToken==`string`?{format:`devin-session-v1`,provider:`devin`,confidence:`low`}:n1(e)||Q$(e.account)&&n1(e.account)||Q$(e.auth)?{format:`workbuddy-oauth-v1`,provider:`workbuddy`,confidence:`low`}:typeof e.api_key==`string`||typeof e.apiKey==`string`?typeof e.organization==`string`||typeof e.project==`string`?{format:`zhipu-key-v1`,provider:`zhipu`,confidence:`low`}:{format:`command-key-v1`,provider:`command`,confidence:`low`}:{format:null,provider:null,confidence:`low`}}function o1(e){if(!Q$(e))return{format:null,provider:null,region:null,regionAmbiguous:!0,confidence:`low`,warnings:[`not_object`],batchImportSupported:!1};let t=[],n=typeof e.format==`string`?e.format.trim():``,r=n||null,i=r?Y$[r]??null:null,a=r&&i?`high`:`low`;if(!i){let o=a1(e);r||=o.format,i=o.provider,a=n&&!Y$[n]?`low`:o.confidence,n&&!Y$[n]&&t.push(`unknown_format`)}i===`workbuddy`&&Array.isArray(e.accounts)&&(r=`workbuddy-accounts`);let o=null,s=!1;if(i===`workbuddy`){let n=i1(e);o=n.region,s=n.ambiguous,n.warning&&t.push(n.warning)}return{format:r,provider:i,region:o,regionAmbiguous:s,confidence:a,warnings:t,batchImportSupported:i===`workbuddy`}}function s1(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(!Q$(t))throw Error(`bad_json`);return t}var c1=`__all__`,l1=[],u1=2;function d1(){let{t:e}=DH(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),d=s,f=d.length>0,[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)({}),[A,j]=(0,v.useState)({}),[M,N]=(0,v.useState)({}),[P,ee]=(0,v.useState)({}),[F,I]=(0,v.useState)(null),[L,te]=(0,v.useState)(null),[R,z]=(0,v.useState)(null),[B,ne]=(0,v.useState)(null),[re,ie]=(0,v.useState)(null),[V,ae]=(0,v.useState)(``),[oe,se]=(0,v.useState)(`all`),[ce,le]=(0,v.useState)(``),[ue,de]=(0,v.useState)(1),[fe,pe]=(0,v.useState)(20),[me,he]=(0,v.useState)({}),[ge,_e]=(0,v.useState)({}),[ve,ye]=(0,v.useState)({}),[be,xe]=(0,v.useState)({}),[Se,Ce]=(0,v.useState)(!1),we=(0,v.useCallback)(async(e=!1)=>{try{let t=(await LH(e)).data||l1;return c(t),t}finally{u(!1)}},[]),Te=(0,v.useCallback)(async(e,t=!0)=>{let n=[...new Set(e)];if(n.length)for(let e=0;e{try{let n=await XH(e,{quota:t});c(t=>t.map(t=>t.id===e?n:t))}catch(t){N(n=>({...n,[e]:t instanceof Error?t.message:String(t)}))}}))}},[]);(0,v.useEffect)(()=>{we(!1).catch(()=>void 0)},[we]),(0,v.useEffect)(()=>{let e=!0;return Promise.all([tU(),SU()]).then(([t,r])=>{e&&(n(t.data||[]),i(r))}).catch(t=>{e&&o(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[]);function Ee(e){return t.find(t=>t.id===e.provider)?.regions.find(t=>t.id===e.region)?.checkin}function De(e){let t=Ee(e)?.timezone;return t===`Local`?r?.timezone:t}let Oe=(0,v.useMemo)(()=>d.map(e=>{let t=me[e.id],n=ge[e.id],r=ve[e.id],i=be[e.id],a=e;return t!==void 0&&(a={...a,enabled:t}),n!==void 0&&(a={...a,name:n}),r!==void 0&&(a={...a,max_inflight:r}),i!==void 0&&(a={...a,priority:i}),a}),[me,ve,ge,be,d]),ke=(0,v.useMemo)(()=>{let e={all:Oe.length,available:0,attention:0,disabled:0};for(let t of Oe){let n=DX(t);n===`hot`||n===`ready`?e.available+=1:n===`disabled`&&(e.disabled+=1),t.enabled&&n!==`hot`&&n!==`ready`&&(e.attention+=1)}return e},[Oe]),Ae=(0,v.useMemo)(()=>{let e=new Map;for(let t of Oe){let n=String(t.provider||`qoder`).toLowerCase();e.set(n,(e.get(n)||0)+1)}return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))},[Oe]),je=Oe.find(e=>e.id===F),Me=Oe.find(e=>e.id===L)||null,Ne=Oe.find(e=>e.id===R)||null,Pe=Oe.find(e=>e.id===B)||null,Fe=(0,v.useMemo)(()=>{let e=V.trim().toLowerCase();return Oe.filter(t=>{let n=DX(t);return!(oe===`all`||oe===`available`&&(n===`hot`||n===`ready`)||oe===`attention`&&t.enabled&&n!==`hot`&&n!==`ready`||oe===`disabled`&&n===`disabled`)||ce&&String(t.provider||`qoder`).toLowerCase()!==ce?!1:!e||[t.name,t.id,t.remote_uid,t.provider,t.auth_type].some(t=>String(t||``).toLowerCase().includes(e))})},[Oe,oe,ce,V]),Ie=[V,oe,ce,fe].join(`\0`),[Le,Re]=(0,v.useState)(Ie);Le!==Ie&&(Re(Ie),de(1));let ze=Math.max(1,Math.ceil(Fe.length/fe)),Be=Math.min(Le===Ie?Math.max(1,ue):1,ze);ue!==Be&&de(Be);let Ve=(0,v.useMemo)(()=>{let e=(Be-1)*fe;return Fe.slice(e,e+fe)},[Be,Fe,fe]);if(l&&!f)return(0,G.jsx)(_Y,{});async function He(e,t,n){D({id:e,kind:t}),N(t=>({...t,[e]:``}));try{return await n(),!0}catch(t){return N(n=>({...n,[e]:t instanceof Error?t.message:String(t)})),!1}finally{D(null)}}async function Ue(t,n){ie(t),await He(t,`device`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)}));let r=await RH(t,n);r.authUrl&&ee(e=>({...e,[t]:r.authUrl||``}));for(let n=0;n<60;n++){await new Promise(e=>window.setTimeout(e,2e3));let n=(await zH(t)).login||{};if(N(r=>({...r,[t]:n.message||e(`waitingQoderLogin`)})),n.status===`ok`||n.status===`error`)break}await we(!1),await Te([t])})}async function We(t){let n=(A[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`wizardCallbackPh`)}));return}await He(t,`callback`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await BH(t,n),j(e=>({...e,[t]:``})),await we(!1),await Te([t])})&&(ie(e=>e===t?null:e),N(e=>({...e,[t]:``})))}async function Ge(t){let n=(O[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`pastePatFirst`)}));return}await He(t,`pat`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await VH(n,t),k(e=>({...e,[t]:``})),await we(!1),await Te([t])})}async function Ke(t){await He(t,`export`,async()=>{let n=await cU(t);await NQ(JSON.stringify(n,null,2)),N(n=>({...n,[t]:e(`credentialCopied`)}))})}async function qe(e,t){he(n=>({...n,[e]:t})),await He(e,`toggle`,async()=>{await aU(e,{enabled:t}),await we(!1)}),he(t=>{let n={...t};return delete n[e],n})}async function Je(t){JY({id:`refresh-${t}`,type:`loading`,title:e(`toastRefreshingAccount`)}),D({id:t,kind:`refresh`}),N(e=>{let n={...e};return delete n[t],n});try{await Te([t]),JY({id:`refresh-${t}`,type:`success`,title:e(`toastAccountRefreshed`)})}catch(n){throw JY({id:`refresh-${t}`,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)}),n}finally{D(null)}}async function Ye(){Ce(!0),JY({id:`refresh-credits`,type:`loading`,title:e(`toastRefreshingCredits`)});try{await Te(s.map(e=>e.id)),JY({id:`refresh-credits`,type:`success`,title:e(`toastCreditsRefreshed`)})}catch(t){throw JY({id:`refresh-credits`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)}),t}finally{Ce(!1)}}function Xe(){h||(y(!1),x(null),C(null),T(``))}async function Ze(t){let n=t.target.files?.[0];if(t.target.value=``,n)try{let t=s1(await n.text()),r=o1(t);if(!r.provider){JY({type:`error`,title:e(`batchImportUnrecognized`)});return}C(t),x(r),T(n.name),y(!0)}catch(t){let n=t instanceof Error?t.message:String(t);JY({type:`error`,title:e(n===`bad_json`?`wizardBadJson`:`batchImportUnrecognized`),description:n===`bad_json`?void 0:n})}}async function Qe(t){if(!S||!b?.batchImportSupported||h)return;g(!0);let n=`batch-import-accounts`;JY({id:n,type:`loading`,title:e(`batchImportLoading`)});try{let{succeeded:r,failed:i,message:a}=N$(await P$(S,{region:t}),e);JY({id:n,type:i>0&&r===0?`error`:i>0?`info`:`success`,title:a}),y(!1),x(null),C(null),T(``),r>0&&await we(!1)}catch(t){JY({id:n,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{g(!1)}}async function $e(e,t){await He(e,`toggle`,async()=>{await aU(e,{auto_checkin:t}),await we(!1)})}async function et(e){await He(e,`checkin`,async()=>{try{await rU(e)}finally{await we(!1)}})}async function tt(t,n){if(!t)throw Error(e(`accountNameRequired`));_e(e=>({...e,[t]:n.name})),ye(e=>({...e,[t]:n.max_inflight})),xe(e=>({...e,[t]:n.priority})),D({id:t,kind:`settings`});try{await aU(t,n),await we(!1)}catch(e){throw e instanceof Error?e:Error(String(e))}finally{D(null),_e(e=>{let n={...e};return delete n[t],n}),ye(e=>{let n={...e};return delete n[t],n}),xe(e=>{let n={...e};return delete n[t],n})}}return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,G.jsx)(bU,{title:a}):null,(0,G.jsxs)(`section`,{"data-gsap-reveal":!0,className:`flex flex-wrap items-center gap-2`,children:[d.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qX,{value:oe,onChange:e=>se(e),ariaLabel:e(`accountStatusFilter`),options:[{id:`all`,label:(0,G.jsxs)(G.Fragment,{children:[e(`filterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:ke.all})]})},{id:`available`,label:(0,G.jsxs)(G.Fragment,{children:[e(`availableAccounts`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:ke.available})]})},{id:`attention`,label:(0,G.jsxs)(G.Fragment,{children:[e(`needsAttention`),(0,G.jsx)(`span`,{className:`mono ${ke.attention?`text-danger`:`text-muted`}`,children:ke.attention})]})},{id:`disabled`,label:(0,G.jsxs)(G.Fragment,{children:[e(`disabled`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:ke.disabled})]})}]}),(0,G.jsxs)(SV,{className:`w-48`,"aria-label":e(`providerFilterAll`),value:ce||c1,onChange:e=>{typeof e==`string`&&le(e===c1?``:e)},children:[(0,G.jsxs)(SV.Trigger,{className:`items-center`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(SV.Indicator,{})]}),(0,G.jsx)(SV.Popover,{children:(0,G.jsxs)(GB,{children:[(0,G.jsxs)(GB.Item,{id:c1,textValue:e(`providerFilterAll`),children:[(0,G.jsxs)(sR,{className:`flex items-center gap-2`,children:[e(`providerFilterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:d.length})]}),(0,G.jsx)(GB.ItemIndicator,{})]}),Ae.map(([t,n])=>(0,G.jsxs)(GB.Item,{id:t,textValue:TZ(t,e),children:[(0,G.jsxs)(sR,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zZ,{provider:t,size:13}),TZ(t,e),(0,G.jsx)(`span`,{className:`mono text-muted`,children:n})]}),(0,G.jsx)(GB.ItemIndicator,{})]},t))]})})]}),(0,G.jsx)(bQ,{className:`w-full sm:w-60`,value:V,onChange:ae,placeholder:e(`searchAccounts`),ariaLabel:e(`searchAccounts`)})]}):null,(0,G.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:Se,onPress:()=>void Ye(),children:[(0,G.jsx)(ni,{size:14}),e(`refreshCredits`)]}),(0,G.jsxs)(`label`,{htmlFor:`accounts-batch-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${h||_?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[h?(0,G.jsx)(uY,{size:14,loading:!0}):(0,G.jsx)(eo,{size:14}),e(`batchImport`)]}),(0,G.jsx)(`input`,{id:`accounts-batch-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:h||_,className:`sr-only`,onChange:e=>void Ze(e)}),(0,G.jsxs)(X,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(wa,{size:14}),e(`addAccount`)]})]})]}),(0,G.jsx)(G$,{isOpen:p,onClose:()=>m(!1),onAdded:()=>{JY({type:`success`,title:e(`toastAccountAdded`)}),we(!1)}}),(0,G.jsx)(J$,{isOpen:_,detection:b,fileName:w,isPending:h,t:e,onClose:Xe,onConfirm:e=>{Qe(e)}}),(0,G.jsx)(w$,{account:Me,t:e,onClose:()=>te(null)},L??`closed`),(0,G.jsx)(S$,{account:Ne,t:e,onClose:()=>z(null)},R??`closed`),(0,G.jsx)(k$,{account:Pe,checkinDefaultTime:Pe&&Ee(Pe)?r?.checkin_times[Pe.provider||``]:void 0,checkinTimezone:Pe?De(Pe):void 0,busy:!!(E&&E.id===B&&E.kind===`settings`),t:e,onClose:()=>ne(null),onSave:e=>tt(B||``,e)},B??`closed`),(0,G.jsx)(K$,{isOpen:!!je,title:e(`delete`),description:e(`deleteAccountConfirm`,{name:je?.name||je?.id||``}),confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:E?.id===F&&E.kind===`delete`,onClose:()=>I(null),onConfirm:()=>{if(!je)return;let t=je.id;I(null),He(t,`delete`,async()=>{await oU(t),await we(!1)}).then(t=>{t&&JY({type:`success`,title:e(`toastAccountDeleted`)})})}}),f?null:(0,G.jsx)(pQ,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(uY,{size:28}),title:e(`noAccounts`),hint:e(`accountEmptyHint`),action:(0,G.jsxs)(X,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(wa,{size:14}),e(`addAccount`)]})}),f&&!Fe.length?(0,G.jsx)(pQ,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(ua,{size:22}),title:e(`noAccountsMatch`),action:(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:()=>{ae(``),se(`all`),le(``)},children:e(`clearFilters`)})}):null,(0,G.jsx)(`section`,{className:`grid auto-rows-[minmax(280px,auto)] gap-2.5 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:Ve.map(t=>(0,G.jsx)(y$,{account:t,busyKind:E?.id===t.id?E.kind:``,authPanelOpen:re===t.id,authUrl:P[t.id],note:M[t.id],pat:O[t.id]||``,t:e,onPatChange:e=>k(n=>({...n,[t.id]:e})),callbackUrl:A[t.id]||``,onCallbackChange:e=>j(n=>({...n,[t.id]:e})),onSubmitCallback:()=>void We(t.id),onDeviceLogin:e=>void Ue(t.id,e),onPatLogin:()=>void Ge(t.id),onExport:()=>void Ke(t.id),onRefresh:()=>void Je(t.id),onDelete:()=>I(t.id),onToggle:e=>void qe(t.id,e),checkinDefaultTime:r?.checkin_times[t.provider||``],onToggleAutoCheckin:Ee(t)?e=>void $e(t.id,e):void 0,onCheckin:Ee(t)?()=>void et(t.id):void 0,onViewCheckins:Ee(t)?()=>z(t.id):void 0,onEdit:()=>ne(t.id),onToggleAuthPanel:()=>ie(e=>e===t.id?null:t.id),onViewModels:()=>te(t.id)},t.id))}),Fe.length?(0,G.jsx)(yQ,{total:Fe.length,page:Be,pageCount:ze,pageSize:fe,pageSizes:_Q,loading:!1,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Be,pages:ze}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:de,onPageSize:pe}):null]})}function f1(){let{t:e,lang:t,setLang:n}=DH(),{setApiKey:r}=jH(),{overview:i,refresh:a}=dU(),{theme:o,toggleTheme:s}=gU(),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),g=ot(),_=rt().state?.from||`/`,y=(0,v.useRef)(null);if(EY(y,`login`),i)return(0,G.jsx)(jt,{to:_===`/login`?`/`:_,replace:!0});async function b(t){t.preventDefault();let n=c.trim();if(!n){h(e(`loginNeedKey`));return}p(!0),h(``);try{r(n),await a(n),g(_===`/login`?`/`:_,{replace:!0})}catch(t){h(PH(t)?e(`loginBadKey`):t instanceof Error?t.message:String(t))}finally{p(!1)}}return(0,G.jsxs)(`div`,{className:`relative min-h-dvh overflow-hidden bg-background text-foreground`,children:[(0,G.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-border`}),(0,G.jsxs)(`main`,{ref:y,className:`relative z-10 mx-auto grid min-h-dvh w-full max-w-[1480px] lg:grid-cols-[minmax(0,1fr)_minmax(480px,45%)]`,children:[(0,G.jsxs)(`section`,{className:`flex min-h-[52vh] flex-col border-separator px-5 py-6 sm:px-10 sm:py-8 lg:min-h-dvh lg:border-r lg:px-14 lg:py-10 xl:px-20`,children:[(0,G.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(uY,{size:36}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-semibold`,children:`CLI2API`}),(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e(`controlPlane`)})]})]}),(0,G.jsxs)(OI,{isAttached:!0,children:[(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:()=>n(t===`zh`?`en`:`zh`),"aria-label":t===`zh`?`English`:`中文`,children:(0,G.jsx)(Xi,{size:15})})}),(0,G.jsx)(eL.Content,{children:t===`zh`?`English`:`中文`})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:s,"aria-label":o===`dark`?`Light mode`:`Dark mode`,children:o===`dark`?(0,G.jsx)(Wa,{size:15}):(0,G.jsx)(fa,{size:15})})}),(0,G.jsx)(eL.Content,{children:o===`dark`?`Light mode`:`Dark mode`})]})]})]}),(0,G.jsxs)(`div`,{className:`my-auto max-w-3xl py-16 lg:py-24`,children:[(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mb-5 mono text-caption text-muted`,children:`:3010`}),(0,G.jsx)(`h1`,{"data-gsap-reveal":!0,className:`max-w-3xl text-[clamp(2.25rem,4vw,3.6rem)] font-semibold leading-[0.98] tracking-[-0.045em] text-balance`,children:e(`loginTitle`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-6 max-w-xl text-section font-normal text-muted sm:text-title sm:font-normal`,children:e(`loginLead`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-10 max-w-xl pt-5 text-body leading-6 text-muted`,children:e(`loginHint`)})]}),(0,G.jsxs)(`footer`,{className:`hidden items-center justify-between text-caption text-muted lg:flex`,children:[(0,G.jsx)(`span`,{children:e(`loginHint`)}),(0,G.jsx)(`span`,{children:e(`routesHint`)})]})]}),(0,G.jsx)(`section`,{className:`flex items-center px-5 py-10 sm:px-10 lg:px-12 xl:px-16`,children:(0,G.jsx)(zw,{"data-gsap-reveal":!0,className:`w-full p-0`,children:(0,G.jsxs)(`form`,{onSubmit:e=>void b(e),children:[(0,G.jsx)(zw.Header,{className:`border-b border-separator px-6 py-6 sm:px-8`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(uY,{size:28,loading:f}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(zw.Title,{className:`text-title`,children:e(`loginFormTitle`)}),(0,G.jsx)(zw.Description,{className:`mt-1`,children:e(`loginDesc`)})]})]})}),(0,G.jsxs)(zw.Content,{className:`space-y-5 px-6 py-7 sm:px-8 sm:py-8`,children:[(0,G.jsxs)(hL,{name:`console-password`,className:`w-full`,isInvalid:!!m,children:[(0,G.jsx)(sR,{children:e(`loginPassword`)}),(0,G.jsxs)(fL,{children:[(0,G.jsx)(fL.Input,{id:`console-password`,type:u?`text`:`password`,value:c,onChange:e=>l(e.target.value),placeholder:e(`loginPasswordPh`),autoComplete:`current-password`,autoFocus:!0,"aria-label":e(`loginPassword`),spellCheck:!1}),(0,G.jsx)(fL.Suffix,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,type:`button`,"aria-label":e(u?`hidePassword`:`showPassword`),onPress:()=>d(e=>!e),children:u?(0,G.jsx)(Bi,{size:16}):(0,G.jsx)(Ri,{size:16})})})]})]}),m?(0,G.jsx)(bU,{title:m}):(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:e(`loginHint`)}),(0,G.jsxs)(X,{type:`submit`,fullWidth:!0,size:`lg`,isPending:f,children:[e(f?`loggingInConsole`:`loginSubmit`),f?null:(0,G.jsx)(Xr,{size:17})]})]})]})})})]})]})}function p1(){return FH(`/api/keys`)}function m1(e){return FH(`/api/keys`,{method:`POST`,body:JSON.stringify(e)})}function h1(e,t){return FH(`/api/keys/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function g1(e){return FH(`/api/keys/${encodeURIComponent(e)}`,{method:`DELETE`})}function _1(){return FH(`/api/system/console-key`)}function v1(){return FH(`/api/system/console-key`,{method:`POST`,body:JSON.stringify({rotate:!0})})}function y1({settings:e,onSaved:t}){let{t:n}=DH(),r=ot(),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return tU().then(t=>{e&&a((t.data||[]).filter(e=>e.regions.some(e=>e.checkin)))}).catch(t=>{e&&d(String(t))}),()=>{e=!1}},[]);async function f(n,r){if(!(!e||r===e.checkin_times[n])){l(!0),d(``);try{t(await CU({checkin_times:{[n]:r}}))}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(e=>{let t={...e};return delete t[n],t}),l(!1)}}}return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(zw.Header,{children:[(0,G.jsx)(zw.Title,{children:n(`checkinDefaultsTitle`)}),(0,G.jsx)(zw.Description,{children:n(`checkinDefaultsHint`)})]}),(0,G.jsxs)(zw.Content,{className:`space-y-4`,children:[u?(0,G.jsx)(bU,{title:u}):null,!e||!i?(0,G.jsx)($,{className:`h-24 w-full`}):i.map(t=>(0,G.jsx)(E$,{label:t.label,hint:t.regions.filter(e=>e.checkin).map(t=>`${t.label} · ${t.checkin?.timezone===`Local`?e.timezone:t.checkin?.timezone}`).join(` / `),children:(0,G.jsx)(lL,{type:`time`,value:o[t.id]??e.checkin_times[t.id]??``,disabled:c,"aria-label":`${t.label} ${n(`autoCheckinTime`)}`,onChange:e=>s(n=>({...n,[t.id]:e.target.value})),onBlur:e=>void f(t.id,e.target.value)})},t.id))]}),(0,G.jsx)(zw.Footer,{children:(0,G.jsx)(X,{variant:`secondary`,onPress:()=>r(`/accounts`),children:n(`navAccounts`)})})]})}function b1(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleDateString(t===`zh`?`zh-CN`:`en-US`,{year:`numeric`,month:`short`,day:`numeric`})}function x1({releases:e,currentVersion:t,nextVersion:n,rollbackTags:r,canRollback:i,submitting:a,onRestore:o}){let{t:s,lang:c}=DH();if(!e.length)return null;let l=n&&n!==t?n:t,u=e.some(e=>e.tag_name===l)?l:e[0]?.tag_name,d=new Set(r);return(0,G.jsxs)(`div`,{className:`mt-5`,children:[(0,G.jsx)(`div`,{className:`mb-2`,children:(0,G.jsx)(`p`,{className:`text-caption font-medium text-foreground`,children:s(`versionHistory`)})}),(0,G.jsx)(Ih,{className:`rounded-lg bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:u?[u]:[],children:e.map(e=>{let r=e.tag_name,l=r===t,u=!!(n&&r===n&&n!==t),f=i&&d.has(r)&&!l,p=b1(e.published_at,c);return(0,G.jsxs)(Ih.Item,{id:r,children:[(0,G.jsx)(Ih.Heading,{children:(0,G.jsxs)(Ih.Trigger,{className:`items-center gap-3 px-3 py-2.5 text-left`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`mono text-body font-semibold`,children:r}),l?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:s(`versionCurrentBadge`)}):null,u?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`warning`,children:s(`versionLatestBadge`)}):null,p?(0,G.jsx)(`span`,{className:`truncate text-caption text-muted`,children:p}):null]}),(0,G.jsx)(Ih.Indicator,{})]})}),(0,G.jsx)(Ih.Panel,{children:(0,G.jsxs)(Ih.Body,{className:`px-3 pb-3`,children:[(0,G.jsx)(`div`,{className:`release-notes-box release-notes-box--compact`,children:(0,G.jsx)(KU,{markdown:BU(e.body,c),emptyLabel:s(`updateNoNotes`)})}),f?(0,G.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:a,onPress:()=>o(r),children:s(`restoreThisVersion`)})}):null]})})]},r)})})]})}function S1(e){let t=new Set,n=[];for(let r of e){let e=r.tag_name?.trim();!e||t.has(e)||(t.add(e),n.push({...r,tag_name:e}))}return n}function C1(e,t,n,r,i){return r?.length?S1(r):S1([...n?[n]:t?[{tag_name:t}]:[],...e?[{tag_name:e}]:[],...i||[]])}var w1=[`general`,`routing`,`security`,`updates`];function T1(){let{t:e}=DH(),[t,n]=kn(),r=t.get(`tab`),i=r&&w1.includes(r)?r:`general`,a=e=>n(e===`general`?{}:{tab:e},{replace:!0}),{setApiKey:o}=jH(),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(``),E=NU(),{info:D,loading:O,checking:k,submitting:A,error:j,setError:M,load:N,canRollback:P,rollbackTo:ee}=E,F=(0,v.useMemo)(()=>C1(D?.current_version||``,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions),[D?.current_version,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions]),I=(0,v.useMemo)(()=>(D?.rollback_versions||[]).map(e=>e.tag_name),[D?.rollback_versions]);(0,v.useEffect)(()=>{let e=window.setTimeout(()=>{_1().then(c).catch(()=>void 0),SU().then(e=>{u(e),f(e.proxy_url||``)}).catch(e=>M(e instanceof Error?e.message:String(e)))},0);return()=>window.clearTimeout(e)},[M]);async function L(e){let t=l?.cross_provider_model_pool??!0;u(t=>t&&{...t,cross_provider_model_pool:e}),m(!0),M(``);try{u(await CU({cross_provider_model_pool:e}))}catch(e){u(e=>e&&{...e,cross_provider_model_pool:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function te(e){let t=l?.checkin_disabled_accounts??!1;u(t=>t&&{...t,checkin_disabled_accounts:e}),m(!0),M(``);try{u(await CU({checkin_disabled_accounts:e}))}catch(e){u(e=>e&&{...e,checkin_disabled_accounts:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function R(e){let t=l?.proxy_url||``;if(e===t){f(t);return}let n=d;f(e),u(t=>t&&{...t,proxy_url:e}),m(!0),M(``);try{let t=await CU({proxy_url:e});u(t),f(t.proxy_url||``)}catch(e){f(n),u(e=>e&&{...e,proxy_url:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function z(e){let t=l?.routing_strategy||`round-robin`;u(t=>t&&{...t,routing_strategy:e}),m(!0),M(``);try{u(await CU({routing_strategy:e}))}catch(e){u(e=>e&&{...e,routing_strategy:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}return O&&!D?(0,G.jsx)(TY,{}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`systemSettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`systemSettingsLead`)})]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:k,onPress:()=>void N(!0),children:[(0,G.jsx)(Jr,{size:15}),e(`checkUpdates`)]})]}),j?(0,G.jsx)(bU,{title:j}):null,(0,G.jsxs)(LF,{selectedKey:i,onSelectionChange:e=>a(String(e)),children:[(0,G.jsx)(LF.ListContainer,{className:`w-fit max-w-full overflow-x-auto`,children:(0,G.jsxs)(LF.List,{"aria-label":e(`systemSettingsTitle`),children:[(0,G.jsxs)(IF,{id:`general`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(Ji,{size:13}),e(`settingsTabGeneral`)]}),(0,G.jsxs)(IF,{id:`routing`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(ii,{size:13}),e(`settingsTabRouting`)]}),(0,G.jsxs)(IF,{id:`security`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(Oa,{size:13}),e(`settingsTabSecurity`)]}),(0,G.jsxs)(IF,{id:`updates`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(Kr,{size:13}),e(`settingsTabUpdates`)]})]})}),(0,G.jsx)(LF.Panel,{id:`general`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pa,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`proxySettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`proxySettingsHint`)})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-1.5`,children:[(0,G.jsx)(sR,{className:`text-body font-medium text-muted`,children:e(`proxyUrl`)}),(0,G.jsx)(lL,{value:d,onChange:e=>f(e.target.value),onBlur:e=>void R(e.target.value.trim()),placeholder:e(`proxyUrlPlaceholder`),disabled:p||!l}),(0,G.jsx)(lR,{className:`text-caption leading-5 text-muted`,children:e(`proxyUrlHint`)})]})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(bi,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`checkinDisabledAccountsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`checkinDisabledAccountsHint`)})]})]}),(0,G.jsx)(fQ,{isSelected:l?.checkin_disabled_accounts??!1,isDisabled:p||!l,ariaLabel:e(`checkinDisabledAccountsAriaLabel`),onChange:e=>void te(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`checkinDisabledAccountsStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.checkin_disabled_accounts?e(`enabled`):e(`disabled`)})]})]}),(0,G.jsx)(y1,{settings:l,onSaved:u})]})}),(0,G.jsx)(LF.Panel,{id:`routing`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pa,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`routingStrategyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`routingStrategyHint`)})]})]}),(0,G.jsx)(`div`,{className:`mt-4 pt-4`,children:(0,G.jsx)(E$,{label:e(`routingStrategy`),children:(0,G.jsxs)(SV,{fullWidth:!0,"aria-label":e(`routingStrategy`),value:l?.routing_strategy||`round-robin`,isDisabled:p||!l,onChange:e=>{typeof e==`string`&&e&&z(e)},children:[(0,G.jsxs)(SV.Trigger,{className:`items-center`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(SV.Indicator,{})]}),(0,G.jsx)(SV.Popover,{children:(0,G.jsxs)(GB,{children:[(0,G.jsxs)(GB.Item,{id:`round-robin`,textValue:`round-robin`,children:[(0,G.jsx)(sR,{children:e(`routingRoundRobin`)}),(0,G.jsx)(GB.ItemIndicator,{})]}),(0,G.jsxs)(GB.Item,{id:`weighted-round-robin`,textValue:`weighted-round-robin`,children:[(0,G.jsx)(sR,{children:e(`routingWeightedRoundRobin`)}),(0,G.jsx)(GB.ItemIndicator,{})]}),(0,G.jsxs)(GB.Item,{id:`fill-first`,textValue:`fill-first`,children:[(0,G.jsx)(sR,{children:e(`routingFillFirst`)}),(0,G.jsx)(GB.ItemIndicator,{})]}),(0,G.jsxs)(GB.Item,{id:`fefo`,textValue:`fefo`,children:[(0,G.jsx)(sR,{children:e(`routingFEFO`)}),(0,G.jsx)(GB.ItemIndicator,{})]})]})})]})})}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 pt-3 text-caption text-muted sm:grid-cols-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.ttl_seconds?`${Math.round(l.session_affinity.ttl_seconds/60)}m`:`—`}),e(`sessionAffinityTTL`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.hits??0}),e(`sessionAffinityHits`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.misses??0}),e(`sessionAffinityMisses`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.escapes??0}),e(`sessionAffinityEscapes`)]})]}),l?.session_affinity?.last_escape_reason?(0,G.jsxs)(lR,{className:`mt-3 text-caption`,children:[e(`lastSessionEscape`),`: `,l.session_affinity.last_escape_reason]}):null,l?.session_affinity?.last_miss_reason?(0,G.jsxs)(lR,{className:`mt-1 text-caption`,children:[e(`lastSessionMiss`),`: `,l.session_affinity.last_miss_reason]}):null]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pa,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`crossProviderModelPoolTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`crossProviderModelPoolHint`)})]})]}),(0,G.jsx)(fQ,{isSelected:l?.cross_provider_model_pool??!0,isDisabled:p||!l,ariaLabel:e(`crossProviderModelPoolAriaLabel`),onChange:e=>void L(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`crossProviderModelPoolStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.cross_provider_model_pool?e(`enabled`):e(`disabled`)})]})]})]})}),(0,G.jsx)(LF.Panel,{id:`security`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`consoleKeyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyHint`)})]})]})}),(0,G.jsx)(`code`,{className:`mono mt-4 block rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:s?.prefix||`—`}),(0,G.jsx)(`p`,{className:`mt-3 text-caption leading-5 text-muted`,children:e(`consoleKeyLead`)}),(0,G.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isPending:h,onPress:()=>y(!0),children:e(`consoleKeyRotate`)})})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pi,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`sqliteProtection`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`sqliteProtectionHint`)})]})]}),(0,G.jsx)(Oa,{size:18,className:`text-success`})]}),(0,G.jsx)(`div`,{className:`mono mt-4 rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:`/data`}),(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2 text-caption text-muted`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(bi,{size:14,className:`text-muted`}),e(`sqliteBackupBeforeUpdate`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(bi,{size:14,className:`text-muted`}),e(`sqliteKeepFive`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(bi,{size:14,className:`text-muted`}),e(`sqliteRollbackTogether`)]})]})]})]})}),(0,G.jsx)(LF.Panel,{id:`updates`,className:`pt-5`,children:(0,G.jsx)(`div`,{className:`grid gap-5`,children:(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`versionUpdate`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`latestVersionHint`)})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:D?.has_update?`warning`:`success`,children:D?.has_update?e(`updateAvailable`):e(`upToDate`)})]}),(0,G.jsxs)(`div`,{className:`px-5 py-5`,children:[(0,G.jsx)(yU,{update:E}),(0,G.jsx)(x1,{releases:F,currentVersion:D?.current_version||``,nextVersion:D?.next_version,rollbackTags:I,canRollback:P,submitting:A,onRestore:T})]})]})})})]}),(0,G.jsx)(K$,{isOpen:!!w,title:e(`restoreVersionTitle`,{version:w}),description:e(`restoreVersionHint`),confirmLabel:e(`restoreThisVersion`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:A,status:`warning`,confirmVariant:`primary`,onClose:()=>{A||T(``)},onConfirm:()=>{let e=w;T(``),ee(e)}}),(0,G.jsx)(Z.Root,{isOpen:_,onOpenChange:e=>{!e&&!h&&y(!1)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,isDismissable:!h,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`consoleKeyRotate`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyRotateHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:h,"aria-label":e(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,isDisabled:h,onPress:()=>y(!1),children:e(`cancel`)}),(0,G.jsx)(X,{variant:`danger`,isPending:h,onPress:()=>{g(!0),v1().then(e=>{c(e),x(e.secret||``),e.secret&&o(e.secret),y(!1)}).catch(e=>{M(e instanceof Error?e.message:String(e))}).finally(()=>g(!1))},children:e(`consoleKeyRotateNow`)})]})]})})})}),(0,G.jsx)(Z.Root,{isOpen:!!b,onOpenChange:e=>{e||x(``)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`consoleKeySecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`consoleKeySecretHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsx)(Z.Body,{className:`px-6 pb-2`,children:(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b})}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,onPress:()=>x(``),children:e(`close`)}),(0,G.jsxs)(X,{onPress:()=>{NQ(b),C(!0),window.setTimeout(()=>C(!1),1200)},children:[(0,G.jsx)(Oi,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}var E1=`__all__`;function D1(e,t){let n=t.trim().toLowerCase();return!n||e.label.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)}function O1({value:e,onChange:t,ariaLabel:n,options:r,allLabel:i,searchPlaceholder:a,emptyLabel:o,loadOptions:s,className:c}){let[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!s)return;let e=!1,t=window.setTimeout(()=>{m(!0),s(l.trim()).then(t=>{e||f(t)}).catch(()=>{e||f([])}).finally(()=>{e||m(!1)})},l.trim()?280:0);return()=>{e=!0,window.clearTimeout(t)}},[s,l]);let h=e||E1,g=(0,v.useMemo)(()=>{let t=s?d:r.filter(e=>D1(e,l)),n=new Map;l.trim()||n.set(E1,{id:E1,label:i});for(let e of t)!e.id||e.id===E1||n.set(e.id,e);if(e){let t=r.find(t=>t.id===e)||d.find(t=>t.id===e)||{id:e,label:e};n.set(e,t)}return[...n.values()]},[i,s,r,l,d,e]),_=g.find(e=>e.id===h)||(e?{id:e,label:e}:{id:E1,label:i});return(0,G.jsxs)(Sw,{className:[`w-fit`,c].filter(Boolean).join(` `),"aria-label":n,value:h,onChange:e=>{typeof e==`string`&&(t(e===E1?``:e),u(``))},onClear:()=>{t(``),u(``)},children:[(0,G.jsxs)(Sw.Trigger,{className:`min-w-44 items-center`,children:[(0,G.jsx)(Sw.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t?e:(0,G.jsx)(`span`,{className:`truncate`,children:_.label})}),e?(0,G.jsx)(Sw.ClearButton,{}):null,(0,G.jsx)(Sw.Indicator,{})]}),(0,G.jsx)(Sw.Popover,{className:`min-w-56`,children:(0,G.jsxs)(Sw.Filter,{inputValue:l,onInputChange:u,filter:()=>!0,children:[(0,G.jsx)(aR,{"aria-label":a,className:`px-2 pt-2`,autoFocus:!0,children:(0,G.jsxs)(aR.Group,{children:[(0,G.jsx)(aR.SearchIcon,{}),(0,G.jsx)(aR.Input,{placeholder:a}),(0,G.jsx)(aR.ClearButton,{})]})}),(0,G.jsx)(GB,{children:g.length===0?(0,G.jsx)(GB.Item,{id:`__empty__`,textValue:o,isDisabled:!0,children:(0,G.jsx)(sR,{className:`block truncate text-muted`,children:p?a:o})}):g.map(e=>(0,G.jsxs)(GB.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(sR,{className:`block truncate`,children:e.label}),e.id!==E1&&e.id!==e.label?(0,G.jsx)(`span`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.id}):null,(0,G.jsx)(GB.ItemIndicator,{})]},e.id))})]})})]})}function k1(e){return e===`ok`?`success`:e===`streaming`||e===`started`||e===`incomplete`?`warning`:e===`error`||e===`canceled`?`danger`:`default`}function A1(e){if(e===`error`)return`danger`;if(e!==`warn`)return`ok`}function j1(e){return e===`error`?`danger`:e===`warn`?`warning`:e===`info`?`success`:`default`}function M1(e,t=`zh`){if(!e)return`—`;let n=new Date(e);return Number.isFinite(n.getTime())?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(n):e}function N1(e){let t=e.requested_reasoning?.trim()||``,n=e.resolved_reasoning?.trim()||``;return!t&&!n?``:t&&n&&t!==n?`${t} → ${n}`:n||t}function P1({log:e,inLabel:t,outLabel:n,pointsLabel:r}){let i=e.prompt_tokens,a=e.completion_tokens,o=e.credits??e.usage_detail?.credit,s=o!=null&&Number.isFinite(o)?L1(o):null;return i==null&&a==null&&s==null?(0,G.jsx)(`span`,{className:`mono text-xs text-muted`,children:`—`}):(0,G.jsxs)(`div`,{className:`leading-4`,children:[i!=null||a!=null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mono text-xs`,children:[i??0,` / `,a??0]}),(0,G.jsxs)(`div`,{className:`mt-0.5 text-caption text-muted`,children:[t,` / `,n]})]}):null,s==null?null:(0,G.jsx)(`div`,{className:`mono text-caption text-success ${i!=null||a!=null?`mt-0.5`:``}`,children:r?r(s):s})]})}function F1(){return(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:Array.from({length:8},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)($,{className:`h-3 w-20`}),(0,G.jsx)($,{className:`h-5 w-36 max-w-full`})]},t))}),(0,G.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-secondary px-3 py-3`,children:[(0,G.jsx)($,{className:`h-3 w-24`}),(0,G.jsx)($,{className:`h-4 w-full`}),(0,G.jsx)($,{className:`h-4 w-4/5`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)($,{className:`h-3 w-20`}),(0,G.jsx)($,{className:`h-16 w-full`})]})]})}function I1(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function L1(e){return e==null||!Number.isFinite(e)?`—`:String(Math.round(e*1e4)/1e4)}var R1=[`all`,`ok`,`incomplete`,`error`,`canceled`],z1=[`all`,`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`],B1=[`all`,`1h`,`24h`,`7d`,`custom`];function V1(e){let t=(e,t,n)=>t.includes(e??``)?e:n,n=dZ(e.get(`from`)),r=dZ(e.get(`to`)),i=n&&r?{start:n,end:r}:null,a=e.get(`stream`);return{requestFilter:t(e.get(`status`),R1,`all`),requestId:e.get(`id`)??``,accountFilter:e.get(`account`)??``,modelFilter:e.get(`model`)??``,providerFilter:e.get(`provider`)??``,streamFilter:a===`stream`||a===`true`?`stream`:a===`sync`||a===`false`?`sync`:`all`,errorKind:t(e.get(`error_kind`),z1,`all`),timeRange:i?`custom`:t(e.get(`range`),B1,`1h`),customRange:i}}function H1(e){let t=new URLSearchParams;e.requestFilter!==`all`&&t.set(`status`,e.requestFilter),e.requestId&&t.set(`id`,e.requestId),e.accountFilter&&t.set(`account`,e.accountFilter),e.modelFilter&&t.set(`model`,e.modelFilter),e.providerFilter&&t.set(`provider`,e.providerFilter),e.streamFilter!==`all`&&t.set(`stream`,e.streamFilter),e.errorKind!==`all`&&t.set(`error_kind`,e.errorKind);let n=e.timeRange===`custom`?uZ(e.customRange?.start):void 0,r=e.timeRange===`custom`?uZ(e.customRange?.end,!0):void 0;return n&&r?(t.set(`from`,n),t.set(`to`,r)):e.timeRange!==`1h`&&t.set(`range`,e.timeRange),t.toString()}function U1(e){if(e===`all`||e===`custom`)return{from:void 0,to:void 0};let t=new Date,n=new Date(t);return e===`1h`&&n.setHours(n.getHours()-1),e===`24h`&&n.setHours(n.getHours()-24),e===`7d`&&n.setDate(n.getDate()-7),{from:n.toISOString(),to:t.toISOString()}}function W1(){let{t:e,lang:t}=DH(),[n,r]=kn(),[i]=(0,v.useState)(()=>V1(new URLSearchParams(window.location.search))),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(`requests`),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(i.requestFilter),[b,x]=(0,v.useState)(`all`),[S,C]=(0,v.useState)(i.requestId),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(i.accountFilter),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(i.modelFilter),[M,N]=(0,v.useState)(i.providerFilter),[P,ee]=(0,v.useState)(i.streamFilter),[F,I]=(0,v.useState)(i.errorKind),[L,te]=(0,v.useState)(i.timeRange),[R,z]=(0,v.useState)(i.customRange),[B,ne]=(0,v.useState)(1),[re,ie]=(0,v.useState)(50),[V,ae]=(0,v.useState)(1),[oe,se]=(0,v.useState)(50),[ce,le]=(0,v.useState)([]),[ue,de]=(0,v.useState)(0),[fe,pe]=(0,v.useState)([]),[me,he]=(0,v.useState)(0),[ge,_e]=(0,v.useState)(null),[ve,ye]=(0,v.useState)(!1),[be,xe]=(0,v.useState)(null),[Se,Ce]=(0,v.useState)(!1),[we,Te]=(0,v.useState)(!1),[Ee,De]=(0,v.useState)(``),Oe=(0,v.useRef)(0),[ke,Ae]=(0,v.useState)(!1),[je,Me]=(0,v.useState)(!1),Ne=n.toString(),Pe=H1({requestFilter:_,requestId:S,accountFilter:E,modelFilter:A,providerFilter:M,streamFilter:P,errorKind:F,timeRange:L,customRange:R}),Fe=(0,v.useRef)(Ne);(0,v.useEffect)(()=>{if(Ne===Fe.current)return;Fe.current=Ne;let e=V1(new URLSearchParams(Ne));y(e.requestFilter),C(e.requestId),D(e.accountFilter),j(e.modelFilter),N(e.providerFilter),ee(e.streamFilter),I(e.errorKind),te(e.timeRange),z(e.customRange)},[Ne]),(0,v.useEffect)(()=>{Pe!==Fe.current&&(Fe.current=Pe,r(Pe,{replace:!0}))},[Pe,r]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([LH(!1),GH()]).then(([t,n])=>{e||(t.status===`fulfilled`&&o(t.value.data||[]),n.status===`fulfilled`&&c(n.value.data||[]))}),()=>{e=!0}},[]);let Ie=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,t.name||t.id);return e},[a]),Le=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,{provider:t.provider,region:t.region});return e},[a]);function Re(t){let n=t.account_id?Le.get(t.account_id):void 0,r=t.provider||n?.provider;return r?EZ(r,n?.region,e):`—`}function ze(t){switch(t){case`pin`:return e(`logsRouting_pin`);case`sticky`:return e(`logsRouting_sticky`);case`sticky_escape`:return e(`logsRouting_sticky_escape`);default:return e(`logsRouting_pool`)}}let Be=(0,v.useMemo)(()=>(a||[]).map(e=>({id:e.id,label:e.name||e.id})),[a]),Ve=(0,v.useMemo)(()=>{let t=new Set;for(let e of a||[])e.provider&&t.add(e.provider);return M&&t.add(M),[{id:``,label:e(`logsFilterProviderAll`)},...[...t].sort().map(t=>({id:t,label:TZ(t,e)}))]},[a,M,e]),He=(0,v.useMemo)(()=>{let e=new Map;for(let t of s||[])e.has(t.id)||e.set(t.id,{id:t.id,label:t.display_name||t.id});return[...e.values()]},[s]),Ue=(0,v.useCallback)(async e=>((await rX({q:e||void 0,limit:20,offset:0})).items||[]).map(e=>({id:e.id,label:e.id})),[]),We=!!(S||_!==`all`||E||A||M||P!==`all`||F!==`all`||L!==`1h`),Ge=[_,S,E,A,M,P,F,L,R?.start?.toString()??``,R?.end?.toString()??``,re].join(`\0`),Ke=[b,w,O,oe].join(`\0`),[qe,Je]=(0,v.useState)(Ge),[Ye,Xe]=(0,v.useState)(Ke);qe!==Ge&&(Je(Ge),ne(1)),Ye!==Ke&&(Xe(Ke),ae(1));let Ze=Math.max(1,Math.ceil(ue/re)),Qe=Math.min(qe===Ge?Math.max(1,B):1,Ze);B!==Qe&&ne(Qe);let $e=Math.max(1,Math.ceil(me/oe)),et=Math.min(Ye===Ke?Math.max(1,V):1,$e);V!==et&&ae(et);let tt=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=S?{from:void 0,to:void 0}:L===`custom`?{from:uZ(R?.start),to:uZ(R?.end,!0)}:U1(L),t=await rX({status:_===`all`?void 0:_,id:S||void 0,account:E||void 0,model:A||void 0,provider:M||void 0,stream:P===`all`?void 0:P===`stream`,error_kind:F===`all`?void 0:F,from:e.from,to:e.to,limit:re,offset:(Qe-1)*re});le(t.items||[]),de(t.total||0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[_,S,E,A,M,P,F,L,R,Qe,re]),nt=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=await oX({level:b===`all`?void 0:b,q:w.trim()||void 0,account:O||void 0,limit:oe,offset:(et-1)*oe});pe(e.items||[]),he(e.total??0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[b,w,O,et,oe]),rt=(0,v.useCallback)(async(e=!1)=>{l===`requests`?await tt(e):await nt(e)},[l,tt,nt]);(0,v.useEffect)(()=>{f(!0);let e=l===`runtime`&&w.trim()?280:0,t=window.setTimeout(()=>void rt(!1),e);return()=>window.clearTimeout(t)},[rt,l,w]),(0,v.useEffect)(()=>{if(l!==`runtime`||et!==1)return;let e=window.setInterval(()=>void nt(!0),3e3);return()=>window.clearInterval(e)},[l,et,nt]);let it=ue===0?0:(Qe-1)*re+1,at=Math.min(ue,Qe*re),ot=me===0?0:(et-1)*oe+1,st=Math.min(me,et*oe),ct=(0,v.useMemo)(()=>l===`requests`?e(`logsShownTotal`,{shown:ce.length?`${it}–${at}`:0,total:ue}):e(`logsShownTotal`,{shown:fe.length?`${ot}–${st}`:0,total:me}),[l,ce.length,fe.length,it,at,ue,ot,st,me,e]);function lt(){C(``),y(`all`),D(``),j(``),N(``),ee(`all`),I(`all`),te(`1h`),z(null),ne(1)}async function ut(e){let t=++Oe.current;xe(e),De(``),Te(!0),Ce(!0);try{let n=await iX(e.id);if(Oe.current!==t)return;xe(n)}catch(e){if(Oe.current!==t)return;De(e instanceof Error?e.message:String(e))}finally{Oe.current===t&&Te(!1)}}function dt(e){_e(e),ye(!0)}async function ft(){Me(!0),JY({id:`logs-clear`,type:`loading`,title:e(`toastClearingLogs`)});try{await aX(),Ae(!1),await tt(!1),JY({id:`logs-clear`,type:`success`,title:e(`toastLogsCleared`)})}catch(t){g(t instanceof Error?t.message:String(t)),JY({id:`logs-clear`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{Me(!1)}}let pt=d&&(l===`requests`?ce.length===0:fe.length===0);return d&&!p?(0,G.jsx)(CY,{}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`navLogs`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`logsLead`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l===`requests`?(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>Ae(!0),isDisabled:je||ue===0,children:[(0,G.jsx)(Ja,{size:14}),e(`logsClear`)]}):null,(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:d,onPress:()=>void rt(!1),children:[(0,G.jsx)(Jr,{size:15}),e(`refresh`)]})]})]}),h?(0,G.jsx)(bU,{title:e(`failedLogs`,{msg:h})}):null,(0,G.jsxs)(LF,{selectedKey:l,onSelectionChange:e=>u(String(e)),children:[(0,G.jsx)(LF.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(LF.List,{children:[(0,G.jsxs)(IF,{id:`requests`,className:`gap-1.5`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Ea,{size:13}),e(`logsRequests`)]}),(0,G.jsxs)(IF,{id:`runtime`,className:`gap-1.5`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Ka,{size:13}),e(`logsRuntime`)]})]})}),(0,G.jsxs)(LF.Panel,{id:`requests`,"data-tab-panel":`requests`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(qX,{value:_,onChange:e=>y(e),ariaLabel:e(`logsFilterAll`),options:[{id:`all`,label:e(`logsFilterAll`)},{id:`ok`,label:e(`logsFilterOk`)},{id:`incomplete`,label:e(`logsFilterIncomplete`)},{id:`error`,label:e(`logsFilterError`)},{id:`canceled`,label:e(`logsFilterCanceled`)}]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[We?(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:lt,children:e(`clearFilters`)}):null,(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:ct})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(O1,{ariaLabel:e(`logsColAccount`),value:E,onChange:D,options:Be,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(O1,{ariaLabel:e(`logsColModel`),value:A,onChange:j,options:He,allLabel:e(`logsFilterModelAll`),searchPlaceholder:e(`logsSearchModel`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(hQ,{ariaLabel:e(`logsColProvider`),value:M,onChange:N,options:Ve}),(0,G.jsx)(O1,{ariaLabel:e(`logsSearchRequestId`),value:S,onChange:C,options:S?[{id:S,label:S}]:[],allLabel:e(`logsFilterIdAll`),searchPlaceholder:e(`logsSearchRequestId`),emptyLabel:e(`logsNoFilterOptions`),loadOptions:Ue,className:`min-w-56`}),(0,G.jsx)(qX,{value:P,onChange:e=>ee(e),ariaLabel:e(`logsFilterStreamAll`),options:[{id:`all`,label:e(`logsFilterStreamAll`)},{id:`stream`,label:e(`logsStreamYes`)},{id:`sync`,label:e(`logsStreamNo`)}]}),(0,G.jsx)(hQ,{ariaLabel:e(`errorKind`),value:F===`all`?``:F,onChange:e=>I(e||`all`),options:[{id:``,label:e(`logsFilterKindAll`)},{id:`quota`,label:e(`logsKindQuota`)},{id:`rate_limit`,label:e(`logsKindRateLimit`)},{id:`auth`,label:e(`logsKindAuth`)},{id:`not_ready`,label:e(`logsKindNotReady`)},{id:`unavailable`,label:e(`logsKindUnavailable`)},{id:`invalid_request`,label:e(`logsKindInvalidRequest`)},{id:`model_not_available`,label:e(`logsKindModelNotAvailable`)}]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e(`logsTimeRange`)}),(0,G.jsx)(qX,{value:L,onChange:e=>te(e),ariaLabel:e(`logsTimeRange`),options:[{id:`all`,label:e(`logsTimeAll`)},{id:`1h`,label:e(`logsTime1h`)},{id:`24h`,label:e(`logsTime24h`)},{id:`7d`,label:e(`logsTime7d`)},{id:`custom`,label:e(`logsTimeCustom`)}]}),L===`custom`?(0,G.jsx)(fZ,{className:`w-[min(100%,42rem)]`,value:R,onChange:z,ariaLabel:e(`logsTimeRange`),fromLabel:e(`logsTimeFrom`),toLabel:e(`logsTimeTo`)}):null]})]}),(0,G.jsx)(zw,{className:`overflow-hidden p-0`,"aria-busy":d,children:pt?(0,G.jsx)(xY,{}):ce.length===0?(0,G.jsx)(pQ,{icon:(0,G.jsx)(ua,{size:22}),title:e(We?`logsNoMatch`:`logsEmptyRequests`),action:We?(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:lt,children:e(`clearFilters`)}):null}):(0,G.jsx)(Q,{children:(0,G.jsx)(Q.ScrollContainer,{children:(0,G.jsxs)(Q.Content,{"aria-label":e(`logsRequests`),children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`logsColTime`)}),(0,G.jsx)(Q.Column,{children:e(`logsColModel`)}),(0,G.jsx)(Q.Column,{children:e(`logsColReasoning`)}),(0,G.jsx)(Q.Column,{children:e(`logsColProvider`)}),(0,G.jsx)(Q.Column,{children:e(`logsColAccount`)}),(0,G.jsx)(Q.Column,{children:e(`logsColStatus`)}),(0,G.jsx)(Q.Column,{children:e(`logsColStream`)}),(0,G.jsx)(Q.Column,{children:e(`logsColLatency`)}),(0,G.jsx)(Q.Column,{children:e(`logsColTTFT`)}),(0,G.jsx)(Q.Column,{children:e(`logsColTokens`)})]}),(0,G.jsx)(Q.Body,{children:ce.map(n=>(0,G.jsxs)(Q.Row,{className:`cursor-pointer`,onAction:()=>void ut(n),children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`py-1`,children:[(0,G.jsx)(`div`,{className:`mono text-xs`,children:M1(n.created_at,t)}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.id})]})}),(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium`,children:n.requested_model||`—`}),n.mapped_model&&n.mapped_model!==n.requested_model?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.mapped_model}):null]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:N1(n)||`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs`,children:Re(n)})}),(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`span`,{className:`text-xs`,children:n.account_id?Ie.get(n.account_id)||n.account_id:`—`}),n.account_id&&Ie.get(n.account_id)&&Ie.get(n.account_id)!==n.account_id?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.account_id}):null]}),(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:k1(n.status),children:n.status}),n.error_kind?(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:n.error_kind}):null]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs text-muted`,children:n.stream?e(`logsStreamYes`):e(`logsStreamNo`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:I1(n.latency_ms)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:I1(n.ttfb_ms)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(P1,{log:n,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})})})]},n.id))})]})})})}),(0,G.jsx)(yQ,{total:ue,page:Qe,pageCount:Ze,pageSize:re,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Qe,pages:Ze}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ne,onPageSize:ie})]}),(0,G.jsxs)(LF.Panel,{id:`runtime`,"data-tab-panel":`runtime`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(bQ,{className:`sm:w-72`,value:w,onChange:T,placeholder:e(`logsSearchRuntime`),ariaLabel:e(`logsSearchRuntime`)}),(0,G.jsx)(O1,{ariaLabel:e(`logsColAccount`),value:O,onChange:k,options:Be,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(qX,{value:b,onChange:e=>x(e),ariaLabel:e(`logsLevelAll`),options:[{id:`all`,label:e(`logsLevelAll`)},{id:`info`,label:e(`logsLevelInfo`)},{id:`warn`,label:e(`logsLevelWarn`)},{id:`error`,label:e(`logsLevelError`)}]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[et===1?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":`ok`}),e(`logsAutoRefresh`)]}):null,(0,G.jsx)(`span`,{className:`mono`,children:ct})]})]}),(0,G.jsx)(zw,{className:`overflow-hidden p-0`,"aria-busy":d,children:pt?(0,G.jsx)(SY,{}):fe.length===0?(0,G.jsx)(pQ,{icon:(0,G.jsx)(Ka,{size:22}),title:e(`logsEmptyRuntime`)}):(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:fe.map(e=>(0,G.jsxs)(`div`,{className:`grid cursor-pointer gap-2 px-5 py-3 transition-colors hover:bg-surface-secondary/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:grid-cols-[150px_72px_minmax(0,1fr)] sm:items-start`,role:`button`,tabIndex:0,onClick:()=>dt(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),dt(e))},children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:M1(e.time,t)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":A1(e.level)}),(0,G.jsx)(`span`,{className:`font-medium text-muted`,children:e.level})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[e.account_id?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption text-muted`,children:e.account_id}):null,(0,G.jsx)(`div`,{className:`mono break-all text-xs leading-5 text-foreground`,children:e.message})]})]},e.id))})}),(0,G.jsx)(yQ,{total:me,page:et,pageCount:$e,pageSize:oe,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:et,pages:$e}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ae,onPageSize:se})]})]}),(0,G.jsx)(Z.Root,{isOpen:ve,onOpenChange:e=>{ye(e),e||_e(null)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`logsRuntimeDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:ge?`#${ge.id}`:`—`})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[e(`logsColTime`),ge?M1(ge.time,t):`—`],[e(`logsRuntimeLevel`),ge?.level||`—`],[e(`logsRuntimeSource`),ge?.source||`—`],[e(`logsColAccount`),ge?.account_id||`—`]].map(([t,n])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:t}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t===e(`logsRuntimeLevel`)&&ge?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:j1(ge.level),children:ge.level}):n})]},String(t)))}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsRuntimeMessage`)}),(0,G.jsx)(`pre`,{className:`mono max-h-[min(38rem,60vh)] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary px-4 py-3 text-xs leading-6 text-foreground`,children:ge?.message||`—`})]})]})]})})})}),(0,G.jsx)(Z.Root,{isOpen:Se,onOpenChange:e=>{Ce(e),e||(Oe.current+=1,Te(!1),De(``),xe(null))},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`logsDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:be?.id})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsx)(Z.Body,{className:`space-y-4 px-5 pb-5`,children:we?(0,G.jsx)(F1,{}):Ee?(0,G.jsx)(bU,{title:e(`requestFailed`),description:Ee}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[[e(`logsColStatus`),be?.status||`—`],[e(`logsColModel`),be?.requested_model||`—`],[e(`logsColReasoning`),be&&N1(be)||`—`],[e(`logsColProvider`),be?Re(be):`—`],[e(`logsColAccount`),be?.account_id?Ie.get(be.account_id)||be.account_id:`—`],[e(`logsColLatency`),I1(be?.latency_ms)],[e(`logsColTTFT`),I1(be?.ttfb_ms)],[e(`logsColStream`),be?.stream?e(`logsStreamYes`):e(`logsStreamNo`)],[e(`logsRouting`),be?ze(be.routing):`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t})]},String(e))),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsColTokens`)}),(0,G.jsx)(`dd`,{className:`mt-1`,children:be?(0,G.jsx)(P1,{log:be,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})}):`—`})]})]}),be&&be.message_count?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsMessageShape`)}),(0,G.jsxs)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageCount`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5`,children:be.message_count})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsEmptyMessageIndexes`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:be.empty_message_indexes?.length?be.empty_message_indexes.join(`, `):`—`})]}),(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageRoles`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:be.message_roles?.join(` → `)||`—`})]})]})]}):null,be?.error_message?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-2 text-xs leading-5 text-muted`,children:[be.error_kind?(0,G.jsx)(`span`,{className:`mono mr-2 text-muted`,children:be.error_kind}):null,be.error_message]}):null,be?.stream_diagnostic?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsStreamDiagnostics`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCancellationSource`),be.stream_diagnostic.cancellation_source||`—`],[e(`logsUpstreamStatus`),be.stream_diagnostic.upstream_status??`—`],[e(`logsSSEEvents`),be.stream_diagnostic.sse_event_count],[e(`logsBytesRead`),be.stream_diagnostic.bytes_read],[e(`logsLastEvent`),be.stream_diagnostic.last_event||`—`],[e(`logsStreamComplete`),be.stream_diagnostic.saw_done?`yes`:`no`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))}),be.stream_diagnostic.context_err||be.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{className:`mt-2 space-y-1 break-all text-muted`,children:[be.stream_diagnostic.context_err?(0,G.jsxs)(`div`,{children:[`context: `,be.stream_diagnostic.context_err]}):null,be.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{children:[`relay: `,be.stream_diagnostic.relay_error]}):null]}):null]}):null,be?.usage_detail?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsUsageDetail`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCreditConsumed`),`${L1(be.usage_detail.credit)} ${be.usage_detail.unit||`credits`}`],[e(`logsColProvider`),be.usage_detail.provider||`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))})]}):null,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsAttempts`)}),be?.attempts?.length?(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:be.attempts.map(e=>(0,G.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 text-xs sm:grid-cols-[48px_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`div`,{className:`mono text-muted`,children:[`#`,e.attempt_index]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:e.account_id||`—`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-muted`,children:e.error_message||e.status})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:k1(e.status===`failover`?`canceled`:e.status),children:e.status})]},e.id))}):(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:e(`logsNoAttempts`)})]})]})})]})})})}),(0,G.jsx)(K$,{isOpen:ke,title:e(`logsClear`),description:e(`logsClearConfirm`),confirmLabel:e(`logsClear`),cancelLabel:e(`close`),closeLabel:e(`close`),isPending:je,onClose:()=>Ae(!1),onConfirm:()=>void ft()})]})}function G1(){return FH(`/api/usage/pricing`)}function K1(e={}){let t=new URLSearchParams;return e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),FH(`/api/usage/cost${t.toString()?`?${t}`:``}`)}var q1=(0,v.lazy)(()=>C(()=>import(`./CostChart-5urt0nTO.js`).then(e=>({default:e.CostChart})),__vite__mapDeps([5,1,4,2]))),J1={window:{from:``,to:``,hours:24},currency:`CNY`,models:[],totals:{id:`total`,label:``,vendor:``,currency:`CNY`,requests:0,cache_hit:0,cache_miss:0,output:0,total_tokens:0,cost:0,cost_off_peak:0,cost_peak:0,peak_requests:0,credits:0,priced:!1},series:[]};function Y1(e,t){if(!t)return`0%`;let n=e/t*100;return`${n>=10?n.toFixed(0):n.toFixed(1)}%`}function X1(){let{t:e,lang:t}=DH(),[n,r]=(0,v.useState)(`all`),[i,a]=(0,v.useState)(`credits`),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!0),[f,p]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!1;return G1().then(t=>{e||l(t)}).catch(()=>{}),()=>{e=!0}},[]);let m=(0,v.useCallback)(async()=>{d(!0);try{let e=await K1(n===`all`?{}:{from:new Date(Date.now()-Number(n)*3600*1e3).toISOString(),to:new Date().toISOString()});s(e),p(``)}catch(e){s(null),p(e instanceof Error?e.message:String(e))}finally{d(!1)}},[n]);(0,v.useEffect)(()=>{m()},[m]);let h=o??J1,g=h.totals,_=g.requests>0&&h.models.length>0,y=h.models.filter(e=>e.priced),b=g.cost>0,x=[{label:e(`usageCredits`),value:_X(g.credits),detail:e(`usageCreditsHint`)},{label:e(`usageTotalTokens`),value:sX(g.total_tokens),detail:`${sX(g.cache_hit)} / ${sX(g.cache_miss)} / ${sX(g.output)} ${e(`usageTokenSplitNote`)}`},{label:e(`usageRequests`),value:String(g.requests),detail:e(`usageModelCount`,{count:h.models.length})},{label:e(`usageCacheHitRate`),value:Y1(g.cache_hit,g.cache_hit+g.cache_miss),detail:sX(g.cache_hit)}],S=i===`credits`?_X(g.credits):i===`tokens`?sX(g.total_tokens):hX(g.cost);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-2`,children:[(0,G.jsx)(qX,{value:n,onChange:e=>r(e),ariaLabel:e(`usageWindow`),options:[{id:`24`,label:e(`usageWindow24h`)},{id:`168`,label:e(`usageWindow7d`)},{id:`all`,label:e(`usageWindowTotal`)}]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:()=>void m(),isDisabled:u,children:[(0,G.jsx)(Jr,{size:14}),e(`refresh`)]})]}),f?(0,G.jsx)(bU,{title:e(`failedStats`,{msg:f})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-4`,children:x.map(e=>(0,G.jsxs)(zw,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:u?(0,G.jsx)($,{className:`h-5 w-16`}):e.value}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:u?(0,G.jsx)($,{className:`h-3 w-24`}):e.detail||`\xA0`})]},e.label))}),(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:e(`usageChartTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:e(`usageChartHint`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(qX,{value:i,onChange:e=>a(e),ariaLabel:e(`usageChartMetric`),options:[{id:`credits`,label:e(`usageColCredits`)},{id:`tokens`,label:e(`usageColTokens`)}]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`default`,children:S})]})]}),(0,G.jsx)(`div`,{className:`p-5`,children:u?(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)($,{className:`h-56 w-full`})}):_?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)($,{className:`h-56 w-full`})}),children:(0,G.jsx)(q1,{series:h.series,models:h.models,lang:t,emptyLabel:e(`usageChartEmpty`),totalLabel:e(`usageTotals`),metric:i})}):(0,G.jsx)(pQ,{title:e(`usageEmpty`),hint:e(`usageRetentionHint`)})})]}),(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:e(`usageBreakdownTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:e(`usageBreakdownHint`)})]})}),u?(0,G.jsx)(`div`,{className:`space-y-3 p-5`,children:[0,1,2].map(e=>(0,G.jsx)($,{className:`h-9 w-full`},e))}):_?(0,G.jsx)(Q,{children:(0,G.jsx)(Q.ScrollContainer,{children:(0,G.jsxs)(Q.Content,{"aria-label":e(`usageBreakdownTitle`),children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`usageColModel`)}),(0,G.jsx)(Q.Column,{children:e(`usageColRequests`)}),(0,G.jsx)(Q.Column,{children:e(`usageColInputHit`)}),(0,G.jsx)(Q.Column,{children:e(`usageColInputMiss`)}),(0,G.jsx)(Q.Column,{children:e(`usageColOutput`)}),(0,G.jsx)(Q.Column,{children:e(`usageColTokens`)}),(0,G.jsx)(Q.Column,{children:e(`usageColCredits`)})]}),(0,G.jsxs)(Q.Body,{children:[h.models.map(e=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:e.requests})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.cache_hit)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.cache_miss)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.output)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.total_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_X(e.credits)})})]},e.id)),(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e(`usageTotals`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:g.requests})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.cache_hit)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.cache_miss)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.output)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.total_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_X(g.credits)})})]})]})]})})}):(0,G.jsx)(pQ,{title:e(`usageEmpty`),hint:e(`usageRetentionHint`)})]}),(0,G.jsx)(Ih,{className:`rounded-xl bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:[],children:(0,G.jsxs)(Ih.Item,{id:`deepseek-estimate`,children:[(0,G.jsx)(Ih.Heading,{children:(0,G.jsxs)(Ih.Trigger,{className:`items-center gap-3 px-5 py-4 text-left`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block font-semibold tracking-[-0.015em]`,children:e(`usageEstimateTitle`)}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted`,children:e(`usageEstimateHint`)})]}),b?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`default`,children:hX(g.cost)}):null,(0,G.jsx)(Ih.Indicator,{})]})}),(0,G.jsx)(Ih.Panel,{children:(0,G.jsxs)(Ih.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-6 text-muted`,children:e(`usageRenderNote`)}),b?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium`,children:e(`usageEstimateChartTitle`)}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`default`,children:hX(g.cost)})]}),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)($,{className:`h-56 w-full`}),children:(0,G.jsx)(q1,{series:h.series,models:y.length?y:h.models,lang:t,emptyLabel:e(`usageEstimateChartEmpty`),totalLabel:e(`usageTotals`),metric:`cost`})})]}):null,y.length?(0,G.jsx)(Q,{children:(0,G.jsx)(Q.ScrollContainer,{children:(0,G.jsxs)(Q.Content,{"aria-label":e(`usageEstimateTitle`),children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`usageColModel`)}),(0,G.jsx)(Q.Column,{children:e(`usageColSplit`)}),(0,G.jsx)(Q.Column,{children:e(`usageColCost`)})]}),(0,G.jsxs)(Q.Body,{children:[y.map(e=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[hX(e.cost_peak),` / `,hX(e.cost_off_peak)]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:hX(e.cost)})})]},e.id)),(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e(`usageTotals`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[hX(g.cost_peak),` / `,hX(g.cost_off_peak)]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:hX(g.cost)})})]})]})]})})}):(0,G.jsx)(`p`,{className:`text-xs text-muted`,children:e(`usageEstimateChartEmpty`)}),(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`mb-2 text-sm font-medium`,children:e(`usagePriceTitle`)}),(0,G.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:e(`usagePeakNote`)}),(0,G.jsxs)(`div`,{className:`divide-y divide-separator rounded-lg bg-background`,children:[(c?.models??[]).map(t=>(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:t.label}),(0,G.jsx)(`span`,{className:`mono text-[10px] text-muted`,children:t.currency})]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-[10px] text-muted`,children:t.id}),(0,G.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-[11px]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:e(`usagePriceBandOff`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[gX(t.off_peak.cache_hit),` · `,gX(t.off_peak.cache_miss),` · `,gX(t.off_peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[e(`usagePriceHit`),` · `,e(`usagePriceMiss`),` · `,e(`usagePriceOutput`)]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:e(`usagePriceBandPeak`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[gX(t.peak.cache_hit),` · `,gX(t.peak.cache_miss),` · `,gX(t.peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[e(`usagePriceHit`),` · `,e(`usagePriceMiss`),` · `,e(`usagePriceOutput`)]})]})]})]},t.id)),c?.models?.length?null:(0,G.jsx)(`div`,{className:`px-4 py-6 text-sm text-muted`,children:e(`usageEmpty`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 text-xs leading-6 text-muted`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:e(`usageNoteTitle`)}),(0,G.jsx)(`p`,{children:e(`usageRetentionHint`)}),(0,G.jsx)(`p`,{children:e(`usagePeakNote`)}),h.unpriced?.length?(0,G.jsx)(`p`,{children:e(`usageUnpricedHint`,{models:h.unpriced.join(`, `)})}):null,c?.note?(0,G.jsx)(`p`,{className:`mono text-[10px]`,children:c.note}):null]})]})]})})]})})]})}var Z1=500,Q1={model:`model`,account:`account`,provider:`provider`};function $1(e,t,n){let r=e.prompt_tokens??0,i=e.completion_tokens??0,a=e.key===`(unknown)`||e.key===`(unassigned)`||!e.key;return{key:e.key,label:n,count:e.count,success:e.count?e.ok/e.count:0,p95:e.latency_p95_ms??null,tokens:r+i,prompt:r,completion:i,credits:e.credits??0,cache_write:e.cache_write_tokens??0,cache_read:e.cache_read_tokens??0,filter:a?void 0:{[Q1[t]]:e.key}}}function e0(e,t,n){let r=n===`ascending`?1:-1;return[...e].sort((e,n)=>{if(t===`label`)return r*e.label.localeCompare(n.label);let i=e[t],a=n[t];return i==null&&a==null?0:i==null?1:a==null?-1:r*(i-a)||e.label.localeCompare(n.label)})}function t0(e){return e?e>=1e3?sX(e):String(Math.round(e*100)/100):`0`}function n0(){let{t:e}=DH(),t=ot(),[n,r]=(0,v.useState)(`stats`),[i,a]=(0,v.useState)(`model`),[o,s]=(0,v.useState)(`24`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!0),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)([]),[y,b]=(0,v.useState)(`count`),[x,S]=(0,v.useState)(`descending`),C=(0,v.useRef)(0);(0,v.useEffect)(()=>{let e=!1;return LH(!1).then(t=>{e||_(t.data||[])}).catch(()=>{}),()=>{e=!0}},[]);let w=c?.start?.toString()??``,T=c?.end?.toString()??``;(0,v.useEffect)(()=>{let e=mZ(o,c);if(!e){p(!1);return}let t=++C.current;tX({...e,dim:[i],limit:Z1}).then(e=>{t===C.current&&(d(e),h(``))}).catch(e=>{t===C.current&&(d(null),h(e instanceof Error?e.message:String(e)))}).finally(()=>{t===C.current&&p(!1)})},[i,o,w,T]);let E=(0,v.useMemo)(()=>{let t=new Map(g.map(e=>[e.id,e.name||e.id]));return e0(((i===`model`?u?.models:i===`account`?u?.accounts:u?.providers)??[]).map(n=>{let r=n.key===`(unknown)`?e(`statsUnknown`):n.key===`(unassigned)`?e(`statsUnassigned`):i===`account`?t.get(n.key)||n.key:i===`provider`?TZ(n.key,e):n.key;return $1(n,i,r)}),y,x)},[u,i,g,y,x,e]),D=u?.totals,O=u?.tokens,k=[{id:`label`,label:e(i===`model`?`logsColModel`:i===`account`?`logsColAccount`:`logsColProvider`)},{id:`count`,label:e(`usageColRequests`),numeric:!0},{id:`success`,label:e(`usageColSuccess`),numeric:!0},{id:`p95`,label:e(`statsLatencyP95`),numeric:!0},{id:`tokens`,label:e(`usageColTokens`),numeric:!0},{id:`cache_write`,label:e(`usageColCacheWrite`),numeric:!0},{id:`credits`,label:e(`usageColCredits`),numeric:!0}],A=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-1`,children:(0,G.jsx)(hZ,{value:o,onChange:s,custom:c,onCustomChange:l,onBusy:()=>p(!0),t:e})}),m?(0,G.jsx)(bU,{title:e(`failedStats`,{msg:m})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-5`,children:[[e(`usageColRequests`),D?sX(D.requests):`—`,e(`statsWindowHint`,{window:e(pZ[o])})],[e(`usageColSuccess`),D?uX(D.success_rate):`—`,D?`${D.ok} / ${D.requests}`:``],[e(`usageColTokens`),O?sX(O.total):`—`,O?`${sX(O.prompt)} / ${sX(O.completion)}`:``],[e(`usageColCacheWrite`),O?sX(O.cache_write??0):`—`,O?`${e(`chartCacheRead`)} ${sX(O.cache_read)}`:``],[e(`usageColCredits`),D?t0(D.credits??0):`—`,``]].map(([e,t,n])=>(0,G.jsxs)(zw,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:f?(0,G.jsx)($,{className:`h-5 w-16`}):t}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:f?(0,G.jsx)($,{className:`h-3 w-24`}):n||`\xA0`})]},e))}),(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,G.jsx)(LF,{selectedKey:i,onSelectionChange:e=>{p(!0),a(String(e))},children:(0,G.jsx)(LF.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(LF.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(IF,{id:`model`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Mi,{size:14}),e(`usageByModel`)]}),(0,G.jsxs)(IF,{id:`account`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(no,{size:14}),e(`usageByAccount`)]}),(0,G.jsxs)(IF,{id:`provider`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Ba,{size:14}),e(`usageByProvider`)]})]})})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:f?``:e(`usageRowCount`,{count:E.length})})]}),f?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)($,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)($,{className:`h-3 w-12`}),(0,G.jsx)($,{className:`h-4 w-16`})]},t))})]},t))}),(0,G.jsx)(`div`,{className:`hidden divide-y divide-separator md:block`,"aria-busy":`true`,children:Array.from({length:6},(e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-6 px-5 py-3.5`,children:[(0,G.jsx)($,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`flex-1`}),Array.from({length:6},(e,t)=>(0,G.jsx)($,{className:`h-4 w-14`},t))]},t))})]}):E.length===0?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-10 text-body text-muted`,children:[(0,G.jsx)(mi,{size:16}),e(`usageEmpty`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:E.map(n=>{let r=!!(n.filter&&u),a=[{label:e(`usageColRequests`),value:String(n.count)},{label:e(`usageColSuccess`),value:uX(n.success),tone:n.success<.9?`text-warning`:void 0},{label:e(`statsLatencyP95`),value:cX(n.p95)},{label:e(`usageColTokens`),value:sX(n.tokens),sub:`${sX(n.prompt)} / ${sX(n.completion)}`},{label:e(`usageColCacheWrite`),value:sX(n.cache_write)},{label:e(`usageColCredits`),value:t0(n.credits)}];return(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4 ${r?`cursor-pointer`:``}`,onClick:r?()=>t(gZ(n.filter??{},u.window.from,u.window.to)):void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(gZ(n.filter??{},u.window.from,u.window.to)))}:void 0,role:r?`button`:void 0,tabIndex:r?0:void 0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i===`provider`&&n.filter?(0,G.jsx)(zZ,{provider:n.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.label})]}),i===`account`&&n.label!==n.key?(0,G.jsx)(`div`,{className:`mono truncate text-caption text-muted`,children:n.key}):null,(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:a.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value}),`sub`in e&&e.sub?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:e.sub}):null]},e.label))})]},n.key)})}),(0,G.jsx)(Q,{className:`usage-table hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{"aria-label":e(`usageTitle`),className:`min-w-[48rem]`,sortDescriptor:{column:y,direction:x},onSortChange:e=>{b(String(e.column)),S(e.direction)},children:[(0,G.jsx)(Q.Header,{children:k.map(e=>(0,G.jsx)(Q.Column,{id:e.id,allowsSorting:!0,isRowHeader:e.id===`label`,className:e.numeric?`text-right`:void 0,children:({sortDirection:t})=>(0,G.jsx)(Q.SortableColumnHeader,{sortDirection:t,className:e.numeric?`justify-end`:void 0,children:e.label})},e.id))}),(0,G.jsx)(Q.Body,{children:E.map(e=>(0,G.jsxs)(Q.Row,{id:e.key,className:e.filter&&u?`cursor-pointer`:void 0,onAction:e.filter&&u?()=>t(gZ(e.filter??{},u.window.from,u.window.to)):void 0,children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i===`provider`&&e.filter?(0,G.jsx)(zZ,{provider:e.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:e.label}),i===`account`&&e.label!==e.key?(0,G.jsx)(`span`,{className:`mono truncate text-caption text-muted`,children:e.key}):null]})}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:e.count}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:(0,G.jsx)(`span`,{className:e.success<.9?`text-warning`:void 0,children:uX(e.success)})}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:cX(e.p95)}),(0,G.jsxs)(Q.Cell,{className:`text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-body`,children:sX(e.tokens)}),(0,G.jsxs)(`div`,{className:`mono text-caption text-muted`,children:[sX(e.prompt),` / `,sX(e.completion)]})]}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:sX(e.cache_write)}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:t0(e.credits)})]},e.key))})]})})})]})]})]});return(0,G.jsxs)(`div`,{className:`space-y-6 sm:space-y-6`,children:[(0,G.jsxs)(`section`,{className:`pb-1`,children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`usageTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(n===`cost`?`usageCostLead`:`usageLead`)})]}),(0,G.jsxs)(LF,{selectedKey:n,onSelectionChange:e=>r(String(e)),children:[(0,G.jsx)(LF.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(LF.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(IF,{id:`stats`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),e(`usageStatsTab`)]}),(0,G.jsxs)(IF,{id:`cost`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),e(`usageCostTab`)]})]})}),(0,G.jsx)(LF.Panel,{id:`stats`,className:`space-y-6 pt-5`,children:A}),(0,G.jsx)(LF.Panel,{id:`cost`,className:`pt-5`,children:(0,G.jsx)(X1,{})})]})]})}var r0=1.1;function i0({label:e,onConfirm:t,isPending:n,children:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>{a.current?.kill()},[]),(0,G.jsxs)(eL,{delay:300,children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e,isPending:n,className:`relative overflow-hidden`,onPressStart:()=>{let e=i.current;!e||n||(a.current?.kill(),a.current=eY.to(e,{scaleX:1,duration:r0*(1-Number(eY.getProperty(e,`scaleX`))),ease:nY.linear,onComplete:()=>{a.current=null,eY.to(e,{scaleX:0,duration:iY()?0:tY.base,ease:nY.out,delay:tY.fast}),t()}}))},onPressEnd:()=>{let e=i.current;!e||!a.current||(a.current.kill(),a.current=null,eY.to(e,{scaleX:0,duration:iY()?0:tY.base,ease:nY.soft}))},children:[(0,G.jsx)(`span`,{ref:i,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 origin-left scale-x-0 bg-danger/20`}),(0,G.jsx)(`span`,{className:`relative inline-flex`,children:r})]})}),(0,G.jsx)(eL.Content,{children:e})]})}function a0(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id});return t}function o0(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i?EZ(r,i,t):TZ(r,t)}function s0(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function c0(e,t){let n=[],r=new Set(e.filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));for(let t of e)t.includes(`:`)&&n.push(t);for(let e of t)r.has(e.provider)&&!n.includes(e.value)&&n.push(e.value);return n}function l0(e,t){return e.length?e.map(e=>o0(e,t)).join(` · `):t(`keysAllProviders`)}function u0(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function d0(){let{t:e}=DH(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1);(0,v.useEffect)(()=>{tU().then(e=>{let t=a0(e.data||[]);n(t),i(t.length>0),o(``)}).catch(e=>{o(e instanceof Error?e.message:String(e))})},[]);async function w(){u(!0);try{let e=await p1();c(e.data||[]),m(``)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}(0,v.useEffect)(()=>{let e=window.setTimeout(()=>void w(),0);return()=>window.clearTimeout(e)},[]);async function T(e){await NQ(e),C(!0),window.setTimeout(()=>C(!1),1200)}async function E(e,t){f(e.id),c(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{let n=await h1(e.id,{enabled:t});c(t=>t.map(t=>t.id===e.id?{...t,...n,secret:void 0}:t))}catch(e){m(e instanceof Error?e.message:String(e)),await w()}finally{f(``)}}async function D(t){f(t.id);try{await g1(t.id),c(e=>e.filter(e=>e.id!==t.id)),JY({type:`success`,title:e(`toastKeyDeleted`)})}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(``)}}return l&&!s.length?(0,G.jsx)(yY,{}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`navKeys`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`keysLead`)})]}),(0,G.jsxs)(X,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(wa,{size:14}),e(`keysCreate`)]})]}),p?(0,G.jsx)(bU,{title:p}):null,a?(0,G.jsx)(bU,{title:e(`keysProvidersLoadFailed`,{message:a})}):null,l?(0,G.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:Math.max(3,s.length)},(e,t)=>(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface p-3`,children:[(0,G.jsx)($,{className:`h-4 w-28`}),(0,G.jsx)($,{className:`mt-2 h-3 w-40`}),(0,G.jsx)($,{className:`mt-4 h-6 w-24`}),(0,G.jsx)($,{className:`mt-6 h-8 w-full`})]},t))}):s.length?(0,G.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,children:s.map(t=>(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(zw.Header,{className:`flex-row items-start justify-between gap-3 px-3 pt-3 pb-2.5`,children:[(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(zw.Title,{className:`truncate text-body`,children:t.name})}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:t.enabled?`success`:`default`,children:t.enabled?e(`enabled`):e(`disabled`)})]}),(0,G.jsxs)(zw.Content,{className:`space-y-2.5 px-3 pb-2.5`,children:[(0,G.jsx)(`div`,{className:`mono w-full rounded-lg bg-surface-secondary px-3 py-2 text-body text-foreground`,title:t.prefix,children:t.prefix}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:(t.providers.length?t.providers:[`all`]).map(t=>(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t===`all`?(0,G.jsx)(na,{size:12}):(0,G.jsx)(zZ,{provider:s0(t),size:12}),(0,G.jsx)(`span`,{children:t===`all`?e(`keysAllProviders`):o0(t,e)})]})},t))}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t.last_used_at?e(`keysLastUsed`,{time:u0(t.last_used_at)}):e(`keysNeverUsed`)})]}),(0,G.jsxs)(zw.Footer,{className:`gap-1.5 bg-surface-secondary px-3 py-2`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:!r,onPress:()=>y(t),children:e(`edit`)}),(0,G.jsx)(i0,{label:e(`holdToDelete`),isPending:d===t.id,onConfirm:()=>void D(t),children:(0,G.jsx)(Ja,{size:14})}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(fQ,{isSelected:t.enabled,isDisabled:d===t.id,ariaLabel:e(`enable`),onChange:e=>void E(t,e)})})]})]},t.id))}):(0,G.jsx)(pQ,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(uY,{size:28}),title:e(`keysEmpty`),hint:e(`keysEmptyHint`),action:(0,G.jsxs)(X,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(wa,{size:14}),e(`keysCreate`)]})}),(0,G.jsx)(f0,{isOpen:h,title:e(`keysCreateTitle`),hint:e(`keysCreateHint`),options:t,t:e,onClose:()=>g(!1),onSave:async e=>{let t=await m1(e);c(e=>[t,...e.map(e=>({...e,secret:void 0}))]),g(!1),x(t)}}),(0,G.jsx)(f0,{isOpen:!!_,title:e(`keysEditTitle`),hint:e(`keysEditHint`),initial:_,options:t,t:e,onClose:()=>y(null),onSave:async e=>{if(!_)return;let t=await h1(_.id,e);c(e=>e.map(e=>e.id===_.id?{...e,...t,secret:void 0}:e)),y(null)}}),(0,G.jsx)(Z.Root,{isOpen:!!b?.secret,onOpenChange:e=>{e||x(null)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`keysSecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`keysSecretHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsxs)(Z.Body,{className:`px-6 pb-2`,children:[(0,G.jsxs)(RB,{status:`warning`,className:`mb-4`,children:[(0,G.jsx)(RB.Indicator,{}),(0,G.jsx)(RB.Content,{children:(0,G.jsx)(RB.Title,{children:e(`keysSecretOnce`)})})]}),(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b?.secret})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,onPress:()=>x(null),children:e(`close`)}),(0,G.jsxs)(X,{onPress:()=>{b?.secret&&T(b.secret)},children:[(0,G.jsx)(Oi,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}function f0({isOpen:e,title:t,hint:n,initial:r,options:i,t:a,onClose:o,onSave:s}){let[c,l]=(0,v.useState)(r?.name||``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(new Set),[m,h]=(0,v.useState)(!0),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;l(r?.name||``),d(c0(r?.providers||[],i));let t=new Set((r?.providers||[]).filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));p(t),h(!0),_(``)},[r,e,i]);function x(e){let t=i.find(t=>t.value===e);h(!1),d(n=>n.includes(e)?(t&&p(e=>{let n=new Set(e);return n.delete(t.provider),n}),n.filter(t=>t!==e)):[...n,e])}async function S(e){e?.preventDefault();let t=c.trim();if(!t){_(a(`keysNameRequired`));return}if(!i.length){_(a(`keysProvidersNotLoaded`));return}b(!0),_(``);try{await s({name:t,providers:m?r?.providers||[]:u})}catch(e){_(e instanceof Error?e.message:String(e))}finally{b(!1)}}return(0,G.jsx)(Z.Root,{isOpen:e,onOpenChange:e=>{!e&&!y&&o()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,G.jsx)(Z.Dialog,{className:`sm:min-w-[32rem]`,children:(0,G.jsxs)(FB,{onSubmit:S,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:t}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:n})]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:y,"aria-label":a(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[g?(0,G.jsxs)(RB,{status:`danger`,children:[(0,G.jsx)(RB.Indicator,{}),(0,G.jsx)(RB.Content,{children:(0,G.jsx)(RB.Title,{children:g})})]}):null,(0,G.jsx)(E$,{label:a(`keysName`),children:(0,G.jsx)(lL,{value:c,onChange:e=>l(e.target.value),placeholder:a(`keysNamePh`),"aria-label":a(`keysName`)})}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(sR,{className:`text-body font-medium text-muted`,children:a(`keysProviders`)}),(0,G.jsx)(lR,{className:`text-caption leading-5 text-muted`,children:a(`keysProvidersHint`)}),i.length?(0,G.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=u.includes(e.value),n=f.has(e.provider);return(0,G.jsx)(aT,{isSelected:t,onChange:()=>x(e.value),className:`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft`,children:(0,G.jsxs)(aT.Content,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(aT.Control,{children:(0,G.jsx)(aT.Indicator,{})}),(0,G.jsx)(zZ,{provider:e.provider,size:16}),(0,G.jsx)(`span`,{className:`text-body font-medium`,children:EZ(e.provider,e.region,a)}),n?(0,G.jsx)(`span`,{className:`rounded-md bg-surface-secondary px-1.5 py-0.5 text-caption font-medium text-muted`,children:a(`keysAllRegions`)}):null]})},e.value)})}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption leading-5 text-muted`,children:a(`keysProvidersNotLoaded`)}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:l0(u,a)})]})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,isDisabled:y,onPress:o,children:a(`cancel`)}),(0,G.jsx)(X,{type:`submit`,isPending:y,isDisabled:!i.length,children:a(r?`save`:`create`)})]})]})})})})})}function p0(){return(0,G.jsx)(hU,{children:(0,G.jsx)(EH,{children:(0,G.jsx)(AH,{children:(0,G.jsx)(uU,{children:(0,G.jsx)(Sn,{children:(0,G.jsxs)(Ft,{children:[(0,G.jsx)(Nt,{path:`/login`,element:(0,G.jsx)(f1,{})}),(0,G.jsx)(Nt,{element:(0,G.jsx)(eX,{}),children:(0,G.jsxs)(Nt,{element:(0,G.jsx)($Y,{}),children:[(0,G.jsx)(Nt,{path:`/`,element:(0,G.jsx)(iQ,{})}),(0,G.jsx)(Nt,{path:`/auth`,element:(0,G.jsx)(jt,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Nt,{path:`/providers`,element:(0,G.jsx)(jQ,{})}),(0,G.jsx)(Nt,{path:`/access`,element:(0,G.jsx)(f$,{})}),(0,G.jsx)(Nt,{path:`/accounts`,element:(0,G.jsx)(d1,{})}),(0,G.jsx)(Nt,{path:`/checkins`,element:(0,G.jsx)(jt,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Nt,{path:`/usage`,element:(0,G.jsx)(n0,{})}),(0,G.jsx)(Nt,{path:`/logs`,element:(0,G.jsx)(W1,{})}),(0,G.jsx)(Nt,{path:`/keys`,element:(0,G.jsx)(d0,{})}),(0,G.jsx)(Nt,{path:`/system`,element:(0,G.jsx)(T1,{})}),(0,G.jsx)(Nt,{path:`*`,element:(0,G.jsx)(jt,{to:`/`,replace:!0})})]})})]})})})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(v.StrictMode,{children:(0,G.jsx)(p0,{})}));export{_X as a,Pv as c,h as d,d as f,l as h,sX as i,Mc as l,s as m,wX as n,cX as o,o as p,hX as r,eY as s,qX as t,Ss as u}; \ No newline at end of file + -d ${o$(JSON.stringify(V))}`,[d,V,L]);if(n&&!t)return(0,G.jsx)(bY,{});async function oe(e,t){await NQ(e),I(t),window.setTimeout(()=>I(``),1100)}async function se(){let e=performance.now();N(`loading`),ee(null),j(``);try{let e=await ZH(V.model,V.messages[0].content,L||void 0);j(JSON.stringify(e,null,2)),N(`success`)}catch(e){j(e instanceof Error?e.message:String(e)),N(`error`)}finally{ee(Math.round(performance.now()-e))}}function ce(){k.current?.abort(),k.current=null}function le(e,t){E(n=>n.map(n=>{if(n.id!==e)return n;let r=typeof t==`function`?t(n):t;return{...n,...r}}))}async function ue(){let e=x.trim();if(!e&&!C.length||!re||z||D===`loading`)return;ce();let t=new AbortController;k.current=t;let n=C,r={id:s$(`user`),role:`user`,content:e,attachments:n,status:`done`},i=s$(`assistant`),a={id:i,role:`assistant`,content:``,status:`streaming`},o=T;E([...o,r,a]),S(``),w([]),O(`loading`);let s=n$(o,{role:`user`,content:t$(e,n)});try{await eU(re,s,L||void 0,{signal:t.signal,onContent:(e,t)=>le(i,{content:t}),onReasoning:(e,t)=>le(i,{reasoning:t}),onToolCalls:e=>le(i,{toolCalls:c$(e,!0)}),onUsage:e=>le(i,{usage:e})}),le(i,e=>({status:`done`,toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),O(`success`)}catch(e){if(t.signal.aborted){le(i,e=>({status:`done`,toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),O(`success`);return}le(i,{status:`error`,error:e instanceof Error?e.message:String(e)}),O(`error`)}finally{k.current===t&&(k.current=null)}}let de=e(M===`success`?`requestComplete`:M===`error`?`requestFailed`:M===`loading`?`requesting`:`requestIdle`),fe=l$()!=null,pe=[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ni,{size:14,className:`text-muted`})},...s.map(t=>({id:t.id,textValue:`${t.name||t.id} ${EZ(t.provider,t.region,e)}`,label:t.name||t.id,hint:EZ(t.provider,t.region,e),icon:(0,G.jsx)(zZ,{provider:t.provider,size:14})}))],me=s.length||!fe?pe:[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ni,{size:14,className:`text-muted`})},{id:`demo-wb`,textValue:`wb-demo WorkBuddy`,label:`wb-demo`,hint:`WorkBuddy`}],he=R.map(t=>{let n=fX(t),r=pX(t),i=t.display_name||t.id,a=r?e(`modelFree`):n,o=t.provider||t.owned_by||``;return{id:t.id,textValue:`${i} ${t.id} ${o} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,o,a].filter(Boolean).join(` · `)}}),ge=he.length||!fe?he:d$.map(t=>{let n=fX(t),r=pX(t),i=t.display_name||t.id,a=r?e(`modelFree`):n;return{id:t.id,textValue:`${i} ${t.id} ${t.provider} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,t.provider,a].filter(Boolean).join(` · `)}}),_e=!!((x.trim()||C.length)&&re&&!z&&(s.length||fe));function ve(){E(i$()),O(`idle`)}return(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`apiPlayground`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`apiPlaygroundHint`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":ie.length?`ok`:void 0}),(0,G.jsx)(`span`,{children:e(`readyAccounts`,{ready:ie.length,total:s.length})})]})]}),(0,G.jsx)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3 sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:e(`baseUrl`)}),(0,G.jsx)(`code`,{className:`mono mt-0.5 block truncate text-body font-medium text-foreground`,children:l})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e(`copyBaseUrl`),onPress:()=>void oe(l,`base`),children:(0,G.jsx)(MQ,{copied:F===`base`,size:15})}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:ie.length?`success`:`warning`,children:ie.length?e(`endpointReady`):e(`degraded`)})]})]})}),s.length?null:(0,G.jsx)(`p`,{className:`px-1 text-caption text-muted`,children:e(`noAccountsForTest`)}),B?(0,G.jsx)(`p`,{className:`px-1 text-caption text-danger`,children:B}):null,(0,G.jsx)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:(0,G.jsxs)(`div`,{className:`flex min-h-[640px] flex-col md:min-h-[72vh]`,children:[(0,G.jsx)($Q,{messages:T,busy:D===`loading`,onLoadDemo:ve}),(0,G.jsx)(UQ,{value:x,onChange:S,attachments:C,onAttachmentsChange:w,disabled:!s.length&&l$()==null,streaming:D===`loading`,canSend:_e,onSend:()=>void ue(),onStop:ce,accountValue:L||`auto`,onAccountChange:e=>h(e===`auto`?``:e),accountOptions:me,modelValue:re,onModelChange:p,modelOptions:ge,modelsLoading:z})]})}),(0,G.jsx)(e$,{open:r,onOpenChange:i,chatPath:u,prompt:y,onPromptChange:b,onTest:()=>void se(),requestState:M,elapsedMs:P,output:A,responseStatus:de,curl:ae,copiedCurl:F===`curl`,onCopyCurl:()=>void oe(ae,`curl`),canSend:!!(y.trim()&&re&&!z)}),(0,G.jsx)(IQ,{access:t?.access})]})}function p$(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=eY.context(()=>{eY.matchMedia().add(`(prefers-reduced-motion: no-preference)`,()=>{let e=eY.utils.toArray(`.meter__fill`);e.length&&eY.from(e,{scaleX:0,transformOrigin:`left center`,duration:tY.calm,ease:nY.emphasized,stagger:rY.base,clearProps:`transform,transformOrigin`})})},t);return()=>n.revert()},[e])}function m$(e,t,n,r,i,a){return[e.has_add_on&&e.add_on_available!==!1?`${n} ${AX(e.add_on_used)} / ${AX(e.add_on_total)} ${e.add_on_unit||`credits`}`:``,e.has_resource_package&&e.resource_package_available!==!1?`${r} ${t} ${AX(e.resource_package_remaining)} ${e.resource_package_unit||`credits`}`:``,a===`workbuddy`?RX(e,i):``].filter(Boolean)}function h$({window:e,t,extra:n}){let r=Math.round(e.percentage??0),i=IX(e,t),a=t(`quotaUsedPercent`,{n:r}),o=LX(e.reset_at,t),s=`${i} · ${a}${o?` · ${o}`:``}`,c=jX(e),l=MX(e),u=l===`danger`?`danger`:l===`warn`?`warning`:`success`;return(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{className:`block w-full min-w-0`,children:(0,G.jsxs)(`div`,{className:`w-full min-w-0 cursor-help`,children:[(0,G.jsxs)(OV,{className:`account-meter account-meter--window w-full`,color:u,size:`md`,minValue:0,maxValue:100,value:Math.round(c*100),"aria-label":i,valueLabel:s,children:[(0,G.jsxs)(OV.Output,{className:`flex w-full items-baseline justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:i}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-foreground/70`,children:a})]}),(0,G.jsx)(OV.Track,{children:(0,G.jsx)(OV.Fill,{})})]}),o?(0,G.jsx)(`div`,{className:`mt-1 text-caption leading-4 text-muted`,children:o}):null]})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`div`,{children:s}),n?.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function g$({quota:e,t,label:n,usedLabel:r,remainingLabel:i,addOnLabel:a,resourcePackageLabel:o,exceededLabel:s,provider:c}){let l=e.unit||`credits`,u=`${AX(e.used)} / ${AX(e.total)}`,d=`${AX(e.remaining)}`,f=m$(e,i,a,o,t,c),p=NX(e),m=c===`codex`?FX(e.plan):``,h=jX(e),g=MX(e),_=g===`danger`?`danger`:g===`warn`?`warning`:`success`,y=(0,v.useRef)(null);p$(y);let b=`${r} ${u} ${l} · ${i} ${d} ${l}${f.length?` · ${f.join(` · `)}`:``}`;return p.length>0?(0,G.jsxs)(`div`,{ref:y,className:`account-quota-windows flex w-full min-w-0 flex-col gap-3`,children:[m?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`text-muted`,children:t(`quotaPlan`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}):null,p.map((e,n)=>(0,G.jsx)(`div`,{className:`w-full min-w-0`,children:(0,G.jsx)(h$,{window:e,t,extra:n===0?f:void 0})},e.id||String(n)))]}):(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`div`,{ref:y,className:`w-full cursor-help`,children:(0,G.jsxs)(OV,{className:`account-meter w-full`,color:_,size:`md`,minValue:0,maxValue:100,value:Math.round(h*100),"aria-label":n,valueLabel:b,children:[(0,G.jsxs)(OV.Output,{className:`flex w-full items-baseline justify-between text-caption`,children:[(0,G.jsxs)(`span`,{className:`text-body font-semibold leading-5 text-foreground tabular-nums`,children:[e.exceeded?(0,G.jsx)(`span`,{className:`mr-1.5 text-danger`,children:s}):null,d,(0,G.jsx)(`span`,{className:`ml-1 text-caption font-normal text-foreground/60`,children:l})]}),(0,G.jsxs)(`span`,{className:`mono text-foreground/55`,children:[r,` `,u]})]}),(0,G.jsx)(OV.Track,{children:(0,G.jsx)(OV.Fill,{})})]})})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsxs)(`div`,{children:[r,` `,u,` `,l]}),(0,G.jsxs)(`div`,{children:[i,` `,d,` `,l]}),f.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function _$({state:e,stateCopy:t,t:n}){let r=(0,v.useRef)(null),i=OX(e),a=kX(e);return(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=eY.context(()=>{let e=eY.utils.toArray(`[data-runtime-seg]`),t=e.filter((e,t)=>tt>=i),r=eY.matchMedia();r.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(t,{scaleY:1,autoAlpha:1}),eY.set(n,{scaleY:.32,autoAlpha:.45})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.set(e,{transformOrigin:`center bottom`}),eY.to(n,{scaleY:.32,autoAlpha:.45,duration:tY.fast,ease:nY.out,overwrite:!0}),eY.to(t,{scaleY:1,autoAlpha:1,duration:tY.base,ease:nY.out,stagger:{amount:.08,from:`start`},overwrite:!0})})},e);return()=>t.revert()},[i,e]),(0,G.jsxs)(`div`,{ref:r,className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-caption font-medium text-foreground/75`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":a===`muted`?void 0:a===`warn`?`warn`:a}),(0,G.jsx)(`span`,{children:n(`runtimeState`)})]}),(0,G.jsx)(`div`,{className:`runtime-meter min-w-[80px] flex-1`,role:`meter`,"aria-label":n(`runtimeState`),"aria-valuemin":0,"aria-valuemax":12,"aria-valuenow":i,"aria-valuetext":t,children:Array.from({length:12},(e,t)=>(0,G.jsx)(`span`,{"data-runtime-seg":!0,"data-on":t{if(!M&&!N&&P.length===0)return;let e=window.setInterval(()=>A(e=>e+1),1e3);return()=>window.clearInterval(e)},[M,N,P.length]);let ee=v$(j,j===`dead`?N:M,o),F=j===`hot`||j===`ready`?`success`:j===`cooling`?`warning`:j===`quota_exhausted`||j===`login`||j===`unavailable`||j===`dead`||j===`auth_failed`?`danger`:void 0,I=e.last_error||e.lastError,L=e.last_error_kind||e.kind,te=EZ(e.provider,e.region,o),R=e.last_checkin_status,z=R===`success`?`checkinRecordSuccess`:R===`already`?`checkinRecordAlready`:R===`skipped`?`checkinRecordSkipped`:R===`error`?`checkinRecordFailed`:`lastCheckinNone`;return(0,v.useLayoutEffect)(()=>{let e=T.current;if(!e)return;let t=k.current;if(k.current=j,!t||t===j)return;let n=eY.context(()=>{let t=eY.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(e,{scale:1,autoAlpha:1})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.fromTo(e,{scale:.94,autoAlpha:.65},{scale:1,autoAlpha:1,duration:.2,ease:`power2.out`,overwrite:!0})})},e);return()=>n.revert()},[j]),(0,v.useLayoutEffect)(()=>{let e=E.current;if(!e||!n)return;let t=eY.context(()=>{let t=eY.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(e,{autoAlpha:1,y:0})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.fromTo(e,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:.2,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[n]),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,"data-state":j,className:`account-card overflow-hidden p-0`,children:[(0,G.jsxs)(zw.Header,{className:`flex-row items-start justify-between gap-2.5 px-4 pt-3.5 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary`,children:(0,G.jsx)(zZ,{provider:e.provider,size:20})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(zw.Title,{className:`truncate text-body leading-5`,children:e.name||e.id}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted`,children:te})]}),(0,G.jsx)(zw.Description,{className:`mono truncate text-caption leading-4 text-foreground/60`,title:`${e.id}${e.remote_uid?` · UID ${e.remote_uid}`:``}`,children:e.remote_uid?`UID ${e.remote_uid}`:e.id})]})]}),(0,G.jsxs)(`div`,{className:`flex max-w-[48%] shrink-0 flex-wrap justify-end gap-1.5`,children:[(0,G.jsx)(`span`,{ref:T,children:P.length&&j===`cooling`?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:F,children:ee})})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:TX(t)})]},e))]})})]}):(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:F,children:ee})}),P.length&&j!==`cooling`?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`warning`,children:o(`partialCooling`)})})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:TX(t)})]},e))]})})]}):null]})]}),(0,G.jsxs)(zw.Content,{className:`gap-1.5 px-4 pb-3`,children:[(0,G.jsx)(_$,{state:j,stateCopy:ee,t:o}),e.quota?(0,G.jsx)(g$,{quota:e.quota,t:o,label:o(`quota`),usedLabel:o(`quotaUsed`),remainingLabel:o(`quotaRemaining`),addOnLabel:o(`quotaAddOn`),resourcePackageLabel:o(`quotaResourcePackage`),exceededLabel:o(`quotaExceeded`),provider:e.provider}):(0,G.jsx)(`span`,{className:`text-caption text-foreground/65`,children:o(j===`hot`||j===`ready`||j===`loading`||j===`starting`?`quotaLoading`:`quotaUnavailable`)}),I?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(`div`,{className:`flex w-full cursor-help gap-2 rounded-lg bg-surface-secondary p-2 text-left text-caption leading-5 text-foreground`,children:[(0,G.jsx)(io,{size:14,className:`mt-0.5 shrink-0 text-danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[L?(0,G.jsx)(`div`,{className:`mono mb-0.5 truncate text-caption opacity-75`,children:L}):null,(0,G.jsx)(`p`,{className:`break-words line-clamp-3`,children:I})]})]})}),(0,G.jsx)(eL.Content,{children:(0,G.jsxs)(`div`,{className:`max-w-md whitespace-pre-wrap break-words`,children:[L?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption opacity-75`,children:L}):null,I]})})]}):null]}),n&&e.enabled?(0,G.jsxs)(`section`,{ref:E,className:`grid gap-3 bg-surface-secondary/55 px-3 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`oauthDeviceFlow`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:e.provider===`codex`?o(`wizardCodexBrowserLead`):o(`qoderLoginHint`)}),(0,G.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.provider===`codex`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(X,{size:`sm`,isPending:t===`device`,onPress:()=>c(`cli`),children:[(0,G.jsx)(Oa,{size:14}),o(`startCodexCliLogin`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>c(`chatgpt`),children:[(0,G.jsx)(Oa,{size:14}),o(`startCodexChatGPTLogin`)]})]}):(0,G.jsxs)(X,{size:`sm`,isPending:t===`device`,onPress:()=>c(),children:[(0,G.jsx)(Oa,{size:14}),o(`startBrowserLogin`)]})}),(e.provider===`trae`||e.provider===`codex`||e.provider===`devin`)&&f&&d?(0,G.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:o(`wizardCallbackLead`)}),(0,G.jsx)(mL,{className:`h-24 w-full resize-none font-mono text-caption leading-5`,value:u||``,onChange:e=>d(e.target.value),placeholder:o(`wizardCallbackPh`),"aria-label":o(`wizardCallbackPh`)}),(0,G.jsx)(X,{size:`sm`,variant:`secondary`,isPending:t===`callback`,onPress:f,children:o(`wizardSubmitCallback`)})]}):null]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`patFallback`)}),(0,G.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,G.jsxs)(hL,{className:`flex-1`,type:`password`,value:a,onChange:s,children:[(0,G.jsx)(sR,{className:`sr-only`,children:o(`pat`)}),(0,G.jsx)(lL,{placeholder:o(`pasteToken`),"aria-label":o(`pat`)})]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:l,children:[(0,G.jsx)(na,{size:14}),o(`usePat`)]})]})]}),r||i?(0,G.jsxs)(`div`,{className:`text-caption`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:o(`authUrl`)}),(0,G.jsx)(`code`,{className:`mono block break-all text-foreground`,children:r}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:()=>window.open(r,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Qr,{size:14}),o(`openAuthUrl`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>{NQ(r).then(e=>{e&&(O(!0),window.setTimeout(()=>O(!1),1100))})},children:[(0,G.jsx)(MQ,{copied:D}),o(D?`copied`:`copy`)]})]})]}):null,i?(0,G.jsx)(`p`,{className:`mt-1 text-muted`,children:i}):null]}):null]}):null,b?(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-t border-separator px-4 py-2 text-caption text-muted`,children:[(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`lastCheckin`)}),(0,G.jsx)(`span`,{className:R===`error`?`text-danger`:``,children:o(z)})]})}),(0,G.jsxs)(eL.Content,{children:[e.last_checkin_at?new Date(e.last_checkin_at).toLocaleString():o(`lastCheckinNone`),e.last_checkin_msg?` · ${e.last_checkin_msg}`:``]})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`autoCheckin`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-foreground/55`,children:e.checkin_time||_}),(0,G.jsx)(fQ,{isSelected:!!e.auto_checkin,isDisabled:!!t,ariaLabel:o(`autoCheckin`),onChange:e=>y?.(e)})]})}),(0,G.jsx)(eL.Content,{children:e.checkin_time?o(`checkinCustom`):o(`checkinInherit`)})]})]}):null,(0,G.jsxs)(zw.Footer,{className:`flex flex-wrap items-center gap-1.5 bg-surface-secondary px-4 py-2`,children:[m?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`secondary`,isPending:t===`refresh`,onPress:m,"aria-label":o(`refreshAccount`),children:(0,G.jsx)(Jr,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`refreshAccount`)})]}):null,(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:n?`secondary`:`ghost`,isDisabled:!e.enabled,onPress:C,"aria-label":o(`authentication`),children:(0,G.jsx)(na,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`authentication`)})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:w,"aria-label":o(`accountModels`),children:(0,G.jsx)(Mi,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`accountModels`)})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:S,"aria-label":o(`editAccount`),children:(0,G.jsx)(ba,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`editAccount`)})]}),b?(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:!e.enabled||!!t,isPending:t===`checkin`,onPress:b,"aria-label":o(`checkinNow`),children:(0,G.jsx)(ci,{size:15})})}),(0,G.jsx)(eL.Content,{children:o(`checkinNow`)})]}):null,(0,G.jsxs)(nV,{children:[(0,G.jsx)(nV.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`secondary`,"aria-label":o(`more`),children:(0,G.jsx)(Ii,{size:16})})}),(0,G.jsx)(nV.Popover,{placement:`bottom end`,children:(0,G.jsxs)(nV.Menu,{"aria-label":o(`more`),onAction:e=>{e===`export`&&p(),e===`checkin-records`&&x?.(),e===`delete`&&h()},children:[e.auth_type===`none`?null:(0,G.jsxs)(nV.Item,{id:`export`,textValue:o(`export`),children:[(0,G.jsx)(Oi,{size:15}),o(`export`)]}),x?(0,G.jsxs)(nV.Item,{id:`checkin-records`,textValue:o(`checkinRecords`),children:[(0,G.jsx)(ca,{size:15}),o(`checkinRecords`)]}):null,(0,G.jsxs)(nV.Item,{id:`delete`,textValue:o(`delete`),className:`text-danger`,children:[(0,G.jsx)(Ja,{size:15}),o(`delete`)]})]})})]}),(0,G.jsx)(`div`,{className:`ml-auto flex shrink-0 flex-nowrap items-center gap-3 whitespace-nowrap`,children:(0,G.jsx)(fQ,{isSelected:!!e.enabled,isDisabled:t===`toggle`,ariaLabel:e.enabled?o(`disable`):o(`enable`),label:e.enabled?o(`enabledState`):o(`disabled`),onChange:g})})]})]})}function b$(e,t){return e.status===`success`?{label:t(`checkinRecordSuccess`),color:`success`}:e.status===`already`?{label:t(`checkinRecordAlready`),color:`warning`}:e.status===`skipped`?{label:t(`checkinRecordSkipped`),color:`default`}:{label:t(`checkinRecordFailed`),color:`danger`}}function x$(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function S$({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.useState)(``),l=e?.id||``,u=t(`checkinRecordsTitle`,{name:e?.name||e?.id||``});async function d(){if(l){o(!0),c(``);try{let e=await iU(l);i(e.data||[])}catch(e){i([]),c(e instanceof Error?e.message:String(e))}finally{o(!1)}}}return(0,v.useEffect)(()=>{l&&d()},[l]),(0,G.jsx)(Z.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:u}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`checkinRecordsHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`px-5 pb-2`,children:[s?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(bU,{title:s})}):null,a?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)($,{className:`h-16 w-full`}),(0,G.jsx)($,{className:`h-16 w-full`}),(0,G.jsx)($,{className:`h-16 w-full`})]}):r.length?(0,G.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(e=>{let n=b$(e,t);return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0`,"data-state":e.status===`error`?`warn`:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:n.color,children:n.label}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:x$(e.created_at)})]}),(0,G.jsx)(`p`,{className:`mt-1 break-words text-caption leading-5 text-foreground/75`,children:e.message||`—`})]})]},e.id)})}):(0,G.jsx)(pQ,{className:`min-h-44 rounded-3xl bg-surface-secondary`,title:t(`checkinRecordsEmpty`),hint:t(`checkinRecordsHint`)})]}),(0,G.jsxs)(Z.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t(`checkinRecordsCount`,{count:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:a,onPress:()=>void d(),children:[(0,G.jsx)(Jr,{size:14}),t(`refresh`)]})]})]})]})})})})}function C$(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function w$({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=e?.id||``,f=t(`accountModelsTitle`,{name:e?.name||e?.id||``}),p=e?EZ(e.provider,e.region,t):``;async function m(e=!1){if(d){e?c(!0):(o(!0),i([])),u(``);try{let t=await(e?qH(d):GH(d));i(t.data||[])}catch(e){i([]),u(e instanceof Error?e.message:String(e))}finally{o(!1),c(!1)}}}return(0,v.useEffect)(()=>{if(!d)return;let e=!1;return GH(d).then(t=>{e||(i(t.data||[]),u(``),o(!1))}).catch(t=>{e||(i([]),u(t instanceof Error?t.message:String(t)),o(!1))}),()=>{e=!0}},[d]),(0,G.jsx)(Z.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:f}),(0,G.jsx)(`p`,{className:`mt-1 text-caption font-normal leading-5 text-muted`,children:t(`accountModelsHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(zZ,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:p}),(0,G.jsx)(`span`,{className:`text-border`,children:`·`}),(0,G.jsx)(`span`,{className:`mono`,children:e.id})]}):null]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`px-5 pb-2`,children:[l?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(bU,{title:t(`accountModelsError`,{msg:l})})}):null,a||s?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)($,{className:`h-14 w-full`}),(0,G.jsx)($,{className:`h-14 w-full`}),(0,G.jsx)($,{className:`h-14 w-full`})]}):r.length?(0,G.jsx)(`ul`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(n=>{let r=n.provider||n.owned_by||e?.provider||`qoder`,i=C$(n),a=fX(n),o=pX(n);return(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":n.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.display_name||n.id}),o?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,a?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a}):null,n.stale?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`warning`,children:t(`fallback`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:n.id}),i?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:i})}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5 text-caption text-muted`,children:[(0,G.jsx)(zZ,{provider:r,size:12}),(0,G.jsx)(`span`,{children:r})]})]},n.id)})}):(0,G.jsx)(pQ,{className:`min-h-48 rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(Mi,{size:22}),title:t(`accountModelsEmpty`),hint:t(`noModelsYet`)})]}),(0,G.jsxs)(Z.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`refreshing`):t(`shownTotal`,{shown:r.length,total:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:s,onPress:()=>void m(!0),children:[(0,G.jsx)(Jr,{size:14}),t(s?`refreshing`:`refresh`)]})]})]})]})})})})}var T$=`w-28`;function E$({label:e,hint:t,labelWidthClass:n=T$,htmlFor:r,align:i=`center`,children:a}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex gap-3 ${i===`start`?`items-start`:`items-center`}`,children:[(0,G.jsx)(sR,{htmlFor:r,className:`${n} shrink-0 ${i===`start`?`pt-2`:``} text-body font-medium text-foreground`,children:e}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 [&_[data-slot=input]]:w-full [&_[data-slot=textarea]]:w-full`,children:a})]}),t?(0,G.jsx)(`p`,{className:`mt-1.5 pl-[7.75rem] text-caption leading-5 text-muted`,children:t}):null]})}function D$({catalog:e,selected:t,onChange:n,isDisabled:r,t:i}){let[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(t),l=(0,v.useMemo)(()=>new Set(t),[t]),u=(0,v.useMemo)(()=>{let t=new Set(s),n=a.trim().toLowerCase(),r=(e||[]).filter(e=>!n||e.toLowerCase().includes(n));return[...r.filter(e=>t.has(e)),...r.filter(e=>!t.has(e))]},[e,a,s]),d=(0,v.useMemo)(()=>{if(!e)return[];let n=new Set(e);return t.filter(e=>!n.has(e))},[e,t]),f=e?.length??0,p=t.filter(e=>!d.includes(e)).length;function m(e){o(e),c(t)}function h(e,r){n(r?[...t,e]:t.filter(t=>t!==e))}function g(){let e=new Set(t);u.forEach(t=>e.add(t)),n([...e])}function _(){let e=new Set(u);n(t.filter(t=>!e.has(t)))}return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(aR,{"aria-label":i(`modelPickerSearch`),value:a,onChange:m,isDisabled:r,className:`min-w-0 flex-1 basis-48`,children:(0,G.jsxs)(aR.Group,{children:[(0,G.jsx)(aR.SearchIcon,{}),(0,G.jsx)(aR.Input,{placeholder:i(`modelPickerSearch`)}),(0,G.jsx)(aR.ClearButton,{})]})}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-caption text-muted`,children:i(`modelPickerCount`,{selected:p,total:f})}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,isDisabled:r||u.length===0,onPress:g,children:[(0,G.jsx)(Si,{size:14}),i(`modelPickerSelectAll`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,isDisabled:r||t.length===0,onPress:_,children:[(0,G.jsx)(Ra,{size:14}),i(`modelPickerClear`)]})]})]}),(0,G.jsxs)(`div`,{className:`max-h-[300px] overflow-y-auto overscroll-contain rounded-lg bg-surface-secondary p-1`,children:[e===null?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(`refreshing`)}):null,d.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md px-2.5 py-1.5`,children:[(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-body text-muted line-through`,children:e}),(0,G.jsx)(`span`,{className:`shrink-0 text-caption text-warning`,children:i(`modelPickerOffline`)}),(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:r,"aria-label":i(`modelPickerRemove`,{model:e}),onPress:()=>h(e,!1),children:(0,G.jsx)(oo,{size:14})})]},`offline-${e}`)),u.map(e=>(0,G.jsx)(aT,{isSelected:l.has(e),isDisabled:r,onChange:t=>h(e,t),className:`flex w-full cursor-pointer rounded-md px-2.5 py-1.5 transition-colors hover:bg-default`,children:(0,G.jsxs)(aT.Content,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,G.jsx)(aT.Control,{children:(0,G.jsx)(aT.Indicator,{})}),(0,G.jsx)(`span`,{className:`mono min-w-0 truncate text-body text-foreground`,children:e})]})},e)),e!==null&&u.length===0?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(f===0?`noAccountModels`:`modelPickerNoMatch`)}):null]})]})}function O$(e){let[t,n]=(0,v.useState)(e);e&&!t&&n(!0);let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(e);return(0,v.useLayoutEffect)(()=>{let t=r.current,o=i.current;if(!t||!o)return;if(a.current){a.current=!1;return}eY.killTweensOf([t,o]);let s=t.getBoundingClientRect().height;if(e){eY.set(t,{overflow:`hidden`});let e=t.scrollHeight;eY.fromTo(t,{height:s===e?0:s},{height:e,duration:aY(tY.base),ease:nY.out,onComplete:()=>eY.set(t,{clearProps:`height,overflow`})}),eY.fromTo(o,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:aY(tY.base),ease:nY.out})}else eY.set(t,{overflow:`hidden`,height:s}),eY.to(o,{autoAlpha:0,y:-4,duration:aY(tY.fast),ease:nY.inOut}),eY.to(t,{height:0,duration:aY(tY.fast+.04),ease:nY.inOut,onComplete:()=>n(!1)});return()=>{eY.killTweensOf([t,o])}},[e,t]),{mounted:t,outerRef:r,innerRef:i}}function k$({account:e,checkinDefaultTime:t,checkinTimezone:n,busy:r,t:i,onClose:a,onSave:o}){let[s,c]=(0,v.useState)(e?.name||``),[l,u]=(0,v.useState)(e?.max_inflight??4),[d,f]=(0,v.useState)(e?.priority??50),[p,m]=(0,v.useState)(e?.proxy_url||``),[h,g]=(0,v.useState)(!!e?.drop_system_prompt),[_,y]=(0,v.useState)(Object.entries(e?.model_aliases||{}).map(([e,t])=>({alias:e,model:t}))),[b,x]=(0,v.useState)({alias:``,model:``}),[S,C]=(0,v.useState)(!!e?.models_restricted),[w,T]=(0,v.useState)(e?.enabled_models||[]),{mounted:E,outerRef:D,innerRef:O}=O$(S),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!e?.checkin_time),[N,P]=(0,v.useState)(e?.checkin_time||null),[ee,F]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!e?.id)return;let t=!1;return GH(e.id).then(e=>{t||A(e.data||[])}).catch(()=>{t||A([])}),()=>{t=!0}},[e?.id]);let I=i(`editAccountTitle`,{name:e?.name||e?.id||``}),L=e?EZ(e.provider,e.region,i):``;async function te(n){n?.preventDefault();let r=s.trim();if(!r){F(i(`accountNameRequired`));return}if(!Number.isInteger(l)||l<1||l>32){F(i(`maxInflightInvalid`));return}if(!Number.isInteger(d)||d<1||d>100){F(i(`priorityInvalid`));return}if(t!==void 0&&!j&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(N??t)){F(i(`checkinTimeInvalid`));return}F(``);try{await o({name:r,max_inflight:l,priority:d,proxy_url:p.trim(),checkin_time:t===void 0?void 0:j?``:N??t,drop_system_prompt:e?.provider===`workbuddy`?h:void 0,model_aliases:Object.fromEntries(_.filter(e=>e.alias.trim()&&e.model.trim()).map(e=>[e.alias.trim(),e.model.trim()])),enabled_models:S?w:[],set_model_routing:!0}),a()}catch(e){F(e instanceof Error?e.message:String(e))}}return(0,G.jsx)(Z.Root,{isOpen:!!e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:I}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:i(`editAccountHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(zZ,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:L})]})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.id})]}):null]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsxs)(Z.Body,{className:`px-6 pb-2 pt-1`,children:[ee?(0,G.jsxs)(RB,{status:`danger`,className:`mb-4`,children:[(0,G.jsx)(RB.Indicator,{}),(0,G.jsx)(RB.Content,{children:(0,G.jsx)(RB.Title,{children:ee})})]}):null,(0,G.jsxs)(FB,{className:`space-y-4`,onSubmit:e=>void te(e),children:[(0,G.jsx)(E$,{label:i(`accountName`),children:(0,G.jsx)(lL,{value:s,onChange:e=>c(e.target.value),placeholder:i(`wizardNamePh`),"aria-label":i(`accountName`),disabled:r,autoFocus:!0})}),(0,G.jsx)(E$,{label:i(`maxInflight`),hint:i(`maxInflightHint`),children:(0,G.jsx)(sV,{value:l,onChange:e=>u(e??4),minValue:1,maxValue:32,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":i(`maxInflight`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:i(`priority`),hint:i(`priorityHint`),children:(0,G.jsx)(sV,{value:d,onChange:e=>f(e??50),minValue:1,maxValue:100,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":i(`priority`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:i(`proxyUrl`),hint:i(`proxyUrlHint`),children:(0,G.jsx)(lL,{value:p,onChange:e=>m(e.target.value),placeholder:i(`proxyUrlPlaceholder`),"aria-label":i(`proxyUrl`),disabled:r})}),e?.provider===`workbuddy`?(0,G.jsx)(E$,{label:i(`dropSystemPrompt`),hint:i(`dropSystemPromptHint`),children:(0,G.jsx)(fQ,{isSelected:h,isDisabled:r,ariaLabel:i(`dropSystemPrompt`),onChange:g})}):null,(0,G.jsx)(E$,{align:`start`,label:i(`accountModelAliases`),hint:i(`accountModelAliasesHint`),children:(0,G.jsxs)(`div`,{className:`space-y-2`,children:[_.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono min-w-0 truncate text-body`,children:[e.alias,` → `,e.model]}),(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:r,onPress:()=>y(t=>t.filter(t=>t.alias!==e.alias)),children:i(`modelAliasRemove`)})]},e.alias)),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,G.jsx)(lL,{"aria-label":i(`modelAliasName`),value:b.alias,onChange:e=>x(t=>({...t,alias:e.target.value})),placeholder:i(`modelAliasPlaceholder`),disabled:r}),(0,G.jsx)(lL,{"aria-label":i(`modelAliasTarget`),value:b.model,onChange:e=>x(t=>({...t,model:e.target.value})),placeholder:i(`accountModelAliasTargetPlaceholder`),disabled:r}),(0,G.jsx)(X,{size:`sm`,variant:`secondary`,isDisabled:r||!b.alias.trim()||!b.model.trim(),onPress:()=>{y(e=>[...e.filter(e=>e.alias!==b.alias.trim()),{alias:b.alias.trim(),model:b.model.trim()}]),x({alias:``,model:``})},children:i(`modelAliasAdd`)})]})]})}),(0,G.jsxs)(`section`,{className:`space-y-3 pt-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:i(`enabledModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:i(`enabledModelsHint`)})]}),(0,G.jsx)(fQ,{isSelected:S,isDisabled:r,ariaLabel:i(`restrictModels`),label:i(S?`restrictModels`:`allModels`),onChange:C})]}),E?(0,G.jsx)(`div`,{ref:D,children:(0,G.jsx)(`div`,{ref:O,children:(0,G.jsx)(D$,{catalog:k?k.map(e=>e.id):null,selected:w,onChange:T,isDisabled:r,t:i})})}):null]}),t===void 0?null:(0,G.jsx)(E$,{label:i(`autoCheckinTime`),hint:i(`checkinScheduleHint`),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(fQ,{isSelected:j,isDisabled:r,onChange:M,ariaLabel:i(`checkinInherit`),label:i(`checkinInherit`)}),(0,G.jsxs)(`p`,{className:`text-caption text-muted`,children:[i(`checkinDefaultValue`,{time:t}),` · `,(0,G.jsx)(`span`,{className:`mono`,children:n})]}),j?null:(0,G.jsx)(lL,{type:`time`,value:N??t,onChange:e=>P(e.target.value),"aria-label":i(`autoCheckinTime`),disabled:r,required:!0})]})})]})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,G.jsx)(X,{variant:`ghost`,isDisabled:r,onPress:a,children:i(`cancel`)}),(0,G.jsx)(X,{isPending:r,onPress:()=>void te(),children:i(`save`)})]})]})})})})}var A$={1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-3`};function j$({options:e,value:t,onChange:n,ariaLabel:r,columns:i=2,className:a=``}){let o=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=eY.context(()=>{let e=eY.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(`[data-option-tile]`,{autoAlpha:1,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{eY.fromTo(`[data-option-tile]`,{autoAlpha:0,y:8},{autoAlpha:1,y:0,duration:.32,stagger:.035,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[e.length]),(0,G.jsx)(`div`,{ref:o,role:`radiogroup`,"aria-label":r,className:`grid gap-3 ${A$[i]} ${a}`.trim(),children:e.map(e=>{let r=e.value===t;return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-option-tile":``,"data-selected":r||void 0,disabled:e.disabled,title:e.hint,onClick:()=>n(e.value),className:`flex h-16 min-w-0 items-center gap-3 rounded-xl bg-surface shadow-surface px-4 text-left transition-colors hover:bg-surface-secondary disabled:cursor-not-allowed disabled:opacity-50 data-selected:border-accent data-selected:bg-accent-soft`,children:[e.icon?(0,G.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground [&_svg]:size-[18px]`,children:e.icon}):null,(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body font-medium leading-5 text-foreground`,children:e.label})]},e.value)})})}function M$(e,t){let n={...e},r=n.format===`workbuddy-accounts`||Array.isArray(n.accounts);return n.format?r&&(n.format=`workbuddy-accounts`):n.format=r?`workbuddy-accounts`:`workbuddy-oauth-v1`,{...n,name:t.name?.trim()||n.name,enabled:t.enabled??!0,provider:`workbuddy`,region:t.region,max_inflight:t.max_inflight??4,priority:t.priority??50,drop_system_prompt:t.drop_system_prompt??!0,...t.proxy_url!=null&&t.proxy_url!==``?{proxy_url:t.proxy_url}:{}}}function N$(e,t){let n=typeof e?.succeeded==`number`?e.succeeded:e?.id||e?1:0,r=typeof e?.failed==`number`?e.failed:0,i=(e?.errors||[]).slice(0,3).map(e=>e.message||`index ${e.index}`).filter(Boolean).join(`; `),a;return a=r>0?t(`accountImportPartial`).replace(`{ok}`,String(n)).replace(`{fail}`,String(r))+(i?` — ${i}`:``):n>1?t(`accountImportBatch`).replace(`{n}`,String(n)):t(`accountImported`),{succeeded:n,failed:r,message:a}}async function P$(e,t){return sU(M$(e,t))}var F$={global:`Global`,cn:`CN`},I$={"qoder-global":`accountTypeQoderGlobal`,"qoder-cn":`accountTypeQoderCN`,"workbuddy-cn":`accountTypeWorkBuddyCN`,"workbuddy-global":`accountTypeWorkBuddyGlobal`,"trae-cn":`accountTypeTraeCN`,"devin-global":`accountTypeDevinGlobal`,"command-global":`accountTypeCommandGlobal`,"codex-global":`accountTypeCodexGlobal`,"zhipu-cn":`accountTypeZhipuCN`,"qwenwork-global":`accountTypeQwenworkGlobal`,"qwenwork-cn":`accountTypeQwenworkCN`,"kimi-cn":`accountTypeKimiCN`},L$={"qoder-global":`accountTypeQoderGlobalHint`,"qoder-cn":`accountTypeQoderCNHint`,"workbuddy-cn":`accountTypeWorkBuddyCNHint`,"workbuddy-global":`accountTypeWorkBuddyGlobalHint`,"trae-cn":`accountTypeTraeCNHint`,"devin-global":`accountTypeDevinGlobalHint`,"command-global":`accountTypeCommandGlobalHint`,"codex-global":`accountTypeCodexGlobalHint`,"zhipu-cn":`accountTypeZhipuCNHint`,"qwenwork-global":`accountTypeQwenworkGlobalHint`,"qwenwork-cn":`accountTypeQwenworkCNHint`,"kimi-cn":`accountTypeKimiCNHint`};function R$({ariaLabel:e}){return(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,"aria-busy":`true`,"aria-label":e,children:Array.from({length:6},(e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-xl bg-surface-secondary px-3 py-2.5`,children:[(0,G.jsx)(qP,{className:`size-7 shrink-0 rounded-lg`}),(0,G.jsx)(qP,{className:`h-4 w-20 rounded-lg`})]},t))})}async function z$(){let e=(await tU().catch(()=>null))?.data||[],t=[];for(let n of e)for(let e of n.regions)t.push({id:`${n.id}-${e.id}`,provider:n.id,region:e.id,descriptor:n});return t}function B$(e,t){let n=I$[e.id];if(n){let e=t(n);if(e!==n)return e}let r=e.descriptor.regions.find(t=>t.id===e.region)?.label||F$[e.region]||``,i=e.descriptor.regions.length>1&&r?` ${r}`:``;return`${e.descriptor.label}${i}`.trim()}function V$(e,t){if(!e)return``;let n=L$[e.id];if(!n)return``;let r=t(n);return r===n?``:r}function H$({phase:e,busy:t,tab:n,forTab:r}){return e===`done`?(0,G.jsx)(bi,{size:16,className:`text-success`}):t&&n===r?(0,G.jsx)(uY,{size:16,loading:!0}):null}var U$=90,W$=2e3;function G$({isOpen:e,onClose:t,onAdded:n}){let{t:r}=DH(),[i,a]=(0,v.useState)(`method`),[o,s]=(0,v.useState)(`browser`),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(4),[x,S]=(0,v.useState)(50),[C,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(`payg`),[N,P]=(0,v.useState)(``),[ee,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(``),[te,R]=(0,v.useState)(`idle`),[z,B]=(0,v.useState)(``),[ne,re]=(0,v.useState)(``),[ie,V]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(``),[se,ce]=(0,v.useState)(`cli`),le=(0,v.useRef)(null),ue=(0,v.useRef)(null),de=(0,v.useRef)(null),fe=(0,v.useRef)(``),pe=(0,v.useRef)(null),me=(0,v.useRef)(null);function he(){pe.current!==null&&(window.clearTimeout(pe.current),pe.current=null)}(0,v.useEffect)(()=>()=>he(),[]),(0,v.useEffect)(()=>{if(!e)return;let t=!1;return p(!0),d([]),l(``),z$().then(e=>{t||(d(e),l(e[0]?.id||``),s(`browser`))}).finally(()=>{t||p(!1)}),()=>{t=!0}},[e]);let ge=u.find(e=>e.id===c),_e=!!ge&&!f,ve=ge?.descriptor.capabilities?.pat_login!==!1,ye=ge?.descriptor.capabilities?.import_export!==!1,be=ge?.descriptor.capabilities?.browser_login!==!1,xe=ge?.provider===`workbuddy`,Se=ge?.provider===`trae`||ge?.provider===`devin`||ge?.provider===`codex`,Ce=te===`busy`||te===`polling`,we=!!fe.current||Ce,Te=te===`done`,Ee=V$(ge,r);(0,v.useEffect)(()=>{o===`pat`&&!ve&&s(`browser`),o===`import`&&!ye&&s(`browser`)},[ye,ve,o]),(0,v.useEffect)(()=>{be||(ve?s(`pat`):ye&&s(`import`))},[be,ye,ve]);function De(){return!Number.isInteger(y)||y<1||y>32?4:y}function Oe(){return!Number.isInteger(x)||x<1||x>100?50:x}function ke(){return{max_inflight:De(),priority:Oe(),drop_system_prompt:xe?C:ge?.provider!==`kimi`,proxy_url:T.trim()}}function Ae(){he(),a(`method`),s(`browser`),l(``),d([]),p(!1),_(``),b(4),S(50),w(!0),E(``),O(``),A(``),M(`payg`),P(``),F(``),L(``),h(!1),R(`idle`),B(``),re(``),V(!1),oe(``),ce(`cli`),fe.current=``}function je(){Ce||(Ae(),t())}function Me(){Ae(),t()}(0,v.useLayoutEffect)(()=>{let t=le.current;if(e||(de.current=null),!t||!e)return;let n=eY.context(()=>{let e=eY.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{eY.set(t,{autoAlpha:1,x:0,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=de.current,n=e&&e!==i?i===`login`?1:-1:0;eY.fromTo(t,{autoAlpha:0,x:20*n,y:n?0:12},{autoAlpha:1,x:0,y:0,duration:tY.slow,ease:nY.out,overwrite:!0}),n&&ue.current&&eY.fromTo(ue.current,{autoAlpha:0,y:6},{autoAlpha:1,y:0,duration:tY.base,ease:nY.out,overwrite:!0})})},t);return de.current=i,()=>n.revert()},[e,i]);function Ne(e){if(Ce||!_e)return;let t=u.find(t=>t.id===e);l(e),s(t?.provider===`zhipu`?`pat`:`browser`),B(``),a(`login`)}async function Pe(){if(fe.current)return fe.current;if(!ge)throw Error(r(`accountTypeHint`));let e=ke(),t=await nU(g.trim()||r(`account`),ge.provider,ge.region,e),n=t?.id||t?.data?.id;if(!n)throw Error(`create account returned no id`);return fe.current=n,n}async function Fe(){B(``),re(``);try{R(`busy`);let e=await Pe();B(r(`wizardStartingSession`)),R(`polling`);let t=await RH(e,ge?.provider===`codex`?se:void 0);t.authUrl&&re(t.authUrl),B(r(`wizardWaitingBrowser`));for(let t=0;t{pe.current=window.setTimeout(e,W$)});let n=(await zH(e)).login||{};if(n.message&&B(n.message),n.status===`ok`)break;if(n.status===`error`)throw Error(n.message||`login failed`);if(t===89)throw Error(r(`wizardLoginTimeout`))}R(`done`),B(r(`wizardAccountReady`)),n(),window.setTimeout(Me,900)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}async function Ie(){let e=ae.trim();if(!e){B(r(`wizardCallbackPh`));return}try{R(`busy`);let t=await Pe();he(),await BH(t,e),R(`done`),B(r(`wizardAccountReady`)),n(),window.setTimeout(Me,900)}catch(e){R(`polling`),B(e instanceof Error?e.message:String(e))}}async function Le(){let e=N.trim();if(!e){B(r(`zhipuKeyRequired`));return}if(!ge){B(r(`accountTypeHint`));return}B(``);try{R(`busy`);let t=ke();await sU({format:`zhipu-key-v1`,api_key:e,mode:j,organization:j===`coding`?ee.trim():``,project:j===`coding`?I.trim():``,name:g.trim()||r(`accountTypeZhipuCN`),enabled:!0,provider:ge.provider,region:ge.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}),R(`done`),B(r(`wizardAccountReady`)),n(),window.setTimeout(Me,700)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}async function Re(){let e=D.trim();if(!e){B(r(`pastePatFirst`));return}B(``);try{R(`busy`);let t=await Pe();B(r(`wizardStartingSession`)),await VH(e,t),R(`done`),B(r(`patDone`)),n(),window.setTimeout(Me,700)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}async function ze(){B(``);let e;try{e=JSON.parse(k)}catch{B(r(`wizardBadJson`));return}if(!e||typeof e!=`object`){B(r(`wizardBadJson`));return}if(!ge){B(r(`accountTypeHint`));return}if(ge.provider===`qoder`&&(typeof e.user_blob!=`string`||typeof e.machine_id!=`string`)){B(r(`wizardBadJson`));return}let t=ke(),i;ge.provider===`workbuddy`?i=M$(e,{region:ge.region===`global`?`global`:`cn`,name:g.trim()||void 0,enabled:!0,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}):(e.format||(ge.descriptor.id===`trae`?e.format=`trae-oauth-v1`:ge.descriptor.id===`devin`?e.format=`devin-session-v1`:ge.descriptor.id===`command`?e.format=`command-key-v1`:ge.descriptor.id===`qwenwork`?e.format=`qwenwork-oauth-v1`:e.format=`qoder-native-v1`),i={...e,name:g.trim()||e.name,enabled:!0,provider:ge.provider,region:ge.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt});try{R(`busy`);let{failed:e,message:t}=N$(await sU(i),r);R(`done`),B(t),n(),window.setTimeout(Me,e>0?1600:700)}catch(e){R(`idle`),B(e instanceof Error?e.message:String(e))}}function Be(){me.current?.click()}function Ve(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>A(String(n.result||``)),n.readAsText(t),e.target.value=``}let He=e=>Ce&&o===e,Ue=u.map(e=>({value:e.id,label:B$(e,r),hint:V$(e,r),icon:(0,G.jsx)(zZ,{provider:e.provider,size:18}),disabled:we})),We=ge?.provider===`zhipu`,Ge=[ge?.descriptor.capabilities?.browser_login===!1?null:{value:`browser`,label:r(`tabBrowser`),icon:(0,G.jsx)(Oa,{size:16})},ve?{value:`pat`,label:r(`tabPat`),icon:(0,G.jsx)(na,{size:16})}:null,ye?{value:`import`,label:r(`tabImport`),icon:(0,G.jsx)(Hi,{size:16})}:null].filter(Boolean),Ke=r(o===`browser`?ge?.provider===`codex`?`wizardCodexBrowserLead`:`wizardBrowserLead`:o===`pat`?ge?.provider===`command`?`wizardPatLeadCommand`:ge?.region===`cn`&&ge?.provider===`qoder`?`wizardPatLeadCN`:`wizardPatLead`:`wizardImportLead`);return(0,G.jsx)(Z.Root,{isOpen:e,onOpenChange:e=>{e||je()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,isDismissable:!Ce,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,className:`sm:max-w-4xl`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`relative items-center justify-center px-12 pt-5 text-center`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:r(`addAccountTitle`)}),(0,G.jsx)(`p`,{ref:ue,className:`mt-1 text-caption font-normal leading-5 text-muted`,children:i===`method`?r(`addAccountDesc`):Ee||r(`addAccountDesc`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":r(`close`),className:`absolute right-4 top-4 grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsx)(Z.Body,{className:`px-6 pb-2`,children:(0,G.jsx)(`div`,{ref:le,children:i===`method`?(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(`section`,{className:`space-y-2.5`,children:f?(0,G.jsx)(R$,{ariaLabel:r(`accountType`)}):_e?(0,G.jsx)(j$,{ariaLabel:r(`accountType`),columns:2,value:``,onChange:Ne,options:Ue}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:r(`accountTypeHint`)})})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-surface-secondary/45 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:(0,G.jsx)(zZ,{provider:ge?.provider,size:18})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-medium text-foreground`,children:ge?B$(ge,r):r(`accountType`)}),(0,G.jsx)(`div`,{className:`truncate text-caption text-muted`,children:Ee})]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>a(`method`),isDisabled:Ce||!!fe.current,children:[(0,G.jsx)(ui,{size:12}),r(`wizardBack`)]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,G.jsx)(E$,{label:r(`accountName`),children:(0,G.jsx)(lL,{value:g,onChange:e=>_(e.target.value),placeholder:r(`wizardNamePh`),"aria-label":r(`accountName`),disabled:we,autoFocus:!0})}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-expanded":m,className:`inline-flex items-center gap-1 text-caption font-medium text-muted transition-colors hover:text-foreground`,children:[(0,G.jsx)(fi,{size:12,className:`transition-transform duration-200 ${m?`rotate-90`:``}`}),r(`wizardAdvanced`)]}),m?(0,G.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-secondary px-3.5 py-3.5`,children:[(0,G.jsx)(E$,{label:r(`maxInflight`),hint:r(`maxInflightHint`),children:(0,G.jsx)(sV,{value:y,onChange:e=>b(e??4),minValue:1,maxValue:32,isDisabled:we,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":r(`maxInflight`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:r(`priority`),hint:r(`priorityHint`),children:(0,G.jsx)(sV,{value:x,onChange:e=>S(e??50),minValue:1,maxValue:100,isDisabled:we,isRequired:!0,children:(0,G.jsxs)(sV.Group,{children:[(0,G.jsx)(sV.DecrementButton,{}),(0,G.jsx)(sV.Input,{"aria-label":r(`priority`)}),(0,G.jsx)(sV.IncrementButton,{})]})})}),(0,G.jsx)(E$,{label:r(`proxyUrl`),hint:r(`proxyUrlHint`),children:(0,G.jsx)(lL,{value:T,onChange:e=>E(e.target.value),placeholder:r(`proxyUrlPlaceholder`),"aria-label":r(`proxyUrl`),disabled:we})}),xe?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:r(`dropSystemPrompt`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:r(`dropSystemPromptCreateHint`)})]}),(0,G.jsx)(fQ,{isSelected:C,isDisabled:we,ariaLabel:r(`dropSystemPrompt`),onChange:w})]}):null]}):null]}),We?(0,G.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-body font-medium text-muted`,children:r(`zhipuAccountMode`)}),(0,G.jsx)(j$,{ariaLabel:r(`zhipuAccountMode`),columns:2,value:j,onChange:e=>{Ce||M(e)},options:[{value:`payg`,label:r(`zhipuModePayg`),hint:r(`zhipuModePaygHint`),disabled:Ce},{value:`coding`,label:r(`zhipuModeCoding`),hint:r(`zhipuModeCodingHint`),disabled:Ce}]})]}),(0,G.jsx)(E$,{label:r(`zhipuApiKey`),children:(0,G.jsx)(lL,{type:`password`,value:N,onChange:e=>P(e.target.value),placeholder:r(`zhipuApiKeyPh`),"aria-label":r(`zhipuApiKey`),disabled:Ce})}),j===`coding`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E$,{label:r(`zhipuOrganization`),children:(0,G.jsx)(lL,{value:ee,onChange:e=>F(e.target.value),placeholder:r(`zhipuOrganizationPh`),"aria-label":r(`zhipuOrganization`),disabled:Ce})}),(0,G.jsx)(E$,{label:r(`zhipuProject`),children:(0,G.jsx)(lL,{value:I,onChange:e=>L(e.target.value),placeholder:r(`zhipuProjectPh`),"aria-label":r(`zhipuProject`),disabled:Ce})})]}):null,z?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:te===`busy`,onPress:()=>void Le(),isDisabled:Te,children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(na,{size:15}),r(`zhipuCreate`)]})})]}):null,We?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qX,{className:`mt-3`,value:o,onChange:e=>{!Ce&&e!==o&&(s(e),B(``),re(``),V(!1))},ariaLabel:r(`authentication`),options:Ge.map(e=>({id:e.value,label:e.label,icon:e.icon}))}),(0,G.jsx)(`p`,{className:`mt-2 min-h-5 text-caption leading-5 text-muted`,children:Ke}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-col gap-4`,children:o===`browser`?(0,G.jsxs)(G.Fragment,{children:[ge?.provider===`codex`?(0,G.jsx)(j$,{ariaLabel:r(`codexLoginMethod`),columns:2,value:se,onChange:e=>{Ce||ce(e)},options:[{value:`cli`,label:r(`codexLoginCli`),hint:r(`codexLoginCliHint`),disabled:Ce||!!fe.current},{value:`chatgpt`,label:r(`codexLoginChatGPT`),hint:r(`codexLoginChatGPTHint`),disabled:Ce||!!fe.current}]}):null,ne?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(H$,{phase:te,busy:Ce,tab:o,forTab:`browser`}),(0,G.jsx)(`span`,{className:`text-muted`,children:z||r(`loginOpenMsg`)})]}),(0,G.jsx)(`code`,{className:`mono mt-2 block break-all text-caption leading-5 text-foreground`,children:ne}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:()=>window.open(ne,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Qr,{size:14}),r(`openAuthUrl`)]}),(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>{NQ(ne).then(e=>{e&&(V(!0),window.setTimeout(()=>V(!1),1100))})},children:[(0,G.jsx)(MQ,{copied:ie}),r(ie?`copied`:`copy`)]})]})]}):null,z&&!ne?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,Se?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:r(`wizardCallbackLead`)}),(0,G.jsx)(mL,{className:`h-28 w-full resize-none font-mono text-caption leading-5`,value:ae,onChange:e=>oe(e.target.value),placeholder:r(`wizardCallbackPh`),"aria-label":r(`wizardCallbackPh`),disabled:Te}),(0,G.jsx)(X,{className:`w-full`,variant:`secondary`,isPending:te===`busy`&&!!ae.trim(),onPress:()=>void Ie(),isDisabled:Te,children:r(`wizardSubmitCallback`)})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:He(`browser`),onPress:()=>void Fe(),children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Oa,{size:15}),r(`wizardStartBrowser`)]})})]}):o===`pat`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E$,{label:r(`tabPat`),children:(0,G.jsx)(lL,{type:`password`,value:D,onChange:e=>O(e.target.value),placeholder:r(`wizardPatPh`),"aria-label":r(`wizardPatPh`),disabled:Ce})}),z?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:He(`pat`),onPress:()=>void Re(),children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`patDone`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(na,{size:15}),r(`wizardCreateAndLogin`)]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:`JSON`}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:Be,isDisabled:Ce,children:[(0,G.jsx)(Hi,{size:13}),r(`wizardChooseFile`)]}),(0,G.jsx)(`input`,{ref:me,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:Ve})]}),(0,G.jsx)(mL,{className:`min-h-32 font-mono text-caption`,value:k,onChange:e=>A(e.target.value),placeholder:r(`wizardImportPh`),"aria-label":r(`tabImport`),disabled:Ce}),z?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[Te?(0,G.jsx)(bi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:Te?`font-medium text-foreground`:`text-muted`,children:z})]}):null,(0,G.jsx)(X,{className:`w-full`,isPending:He(`import`),onPress:()=>void ze(),children:Te?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bi,{size:15}),r(`accountImported`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Hi,{size:15}),r(`importCredential`)]})})]})})]})]})})}),(0,G.jsx)(Z.Footer,{className:`justify-end px-5 pb-5`,children:(0,G.jsx)(X,{variant:`ghost`,onPress:je,isDisabled:Ce,children:r(`cancel`)})})]})})})})}function K$({isOpen:e,title:t,description:n,confirmLabel:r,cancelLabel:i,closeLabel:a,isPending:o,status:s=`danger`,confirmVariant:c=`danger`,onClose:l,onConfirm:u}){return(0,G.jsx)(wS.Root,{isOpen:e,onOpenChange:e=>{!e&&!o&&l()},children:(0,G.jsx)(wS.Backdrop,{variant:`blur`,isDismissable:!o,children:(0,G.jsx)(wS.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(wS.Dialog,{children:[(0,G.jsxs)(wS.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(wS.Icon,{status:s}),(0,G.jsx)(`div`,{children:(0,G.jsx)(wS.Heading,{children:t})})]}),(0,G.jsx)(wS.CloseTrigger,{isDisabled:o,"aria-label":a})]}),(0,G.jsx)(wS.Body,{children:(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:n})}),(0,G.jsxs)(wS.Footer,{children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:l,children:i}),(0,G.jsx)(X,{size:`sm`,variant:c,isPending:o,onPress:u,children:r})]})]})})})})}function q$(e,t){return e===`region_mixed`?t(`batchImportRegionMixed`):e===`region_unknown`?t(`batchImportRegionUnknown`):e===`unknown_format`?t(`batchImportUnknownFormat`):``}function J$({isOpen:e,detection:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let[s,c]=(0,v.useState)(`cn`);(0,v.useEffect)(()=>{t&&(t.region===`cn`||t.region===`global`?c(t.region):c(`cn`))},[t]);let l=!!t?.batchImportSupported,u=t?.provider,d=t?.format||i(`batchImportFormatUnknown`),f=u?TZ(u,i):i(`batchImportProviderUnknown`),p=(t?.warnings||[]).map(e=>q$(e,i)).filter(Boolean);return(0,G.jsx)(Z.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`sm`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,24rem)] sm:mx-0`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:i(`batchImportConfirmTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`batchImportConfirmHint`,{file:n}):i(`batchImportConfirmHintNoFile`)})]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-4 px-5 pb-2`,children:[(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[u?(0,G.jsx)(zZ,{provider:u,size:18}):null,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:f}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:d})]})]})}),l?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:i(`batchImportRegion`)}),(0,G.jsx)(qX,{value:s,onChange:e=>{(e===`cn`||e===`global`)&&c(e)},ariaLabel:i(`batchImportRegion`),options:[{id:`cn`,label:i(`accountTypeWorkBuddyCN`)},{id:`global`,label:i(`accountTypeWorkBuddyGlobal`)}]}),t?.regionAmbiguous?(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(`batchImportRegionPickHint`)}):null]}):(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`batchImportProviderUnsupported`)}),p.length?(0,G.jsx)(`ul`,{className:`space-y-1 text-caption leading-5 text-muted`,children:p.map(e=>(0,G.jsx)(`li`,{children:e},e))}):null]}),(0,G.jsxs)(Z.Footer,{className:`flex-col-reverse gap-2 px-5 pb-5 sm:flex-row sm:justify-end`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(l?`cancel`:`close`)}),l?(0,G.jsx)(X,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,onPress:()=>o(s),children:i(`batchImportConfirmAction`)}):null]})]})})})})}var Y$={"workbuddy-accounts":`workbuddy`,"workbuddy-oauth-v1":`workbuddy`,"qoder-native-v1":`qoder`,"trae-oauth-v1":`trae`,"devin-session-v1":`devin`,"command-key-v1":`command`,"codex-oauth-v1":`codex`,"zhipu-key-v1":`zhipu`,"qwenwork-oauth-v1":`qwenwork`},X$=[`codebuddy.cn`],Z$=[`workbuddy.ai`,`workbuddy.com`];function Q$(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $$(e){let t=[],n=e=>{typeof e==`string`&&e.trim()&&t.push(e.trim().toLowerCase())};if(n(e.domain),Q$(e.account)&&n(e.account.domain),Array.isArray(e.accounts))for(let t of e.accounts)Q$(t)&&n(t.domain);return t}function e1(e){return X$.some(t=>e.includes(t))}function t1(e){return Z$.some(t=>e.includes(t))}function n1(e){return typeof e.accessToken==`string`||typeof e.access_token==`string`||typeof e.refreshToken==`string`||typeof e.refresh_token==`string`}function r1(e){return Q$(e)?n1(e)||typeof e.domain==`string`||typeof e.uid==`string`:!1}function i1(e){let t=$$(e);if(t.length===0)return{region:`cn`,ambiguous:!0,warning:`region_unknown`};let n=t.some(e1),r=t.some(t1);return n&&r?{region:null,ambiguous:!0,warning:`region_mixed`}:n?{region:`cn`,ambiguous:!1}:r?{region:`global`,ambiguous:!1}:{region:`cn`,ambiguous:!0,warning:`region_unknown`}}function a1(e){return Array.isArray(e.accounts)&&e.accounts.some(r1)?{format:`workbuddy-accounts`,provider:`workbuddy`,confidence:`medium`}:(typeof e.user_blob==`string`||typeof e.userBlob==`string`)&&(typeof e.machine_id==`string`||typeof e.machineId==`string`)?{format:`qoder-native-v1`,provider:`qoder`,confidence:`medium`}:typeof e.session_token==`string`||typeof e.sessionToken==`string`?{format:`devin-session-v1`,provider:`devin`,confidence:`low`}:n1(e)||Q$(e.account)&&n1(e.account)||Q$(e.auth)?{format:`workbuddy-oauth-v1`,provider:`workbuddy`,confidence:`low`}:typeof e.api_key==`string`||typeof e.apiKey==`string`?typeof e.organization==`string`||typeof e.project==`string`?{format:`zhipu-key-v1`,provider:`zhipu`,confidence:`low`}:{format:`command-key-v1`,provider:`command`,confidence:`low`}:{format:null,provider:null,confidence:`low`}}function o1(e){if(!Q$(e))return{format:null,provider:null,region:null,regionAmbiguous:!0,confidence:`low`,warnings:[`not_object`],batchImportSupported:!1};let t=[],n=typeof e.format==`string`?e.format.trim():``,r=n||null,i=r?Y$[r]??null:null,a=r&&i?`high`:`low`;if(!i){let o=a1(e);r||=o.format,i=o.provider,a=n&&!Y$[n]?`low`:o.confidence,n&&!Y$[n]&&t.push(`unknown_format`)}i===`workbuddy`&&Array.isArray(e.accounts)&&(r=`workbuddy-accounts`);let o=null,s=!1;if(i===`workbuddy`){let n=i1(e);o=n.region,s=n.ambiguous,n.warning&&t.push(n.warning)}return{format:r,provider:i,region:o,regionAmbiguous:s,confidence:a,warnings:t,batchImportSupported:i===`workbuddy`}}function s1(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(!Q$(t))throw Error(`bad_json`);return t}var c1=`__all__`,l1=[],u1=2;function d1(){let{t:e}=DH(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),d=s,f=d.length>0,[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)({}),[A,j]=(0,v.useState)({}),[M,N]=(0,v.useState)({}),[P,ee]=(0,v.useState)({}),[F,I]=(0,v.useState)(null),[L,te]=(0,v.useState)(null),[R,z]=(0,v.useState)(null),[B,ne]=(0,v.useState)(null),[re,ie]=(0,v.useState)(null),[V,ae]=(0,v.useState)(``),[oe,se]=(0,v.useState)(`all`),[ce,le]=(0,v.useState)(``),[ue,de]=(0,v.useState)(1),[fe,pe]=(0,v.useState)(20),[me,he]=(0,v.useState)({}),[ge,_e]=(0,v.useState)({}),[ve,ye]=(0,v.useState)({}),[be,xe]=(0,v.useState)({}),[Se,Ce]=(0,v.useState)(!1),we=(0,v.useCallback)(async(e=!1)=>{try{let t=(await LH(e)).data||l1;return c(t),t}finally{u(!1)}},[]),Te=(0,v.useCallback)(async(e,t=!0)=>{let n=[...new Set(e)];if(n.length)for(let e=0;e{try{let n=await XH(e,{quota:t});c(t=>t.map(t=>t.id===e?n:t))}catch(t){N(n=>({...n,[e]:t instanceof Error?t.message:String(t)}))}}))}},[]);(0,v.useEffect)(()=>{we(!1).catch(()=>void 0)},[we]),(0,v.useEffect)(()=>{let e=!0;return Promise.all([tU(),SU()]).then(([t,r])=>{e&&(n(t.data||[]),i(r))}).catch(t=>{e&&o(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[]);function Ee(e){return t.find(t=>t.id===e.provider)?.regions.find(t=>t.id===e.region)?.checkin}function De(e){let t=Ee(e)?.timezone;return t===`Local`?r?.timezone:t}let Oe=(0,v.useMemo)(()=>d.map(e=>{let t=me[e.id],n=ge[e.id],r=ve[e.id],i=be[e.id],a=e;return t!==void 0&&(a={...a,enabled:t}),n!==void 0&&(a={...a,name:n}),r!==void 0&&(a={...a,max_inflight:r}),i!==void 0&&(a={...a,priority:i}),a}),[me,ve,ge,be,d]),ke=(0,v.useMemo)(()=>{let e={all:Oe.length,available:0,attention:0,disabled:0};for(let t of Oe){let n=DX(t);n===`hot`||n===`ready`?e.available+=1:n===`disabled`&&(e.disabled+=1),t.enabled&&n!==`hot`&&n!==`ready`&&(e.attention+=1)}return e},[Oe]),Ae=(0,v.useMemo)(()=>{let e=new Map;for(let t of Oe){let n=String(t.provider||`qoder`).toLowerCase();e.set(n,(e.get(n)||0)+1)}return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))},[Oe]),je=Oe.find(e=>e.id===F),Me=Oe.find(e=>e.id===L)||null,Ne=Oe.find(e=>e.id===R)||null,Pe=Oe.find(e=>e.id===B)||null,Fe=(0,v.useMemo)(()=>{let e=V.trim().toLowerCase();return Oe.filter(t=>{let n=DX(t);return!(oe===`all`||oe===`available`&&(n===`hot`||n===`ready`)||oe===`attention`&&t.enabled&&n!==`hot`&&n!==`ready`||oe===`disabled`&&n===`disabled`)||ce&&String(t.provider||`qoder`).toLowerCase()!==ce?!1:!e||[t.name,t.id,t.remote_uid,t.provider,t.auth_type].some(t=>String(t||``).toLowerCase().includes(e))})},[Oe,oe,ce,V]),Ie=[V,oe,ce,fe].join(`\0`),[Le,Re]=(0,v.useState)(Ie);Le!==Ie&&(Re(Ie),de(1));let ze=Math.max(1,Math.ceil(Fe.length/fe)),Be=Math.min(Le===Ie?Math.max(1,ue):1,ze);ue!==Be&&de(Be);let Ve=(0,v.useMemo)(()=>{let e=(Be-1)*fe;return Fe.slice(e,e+fe)},[Be,Fe,fe]);if(l&&!f)return(0,G.jsx)(_Y,{});async function He(e,t,n){D({id:e,kind:t}),N(t=>({...t,[e]:``}));try{return await n(),!0}catch(t){return N(n=>({...n,[e]:t instanceof Error?t.message:String(t)})),!1}finally{D(null)}}async function Ue(t,n){ie(t),await He(t,`device`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)}));let r=await RH(t,n);r.authUrl&&ee(e=>({...e,[t]:r.authUrl||``}));for(let n=0;n<60;n++){await new Promise(e=>window.setTimeout(e,2e3));let n=(await zH(t)).login||{};if(N(r=>({...r,[t]:n.message||e(`waitingQoderLogin`)})),n.status===`ok`||n.status===`error`)break}await we(!1),await Te([t])})}async function We(t){let n=(A[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`wizardCallbackPh`)}));return}await He(t,`callback`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await BH(t,n),j(e=>({...e,[t]:``})),await we(!1),await Te([t])})&&(ie(e=>e===t?null:e),N(e=>({...e,[t]:``})))}async function Ge(t){let n=(O[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`pastePatFirst`)}));return}await He(t,`pat`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await VH(n,t),k(e=>({...e,[t]:``})),await we(!1),await Te([t])})}async function Ke(t){await He(t,`export`,async()=>{let n=await cU(t);await NQ(JSON.stringify(n,null,2)),N(n=>({...n,[t]:e(`credentialCopied`)}))})}async function qe(e,t){he(n=>({...n,[e]:t})),await He(e,`toggle`,async()=>{await aU(e,{enabled:t}),await we(!1)}),he(t=>{let n={...t};return delete n[e],n})}async function Je(t){JY({id:`refresh-${t}`,type:`loading`,title:e(`toastRefreshingAccount`)}),D({id:t,kind:`refresh`}),N(e=>{let n={...e};return delete n[t],n});try{await Te([t]),JY({id:`refresh-${t}`,type:`success`,title:e(`toastAccountRefreshed`)})}catch(n){throw JY({id:`refresh-${t}`,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)}),n}finally{D(null)}}async function Ye(){Ce(!0),JY({id:`refresh-credits`,type:`loading`,title:e(`toastRefreshingCredits`)});try{await Te(s.map(e=>e.id)),JY({id:`refresh-credits`,type:`success`,title:e(`toastCreditsRefreshed`)})}catch(t){throw JY({id:`refresh-credits`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)}),t}finally{Ce(!1)}}function Xe(){h||(y(!1),x(null),C(null),T(``))}async function Ze(t){let n=t.target.files?.[0];if(t.target.value=``,n)try{let t=s1(await n.text()),r=o1(t);if(!r.provider){JY({type:`error`,title:e(`batchImportUnrecognized`)});return}C(t),x(r),T(n.name),y(!0)}catch(t){let n=t instanceof Error?t.message:String(t);JY({type:`error`,title:e(n===`bad_json`?`wizardBadJson`:`batchImportUnrecognized`),description:n===`bad_json`?void 0:n})}}async function Qe(t){if(!S||!b?.batchImportSupported||h)return;g(!0);let n=`batch-import-accounts`;JY({id:n,type:`loading`,title:e(`batchImportLoading`)});try{let{succeeded:r,failed:i,message:a}=N$(await P$(S,{region:t}),e);JY({id:n,type:i>0&&r===0?`error`:i>0?`info`:`success`,title:a}),y(!1),x(null),C(null),T(``),r>0&&await we(!1)}catch(t){JY({id:n,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{g(!1)}}async function $e(e,t){await He(e,`toggle`,async()=>{await aU(e,{auto_checkin:t}),await we(!1)})}async function et(e){await He(e,`checkin`,async()=>{try{await rU(e)}finally{await we(!1)}})}async function tt(t,n){if(!t)throw Error(e(`accountNameRequired`));_e(e=>({...e,[t]:n.name})),ye(e=>({...e,[t]:n.max_inflight})),xe(e=>({...e,[t]:n.priority})),D({id:t,kind:`settings`});try{await aU(t,n),await we(!1)}catch(e){throw e instanceof Error?e:Error(String(e))}finally{D(null),_e(e=>{let n={...e};return delete n[t],n}),ye(e=>{let n={...e};return delete n[t],n}),xe(e=>{let n={...e};return delete n[t],n})}}return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,G.jsx)(bU,{title:a}):null,(0,G.jsxs)(`section`,{"data-gsap-reveal":!0,className:`flex flex-wrap items-center gap-2`,children:[d.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qX,{value:oe,onChange:e=>se(e),ariaLabel:e(`accountStatusFilter`),options:[{id:`all`,label:(0,G.jsxs)(G.Fragment,{children:[e(`filterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:ke.all})]})},{id:`available`,label:(0,G.jsxs)(G.Fragment,{children:[e(`availableAccounts`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:ke.available})]})},{id:`attention`,label:(0,G.jsxs)(G.Fragment,{children:[e(`needsAttention`),(0,G.jsx)(`span`,{className:`mono ${ke.attention?`text-danger`:`text-muted`}`,children:ke.attention})]})},{id:`disabled`,label:(0,G.jsxs)(G.Fragment,{children:[e(`disabled`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:ke.disabled})]})}]}),(0,G.jsxs)(SV,{className:`w-48`,"aria-label":e(`providerFilterAll`),value:ce||c1,onChange:e=>{typeof e==`string`&&le(e===c1?``:e)},children:[(0,G.jsxs)(SV.Trigger,{className:`items-center`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(SV.Indicator,{})]}),(0,G.jsx)(SV.Popover,{children:(0,G.jsxs)(GB,{children:[(0,G.jsxs)(GB.Item,{id:c1,textValue:e(`providerFilterAll`),children:[(0,G.jsxs)(sR,{className:`flex items-center gap-2`,children:[e(`providerFilterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:d.length})]}),(0,G.jsx)(GB.ItemIndicator,{})]}),Ae.map(([t,n])=>(0,G.jsxs)(GB.Item,{id:t,textValue:TZ(t,e),children:[(0,G.jsxs)(sR,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zZ,{provider:t,size:13}),TZ(t,e),(0,G.jsx)(`span`,{className:`mono text-muted`,children:n})]}),(0,G.jsx)(GB.ItemIndicator,{})]},t))]})})]}),(0,G.jsx)(bQ,{className:`w-full sm:w-60`,value:V,onChange:ae,placeholder:e(`searchAccounts`),ariaLabel:e(`searchAccounts`)})]}):null,(0,G.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto`,children:[(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:Se,onPress:()=>void Ye(),children:[(0,G.jsx)(ni,{size:14}),e(`refreshCredits`)]}),(0,G.jsxs)(`label`,{htmlFor:`accounts-batch-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${h||_?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[h?(0,G.jsx)(uY,{size:14,loading:!0}):(0,G.jsx)(eo,{size:14}),e(`batchImport`)]}),(0,G.jsx)(`input`,{id:`accounts-batch-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:h||_,className:`sr-only`,onChange:e=>void Ze(e)}),(0,G.jsxs)(X,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(wa,{size:14}),e(`addAccount`)]})]})]}),(0,G.jsx)(G$,{isOpen:p,onClose:()=>m(!1),onAdded:()=>{JY({type:`success`,title:e(`toastAccountAdded`)}),we(!1)}}),(0,G.jsx)(J$,{isOpen:_,detection:b,fileName:w,isPending:h,t:e,onClose:Xe,onConfirm:e=>{Qe(e)}}),(0,G.jsx)(w$,{account:Me,t:e,onClose:()=>te(null)},L??`closed`),(0,G.jsx)(S$,{account:Ne,t:e,onClose:()=>z(null)},R??`closed`),(0,G.jsx)(k$,{account:Pe,checkinDefaultTime:Pe&&Ee(Pe)?r?.checkin_times[Pe.provider||``]:void 0,checkinTimezone:Pe?De(Pe):void 0,busy:!!(E&&E.id===B&&E.kind===`settings`),t:e,onClose:()=>ne(null),onSave:e=>tt(B||``,e)},B??`closed`),(0,G.jsx)(K$,{isOpen:!!je,title:e(`delete`),description:e(`deleteAccountConfirm`,{name:je?.name||je?.id||``}),confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:E?.id===F&&E.kind===`delete`,onClose:()=>I(null),onConfirm:()=>{if(!je)return;let t=je.id;I(null),He(t,`delete`,async()=>{await oU(t),await we(!1)}).then(t=>{t&&JY({type:`success`,title:e(`toastAccountDeleted`)})})}}),f?null:(0,G.jsx)(pQ,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(uY,{size:28}),title:e(`noAccounts`),hint:e(`accountEmptyHint`),action:(0,G.jsxs)(X,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(wa,{size:14}),e(`addAccount`)]})}),f&&!Fe.length?(0,G.jsx)(pQ,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(ua,{size:22}),title:e(`noAccountsMatch`),action:(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:()=>{ae(``),se(`all`),le(``)},children:e(`clearFilters`)})}):null,(0,G.jsx)(`section`,{className:`grid auto-rows-[minmax(280px,auto)] gap-2.5 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:Ve.map(t=>(0,G.jsx)(y$,{account:t,busyKind:E?.id===t.id?E.kind:``,authPanelOpen:re===t.id,authUrl:P[t.id],note:M[t.id],pat:O[t.id]||``,t:e,onPatChange:e=>k(n=>({...n,[t.id]:e})),callbackUrl:A[t.id]||``,onCallbackChange:e=>j(n=>({...n,[t.id]:e})),onSubmitCallback:()=>void We(t.id),onDeviceLogin:e=>void Ue(t.id,e),onPatLogin:()=>void Ge(t.id),onExport:()=>void Ke(t.id),onRefresh:()=>void Je(t.id),onDelete:()=>I(t.id),onToggle:e=>void qe(t.id,e),checkinDefaultTime:r?.checkin_times[t.provider||``],onToggleAutoCheckin:Ee(t)?e=>void $e(t.id,e):void 0,onCheckin:Ee(t)?()=>void et(t.id):void 0,onViewCheckins:Ee(t)?()=>z(t.id):void 0,onEdit:()=>ne(t.id),onToggleAuthPanel:()=>ie(e=>e===t.id?null:t.id),onViewModels:()=>te(t.id)},t.id))}),Fe.length?(0,G.jsx)(yQ,{total:Fe.length,page:Be,pageCount:ze,pageSize:fe,pageSizes:_Q,loading:!1,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Be,pages:ze}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:de,onPageSize:pe}):null]})}function f1(){let{t:e,lang:t,setLang:n}=DH(),{setApiKey:r}=jH(),{overview:i,refresh:a}=dU(),{theme:o,toggleTheme:s}=gU(),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),g=ot(),_=rt().state?.from||`/`,y=(0,v.useRef)(null);if(EY(y,`login`),i)return(0,G.jsx)(jt,{to:_===`/login`?`/`:_,replace:!0});async function b(t){t.preventDefault();let n=c.trim();if(!n){h(e(`loginNeedKey`));return}p(!0),h(``);try{r(n),await a(n),g(_===`/login`?`/`:_,{replace:!0})}catch(t){h(PH(t)?e(`loginBadKey`):t instanceof Error?t.message:String(t))}finally{p(!1)}}return(0,G.jsxs)(`div`,{className:`relative min-h-dvh overflow-hidden bg-background text-foreground`,children:[(0,G.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-border`}),(0,G.jsxs)(`main`,{ref:y,className:`relative z-10 mx-auto grid min-h-dvh w-full max-w-[1480px] lg:grid-cols-[minmax(0,1fr)_minmax(480px,45%)]`,children:[(0,G.jsxs)(`section`,{className:`flex min-h-[52vh] flex-col border-separator px-5 py-6 sm:px-10 sm:py-8 lg:min-h-dvh lg:border-r lg:px-14 lg:py-10 xl:px-20`,children:[(0,G.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(uY,{size:36}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-semibold`,children:`CLI2API`}),(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e(`controlPlane`)})]})]}),(0,G.jsxs)(OI,{isAttached:!0,children:[(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:()=>n(t===`zh`?`en`:`zh`),"aria-label":t===`zh`?`English`:`中文`,children:(0,G.jsx)(Xi,{size:15})})}),(0,G.jsx)(eL.Content,{children:t===`zh`?`English`:`中文`})]}),(0,G.jsxs)(eL,{children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:s,"aria-label":o===`dark`?`Light mode`:`Dark mode`,children:o===`dark`?(0,G.jsx)(Wa,{size:15}):(0,G.jsx)(fa,{size:15})})}),(0,G.jsx)(eL.Content,{children:o===`dark`?`Light mode`:`Dark mode`})]})]})]}),(0,G.jsxs)(`div`,{className:`my-auto max-w-3xl py-16 lg:py-24`,children:[(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mb-5 mono text-caption text-muted`,children:`:3010`}),(0,G.jsx)(`h1`,{"data-gsap-reveal":!0,className:`max-w-3xl text-[clamp(2.25rem,4vw,3.6rem)] font-semibold leading-[0.98] tracking-[-0.045em] text-balance`,children:e(`loginTitle`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-6 max-w-xl text-section font-normal text-muted sm:text-title sm:font-normal`,children:e(`loginLead`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-10 max-w-xl pt-5 text-body leading-6 text-muted`,children:e(`loginHint`)})]}),(0,G.jsxs)(`footer`,{className:`hidden items-center justify-between text-caption text-muted lg:flex`,children:[(0,G.jsx)(`span`,{children:e(`loginHint`)}),(0,G.jsx)(`span`,{children:e(`routesHint`)})]})]}),(0,G.jsx)(`section`,{className:`flex items-center px-5 py-10 sm:px-10 lg:px-12 xl:px-16`,children:(0,G.jsx)(zw,{"data-gsap-reveal":!0,className:`w-full p-0`,children:(0,G.jsxs)(`form`,{onSubmit:e=>void b(e),children:[(0,G.jsx)(zw.Header,{className:`border-b border-separator px-6 py-6 sm:px-8`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(uY,{size:28,loading:f}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(zw.Title,{className:`text-title`,children:e(`loginFormTitle`)}),(0,G.jsx)(zw.Description,{className:`mt-1`,children:e(`loginDesc`)})]})]})}),(0,G.jsxs)(zw.Content,{className:`space-y-5 px-6 py-7 sm:px-8 sm:py-8`,children:[(0,G.jsxs)(hL,{name:`console-password`,className:`w-full`,isInvalid:!!m,children:[(0,G.jsx)(sR,{children:e(`loginPassword`)}),(0,G.jsxs)(fL,{children:[(0,G.jsx)(fL.Input,{id:`console-password`,type:u?`text`:`password`,value:c,onChange:e=>l(e.target.value),placeholder:e(`loginPasswordPh`),autoComplete:`current-password`,autoFocus:!0,"aria-label":e(`loginPassword`),spellCheck:!1}),(0,G.jsx)(fL.Suffix,{children:(0,G.jsx)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,type:`button`,"aria-label":e(u?`hidePassword`:`showPassword`),onPress:()=>d(e=>!e),children:u?(0,G.jsx)(Bi,{size:16}):(0,G.jsx)(Ri,{size:16})})})]})]}),m?(0,G.jsx)(bU,{title:m}):(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:e(`loginHint`)}),(0,G.jsxs)(X,{type:`submit`,fullWidth:!0,size:`lg`,isPending:f,children:[e(f?`loggingInConsole`:`loginSubmit`),f?null:(0,G.jsx)(Xr,{size:17})]})]})]})})})]})]})}function p1(){return FH(`/api/keys`)}function m1(e){return FH(`/api/keys`,{method:`POST`,body:JSON.stringify(e)})}function h1(e,t){return FH(`/api/keys/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function g1(e){return FH(`/api/keys/${encodeURIComponent(e)}`,{method:`DELETE`})}function _1(){return FH(`/api/system/console-key`)}function v1(){return FH(`/api/system/console-key`,{method:`POST`,body:JSON.stringify({rotate:!0})})}function y1({settings:e,onSaved:t}){let{t:n}=DH(),r=ot(),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return tU().then(t=>{e&&a((t.data||[]).filter(e=>e.regions.some(e=>e.checkin)))}).catch(t=>{e&&d(String(t))}),()=>{e=!1}},[]);async function f(n,r){if(!(!e||r===e.checkin_times[n])){l(!0),d(``);try{t(await CU({checkin_times:{[n]:r}}))}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(e=>{let t={...e};return delete t[n],t}),l(!1)}}}return(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(zw.Header,{children:[(0,G.jsx)(zw.Title,{children:n(`checkinDefaultsTitle`)}),(0,G.jsx)(zw.Description,{children:n(`checkinDefaultsHint`)})]}),(0,G.jsxs)(zw.Content,{className:`space-y-4`,children:[u?(0,G.jsx)(bU,{title:u}):null,!e||!i?(0,G.jsx)($,{className:`h-24 w-full`}):i.map(t=>(0,G.jsx)(E$,{label:t.label,hint:t.regions.filter(e=>e.checkin).map(t=>`${t.label} · ${t.checkin?.timezone===`Local`?e.timezone:t.checkin?.timezone}`).join(` / `),children:(0,G.jsx)(lL,{type:`time`,value:o[t.id]??e.checkin_times[t.id]??``,disabled:c,"aria-label":`${t.label} ${n(`autoCheckinTime`)}`,onChange:e=>s(n=>({...n,[t.id]:e.target.value})),onBlur:e=>void f(t.id,e.target.value)})},t.id))]}),(0,G.jsx)(zw.Footer,{children:(0,G.jsx)(X,{variant:`secondary`,onPress:()=>r(`/accounts`),children:n(`navAccounts`)})})]})}function b1(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleDateString(t===`zh`?`zh-CN`:`en-US`,{year:`numeric`,month:`short`,day:`numeric`})}function x1({releases:e,currentVersion:t,nextVersion:n,rollbackTags:r,canRollback:i,submitting:a,onRestore:o}){let{t:s,lang:c}=DH();if(!e.length)return null;let l=n&&n!==t?n:t,u=e.some(e=>e.tag_name===l)?l:e[0]?.tag_name,d=new Set(r);return(0,G.jsxs)(`div`,{className:`mt-5`,children:[(0,G.jsx)(`div`,{className:`mb-2`,children:(0,G.jsx)(`p`,{className:`text-caption font-medium text-foreground`,children:s(`versionHistory`)})}),(0,G.jsx)(Ih,{className:`rounded-lg bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:u?[u]:[],children:e.map(e=>{let r=e.tag_name,l=r===t,u=!!(n&&r===n&&n!==t),f=i&&d.has(r)&&!l,p=b1(e.published_at,c);return(0,G.jsxs)(Ih.Item,{id:r,children:[(0,G.jsx)(Ih.Heading,{children:(0,G.jsxs)(Ih.Trigger,{className:`items-center gap-3 px-3 py-2.5 text-left`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`mono text-body font-semibold`,children:r}),l?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`success`,children:s(`versionCurrentBadge`)}):null,u?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`warning`,children:s(`versionLatestBadge`)}):null,p?(0,G.jsx)(`span`,{className:`truncate text-caption text-muted`,children:p}):null]}),(0,G.jsx)(Ih.Indicator,{})]})}),(0,G.jsx)(Ih.Panel,{children:(0,G.jsxs)(Ih.Body,{className:`px-3 pb-3`,children:[(0,G.jsx)(`div`,{className:`release-notes-box release-notes-box--compact`,children:(0,G.jsx)(KU,{markdown:BU(e.body,c),emptyLabel:s(`updateNoNotes`)})}),f?(0,G.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:a,onPress:()=>o(r),children:s(`restoreThisVersion`)})}):null]})})]},r)})})]})}function S1(e){let t=new Set,n=[];for(let r of e){let e=r.tag_name?.trim();!e||t.has(e)||(t.add(e),n.push({...r,tag_name:e}))}return n}function C1(e,t,n,r,i){return r?.length?S1(r):S1([...n?[n]:t?[{tag_name:t}]:[],...e?[{tag_name:e}]:[],...i||[]])}var w1=[`general`,`routing`,`security`,`updates`];function T1(){let{t:e}=DH(),[t,n]=kn(),r=t.get(`tab`),i=r&&w1.includes(r)?r:`general`,a=e=>n(e===`general`?{}:{tab:e},{replace:!0}),{setApiKey:o}=jH(),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(``),E=NU(),{info:D,loading:O,checking:k,submitting:A,error:j,setError:M,load:N,canRollback:P,rollbackTo:ee}=E,F=(0,v.useMemo)(()=>C1(D?.current_version||``,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions),[D?.current_version,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions]),I=(0,v.useMemo)(()=>(D?.rollback_versions||[]).map(e=>e.tag_name),[D?.rollback_versions]);(0,v.useEffect)(()=>{let e=window.setTimeout(()=>{_1().then(c).catch(()=>void 0),SU().then(e=>{u(e),f(e.proxy_url||``)}).catch(e=>M(e instanceof Error?e.message:String(e)))},0);return()=>window.clearTimeout(e)},[M]);async function L(e){let t=l?.cross_provider_model_pool??!0;u(t=>t&&{...t,cross_provider_model_pool:e}),m(!0),M(``);try{u(await CU({cross_provider_model_pool:e}))}catch(e){u(e=>e&&{...e,cross_provider_model_pool:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function te(e){let t=l?.checkin_disabled_accounts??!1;u(t=>t&&{...t,checkin_disabled_accounts:e}),m(!0),M(``);try{u(await CU({checkin_disabled_accounts:e}))}catch(e){u(e=>e&&{...e,checkin_disabled_accounts:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function R(e){let t=l?.proxy_url||``;if(e===t){f(t);return}let n=d;f(e),u(t=>t&&{...t,proxy_url:e}),m(!0),M(``);try{let t=await CU({proxy_url:e});u(t),f(t.proxy_url||``)}catch(e){f(n),u(e=>e&&{...e,proxy_url:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function z(e){let t=l?.routing_strategy||`round-robin`;u(t=>t&&{...t,routing_strategy:e}),m(!0),M(``);try{u(await CU({routing_strategy:e}))}catch(e){u(e=>e&&{...e,routing_strategy:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}return O&&!D?(0,G.jsx)(TY,{}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`systemSettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`systemSettingsLead`)})]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:k,onPress:()=>void N(!0),children:[(0,G.jsx)(Jr,{size:15}),e(`checkUpdates`)]})]}),j?(0,G.jsx)(bU,{title:j}):null,(0,G.jsxs)(LF,{selectedKey:i,onSelectionChange:e=>a(String(e)),children:[(0,G.jsx)(LF.ListContainer,{className:`w-fit max-w-full overflow-x-auto`,children:(0,G.jsxs)(LF.List,{"aria-label":e(`systemSettingsTitle`),children:[(0,G.jsxs)(IF,{id:`general`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(Ji,{size:13}),e(`settingsTabGeneral`)]}),(0,G.jsxs)(IF,{id:`routing`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(ii,{size:13}),e(`settingsTabRouting`)]}),(0,G.jsxs)(IF,{id:`security`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(Oa,{size:13}),e(`settingsTabSecurity`)]}),(0,G.jsxs)(IF,{id:`updates`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{}),(0,G.jsx)(Kr,{size:13}),e(`settingsTabUpdates`)]})]})}),(0,G.jsx)(LF.Panel,{id:`general`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pa,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`proxySettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`proxySettingsHint`)})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-1.5`,children:[(0,G.jsx)(sR,{className:`text-body font-medium text-muted`,children:e(`proxyUrl`)}),(0,G.jsx)(lL,{value:d,onChange:e=>f(e.target.value),onBlur:e=>void R(e.target.value.trim()),placeholder:e(`proxyUrlPlaceholder`),disabled:p||!l}),(0,G.jsx)(lR,{className:`text-caption leading-5 text-muted`,children:e(`proxyUrlHint`)})]})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(bi,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`checkinDisabledAccountsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`checkinDisabledAccountsHint`)})]})]}),(0,G.jsx)(fQ,{isSelected:l?.checkin_disabled_accounts??!1,isDisabled:p||!l,ariaLabel:e(`checkinDisabledAccountsAriaLabel`),onChange:e=>void te(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`checkinDisabledAccountsStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.checkin_disabled_accounts?e(`enabled`):e(`disabled`)})]})]}),(0,G.jsx)(y1,{settings:l,onSaved:u})]})}),(0,G.jsx)(LF.Panel,{id:`routing`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pa,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`routingStrategyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`routingStrategyHint`)})]})]}),(0,G.jsx)(`div`,{className:`mt-4 pt-4`,children:(0,G.jsx)(E$,{label:e(`routingStrategy`),children:(0,G.jsxs)(SV,{fullWidth:!0,"aria-label":e(`routingStrategy`),value:l?.routing_strategy||`round-robin`,isDisabled:p||!l,onChange:e=>{typeof e==`string`&&e&&z(e)},children:[(0,G.jsxs)(SV.Trigger,{className:`items-center`,children:[(0,G.jsx)(SV.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(SV.Indicator,{})]}),(0,G.jsx)(SV.Popover,{children:(0,G.jsxs)(GB,{children:[(0,G.jsxs)(GB.Item,{id:`round-robin`,textValue:`round-robin`,children:[(0,G.jsx)(sR,{children:e(`routingRoundRobin`)}),(0,G.jsx)(GB.ItemIndicator,{})]}),(0,G.jsxs)(GB.Item,{id:`weighted-round-robin`,textValue:`weighted-round-robin`,children:[(0,G.jsx)(sR,{children:e(`routingWeightedRoundRobin`)}),(0,G.jsx)(GB.ItemIndicator,{})]}),(0,G.jsxs)(GB.Item,{id:`fill-first`,textValue:`fill-first`,children:[(0,G.jsx)(sR,{children:e(`routingFillFirst`)}),(0,G.jsx)(GB.ItemIndicator,{})]}),(0,G.jsxs)(GB.Item,{id:`fefo`,textValue:`fefo`,children:[(0,G.jsx)(sR,{children:e(`routingFEFO`)}),(0,G.jsx)(GB.ItemIndicator,{})]})]})})]})})}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 pt-3 text-caption text-muted sm:grid-cols-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.ttl_seconds?`${Math.round(l.session_affinity.ttl_seconds/60)}m`:`—`}),e(`sessionAffinityTTL`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.hits??0}),e(`sessionAffinityHits`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.misses??0}),e(`sessionAffinityMisses`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.escapes??0}),e(`sessionAffinityEscapes`)]})]}),l?.session_affinity?.last_escape_reason?(0,G.jsxs)(lR,{className:`mt-3 text-caption`,children:[e(`lastSessionEscape`),`: `,l.session_affinity.last_escape_reason]}):null,l?.session_affinity?.last_miss_reason?(0,G.jsxs)(lR,{className:`mt-1 text-caption`,children:[e(`lastSessionMiss`),`: `,l.session_affinity.last_miss_reason]}):null]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pa,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`crossProviderModelPoolTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`crossProviderModelPoolHint`)})]})]}),(0,G.jsx)(fQ,{isSelected:l?.cross_provider_model_pool??!0,isDisabled:p||!l,ariaLabel:e(`crossProviderModelPoolAriaLabel`),onChange:e=>void L(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`crossProviderModelPoolStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.cross_provider_model_pool?e(`enabled`):e(`disabled`)})]})]})]})}),(0,G.jsx)(LF.Panel,{id:`security`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`consoleKeyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyHint`)})]})]})}),(0,G.jsx)(`code`,{className:`mono mt-4 block rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:s?.prefix||`—`}),(0,G.jsx)(`p`,{className:`mt-3 text-caption leading-5 text-muted`,children:e(`consoleKeyLead`)}),(0,G.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isPending:h,onPress:()=>y(!0),children:e(`consoleKeyRotate`)})})]}),(0,G.jsxs)(zw,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Pi,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`sqliteProtection`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`sqliteProtectionHint`)})]})]}),(0,G.jsx)(Oa,{size:18,className:`text-success`})]}),(0,G.jsx)(`div`,{className:`mono mt-4 rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:`/data`}),(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2 text-caption text-muted`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(bi,{size:14,className:`text-muted`}),e(`sqliteBackupBeforeUpdate`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(bi,{size:14,className:`text-muted`}),e(`sqliteKeepFive`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(bi,{size:14,className:`text-muted`}),e(`sqliteRollbackTogether`)]})]})]})]})}),(0,G.jsx)(LF.Panel,{id:`updates`,className:`pt-5`,children:(0,G.jsx)(`div`,{className:`grid gap-5`,children:(0,G.jsxs)(zw,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`versionUpdate`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`latestVersionHint`)})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:D?.has_update?`warning`:`success`,children:D?.has_update?e(`updateAvailable`):e(`upToDate`)})]}),(0,G.jsxs)(`div`,{className:`px-5 py-5`,children:[(0,G.jsx)(yU,{update:E}),(0,G.jsx)(x1,{releases:F,currentVersion:D?.current_version||``,nextVersion:D?.next_version,rollbackTags:I,canRollback:P,submitting:A,onRestore:T})]})]})})})]}),(0,G.jsx)(K$,{isOpen:!!w,title:e(`restoreVersionTitle`,{version:w}),description:e(`restoreVersionHint`),confirmLabel:e(`restoreThisVersion`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:A,status:`warning`,confirmVariant:`primary`,onClose:()=>{A||T(``)},onConfirm:()=>{let e=w;T(``),ee(e)}}),(0,G.jsx)(Z.Root,{isOpen:_,onOpenChange:e=>{!e&&!h&&y(!1)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,isDismissable:!h,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`consoleKeyRotate`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyRotateHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:h,"aria-label":e(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,isDisabled:h,onPress:()=>y(!1),children:e(`cancel`)}),(0,G.jsx)(X,{variant:`danger`,isPending:h,onPress:()=>{g(!0),v1().then(e=>{c(e),x(e.secret||``),e.secret&&o(e.secret),y(!1)}).catch(e=>{M(e instanceof Error?e.message:String(e))}).finally(()=>g(!1))},children:e(`consoleKeyRotateNow`)})]})]})})})}),(0,G.jsx)(Z.Root,{isOpen:!!b,onOpenChange:e=>{e||x(``)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`consoleKeySecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`consoleKeySecretHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsx)(Z.Body,{className:`px-6 pb-2`,children:(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b})}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,onPress:()=>x(``),children:e(`close`)}),(0,G.jsxs)(X,{onPress:()=>{NQ(b),C(!0),window.setTimeout(()=>C(!1),1200)},children:[(0,G.jsx)(Oi,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}var E1=`__all__`;function D1(e,t){let n=t.trim().toLowerCase();return!n||e.label.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)}function O1({value:e,onChange:t,ariaLabel:n,options:r,allLabel:i,searchPlaceholder:a,emptyLabel:o,loadOptions:s,className:c}){let[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!s)return;let e=!1,t=window.setTimeout(()=>{m(!0),s(l.trim()).then(t=>{e||f(t)}).catch(()=>{e||f([])}).finally(()=>{e||m(!1)})},l.trim()?280:0);return()=>{e=!0,window.clearTimeout(t)}},[s,l]);let h=e||E1,g=(0,v.useMemo)(()=>{let t=s?d:r.filter(e=>D1(e,l)),n=new Map;l.trim()||n.set(E1,{id:E1,label:i});for(let e of t)!e.id||e.id===E1||n.set(e.id,e);if(e){let t=r.find(t=>t.id===e)||d.find(t=>t.id===e)||{id:e,label:e};n.set(e,t)}return[...n.values()]},[i,s,r,l,d,e]),_=g.find(e=>e.id===h)||(e?{id:e,label:e}:{id:E1,label:i});return(0,G.jsxs)(Sw,{className:[`w-fit`,c].filter(Boolean).join(` `),"aria-label":n,value:h,onChange:e=>{typeof e==`string`&&(t(e===E1?``:e),u(``))},onClear:()=>{t(``),u(``)},children:[(0,G.jsxs)(Sw.Trigger,{className:`min-w-44 items-center`,children:[(0,G.jsx)(Sw.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t?e:(0,G.jsx)(`span`,{className:`truncate`,children:_.label})}),e?(0,G.jsx)(Sw.ClearButton,{}):null,(0,G.jsx)(Sw.Indicator,{})]}),(0,G.jsx)(Sw.Popover,{className:`min-w-56`,children:(0,G.jsxs)(Sw.Filter,{inputValue:l,onInputChange:u,filter:()=>!0,children:[(0,G.jsx)(aR,{"aria-label":a,className:`px-2 pt-2`,autoFocus:!0,children:(0,G.jsxs)(aR.Group,{children:[(0,G.jsx)(aR.SearchIcon,{}),(0,G.jsx)(aR.Input,{placeholder:a}),(0,G.jsx)(aR.ClearButton,{})]})}),(0,G.jsx)(GB,{children:g.length===0?(0,G.jsx)(GB.Item,{id:`__empty__`,textValue:o,isDisabled:!0,children:(0,G.jsx)(sR,{className:`block truncate text-muted`,children:p?a:o})}):g.map(e=>(0,G.jsxs)(GB.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(sR,{className:`block truncate`,children:e.label}),e.id!==E1&&e.id!==e.label?(0,G.jsx)(`span`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.id}):null,(0,G.jsx)(GB.ItemIndicator,{})]},e.id))})]})})]})}function k1(e){return e===`ok`?`success`:e===`streaming`||e===`started`||e===`incomplete`?`warning`:e===`error`||e===`canceled`?`danger`:`default`}function A1(e){if(e===`error`)return`danger`;if(e!==`warn`)return`ok`}function j1(e){return e===`error`?`danger`:e===`warn`?`warning`:e===`info`?`success`:`default`}function M1(e,t=`zh`){if(!e)return`—`;let n=new Date(e);return Number.isFinite(n.getTime())?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(n):e}function N1(e){let t=e.requested_reasoning?.trim()||``,n=e.resolved_reasoning?.trim()||``;return!t&&!n?``:t&&n&&t!==n?`${t} → ${n}`:n||t}function P1({log:e,inLabel:t,outLabel:n,pointsLabel:r}){let i=e.prompt_tokens,a=e.completion_tokens,o=e.credits??e.usage_detail?.credit,s=o!=null&&Number.isFinite(o)?L1(o):null;return i==null&&a==null&&s==null?(0,G.jsx)(`span`,{className:`mono text-xs text-muted`,children:`—`}):(0,G.jsxs)(`div`,{className:`leading-4`,children:[i!=null||a!=null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mono text-xs`,children:[i??0,` / `,a??0]}),(0,G.jsxs)(`div`,{className:`mt-0.5 text-caption text-muted`,children:[t,` / `,n]})]}):null,s==null?null:(0,G.jsx)(`div`,{className:`mono text-caption text-success ${i!=null||a!=null?`mt-0.5`:``}`,children:r?r(s):s})]})}function F1(){return(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:Array.from({length:8},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)($,{className:`h-3 w-20`}),(0,G.jsx)($,{className:`h-5 w-36 max-w-full`})]},t))}),(0,G.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-secondary px-3 py-3`,children:[(0,G.jsx)($,{className:`h-3 w-24`}),(0,G.jsx)($,{className:`h-4 w-full`}),(0,G.jsx)($,{className:`h-4 w-4/5`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)($,{className:`h-3 w-20`}),(0,G.jsx)($,{className:`h-16 w-full`})]})]})}function I1(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function L1(e){return e==null||!Number.isFinite(e)?`—`:String(Math.round(e*1e4)/1e4)}var R1=[`all`,`ok`,`incomplete`,`error`,`canceled`],z1=[`all`,`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`],B1=[`all`,`1h`,`24h`,`7d`,`custom`];function V1(e){let t=(e,t,n)=>t.includes(e??``)?e:n,n=dZ(e.get(`from`)),r=dZ(e.get(`to`)),i=n&&r?{start:n,end:r}:null,a=e.get(`stream`);return{requestFilter:t(e.get(`status`),R1,`all`),requestId:e.get(`id`)??``,accountFilter:e.get(`account`)??``,modelFilter:e.get(`model`)??``,providerFilter:e.get(`provider`)??``,streamFilter:a===`stream`||a===`true`?`stream`:a===`sync`||a===`false`?`sync`:`all`,errorKind:t(e.get(`error_kind`),z1,`all`),timeRange:i?`custom`:t(e.get(`range`),B1,`1h`),customRange:i}}function H1(e){let t=new URLSearchParams;e.requestFilter!==`all`&&t.set(`status`,e.requestFilter),e.requestId&&t.set(`id`,e.requestId),e.accountFilter&&t.set(`account`,e.accountFilter),e.modelFilter&&t.set(`model`,e.modelFilter),e.providerFilter&&t.set(`provider`,e.providerFilter),e.streamFilter!==`all`&&t.set(`stream`,e.streamFilter),e.errorKind!==`all`&&t.set(`error_kind`,e.errorKind);let n=e.timeRange===`custom`?uZ(e.customRange?.start):void 0,r=e.timeRange===`custom`?uZ(e.customRange?.end,!0):void 0;return n&&r?(t.set(`from`,n),t.set(`to`,r)):e.timeRange!==`1h`&&t.set(`range`,e.timeRange),t.toString()}function U1(e){if(e===`all`||e===`custom`)return{from:void 0,to:void 0};let t=new Date,n=new Date(t);return e===`1h`&&n.setHours(n.getHours()-1),e===`24h`&&n.setHours(n.getHours()-24),e===`7d`&&n.setDate(n.getDate()-7),{from:n.toISOString(),to:t.toISOString()}}function W1(){let{t:e,lang:t}=DH(),[n,r]=kn(),[i]=(0,v.useState)(()=>V1(new URLSearchParams(window.location.search))),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(`requests`),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(i.requestFilter),[b,x]=(0,v.useState)(`all`),[S,C]=(0,v.useState)(i.requestId),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(i.accountFilter),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(i.modelFilter),[M,N]=(0,v.useState)(i.providerFilter),[P,ee]=(0,v.useState)(i.streamFilter),[F,I]=(0,v.useState)(i.errorKind),[L,te]=(0,v.useState)(i.timeRange),[R,z]=(0,v.useState)(i.customRange),[B,ne]=(0,v.useState)(1),[re,ie]=(0,v.useState)(50),[V,ae]=(0,v.useState)(1),[oe,se]=(0,v.useState)(50),[ce,le]=(0,v.useState)([]),[ue,de]=(0,v.useState)(0),[fe,pe]=(0,v.useState)([]),[me,he]=(0,v.useState)(0),[ge,_e]=(0,v.useState)(null),[ve,ye]=(0,v.useState)(!1),[be,xe]=(0,v.useState)(null),[Se,Ce]=(0,v.useState)(!1),[we,Te]=(0,v.useState)(!1),[Ee,De]=(0,v.useState)(``),Oe=(0,v.useRef)(0),[ke,Ae]=(0,v.useState)(!1),[je,Me]=(0,v.useState)(!1),Ne=n.toString(),Pe=H1({requestFilter:_,requestId:S,accountFilter:E,modelFilter:A,providerFilter:M,streamFilter:P,errorKind:F,timeRange:L,customRange:R}),Fe=(0,v.useRef)(Ne);(0,v.useEffect)(()=>{if(Ne===Fe.current)return;Fe.current=Ne;let e=V1(new URLSearchParams(Ne));y(e.requestFilter),C(e.requestId),D(e.accountFilter),j(e.modelFilter),N(e.providerFilter),ee(e.streamFilter),I(e.errorKind),te(e.timeRange),z(e.customRange)},[Ne]),(0,v.useEffect)(()=>{Pe!==Fe.current&&(Fe.current=Pe,r(Pe,{replace:!0}))},[Pe,r]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([LH(!1),GH()]).then(([t,n])=>{e||(t.status===`fulfilled`&&o(t.value.data||[]),n.status===`fulfilled`&&c(n.value.data||[]))}),()=>{e=!0}},[]);let Ie=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,t.name||t.id);return e},[a]),Le=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,{provider:t.provider,region:t.region});return e},[a]);function Re(t){let n=t.account_id?Le.get(t.account_id):void 0,r=t.provider||n?.provider;return r?EZ(r,n?.region,e):`—`}function ze(t){switch(t){case`pin`:return e(`logsRouting_pin`);case`sticky`:return e(`logsRouting_sticky`);case`sticky_escape`:return e(`logsRouting_sticky_escape`);default:return e(`logsRouting_pool`)}}let Be=(0,v.useMemo)(()=>(a||[]).map(e=>({id:e.id,label:e.name||e.id})),[a]),Ve=(0,v.useMemo)(()=>{let t=new Set;for(let e of a||[])e.provider&&t.add(e.provider);return M&&t.add(M),[{id:``,label:e(`logsFilterProviderAll`)},...[...t].sort().map(t=>({id:t,label:TZ(t,e)}))]},[a,M,e]),He=(0,v.useMemo)(()=>{let e=new Map;for(let t of s||[])e.has(t.id)||e.set(t.id,{id:t.id,label:t.display_name||t.id});return[...e.values()]},[s]),Ue=(0,v.useCallback)(async e=>((await rX({q:e||void 0,limit:20,offset:0})).items||[]).map(e=>({id:e.id,label:e.id})),[]),We=!!(S||_!==`all`||E||A||M||P!==`all`||F!==`all`||L!==`1h`),Ge=[_,S,E,A,M,P,F,L,R?.start?.toString()??``,R?.end?.toString()??``,re].join(`\0`),Ke=[b,w,O,oe].join(`\0`),[qe,Je]=(0,v.useState)(Ge),[Ye,Xe]=(0,v.useState)(Ke);qe!==Ge&&(Je(Ge),ne(1)),Ye!==Ke&&(Xe(Ke),ae(1));let Ze=Math.max(1,Math.ceil(ue/re)),Qe=Math.min(qe===Ge?Math.max(1,B):1,Ze);B!==Qe&&ne(Qe);let $e=Math.max(1,Math.ceil(me/oe)),et=Math.min(Ye===Ke?Math.max(1,V):1,$e);V!==et&&ae(et);let tt=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=S?{from:void 0,to:void 0}:L===`custom`?{from:uZ(R?.start),to:uZ(R?.end,!0)}:U1(L),t=await rX({status:_===`all`?void 0:_,id:S||void 0,account:E||void 0,model:A||void 0,provider:M||void 0,stream:P===`all`?void 0:P===`stream`,error_kind:F===`all`?void 0:F,from:e.from,to:e.to,limit:re,offset:(Qe-1)*re});le(t.items||[]),de(t.total||0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[_,S,E,A,M,P,F,L,R,Qe,re]),nt=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=await oX({level:b===`all`?void 0:b,q:w.trim()||void 0,account:O||void 0,limit:oe,offset:(et-1)*oe});pe(e.items||[]),he(e.total??0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[b,w,O,et,oe]),rt=(0,v.useCallback)(async(e=!1)=>{l===`requests`?await tt(e):await nt(e)},[l,tt,nt]);(0,v.useEffect)(()=>{f(!0);let e=l===`runtime`&&w.trim()?280:0,t=window.setTimeout(()=>void rt(!1),e);return()=>window.clearTimeout(t)},[rt,l,w]),(0,v.useEffect)(()=>{if(l!==`runtime`||et!==1)return;let e=window.setInterval(()=>void nt(!0),3e3);return()=>window.clearInterval(e)},[l,et,nt]);let it=ue===0?0:(Qe-1)*re+1,at=Math.min(ue,Qe*re),ot=me===0?0:(et-1)*oe+1,st=Math.min(me,et*oe),ct=(0,v.useMemo)(()=>l===`requests`?e(`logsShownTotal`,{shown:ce.length?`${it}–${at}`:0,total:ue}):e(`logsShownTotal`,{shown:fe.length?`${ot}–${st}`:0,total:me}),[l,ce.length,fe.length,it,at,ue,ot,st,me,e]);function lt(){C(``),y(`all`),D(``),j(``),N(``),ee(`all`),I(`all`),te(`1h`),z(null),ne(1)}async function ut(e){let t=++Oe.current;xe(e),De(``),Te(!0),Ce(!0);try{let n=await iX(e.id);if(Oe.current!==t)return;xe(n)}catch(e){if(Oe.current!==t)return;De(e instanceof Error?e.message:String(e))}finally{Oe.current===t&&Te(!1)}}function dt(e){_e(e),ye(!0)}async function ft(){Me(!0),JY({id:`logs-clear`,type:`loading`,title:e(`toastClearingLogs`)});try{await aX(),Ae(!1),await tt(!1),JY({id:`logs-clear`,type:`success`,title:e(`toastLogsCleared`)})}catch(t){g(t instanceof Error?t.message:String(t)),JY({id:`logs-clear`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{Me(!1)}}let pt=d&&(l===`requests`?ce.length===0:fe.length===0);return d&&!p?(0,G.jsx)(CY,{}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`navLogs`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`logsLead`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l===`requests`?(0,G.jsxs)(X,{size:`sm`,variant:`ghost`,onPress:()=>Ae(!0),isDisabled:je||ue===0,children:[(0,G.jsx)(Ja,{size:14}),e(`logsClear`)]}):null,(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,isPending:d,onPress:()=>void rt(!1),children:[(0,G.jsx)(Jr,{size:15}),e(`refresh`)]})]})]}),h?(0,G.jsx)(bU,{title:e(`failedLogs`,{msg:h})}):null,(0,G.jsxs)(LF,{selectedKey:l,onSelectionChange:e=>u(String(e)),children:[(0,G.jsx)(LF.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(LF.List,{children:[(0,G.jsxs)(IF,{id:`requests`,className:`gap-1.5`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Ea,{size:13}),e(`logsRequests`)]}),(0,G.jsxs)(IF,{id:`runtime`,className:`gap-1.5`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Ka,{size:13}),e(`logsRuntime`)]})]})}),(0,G.jsxs)(LF.Panel,{id:`requests`,"data-tab-panel":`requests`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(qX,{value:_,onChange:e=>y(e),ariaLabel:e(`logsFilterAll`),options:[{id:`all`,label:e(`logsFilterAll`)},{id:`ok`,label:e(`logsFilterOk`)},{id:`incomplete`,label:e(`logsFilterIncomplete`)},{id:`error`,label:e(`logsFilterError`)},{id:`canceled`,label:e(`logsFilterCanceled`)}]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[We?(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:lt,children:e(`clearFilters`)}):null,(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:ct})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(O1,{ariaLabel:e(`logsColAccount`),value:E,onChange:D,options:Be,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(O1,{ariaLabel:e(`logsColModel`),value:A,onChange:j,options:He,allLabel:e(`logsFilterModelAll`),searchPlaceholder:e(`logsSearchModel`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(hQ,{ariaLabel:e(`logsColProvider`),value:M,onChange:N,options:Ve}),(0,G.jsx)(O1,{ariaLabel:e(`logsSearchRequestId`),value:S,onChange:C,options:S?[{id:S,label:S}]:[],allLabel:e(`logsFilterIdAll`),searchPlaceholder:e(`logsSearchRequestId`),emptyLabel:e(`logsNoFilterOptions`),loadOptions:Ue,className:`min-w-56`}),(0,G.jsx)(qX,{value:P,onChange:e=>ee(e),ariaLabel:e(`logsFilterStreamAll`),options:[{id:`all`,label:e(`logsFilterStreamAll`)},{id:`stream`,label:e(`logsStreamYes`)},{id:`sync`,label:e(`logsStreamNo`)}]}),(0,G.jsx)(hQ,{ariaLabel:e(`errorKind`),value:F===`all`?``:F,onChange:e=>I(e||`all`),options:[{id:``,label:e(`logsFilterKindAll`)},{id:`quota`,label:e(`logsKindQuota`)},{id:`rate_limit`,label:e(`logsKindRateLimit`)},{id:`auth`,label:e(`logsKindAuth`)},{id:`not_ready`,label:e(`logsKindNotReady`)},{id:`unavailable`,label:e(`logsKindUnavailable`)},{id:`invalid_request`,label:e(`logsKindInvalidRequest`)},{id:`model_not_available`,label:e(`logsKindModelNotAvailable`)}]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e(`logsTimeRange`)}),(0,G.jsx)(qX,{value:L,onChange:e=>te(e),ariaLabel:e(`logsTimeRange`),options:[{id:`all`,label:e(`logsTimeAll`)},{id:`1h`,label:e(`logsTime1h`)},{id:`24h`,label:e(`logsTime24h`)},{id:`7d`,label:e(`logsTime7d`)},{id:`custom`,label:e(`logsTimeCustom`)}]}),L===`custom`?(0,G.jsx)(fZ,{className:`w-[min(100%,42rem)]`,value:R,onChange:z,ariaLabel:e(`logsTimeRange`),fromLabel:e(`logsTimeFrom`),toLabel:e(`logsTimeTo`)}):null]})]}),(0,G.jsx)(zw,{className:`overflow-hidden p-0`,"aria-busy":d,children:pt?(0,G.jsx)(xY,{}):ce.length===0?(0,G.jsx)(pQ,{icon:(0,G.jsx)(ua,{size:22}),title:e(We?`logsNoMatch`:`logsEmptyRequests`),action:We?(0,G.jsx)(X,{size:`sm`,variant:`ghost`,onPress:lt,children:e(`clearFilters`)}):null}):(0,G.jsx)(Q,{children:(0,G.jsx)(Q.ScrollContainer,{children:(0,G.jsxs)(Q.Content,{"aria-label":e(`logsRequests`),children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`logsColTime`)}),(0,G.jsx)(Q.Column,{children:e(`logsColModel`)}),(0,G.jsx)(Q.Column,{children:e(`logsColReasoning`)}),(0,G.jsx)(Q.Column,{children:e(`logsColProvider`)}),(0,G.jsx)(Q.Column,{children:e(`logsColAccount`)}),(0,G.jsx)(Q.Column,{children:e(`logsColStatus`)}),(0,G.jsx)(Q.Column,{children:e(`logsColStream`)}),(0,G.jsx)(Q.Column,{children:e(`logsColLatency`)}),(0,G.jsx)(Q.Column,{children:e(`logsColTTFT`)}),(0,G.jsx)(Q.Column,{children:e(`logsColTokens`)})]}),(0,G.jsx)(Q.Body,{children:ce.map(n=>(0,G.jsxs)(Q.Row,{className:`cursor-pointer`,onAction:()=>void ut(n),children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`py-1`,children:[(0,G.jsx)(`div`,{className:`mono text-xs`,children:M1(n.created_at,t)}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.id})]})}),(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium`,children:n.requested_model||`—`}),n.mapped_model&&n.mapped_model!==n.requested_model?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.mapped_model}):null]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:N1(n)||`—`})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs`,children:Re(n)})}),(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`span`,{className:`text-xs`,children:n.account_id?Ie.get(n.account_id)||n.account_id:`—`}),n.account_id&&Ie.get(n.account_id)&&Ie.get(n.account_id)!==n.account_id?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.account_id}):null]}),(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:k1(n.status),children:n.status}),n.error_kind?(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:n.error_kind}):null]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs text-muted`,children:n.stream?e(`logsStreamYes`):e(`logsStreamNo`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:I1(n.latency_ms)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:I1(n.ttfb_ms)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(P1,{log:n,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})})})]},n.id))})]})})})}),(0,G.jsx)(yQ,{total:ue,page:Qe,pageCount:Ze,pageSize:re,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Qe,pages:Ze}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ne,onPageSize:ie})]}),(0,G.jsxs)(LF.Panel,{id:`runtime`,"data-tab-panel":`runtime`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(bQ,{className:`sm:w-72`,value:w,onChange:T,placeholder:e(`logsSearchRuntime`),ariaLabel:e(`logsSearchRuntime`)}),(0,G.jsx)(O1,{ariaLabel:e(`logsColAccount`),value:O,onChange:k,options:Be,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(qX,{value:b,onChange:e=>x(e),ariaLabel:e(`logsLevelAll`),options:[{id:`all`,label:e(`logsLevelAll`)},{id:`info`,label:e(`logsLevelInfo`)},{id:`warn`,label:e(`logsLevelWarn`)},{id:`error`,label:e(`logsLevelError`)}]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[et===1?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":`ok`}),e(`logsAutoRefresh`)]}):null,(0,G.jsx)(`span`,{className:`mono`,children:ct})]})]}),(0,G.jsx)(zw,{className:`overflow-hidden p-0`,"aria-busy":d,children:pt?(0,G.jsx)(SY,{}):fe.length===0?(0,G.jsx)(pQ,{icon:(0,G.jsx)(Ka,{size:22}),title:e(`logsEmptyRuntime`)}):(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:fe.map(e=>(0,G.jsxs)(`div`,{className:`grid cursor-pointer gap-2 px-5 py-3 transition-colors hover:bg-surface-secondary/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:grid-cols-[150px_72px_minmax(0,1fr)] sm:items-start`,role:`button`,tabIndex:0,onClick:()=>dt(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),dt(e))},children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:M1(e.time,t)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":A1(e.level)}),(0,G.jsx)(`span`,{className:`font-medium text-muted`,children:e.level})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[e.account_id?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption text-muted`,children:e.account_id}):null,(0,G.jsx)(`div`,{className:`mono break-all text-xs leading-5 text-foreground`,children:e.message})]})]},e.id))})}),(0,G.jsx)(yQ,{total:me,page:et,pageCount:$e,pageSize:oe,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:et,pages:$e}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ae,onPageSize:se})]})]}),(0,G.jsx)(Z.Root,{isOpen:ve,onOpenChange:e=>{ye(e),e||_e(null)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`logsRuntimeDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:ge?`#${ge.id}`:`—`})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[e(`logsColTime`),ge?M1(ge.time,t):`—`],[e(`logsRuntimeLevel`),ge?.level||`—`],[e(`logsRuntimeSource`),ge?.source||`—`],[e(`logsColAccount`),ge?.account_id||`—`]].map(([t,n])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:t}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t===e(`logsRuntimeLevel`)&&ge?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:j1(ge.level),children:ge.level}):n})]},String(t)))}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsRuntimeMessage`)}),(0,G.jsx)(`pre`,{className:`mono max-h-[min(38rem,60vh)] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary px-4 py-3 text-xs leading-6 text-foreground`,children:ge?.message||`—`})]})]})]})})})}),(0,G.jsx)(Z.Root,{isOpen:Se,onOpenChange:e=>{Ce(e),e||(Oe.current+=1,Te(!1),De(``),xe(null))},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Z.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`logsDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:be?.id})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,G.jsx)(oo,{size:16})})]}),(0,G.jsx)(Z.Body,{className:`space-y-4 px-5 pb-5`,children:we?(0,G.jsx)(F1,{}):Ee?(0,G.jsx)(bU,{title:e(`requestFailed`),description:Ee}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[[e(`logsColStatus`),be?.status||`—`],[e(`logsColModel`),be?.requested_model||`—`],[e(`logsColReasoning`),be&&N1(be)||`—`],[e(`logsColProvider`),be?Re(be):`—`],[e(`logsColAccount`),be?.account_id?Ie.get(be.account_id)||be.account_id:`—`],[e(`logsColLatency`),I1(be?.latency_ms)],[e(`logsColTTFT`),I1(be?.ttfb_ms)],[e(`logsColStream`),be?.stream?e(`logsStreamYes`):e(`logsStreamNo`)],[e(`logsRouting`),be?ze(be.routing):`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t})]},String(e))),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsColTokens`)}),(0,G.jsx)(`dd`,{className:`mt-1`,children:be?(0,G.jsx)(P1,{log:be,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})}):`—`})]})]}),be&&be.message_count?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsMessageShape`)}),(0,G.jsxs)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageCount`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5`,children:be.message_count})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsEmptyMessageIndexes`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:be.empty_message_indexes?.length?be.empty_message_indexes.join(`, `):`—`})]}),(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageRoles`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:be.message_roles?.join(` → `)||`—`})]})]})]}):null,be?.error_message?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-2 text-xs leading-5 text-muted`,children:[be.error_kind?(0,G.jsx)(`span`,{className:`mono mr-2 text-muted`,children:be.error_kind}):null,be.error_message]}):null,be?.stream_diagnostic?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsStreamDiagnostics`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCancellationSource`),be.stream_diagnostic.cancellation_source||`—`],[e(`logsUpstreamStatus`),be.stream_diagnostic.upstream_status??`—`],[e(`logsSSEEvents`),be.stream_diagnostic.sse_event_count],[e(`logsBytesRead`),be.stream_diagnostic.bytes_read],[e(`logsLastEvent`),be.stream_diagnostic.last_event||`—`],[e(`logsStreamComplete`),be.stream_diagnostic.saw_done?`yes`:`no`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))}),be.stream_diagnostic.context_err||be.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{className:`mt-2 space-y-1 break-all text-muted`,children:[be.stream_diagnostic.context_err?(0,G.jsxs)(`div`,{children:[`context: `,be.stream_diagnostic.context_err]}):null,be.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{children:[`relay: `,be.stream_diagnostic.relay_error]}):null]}):null]}):null,be?.usage_detail?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsUsageDetail`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCreditConsumed`),`${L1(be.usage_detail.credit)} ${be.usage_detail.unit||`credits`}`],[e(`logsColProvider`),be.usage_detail.provider||`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))})]}):null,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsAttempts`)}),be?.attempts?.length?(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:be.attempts.map(e=>(0,G.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 text-xs sm:grid-cols-[48px_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`div`,{className:`mono text-muted`,children:[`#`,e.attempt_index]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:e.account_id||`—`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-muted`,children:e.error_message||e.status})]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:k1(e.status===`failover`?`canceled`:e.status),children:e.status})]},e.id))}):(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:e(`logsNoAttempts`)})]})]})})]})})})}),(0,G.jsx)(K$,{isOpen:ke,title:e(`logsClear`),description:e(`logsClearConfirm`),confirmLabel:e(`logsClear`),cancelLabel:e(`close`),closeLabel:e(`close`),isPending:je,onClose:()=>Ae(!1),onConfirm:()=>void ft()})]})}function G1(){return FH(`/api/usage/pricing`)}function K1(e={}){let t=new URLSearchParams;return e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),FH(`/api/usage/cost${t.toString()?`?${t}`:``}`)}var q1=(0,v.lazy)(()=>C(()=>import(`./CostChart-X9vZokWw.js`).then(e=>({default:e.CostChart})),__vite__mapDeps([5,1,4,2]))),J1={window:{from:``,to:``,hours:24},currency:`CNY`,models:[],totals:{id:`total`,label:``,vendor:``,currency:`CNY`,requests:0,cache_hit:0,cache_miss:0,output:0,total_tokens:0,cost:0,cost_off_peak:0,cost_peak:0,peak_requests:0,credits:0,priced:!1},series:[]};function Y1(e,t){if(!t)return`0%`;let n=e/t*100;return`${n>=10?n.toFixed(0):n.toFixed(1)}%`}function X1(){let{t:e,lang:t}=DH(),[n,r]=(0,v.useState)(`all`),[i,a]=(0,v.useState)(`credits`),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!0),[f,p]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!1;return G1().then(t=>{e||l(t)}).catch(()=>{}),()=>{e=!0}},[]);let m=(0,v.useCallback)(async()=>{d(!0);try{let e=await K1(n===`all`?{}:{from:new Date(Date.now()-Number(n)*3600*1e3).toISOString(),to:new Date().toISOString()});s(e),p(``)}catch(e){s(null),p(e instanceof Error?e.message:String(e))}finally{d(!1)}},[n]);(0,v.useEffect)(()=>{m()},[m]);let h=o??J1,g=h.totals,_=g.requests>0&&h.models.length>0,y=h.models.filter(e=>e.priced),b=g.cost>0,x=[{label:e(`usageCredits`),value:_X(g.credits),detail:e(`usageCreditsHint`)},{label:e(`usageTotalTokens`),value:sX(g.total_tokens),detail:`${sX(g.cache_hit)} / ${sX(g.cache_miss)} / ${sX(g.output)} ${e(`usageTokenSplitNote`)}`},{label:e(`usageRequests`),value:String(g.requests),detail:e(`usageModelCount`,{count:h.models.length})},{label:e(`usageCacheHitRate`),value:Y1(g.cache_hit,g.cache_hit+g.cache_miss),detail:sX(g.cache_hit)}],S=i===`credits`?_X(g.credits):i===`tokens`?sX(g.total_tokens):hX(g.cost);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-2`,children:[(0,G.jsx)(qX,{value:n,onChange:e=>r(e),ariaLabel:e(`usageWindow`),options:[{id:`24`,label:e(`usageWindow24h`)},{id:`168`,label:e(`usageWindow7d`)},{id:`all`,label:e(`usageWindowTotal`)}]}),(0,G.jsxs)(X,{size:`sm`,variant:`secondary`,onPress:()=>void m(),isDisabled:u,children:[(0,G.jsx)(Jr,{size:14}),e(`refresh`)]})]}),f?(0,G.jsx)(bU,{title:e(`failedStats`,{msg:f})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-4`,children:x.map(e=>(0,G.jsxs)(zw,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:u?(0,G.jsx)($,{className:`h-5 w-16`}):e.value}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:u?(0,G.jsx)($,{className:`h-3 w-24`}):e.detail||`\xA0`})]},e.label))}),(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:e(`usageChartTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:e(`usageChartHint`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(qX,{value:i,onChange:e=>a(e),ariaLabel:e(`usageChartMetric`),options:[{id:`credits`,label:e(`usageColCredits`)},{id:`tokens`,label:e(`usageColTokens`)}]}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`default`,children:S})]})]}),(0,G.jsx)(`div`,{className:`p-5`,children:u?(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)($,{className:`h-56 w-full`})}):_?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)($,{className:`h-56 w-full`})}),children:(0,G.jsx)(q1,{series:h.series,models:h.models,lang:t,emptyLabel:e(`usageChartEmpty`),totalLabel:e(`usageTotals`),metric:i})}):(0,G.jsx)(pQ,{title:e(`usageEmpty`),hint:e(`usageRetentionHint`)})})]}),(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:e(`usageBreakdownTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:e(`usageBreakdownHint`)})]})}),u?(0,G.jsx)(`div`,{className:`space-y-3 p-5`,children:[0,1,2].map(e=>(0,G.jsx)($,{className:`h-9 w-full`},e))}):_?(0,G.jsx)(Q,{children:(0,G.jsx)(Q.ScrollContainer,{children:(0,G.jsxs)(Q.Content,{"aria-label":e(`usageBreakdownTitle`),children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`usageColModel`)}),(0,G.jsx)(Q.Column,{children:e(`usageColRequests`)}),(0,G.jsx)(Q.Column,{children:e(`usageColInputHit`)}),(0,G.jsx)(Q.Column,{children:e(`usageColInputMiss`)}),(0,G.jsx)(Q.Column,{children:e(`usageColOutput`)}),(0,G.jsx)(Q.Column,{children:e(`usageColTokens`)}),(0,G.jsx)(Q.Column,{children:e(`usageColCredits`)})]}),(0,G.jsxs)(Q.Body,{children:[h.models.map(e=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:e.requests})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.cache_hit)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.cache_miss)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.output)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:sX(e.total_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_X(e.credits)})})]},e.id)),(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e(`usageTotals`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:g.requests})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.cache_hit)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.cache_miss)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.output)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:sX(g.total_tokens)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_X(g.credits)})})]})]})]})})}):(0,G.jsx)(pQ,{title:e(`usageEmpty`),hint:e(`usageRetentionHint`)})]}),(0,G.jsx)(Ih,{className:`rounded-xl bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:[],children:(0,G.jsxs)(Ih.Item,{id:`deepseek-estimate`,children:[(0,G.jsx)(Ih.Heading,{children:(0,G.jsxs)(Ih.Trigger,{className:`items-center gap-3 px-5 py-4 text-left`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block font-semibold tracking-[-0.015em]`,children:e(`usageEstimateTitle`)}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted`,children:e(`usageEstimateHint`)})]}),b?(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`default`,children:hX(g.cost)}):null,(0,G.jsx)(Ih.Indicator,{})]})}),(0,G.jsx)(Ih.Panel,{children:(0,G.jsxs)(Ih.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-6 text-muted`,children:e(`usageRenderNote`)}),b?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium`,children:e(`usageEstimateChartTitle`)}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:`default`,children:hX(g.cost)})]}),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)($,{className:`h-56 w-full`}),children:(0,G.jsx)(q1,{series:h.series,models:y.length?y:h.models,lang:t,emptyLabel:e(`usageEstimateChartEmpty`),totalLabel:e(`usageTotals`),metric:`cost`})})]}):null,y.length?(0,G.jsx)(Q,{children:(0,G.jsx)(Q.ScrollContainer,{children:(0,G.jsxs)(Q.Content,{"aria-label":e(`usageEstimateTitle`),children:[(0,G.jsxs)(Q.Header,{children:[(0,G.jsx)(Q.Column,{isRowHeader:!0,children:e(`usageColModel`)}),(0,G.jsx)(Q.Column,{children:e(`usageColSplit`)}),(0,G.jsx)(Q.Column,{children:e(`usageColCost`)})]}),(0,G.jsxs)(Q.Body,{children:[y.map(e=>(0,G.jsxs)(Q.Row,{children:[(0,G.jsxs)(Q.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[hX(e.cost_peak),` / `,hX(e.cost_off_peak)]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:hX(e.cost)})})]},e.id)),(0,G.jsxs)(Q.Row,{children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e(`usageTotals`)})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[hX(g.cost_peak),` / `,hX(g.cost_off_peak)]})}),(0,G.jsx)(Q.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:hX(g.cost)})})]})]})]})})}):(0,G.jsx)(`p`,{className:`text-xs text-muted`,children:e(`usageEstimateChartEmpty`)}),(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`mb-2 text-sm font-medium`,children:e(`usagePriceTitle`)}),(0,G.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:e(`usagePeakNote`)}),(0,G.jsxs)(`div`,{className:`divide-y divide-separator rounded-lg bg-background`,children:[(c?.models??[]).map(t=>(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:t.label}),(0,G.jsx)(`span`,{className:`mono text-[10px] text-muted`,children:t.currency})]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-[10px] text-muted`,children:t.id}),(0,G.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-[11px]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:e(`usagePriceBandOff`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[gX(t.off_peak.cache_hit),` · `,gX(t.off_peak.cache_miss),` · `,gX(t.off_peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[e(`usagePriceHit`),` · `,e(`usagePriceMiss`),` · `,e(`usagePriceOutput`)]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:e(`usagePriceBandPeak`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[gX(t.peak.cache_hit),` · `,gX(t.peak.cache_miss),` · `,gX(t.peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[e(`usagePriceHit`),` · `,e(`usagePriceMiss`),` · `,e(`usagePriceOutput`)]})]})]})]},t.id)),c?.models?.length?null:(0,G.jsx)(`div`,{className:`px-4 py-6 text-sm text-muted`,children:e(`usageEmpty`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 text-xs leading-6 text-muted`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:e(`usageNoteTitle`)}),(0,G.jsx)(`p`,{children:e(`usageRetentionHint`)}),(0,G.jsx)(`p`,{children:e(`usagePeakNote`)}),h.unpriced?.length?(0,G.jsx)(`p`,{children:e(`usageUnpricedHint`,{models:h.unpriced.join(`, `)})}):null,c?.note?(0,G.jsx)(`p`,{className:`mono text-[10px]`,children:c.note}):null]})]})]})})]})})]})}var Z1=500,Q1={model:`model`,account:`account`,provider:`provider`};function $1(e,t,n){let r=e.prompt_tokens??0,i=e.completion_tokens??0,a=e.key===`(unknown)`||e.key===`(unassigned)`||!e.key;return{key:e.key,label:n,count:e.count,success:e.count?e.ok/e.count:0,p95:e.latency_p95_ms??null,tokens:r+i,prompt:r,completion:i,credits:e.credits??0,cache_write:e.cache_write_tokens??0,cache_read:e.cache_read_tokens??0,filter:a?void 0:{[Q1[t]]:e.key}}}function e0(e,t,n){let r=n===`ascending`?1:-1;return[...e].sort((e,n)=>{if(t===`label`)return r*e.label.localeCompare(n.label);let i=e[t],a=n[t];return i==null&&a==null?0:i==null?1:a==null?-1:r*(i-a)||e.label.localeCompare(n.label)})}function t0(e){return e?e>=1e3?sX(e):String(Math.round(e*100)/100):`0`}function n0(){let{t:e}=DH(),t=ot(),[n,r]=(0,v.useState)(`stats`),[i,a]=(0,v.useState)(`model`),[o,s]=(0,v.useState)(`24`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!0),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)([]),[y,b]=(0,v.useState)(`count`),[x,S]=(0,v.useState)(`descending`),C=(0,v.useRef)(0);(0,v.useEffect)(()=>{let e=!1;return LH(!1).then(t=>{e||_(t.data||[])}).catch(()=>{}),()=>{e=!0}},[]);let w=c?.start?.toString()??``,T=c?.end?.toString()??``;(0,v.useEffect)(()=>{let e=mZ(o,c);if(!e){p(!1);return}let t=++C.current;tX({...e,dim:[i],limit:Z1}).then(e=>{t===C.current&&(d(e),h(``))}).catch(e=>{t===C.current&&(d(null),h(e instanceof Error?e.message:String(e)))}).finally(()=>{t===C.current&&p(!1)})},[i,o,w,T]);let E=(0,v.useMemo)(()=>{let t=new Map(g.map(e=>[e.id,e.name||e.id]));return e0(((i===`model`?u?.models:i===`account`?u?.accounts:u?.providers)??[]).map(n=>{let r=n.key===`(unknown)`?e(`statsUnknown`):n.key===`(unassigned)`?e(`statsUnassigned`):i===`account`?t.get(n.key)||n.key:i===`provider`?TZ(n.key,e):n.key;return $1(n,i,r)}),y,x)},[u,i,g,y,x,e]),D=u?.totals,O=u?.tokens,k=[{id:`label`,label:e(i===`model`?`logsColModel`:i===`account`?`logsColAccount`:`logsColProvider`)},{id:`count`,label:e(`usageColRequests`),numeric:!0},{id:`success`,label:e(`usageColSuccess`),numeric:!0},{id:`p95`,label:e(`statsLatencyP95`),numeric:!0},{id:`tokens`,label:e(`usageColTokens`),numeric:!0},{id:`cache_write`,label:e(`usageColCacheWrite`),numeric:!0},{id:`credits`,label:e(`usageColCredits`),numeric:!0}],A=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-1`,children:(0,G.jsx)(hZ,{value:o,onChange:s,custom:c,onCustomChange:l,onBusy:()=>p(!0),t:e})}),m?(0,G.jsx)(bU,{title:e(`failedStats`,{msg:m})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-5`,children:[[e(`usageColRequests`),D?sX(D.requests):`—`,e(`statsWindowHint`,{window:e(pZ[o])})],[e(`usageColSuccess`),D?uX(D.success_rate):`—`,D?`${D.ok} / ${D.requests}`:``],[e(`usageColTokens`),O?sX(O.total):`—`,O?`${sX(O.prompt)} / ${sX(O.completion)}`:``],[e(`usageColCacheWrite`),O?sX(O.cache_write??0):`—`,O?`${e(`chartCacheRead`)} ${sX(O.cache_read)}`:``],[e(`usageColCredits`),D?t0(D.credits??0):`—`,``]].map(([e,t,n])=>(0,G.jsxs)(zw,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:f?(0,G.jsx)($,{className:`h-5 w-16`}):t}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:f?(0,G.jsx)($,{className:`h-3 w-24`}):n||`\xA0`})]},e))}),(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,G.jsx)(LF,{selectedKey:i,onSelectionChange:e=>{p(!0),a(String(e))},children:(0,G.jsx)(LF.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(LF.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(IF,{id:`model`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Mi,{size:14}),e(`usageByModel`)]}),(0,G.jsxs)(IF,{id:`account`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(no,{size:14}),e(`usageByAccount`)]}),(0,G.jsxs)(IF,{id:`provider`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),(0,G.jsx)(Ba,{size:14}),e(`usageByProvider`)]})]})})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:f?``:e(`usageRowCount`,{count:E.length})})]}),f?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)($,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)($,{className:`h-3 w-12`}),(0,G.jsx)($,{className:`h-4 w-16`})]},t))})]},t))}),(0,G.jsx)(`div`,{className:`hidden divide-y divide-separator md:block`,"aria-busy":`true`,children:Array.from({length:6},(e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-6 px-5 py-3.5`,children:[(0,G.jsx)($,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`flex-1`}),Array.from({length:6},(e,t)=>(0,G.jsx)($,{className:`h-4 w-14`},t))]},t))})]}):E.length===0?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-10 text-body text-muted`,children:[(0,G.jsx)(mi,{size:16}),e(`usageEmpty`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:E.map(n=>{let r=!!(n.filter&&u),a=[{label:e(`usageColRequests`),value:String(n.count)},{label:e(`usageColSuccess`),value:uX(n.success),tone:n.success<.9?`text-warning`:void 0},{label:e(`statsLatencyP95`),value:cX(n.p95)},{label:e(`usageColTokens`),value:sX(n.tokens),sub:`${sX(n.prompt)} / ${sX(n.completion)}`},{label:e(`usageColCacheWrite`),value:sX(n.cache_write)},{label:e(`usageColCredits`),value:t0(n.credits)}];return(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4 ${r?`cursor-pointer`:``}`,onClick:r?()=>t(gZ(n.filter??{},u.window.from,u.window.to)):void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(gZ(n.filter??{},u.window.from,u.window.to)))}:void 0,role:r?`button`:void 0,tabIndex:r?0:void 0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i===`provider`&&n.filter?(0,G.jsx)(zZ,{provider:n.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.label})]}),i===`account`&&n.label!==n.key?(0,G.jsx)(`div`,{className:`mono truncate text-caption text-muted`,children:n.key}):null,(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:a.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value}),`sub`in e&&e.sub?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:e.sub}):null]},e.label))})]},n.key)})}),(0,G.jsx)(Q,{className:`usage-table hidden md:block`,children:(0,G.jsx)(Q.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(Q.Content,{"aria-label":e(`usageTitle`),className:`min-w-[48rem]`,sortDescriptor:{column:y,direction:x},onSortChange:e=>{b(String(e.column)),S(e.direction)},children:[(0,G.jsx)(Q.Header,{children:k.map(e=>(0,G.jsx)(Q.Column,{id:e.id,allowsSorting:!0,isRowHeader:e.id===`label`,className:e.numeric?`text-right`:void 0,children:({sortDirection:t})=>(0,G.jsx)(Q.SortableColumnHeader,{sortDirection:t,className:e.numeric?`justify-end`:void 0,children:e.label})},e.id))}),(0,G.jsx)(Q.Body,{children:E.map(e=>(0,G.jsxs)(Q.Row,{id:e.key,className:e.filter&&u?`cursor-pointer`:void 0,onAction:e.filter&&u?()=>t(gZ(e.filter??{},u.window.from,u.window.to)):void 0,children:[(0,G.jsx)(Q.Cell,{children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i===`provider`&&e.filter?(0,G.jsx)(zZ,{provider:e.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:e.label}),i===`account`&&e.label!==e.key?(0,G.jsx)(`span`,{className:`mono truncate text-caption text-muted`,children:e.key}):null]})}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:e.count}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:(0,G.jsx)(`span`,{className:e.success<.9?`text-warning`:void 0,children:uX(e.success)})}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:cX(e.p95)}),(0,G.jsxs)(Q.Cell,{className:`text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-body`,children:sX(e.tokens)}),(0,G.jsxs)(`div`,{className:`mono text-caption text-muted`,children:[sX(e.prompt),` / `,sX(e.completion)]})]}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:sX(e.cache_write)}),(0,G.jsx)(Q.Cell,{className:`mono text-right text-body`,children:t0(e.credits)})]},e.key))})]})})})]})]})]});return(0,G.jsxs)(`div`,{className:`space-y-6 sm:space-y-6`,children:[(0,G.jsxs)(`section`,{className:`pb-1`,children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`usageTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(n===`cost`?`usageCostLead`:`usageLead`)})]}),(0,G.jsxs)(LF,{selectedKey:n,onSelectionChange:e=>r(String(e)),children:[(0,G.jsx)(LF.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(LF.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(IF,{id:`stats`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),e(`usageStatsTab`)]}),(0,G.jsxs)(IF,{id:`cost`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(LF.Indicator,{className:`transition-none`}),e(`usageCostTab`)]})]})}),(0,G.jsx)(LF.Panel,{id:`stats`,className:`space-y-6 pt-5`,children:A}),(0,G.jsx)(LF.Panel,{id:`cost`,className:`pt-5`,children:(0,G.jsx)(X1,{})})]})]})}var r0=1.1;function i0({label:e,onConfirm:t,isPending:n,children:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>{a.current?.kill()},[]),(0,G.jsxs)(eL,{delay:300,children:[(0,G.jsx)(eL.Trigger,{children:(0,G.jsxs)(X,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e,isPending:n,className:`relative overflow-hidden`,onPressStart:()=>{let e=i.current;!e||n||(a.current?.kill(),a.current=eY.to(e,{scaleX:1,duration:r0*(1-Number(eY.getProperty(e,`scaleX`))),ease:nY.linear,onComplete:()=>{a.current=null,eY.to(e,{scaleX:0,duration:iY()?0:tY.base,ease:nY.out,delay:tY.fast}),t()}}))},onPressEnd:()=>{let e=i.current;!e||!a.current||(a.current.kill(),a.current=null,eY.to(e,{scaleX:0,duration:iY()?0:tY.base,ease:nY.soft}))},children:[(0,G.jsx)(`span`,{ref:i,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 origin-left scale-x-0 bg-danger/20`}),(0,G.jsx)(`span`,{className:`relative inline-flex`,children:r})]})}),(0,G.jsx)(eL.Content,{children:e})]})}function a0(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id});return t}function o0(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i?EZ(r,i,t):TZ(r,t)}function s0(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function c0(e,t){let n=[],r=new Set(e.filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));for(let t of e)t.includes(`:`)&&n.push(t);for(let e of t)r.has(e.provider)&&!n.includes(e.value)&&n.push(e.value);return n}function l0(e,t){return e.length?e.map(e=>o0(e,t)).join(` · `):t(`keysAllProviders`)}function u0(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function d0(){let{t:e}=DH(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1);(0,v.useEffect)(()=>{tU().then(e=>{let t=a0(e.data||[]);n(t),i(t.length>0),o(``)}).catch(e=>{o(e instanceof Error?e.message:String(e))})},[]);async function w(){u(!0);try{let e=await p1();c(e.data||[]),m(``)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}(0,v.useEffect)(()=>{let e=window.setTimeout(()=>void w(),0);return()=>window.clearTimeout(e)},[]);async function T(e){await NQ(e),C(!0),window.setTimeout(()=>C(!1),1200)}async function E(e,t){f(e.id),c(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{let n=await h1(e.id,{enabled:t});c(t=>t.map(t=>t.id===e.id?{...t,...n,secret:void 0}:t))}catch(e){m(e instanceof Error?e.message:String(e)),await w()}finally{f(``)}}async function D(t){f(t.id);try{await g1(t.id),c(e=>e.filter(e=>e.id!==t.id)),JY({type:`success`,title:e(`toastKeyDeleted`)})}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(``)}}return l&&!s.length?(0,G.jsx)(yY,{}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`navKeys`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`keysLead`)})]}),(0,G.jsxs)(X,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(wa,{size:14}),e(`keysCreate`)]})]}),p?(0,G.jsx)(bU,{title:p}):null,a?(0,G.jsx)(bU,{title:e(`keysProvidersLoadFailed`,{message:a})}):null,l?(0,G.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:Math.max(3,s.length)},(e,t)=>(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface p-3`,children:[(0,G.jsx)($,{className:`h-4 w-28`}),(0,G.jsx)($,{className:`mt-2 h-3 w-40`}),(0,G.jsx)($,{className:`mt-4 h-6 w-24`}),(0,G.jsx)($,{className:`mt-6 h-8 w-full`})]},t))}):s.length?(0,G.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,children:s.map(t=>(0,G.jsxs)(zw,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(zw.Header,{className:`flex-row items-start justify-between gap-3 px-3 pt-3 pb-2.5`,children:[(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(zw.Title,{className:`truncate text-body`,children:t.name})}),(0,G.jsx)(lT,{size:`sm`,variant:`soft`,color:t.enabled?`success`:`default`,children:t.enabled?e(`enabled`):e(`disabled`)})]}),(0,G.jsxs)(zw.Content,{className:`space-y-2.5 px-3 pb-2.5`,children:[(0,G.jsx)(`div`,{className:`mono w-full rounded-lg bg-surface-secondary px-3 py-2 text-body text-foreground`,title:t.prefix,children:t.prefix}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:(t.providers.length?t.providers:[`all`]).map(t=>(0,G.jsx)(lT,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t===`all`?(0,G.jsx)(na,{size:12}):(0,G.jsx)(zZ,{provider:s0(t),size:12}),(0,G.jsx)(`span`,{children:t===`all`?e(`keysAllProviders`):o0(t,e)})]})},t))}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t.last_used_at?e(`keysLastUsed`,{time:u0(t.last_used_at)}):e(`keysNeverUsed`)})]}),(0,G.jsxs)(zw.Footer,{className:`gap-1.5 bg-surface-secondary px-3 py-2`,children:[(0,G.jsx)(X,{size:`sm`,variant:`ghost`,isDisabled:!r,onPress:()=>y(t),children:e(`edit`)}),(0,G.jsx)(i0,{label:e(`holdToDelete`),isPending:d===t.id,onConfirm:()=>void D(t),children:(0,G.jsx)(Ja,{size:14})}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(fQ,{isSelected:t.enabled,isDisabled:d===t.id,ariaLabel:e(`enable`),onChange:e=>void E(t,e)})})]})]},t.id))}):(0,G.jsx)(pQ,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(uY,{size:28}),title:e(`keysEmpty`),hint:e(`keysEmptyHint`),action:(0,G.jsxs)(X,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(wa,{size:14}),e(`keysCreate`)]})}),(0,G.jsx)(f0,{isOpen:h,title:e(`keysCreateTitle`),hint:e(`keysCreateHint`),options:t,t:e,onClose:()=>g(!1),onSave:async e=>{let t=await m1(e);c(e=>[t,...e.map(e=>({...e,secret:void 0}))]),g(!1),x(t)}}),(0,G.jsx)(f0,{isOpen:!!_,title:e(`keysEditTitle`),hint:e(`keysEditHint`),initial:_,options:t,t:e,onClose:()=>y(null),onSave:async e=>{if(!_)return;let t=await h1(_.id,e);c(e=>e.map(e=>e.id===_.id?{...e,...t,secret:void 0}:e)),y(null)}}),(0,G.jsx)(Z.Root,{isOpen:!!b?.secret,onOpenChange:e=>{e||x(null)},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Z.Dialog,{children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:e(`keysSecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`keysSecretHint`)})]}),(0,G.jsx)(Z.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsxs)(Z.Body,{className:`px-6 pb-2`,children:[(0,G.jsxs)(RB,{status:`warning`,className:`mb-4`,children:[(0,G.jsx)(RB.Indicator,{}),(0,G.jsx)(RB.Content,{children:(0,G.jsx)(RB.Title,{children:e(`keysSecretOnce`)})})]}),(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b?.secret})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,onPress:()=>x(null),children:e(`close`)}),(0,G.jsxs)(X,{onPress:()=>{b?.secret&&T(b.secret)},children:[(0,G.jsx)(Oi,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}function f0({isOpen:e,title:t,hint:n,initial:r,options:i,t:a,onClose:o,onSave:s}){let[c,l]=(0,v.useState)(r?.name||``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(new Set),[m,h]=(0,v.useState)(!0),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;l(r?.name||``),d(c0(r?.providers||[],i));let t=new Set((r?.providers||[]).filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));p(t),h(!0),_(``)},[r,e,i]);function x(e){let t=i.find(t=>t.value===e);h(!1),d(n=>n.includes(e)?(t&&p(e=>{let n=new Set(e);return n.delete(t.provider),n}),n.filter(t=>t!==e)):[...n,e])}async function S(e){e?.preventDefault();let t=c.trim();if(!t){_(a(`keysNameRequired`));return}if(!i.length){_(a(`keysProvidersNotLoaded`));return}b(!0),_(``);try{await s({name:t,providers:m?r?.providers||[]:u})}catch(e){_(e instanceof Error?e.message:String(e))}finally{b(!1)}}return(0,G.jsx)(Z.Root,{isOpen:e,onOpenChange:e=>{!e&&!y&&o()},children:(0,G.jsx)(Z.Backdrop,{variant:`blur`,children:(0,G.jsx)(Z.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,G.jsx)(Z.Dialog,{className:`sm:min-w-[32rem]`,children:(0,G.jsxs)(FB,{onSubmit:S,children:[(0,G.jsxs)(Z.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Z.Heading,{className:`text-section font-semibold`,children:t}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:n})]}),(0,G.jsx)(Z.CloseTrigger,{isDisabled:y,"aria-label":a(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(oo,{size:18})})]}),(0,G.jsxs)(Z.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[g?(0,G.jsxs)(RB,{status:`danger`,children:[(0,G.jsx)(RB.Indicator,{}),(0,G.jsx)(RB.Content,{children:(0,G.jsx)(RB.Title,{children:g})})]}):null,(0,G.jsx)(E$,{label:a(`keysName`),children:(0,G.jsx)(lL,{value:c,onChange:e=>l(e.target.value),placeholder:a(`keysNamePh`),"aria-label":a(`keysName`)})}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(sR,{className:`text-body font-medium text-muted`,children:a(`keysProviders`)}),(0,G.jsx)(lR,{className:`text-caption leading-5 text-muted`,children:a(`keysProvidersHint`)}),i.length?(0,G.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=u.includes(e.value),n=f.has(e.provider);return(0,G.jsx)(aT,{isSelected:t,onChange:()=>x(e.value),className:`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft`,children:(0,G.jsxs)(aT.Content,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(aT.Control,{children:(0,G.jsx)(aT.Indicator,{})}),(0,G.jsx)(zZ,{provider:e.provider,size:16}),(0,G.jsx)(`span`,{className:`text-body font-medium`,children:EZ(e.provider,e.region,a)}),n?(0,G.jsx)(`span`,{className:`rounded-md bg-surface-secondary px-1.5 py-0.5 text-caption font-medium text-muted`,children:a(`keysAllRegions`)}):null]})},e.value)})}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption leading-5 text-muted`,children:a(`keysProvidersNotLoaded`)}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:l0(u,a)})]})]}),(0,G.jsxs)(Z.Footer,{className:`justify-end`,children:[(0,G.jsx)(X,{variant:`ghost`,isDisabled:y,onPress:o,children:a(`cancel`)}),(0,G.jsx)(X,{type:`submit`,isPending:y,isDisabled:!i.length,children:a(r?`save`:`create`)})]})]})})})})})}function p0(){return(0,G.jsx)(hU,{children:(0,G.jsx)(EH,{children:(0,G.jsx)(AH,{children:(0,G.jsx)(uU,{children:(0,G.jsx)(Sn,{children:(0,G.jsxs)(Ft,{children:[(0,G.jsx)(Nt,{path:`/login`,element:(0,G.jsx)(f1,{})}),(0,G.jsx)(Nt,{element:(0,G.jsx)(eX,{}),children:(0,G.jsxs)(Nt,{element:(0,G.jsx)($Y,{}),children:[(0,G.jsx)(Nt,{path:`/`,element:(0,G.jsx)(iQ,{})}),(0,G.jsx)(Nt,{path:`/auth`,element:(0,G.jsx)(jt,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Nt,{path:`/providers`,element:(0,G.jsx)(jQ,{})}),(0,G.jsx)(Nt,{path:`/access`,element:(0,G.jsx)(f$,{})}),(0,G.jsx)(Nt,{path:`/accounts`,element:(0,G.jsx)(d1,{})}),(0,G.jsx)(Nt,{path:`/checkins`,element:(0,G.jsx)(jt,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Nt,{path:`/usage`,element:(0,G.jsx)(n0,{})}),(0,G.jsx)(Nt,{path:`/logs`,element:(0,G.jsx)(W1,{})}),(0,G.jsx)(Nt,{path:`/keys`,element:(0,G.jsx)(d0,{})}),(0,G.jsx)(Nt,{path:`/system`,element:(0,G.jsx)(T1,{})}),(0,G.jsx)(Nt,{path:`*`,element:(0,G.jsx)(jt,{to:`/`,replace:!0})})]})})]})})})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(v.StrictMode,{children:(0,G.jsx)(p0,{})}));export{_X as a,Pv as c,h as d,d as f,l as h,sX as i,Mc as l,s as m,wX as n,cX as o,o as p,hX as r,eY as s,qX as t,Ss as u}; \ No newline at end of file diff --git a/internal/webui/static/index.html b/internal/webui/static/index.html index 97764599..b5a5118a 100644 --- a/internal/webui/static/index.html +++ b/internal/webui/static/index.html @@ -19,7 +19,7 @@ - +