@kaitranntt/ccs 7.20.1-dev.1 → 7.20.1-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/api-command.js +2 -2
- package/dist/commands/api-command.js.map +1 -1
- package/dist/ui/assets/{accounts-DjriQaux.js → accounts-CBHdGCQd.js} +1 -1
- package/dist/ui/assets/{alert-dialog-CPkBZdxX.js → alert-dialog-DsTxhlFk.js} +1 -1
- package/dist/ui/assets/{api-ful0juAi.js → api-DFeR1iJt.js} +1 -1
- package/dist/ui/assets/{auth-section-cj5RF2YC.js → auth-section-Ve_TIR5H.js} +1 -1
- package/dist/ui/assets/backups-section-CQtajr1G.js +1 -0
- package/dist/ui/assets/{cliproxy-CfnF3x1J.js → cliproxy-C9-WQ2K1.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-C3-aaKZ4.js → cliproxy-control-panel-BHNeiJAP.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-8tDtDzY6.js → confirm-dialog-DO64zZqj.js} +1 -1
- package/dist/ui/assets/{copilot-DqdZcqhE.js → copilot-MbZr8wG3.js} +2 -2
- package/dist/ui/assets/{globalenv-section-C32LknWn.js → globalenv-section-CSL8d808.js} +1 -1
- package/dist/ui/assets/{health-By7mDK3f.js → health-DYJGIuhY.js} +1 -1
- package/dist/ui/assets/{index-nK4RTWya.js → index-C1c994wt.js} +2 -2
- package/dist/ui/assets/{index-IQ6bFgHE.js → index-D3SAzu5s.js} +1 -1
- package/dist/ui/assets/{index-DIZW46YP.js → index-DzAtu2WP.js} +1 -1
- package/dist/ui/assets/{index-BT0zZuh6.js → index-QzEXdM_L.js} +1 -1
- package/dist/ui/assets/{shared-CWZXvj7S.js → shared-BZUOuxLa.js} +1 -1
- package/dist/ui/assets/{switch-CzVXYNya.js → switch-C7NO4S4-.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/web-server/routes/persist-routes.d.ts.map +1 -1
- package/dist/web-server/routes/persist-routes.js +25 -2
- package/dist/web-server/routes/persist-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/backups-section-BtbLGda5.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DzAtu2WP.js","assets/radix-ui-DP8--cuX.js","assets/react-vendor-CNOkPC89.js","assets/switch-C7NO4S4-.js","assets/icons-B8zfgpli.js","assets/tanstack-C1q4365B.js","assets/notifications-B2HqRBj7.js","assets/utils-CzKF5WmX.js","assets/form-utils-C-pVd1--.js","assets/code-highlight-BRUf_pqB.js","assets/globalenv-section-CSL8d808.js","assets/index-QzEXdM_L.js","assets/auth-section-Ve_TIR5H.js","assets/backups-section-CQtajr1G.js","assets/alert-dialog-DsTxhlFk.js","assets/index-D3SAzu5s.js","assets/charts-BBPXh0Ar.js","assets/api-DFeR1iJt.js","assets/confirm-dialog-DO64zZqj.js","assets/cliproxy-C9-WQ2K1.js","assets/cliproxy-control-panel-BHNeiJAP.js","assets/copilot-MbZr8wG3.js","assets/accounts-CBHdGCQd.js","assets/health-DYJGIuhY.js","assets/shared-BZUOuxLa.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{j as i,S as Gr,R as Zp,C as Wp,a as Jp,T as $p,D as Fp,P as Ip,O as Pp,b as L0,c as Y0,d as G0,e as K0,f as Q0,A as V0,g as X0,h as Z0,i as W0,k as J0,l as $0,m as F0,n as I0,I as P0,o as eg,V as ev,p as tv,q as tg,r as nv,L as ng,s as ag,t as lg,u as av,v as lv,w as sg,x as sv,y as ig,z as rg,B as iv,E as og,F as rv,G as ug,H as cg,J as ov,K as uv,M as dg,N as cv,Q as dv,U as fv,W as mv,X as fg,Y as hv,Z as pv,_ as gv}from"./radix-ui-DP8--cuX.js";import{e as mg,f as xv,r as y,u as Hc,O as Oc,N as yv,h as Lc,L as Ac,R as vv,g as bv,i as Sv,c as P,B as Nv,j as jv,k as nn}from"./react-vendor-CNOkPC89.js";import{Q as Cv,u as Nt,a as zt,b as Ot,c as wv}from"./tanstack-C1q4365B.js";import{t as he,T as Ev}from"./notifications-B2HqRBj7.js";import{L as fa,X as fi,P as Mv,H as Tv,C as zv,K as hg,G as Ov,Z as pg,a as gg,F as xg,U as yg,A as oi,S as Av,b as Kr,c as Dv,M as _v,E as Qr,d as Vr,B as kv,W as Rv,e as ip,f as Uv,g as qv,h as rp,i as op,j as ls,k as vg,l as Br,m as bg,n as Bv,o as Hv,p as Xr,q as Yc,r as Zr,s as Gc,R as Lv,t as Yv,u as Gv,T as dl,I as Wr,v as Kv,w as Qv,x as Vv,y as Xv,z as Zv,D as Wv,J as Jv,N as Kc,O as Jr,Q as Qc,V as up,Y as $v,_ as Vc,$ as Fv,a0 as Iv,a1 as Pv,a2 as cp,a3 as Dc,a4 as eb,a5 as tb}from"./icons-B8zfgpli.js";import{t as nb,c as ab,a as $r,e as ei,f as ai,b as lb,d as sb,g as ib,h as rb,i as ob,j as ub,k as cb,l as db,m as fb,n as mb,o as hb,p as pb,q as gb,r as xb,s as yb,u as vb,v as bb,w as Sb,x as Nb,y as jb,z as Cb,A as wb,B as Eb,C as Mb,D as Tb,E as zb,F as Ob,G as Ab,H as Db,I as _b,J as kb}from"./utils-CzKF5WmX.js";import{o as dp,s as fp,p as Rb,a as Ub,$ as qb,b as Sg,c as Bb,d as rl,u as Hb,e as Lb}from"./form-utils-C-pVd1--.js";import{H as Yb,t as mp}from"./code-highlight-BRUf_pqB.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))u(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const h of m.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&u(h)}).observe(document,{childList:!0,subtree:!0});function o(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function u(d){if(d.ep)return;d.ep=!0;const m=o(d);fetch(d.href,m)}})();var gc={exports:{}},ti={},xc={exports:{}},yc={};var hp;function Gb(){return hp||(hp=1,(function(a){function s(z,Z){var ae=z.length;z.push(Z);e:for(;0<ae;){var ye=ae-1>>>1,ve=z[ye];if(0<d(ve,Z))z[ye]=Z,z[ae]=ve,ae=ye;else break e}}function o(z){return z.length===0?null:z[0]}function u(z){if(z.length===0)return null;var Z=z[0],ae=z.pop();if(ae!==Z){z[0]=ae;e:for(var ye=0,ve=z.length,Ae=ve>>>1;ye<Ae;){var ce=2*(ye+1)-1,X=z[ce],F=ce+1,le=z[F];if(0>d(X,ae))F<ve&&0>d(le,X)?(z[ye]=le,z[F]=ae,ye=F):(z[ye]=X,z[ce]=ae,ye=ce);else if(F<ve&&0>d(le,ae))z[ye]=le,z[F]=ae,ye=F;else break e}}return Z}function d(z,Z){var ae=z.sortIndex-Z.sortIndex;return ae!==0?ae:z.id-Z.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;a.unstable_now=function(){return m.now()}}else{var h=Date,p=h.now();a.unstable_now=function(){return h.now()-p}}var x=[],S=[],E=1,v=null,b=3,D=!1,T=!1,k=!1,U=!1,M=typeof setTimeout=="function"?setTimeout:null,Y=typeof clearTimeout=="function"?clearTimeout:null,H=typeof setImmediate<"u"?setImmediate:null;function V(z){for(var Z=o(S);Z!==null;){if(Z.callback===null)u(S);else if(Z.startTime<=z)u(S),Z.sortIndex=Z.expirationTime,s(x,Z);else break;Z=o(S)}}function R(z){if(k=!1,V(z),!T)if(o(x)!==null)T=!0,j||(j=!0,re());else{var Z=o(S);Z!==null&&$(R,Z.startTime-z)}}var j=!1,L=-1,J=5,ee=-1;function de(){return U?!0:!(a.unstable_now()-ee<J)}function Se(){if(U=!1,j){var z=a.unstable_now();ee=z;var Z=!0;try{e:{T=!1,k&&(k=!1,Y(L),L=-1),D=!0;var ae=b;try{t:{for(V(z),v=o(x);v!==null&&!(v.expirationTime>z&&de());){var ye=v.callback;if(typeof ye=="function"){v.callback=null,b=v.priorityLevel;var ve=ye(v.expirationTime<=z);if(z=a.unstable_now(),typeof ve=="function"){v.callback=ve,V(z),Z=!0;break t}v===o(x)&&u(x),V(z)}else u(x);v=o(x)}if(v!==null)Z=!0;else{var Ae=o(S);Ae!==null&&$(R,Ae.startTime-z),Z=!1}}break e}finally{v=null,b=ae,D=!1}Z=void 0}}finally{Z?re():j=!1}}}var re;if(typeof H=="function")re=function(){H(Se)};else if(typeof MessageChannel<"u"){var Ye=new MessageChannel,je=Ye.port2;Ye.port1.onmessage=Se,re=function(){je.postMessage(null)}}else re=function(){M(Se,0)};function $(z,Z){L=M(function(){z(a.unstable_now())},Z)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(z){z.callback=null},a.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<z?Math.floor(1e3/z):5},a.unstable_getCurrentPriorityLevel=function(){return b},a.unstable_next=function(z){switch(b){case 1:case 2:case 3:var Z=3;break;default:Z=b}var ae=b;b=Z;try{return z()}finally{b=ae}},a.unstable_requestPaint=function(){U=!0},a.unstable_runWithPriority=function(z,Z){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var ae=b;b=z;try{return Z()}finally{b=ae}},a.unstable_scheduleCallback=function(z,Z,ae){var ye=a.unstable_now();switch(typeof ae=="object"&&ae!==null?(ae=ae.delay,ae=typeof ae=="number"&&0<ae?ye+ae:ye):ae=ye,z){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=ae+ve,z={id:E++,callback:Z,priorityLevel:z,startTime:ae,expirationTime:ve,sortIndex:-1},ae>ye?(z.sortIndex=ae,s(S,z),o(x)===null&&z===o(S)&&(k?(Y(L),L=-1):k=!0,$(R,ae-ye))):(z.sortIndex=ve,s(x,z),T||D||(T=!0,j||(j=!0,re()))),z},a.unstable_shouldYield=de,a.unstable_wrapCallback=function(z){var Z=b;return function(){var ae=b;b=Z;try{return z.apply(this,arguments)}finally{b=ae}}}})(yc)),yc}var pp;function Kb(){return pp||(pp=1,xc.exports=Gb()),xc.exports}var gp;function Qb(){if(gp)return ti;gp=1;var a=Kb(),s=mg(),o=xv();function u(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function m(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(m(e)!==e)throw Error(u(188))}function S(e){var t=e.alternate;if(!t){if(t=m(e),t===null)throw Error(u(188));return t!==e?null:e}for(var n=e,l=t;;){var r=n.return;if(r===null)break;var c=r.alternate;if(c===null){if(l=r.return,l!==null){n=l;continue}break}if(r.child===c.child){for(c=r.child;c;){if(c===n)return x(r),e;if(c===l)return x(r),t;c=c.sibling}throw Error(u(188))}if(n.return!==l.return)n=r,l=c;else{for(var f=!1,g=r.child;g;){if(g===n){f=!0,n=r,l=c;break}if(g===l){f=!0,l=r,n=c;break}g=g.sibling}if(!f){for(g=c.child;g;){if(g===n){f=!0,n=c,l=r;break}if(g===l){f=!0,l=c,n=r;break}g=g.sibling}if(!f)throw Error(u(189))}}if(n.alternate!==l)throw Error(u(190))}if(n.tag!==3)throw Error(u(188));return n.stateNode.current===n?e:t}function E(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=E(e),t!==null)return t;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),D=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),H=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),de=Symbol.for("react.memo_cache_sentinel"),Se=Symbol.iterator;function re(e){return e===null||typeof e!="object"?null:(e=Se&&e[Se]||e["@@iterator"],typeof e=="function"?e:null)}var Ye=Symbol.for("react.client.reference");function je(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Ye?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case M:return"Profiler";case U:return"StrictMode";case R:return"Suspense";case j:return"SuspenseList";case ee:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case T:return"Portal";case H:return e.displayName||"Context";case Y:return(e._context.displayName||"Context")+".Consumer";case V:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return t=e.displayName||null,t!==null?t:je(e.type)||"Memo";case J:t=e._payload,e=e._init;try{return je(e(t))}catch{}}return null}var $=Array.isArray,z=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},ye=[],ve=-1;function Ae(e){return{current:e}}function ce(e){0>ve||(e.current=ye[ve],ye[ve]=null,ve--)}function X(e,t){ve++,ye[ve]=e.current,e.current=t}var F=Ae(null),le=Ae(null),I=Ae(null),ne=Ae(null);function xe(e,t){switch(X(I,t),X(le,e),X(F,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?zh(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=zh(t),e=Oh(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ce(F),X(F,e)}function De(){ce(F),ce(le),ce(I)}function Ge(e){e.memoizedState!==null&&X(ne,e);var t=F.current,n=Oh(t,e.type);t!==n&&(X(le,e),X(F,n))}function gt(e){le.current===e&&(ce(F),ce(le)),ne.current===e&&(ce(ne),$s._currentValue=ae)}var xt,Qe;function tt(e){if(xt===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);xt=t&&t[1]||"",Qe=-1<n.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+xt+e+Qe}var kt=!1;function Qt(e,t){if(!e||kt)return"";kt=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var Q=function(){throw Error()};if(Object.defineProperty(Q.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Q,[])}catch(q){var _=q}Reflect.construct(e,[],Q)}else{try{Q.call()}catch(q){_=q}e.call(Q.prototype)}}else{try{throw Error()}catch(q){_=q}(Q=e())&&typeof Q.catch=="function"&&Q.catch(function(){})}}catch(q){if(q&&_&&typeof q.stack=="string")return[q.stack,_.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=l.DetermineComponentFrameRoot(),f=c[0],g=c[1];if(f&&g){var N=f.split(`
|
|
@@ -44,4 +44,4 @@ Error generating stack: `+l.message+`
|
|
|
44
44
|
`).map(function(us,cs){return cs>=At&&cs<=Yn?ie+us:us}).join(`
|
|
45
45
|
`),selectionStart:ge&&/\S/.test(ge)?Te+ie.length:Te,selectionEnd:nt+ie.length*(Yn-At+1)})}else{var vt=Te+ie.length;Tn({value:fe.substring(0,Te)+ie+fe.substring(nt),selectionStart:vt,selectionEnd:vt})}else if(W.key==="Backspace"){var Wt=Te!==nt,vn=fe.substring(0,Te);if(vn.endsWith(ie)&&!Wt){W.preventDefault();var vt=Te-ie.length;Tn({value:fe.substring(0,Te-ie.length)+fe.substring(nt),selectionStart:vt,selectionEnd:vt})}}else if(W.key==="Enter"){if(Te===nt){var rs=Zt(fe,Te).pop(),Ka=rs?.match(/^\s+/);if(Ka?.[0]){W.preventDefault();var os=`
|
|
46
46
|
`+Ka[0],vt=Te+os.length;Tn({value:fe.substring(0,Te)+os+fe.substring(nt),selectionStart:vt,selectionEnd:vt})}}}else if(W.keyCode===S||W.keyCode===E||W.keyCode===v||W.keyCode===b){var rn=void 0;W.keyCode===S&&W.shiftKey?rn=["(",")"]:W.keyCode===E?W.shiftKey?rn=["{","}"]:rn=["[","]"]:W.keyCode===v?W.shiftKey?rn=['"','"']:rn=["'","'"]:W.keyCode===b&&!W.shiftKey&&(rn=["`","`"]),Te!==nt&&rn&&(W.preventDefault(),Tn({value:fe.substring(0,Te)+rn[0]+fe.substring(Te,nt)+rn[1]+fe.substring(nt),selectionStart:Te,selectionEnd:nt+2}))}else(U?W.metaKey&&W.keyCode===p:W.ctrlKey&&W.keyCode===p)&&!W.shiftKey&&!W.altKey?(W.preventDefault(),hl()):(U?W.metaKey&&W.keyCode===p&&W.shiftKey:k?W.ctrlKey&&W.keyCode===h:W.ctrlKey&&W.keyCode===p&&W.shiftKey)&&!W.altKey?(W.preventDefault(),ss()):W.keyCode===x&&W.ctrlKey&&(!U||W.shiftKey)&&(W.preventDefault(),ma(function(Gn){return!Gn}))}},Ln=function(W){var Me=W.currentTarget,fe=Me.value,Te=Me.selectionStart,nt=Me.selectionEnd;Hn({value:fe,selectionStart:Te,selectionEnd:nt},!0),F(fe)};return m.useEffect(function(){Ga()},[Ga]),m.useImperativeHandle(L,function(){return{get session(){return{history:Ce.current}},set session(W){Ce.current=W.history}}},[]),m.createElement("div",a({},qn,{style:a(a({},V.container),gt)}),m.createElement("pre",a({className:xe,"aria-hidden":"true",style:a(a(a({},V.editor),V.highlight),Bn)},typeof ot=="string"?{dangerouslySetInnerHTML:{__html:ot+"<br />"}}:{children:ot})),m.createElement("textarea",{ref:function(W){return Vt.current=W},style:a(a(a({},V.editor),V.textarea),Bn),className:M+(tt?" ".concat(tt):""),id:kt,value:Qt,onChange:Ln,onKeyDown:is,onClick:ve,onKeyUp:X,onFocus:Ae,onBlur:ye,disabled:ee,form:de,maxLength:z,minLength:Z,name:ae,placeholder:ne,readOnly:De,required:Ge,autoFocus:J,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),m.createElement("style",{dangerouslySetInnerHTML:{__html:Y}}))}),V={container:{position:"relative",textAlign:"left",boxSizing:"border-box",padding:0,overflow:"hidden"},textarea:{position:"absolute",top:0,left:0,height:"100%",width:"100%",resize:"none",color:"inherit",overflow:"hidden",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased",WebkitTextFillColor:"transparent"},highlight:{position:"relative",pointerEvents:"none"},editor:{margin:0,border:0,background:"none",boxSizing:"inherit",display:"inherit",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontVariantLigatures:"inherit",fontWeight:"inherit",letterSpacing:"inherit",lineHeight:"inherit",tabSize:"inherit",textIndent:"inherit",textRendering:"inherit",textTransform:"inherit",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"break-word"}};return Gt.default=H,Gt}var Xj=Vj();const Zj=bv(Xj),Wj=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function Jj(a){return Wj.some(s=>s.test(a))}function $j(a){if(!a.trim())return{valid:!0};try{return JSON.parse(a),{valid:!0}}catch(s){const u=s.message,d=u.match(/position (\d+)/);if(d){const m=parseInt(d[1],10),h=a.substring(0,m).split(`
|
|
47
|
-
`);return{valid:!1,error:u,line:h.length}}return{valid:!1,error:u}}}function lx({value:a,onChange:s,language:o="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=Tg(),[p,x]=y.useState(!1),[S,E]=y.useState(!0),v=y.useMemo(()=>o==="json"?$j(a):{valid:!0},[a,o]),b=y.useCallback(D=>i.jsx(Yb,{theme:h?mp.nightOwl:mp.github,code:D,language:o,children:({tokens:T,getLineProps:k,getTokenProps:U})=>{let M=!1;return i.jsx(i.Fragment,{children:T.map((Y,H)=>i.jsx("div",{...k({line:Y}),className:K(v.line===H+1&&"bg-destructive/20"),children:Y.map((V,R)=>{let j=!1;if(V.types.includes("property")){const J=V.content.replace(/['"]/g,"");Jj(J)?M=!0:M=!1}else(V.types.includes("string")||V.types.includes("number")||V.types.includes("boolean"))&&M?(j=!0,M=!1):V.types.includes("punctuation")&&V.content!==":"&&V.content!=="["&&V.content!=="{"&&(M=!1);const L=U({token:V});return j&&S&&(L.className=K(L.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...L},R)})},H))})}}),[h,o,v.line,S]);return i.jsxs("div",{className:K("flex flex-col",d),children:[i.jsxs("div",{className:K("relative rounded-md border overflow-hidden","bg-muted/30",p&&"ring-2 ring-ring ring-offset-2 ring-offset-background",u&&"opacity-70 cursor-not-allowed",!v.valid&&"border-destructive"),style:{minHeight:m},children:[i.jsx(Zj,{value:a,onValueChange:u?()=>{}:s,highlight:b,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:K("focus:outline-none font-mono text-sm",u&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:m}},h?"dark-editor":"light-editor"),i.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:i.jsx(dt,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>E(!S),title:S?"Reveal sensitive values":"Mask sensitive values",children:S?i.jsx(Vr,{className:"h-3 w-3"}):i.jsx(Qr,{className:"h-3 w-3"})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[v.valid?i.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[i.jsx(Xr,{className:"w-3 h-3 text-green-500"}),"Valid ",o.toUpperCase()]}):i.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[i.jsx(Vc,{className:"w-3 h-3"}),v.error,v.line&&` (line ${v.line})`]}),u&&i.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const sx=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:lx},Symbol.toStringTag,{value:"Module"})),Fj={webSearchConfig:null,webSearchStatus:null,webSearchLoading:!0,webSearchStatusLoading:!0,webSearchSaving:!1,webSearchError:null,webSearchSuccess:!1,globalEnvConfig:null,globalEnvLoading:!0,globalEnvSaving:!1,globalEnvError:null,globalEnvSuccess:!1,proxyConfig:null,proxyLoading:!0,proxySaving:!1,proxyError:null,proxySuccess:!1,proxyTestResult:null,proxyTesting:!1,rawConfig:null,rawConfigLoading:!1};function Ij(a,s){switch(s.type){case"SET_WEBSEARCH_CONFIG":return{...a,webSearchConfig:s.payload};case"SET_WEBSEARCH_STATUS":return{...a,webSearchStatus:s.payload};case"SET_WEBSEARCH_LOADING":return{...a,webSearchLoading:s.payload};case"SET_WEBSEARCH_STATUS_LOADING":return{...a,webSearchStatusLoading:s.payload};case"SET_WEBSEARCH_SAVING":return{...a,webSearchSaving:s.payload};case"SET_WEBSEARCH_ERROR":return{...a,webSearchError:s.payload};case"SET_WEBSEARCH_SUCCESS":return{...a,webSearchSuccess:s.payload};case"SET_GLOBALENV_CONFIG":return{...a,globalEnvConfig:s.payload};case"SET_GLOBALENV_LOADING":return{...a,globalEnvLoading:s.payload};case"SET_GLOBALENV_SAVING":return{...a,globalEnvSaving:s.payload};case"SET_GLOBALENV_ERROR":return{...a,globalEnvError:s.payload};case"SET_GLOBALENV_SUCCESS":return{...a,globalEnvSuccess:s.payload};case"SET_PROXY_CONFIG":return{...a,proxyConfig:s.payload};case"SET_PROXY_LOADING":return{...a,proxyLoading:s.payload};case"SET_PROXY_SAVING":return{...a,proxySaving:s.payload};case"SET_PROXY_ERROR":return{...a,proxyError:s.payload};case"SET_PROXY_SUCCESS":return{...a,proxySuccess:s.payload};case"SET_PROXY_TEST_RESULT":return{...a,proxyTestResult:s.payload};case"SET_PROXY_TESTING":return{...a,proxyTesting:s.payload};case"SET_RAW_CONFIG":return{...a,rawConfig:s.payload};case"SET_RAW_CONFIG_LOADING":return{...a,rawConfigLoading:s.payload};default:return a}}const ix=y.createContext(null);function Pj({children:a}){const[s,o]=y.useReducer(Ij,Fj);return i.jsx(ix.Provider,{value:{state:s,dispatch:o},children:a})}function rx(){const a=y.useContext(ix);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function e2(){const{dispatch:a}=rx(),s=y.useCallback(j=>a({type:"SET_WEBSEARCH_CONFIG",payload:j}),[a]),o=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS",payload:j}),[a]),u=y.useCallback(j=>a({type:"SET_WEBSEARCH_LOADING",payload:j}),[a]),d=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:j}),[a]),m=y.useCallback(j=>a({type:"SET_WEBSEARCH_SAVING",payload:j}),[a]),h=y.useCallback(j=>a({type:"SET_WEBSEARCH_ERROR",payload:j}),[a]),p=y.useCallback(j=>a({type:"SET_WEBSEARCH_SUCCESS",payload:j}),[a]),x=y.useCallback(j=>a({type:"SET_GLOBALENV_CONFIG",payload:j}),[a]),S=y.useCallback(j=>a({type:"SET_GLOBALENV_LOADING",payload:j}),[a]),E=y.useCallback(j=>a({type:"SET_GLOBALENV_SAVING",payload:j}),[a]),v=y.useCallback(j=>a({type:"SET_GLOBALENV_ERROR",payload:j}),[a]),b=y.useCallback(j=>a({type:"SET_GLOBALENV_SUCCESS",payload:j}),[a]),D=y.useCallback(j=>a({type:"SET_PROXY_CONFIG",payload:j}),[a]),T=y.useCallback(j=>a({type:"SET_PROXY_LOADING",payload:j}),[a]),k=y.useCallback(j=>a({type:"SET_PROXY_SAVING",payload:j}),[a]),U=y.useCallback(j=>a({type:"SET_PROXY_ERROR",payload:j}),[a]),M=y.useCallback(j=>a({type:"SET_PROXY_SUCCESS",payload:j}),[a]),Y=y.useCallback(j=>a({type:"SET_PROXY_TEST_RESULT",payload:j}),[a]),H=y.useCallback(j=>a({type:"SET_PROXY_TESTING",payload:j}),[a]),V=y.useCallback(j=>a({type:"SET_RAW_CONFIG",payload:j}),[a]),R=y.useCallback(j=>a({type:"SET_RAW_CONFIG_LOADING",payload:j}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:o,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:S,setGlobalEnvSaving:E,setGlobalEnvError:v,setGlobalEnvSuccess:b,setProxyConfig:D,setProxyLoading:T,setProxySaving:k,setProxyError:U,setProxySuccess:M,setProxyTestResult:Y,setProxyTesting:H,setRawConfig:V,setRawConfigLoading:R}),[s,o,u,d,m,h,p,x,S,E,v,b,D,T,k,U,M,Y,H,V,R])}function t2(){const[a,s]=Sv(),o=a.get("tab")?.toLowerCase(),u=o==="globalenv"?"globalenv":o==="proxy"?"proxy":o==="auth"?"auth":o==="backups"?"backups":"websearch",d=y.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function n2(){const{state:a}=rx(),s=e2(),[o,u]=y.useState(!1),d=y.useCallback(async()=>{try{s.setRawConfigLoading(!0);const h=await fetch("/api/config/raw");if(!h.ok){s.setRawConfig(null);return}const p=await h.text();s.setRawConfig(p)}catch{s.setRawConfig(null)}finally{s.setRawConfigLoading(!1)}},[s]),m=y.useCallback(async()=>{if(a.rawConfig)try{await navigator.clipboard.writeText(a.rawConfig),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[a.rawConfig]);return{rawConfig:a.rawConfig,loading:a.rawConfigLoading,copied:o,fetchRawConfig:d,copyToClipboard:m}}function a2({activeTab:a,onTabChange:s}){return i.jsx(Fg,{value:a,onValueChange:o=>s(o),children:i.jsxs(od,{className:"w-full",children:[i.jsxs(La,{value:"websearch",className:"flex-1 gap-2",children:[i.jsx(Fv,{className:"w-4 h-4"}),"WebSearch"]}),i.jsxs(La,{value:"globalenv",className:"flex-1 gap-2",children:[i.jsx(Qc,{className:"w-4 h-4"}),"Global Env"]}),i.jsxs(La,{value:"proxy",className:"flex-1 gap-2",children:[i.jsx(Iv,{className:"w-4 h-4"}),"Proxy"]}),i.jsxs(La,{value:"auth",className:"flex-1 gap-2",children:[i.jsx(vg,{className:"w-4 h-4"}),"Auth"]}),i.jsxs(La,{value:"backups",className:"flex-1 gap-2",children:[i.jsx(Pv,{className:"w-4 h-4"}),"Backups"]})]})})}function l2(){return i.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[i.jsx(Le,{className:"h-4 w-2/3"}),i.jsx("div",{className:"p-4 rounded-lg border",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-5 w-32"}),i.jsx(Le,{className:"h-4 w-48"})]}),i.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(Le,{className:"h-5 w-24"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}function ox(a,s=3,o=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,o)).then(()=>ox(a,s-1,o*2))})}function gi(a){return y.lazy(()=>ox(a))}const s2=gi(()=>Dt(()=>import("./index-DIZW46YP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),i2=gi(()=>Dt(()=>import("./globalenv-section-C32LknWn.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),r2=gi(()=>Dt(()=>import("./index-BT0zZuh6.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),o2=gi(()=>Dt(()=>import("./auth-section-cj5RF2YC.js"),__vite__mapDeps([12,1,2,4,5,6,7,8,9]))),u2=gi(()=>Dt(()=>import("./backups-section-BtbLGda5.js"),__vite__mapDeps([13,1,2,14,4,5,6,7,8,9])));class c2 extends y.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}render(){return this.state.hasError?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center p-6 max-w-md",children:[i.jsx(Vc,{className:"w-12 h-12 mx-auto mb-4 text-destructive"}),i.jsx("p",{className:"font-medium text-foreground mb-2",children:"Failed to load section"}),i.jsx("p",{className:"text-sm mb-4",children:this.state.error?.message||"Unknown error occurred"}),i.jsxs(dt,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(Dc,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function d2(){const{activeTab:a,setActiveTab:s}=t2(),{rawConfig:o,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=n2();y.useEffect(()=>{m()},[m]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsx("div",{className:"h-[calc(100vh-100px)]",children:i.jsxs(ld,{direction:"horizontal",className:"h-full",children:[i.jsx(ui,{defaultSize:40,minSize:30,maxSize:55,children:i.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[i.jsx("div",{className:"p-5 border-b bg-background",children:i.jsx(a2,{activeTab:a,onTabChange:p})}),i.jsx(c2,{children:i.jsxs(y.Suspense,{fallback:i.jsx(l2,{}),children:[a==="websearch"&&i.jsx(s2,{}),a==="globalenv"&&i.jsx(i2,{}),a==="proxy"&&i.jsx(r2,{}),a==="auth"&&i.jsx(o2,{}),a==="backups"&&i.jsx(u2,{})]})})]})}),i.jsx(sd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx(Zr,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(ui,{defaultSize:60,minSize:35,children:i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(cp,{className:"w-5 h-5 text-primary"}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-semibold",children:"config.yaml"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(dt,{variant:"outline",size:"sm",onClick:h,disabled:!o,children:d?i.jsxs(i.Fragment,{children:[i.jsx(ls,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Br,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(dt,{variant:"outline",size:"sm",onClick:m,disabled:u,children:i.jsx(Dc,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),i.jsx("div",{className:"flex-1 overflow-auto",children:u?i.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[i.jsx(Dc,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):o?i.jsx(lx,{value:o,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsxs("div",{className:"text-center",children:[i.jsx(cp,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{children:"Config file not found"}),i.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})})}function f2(){return i.jsx(Pj,{children:i.jsx(d2,{})})}const m2=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:f2},Symbol.toStringTag,{value:"Module"})),Xw=hv,Zw=gv,Ww=pv,h2=y.forwardRef(({className:a,align:s="center",sideOffset:o=4,...u},d)=>i.jsx(mv,{children:i.jsx(fg,{ref:d,align:s,sideOffset:o,className:K("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...u})}));h2.displayName=fg.displayName;function p2(a,s,o="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:o}).format(s).split(/\s/g).slice(2).join(" ")}const g2={},ri={};function ul(a,s){try{const u=(g2[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in ri?ri[u]:Lp(u,u.split(":"))}catch{if(a in ri)return ri[a];const o=a?.match(x2);return o?Lp(a,o.slice(1)):NaN}}const x2=/([+-]\d\d):?(\d\d)?/;function Lp(a,s){const o=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return ri[a]=o*60+u>0?o*60+u+d:o*60-u-d}class Rn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(ul(this.timeZone,this))?this.setTime(NaN):s.length?typeof s[0]=="number"&&(s.length===1||s.length===2&&typeof s[1]!="number")?this.setTime(s[0]):typeof s[0]=="string"?this.setTime(+new Date(s[0])):s[0]instanceof Date?this.setTime(+s[0]):(this.setTime(+new Date(...s)),ux(this),Bc(this)):this.setTime(Date.now())}static tz(s,...o){return o.length?new Rn(...o,s):new Rn(Date.now(),s)}withTimeZone(s){return new Rn(+this,s)}getTimezoneOffset(){const s=-ul(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Bc(this),+this}[Symbol.for("constructDateFrom")](s){return new Rn(+new Date(s),this.timeZone)}}const Yp=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!Yp.test(a))return;const s=a.replace(Yp,"$1UTC");Rn.prototype[s]&&(a.startsWith("get")?Rn.prototype[a]=function(){return this.internal[s]()}:(Rn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),y2(this),+this},Rn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Bc(this),+this}))});function Bc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-ul(a.timeZone,a)*60))}function y2(a){Date.prototype.setFullYear.call(a,a.internal.getUTCFullYear(),a.internal.getUTCMonth(),a.internal.getUTCDate()),Date.prototype.setHours.call(a,a.internal.getUTCHours(),a.internal.getUTCMinutes(),a.internal.getUTCSeconds(),a.internal.getUTCMilliseconds()),ux(a)}function ux(a){const s=ul(a.timeZone,a),o=s>0?Math.floor(s):Math.ceil(s),u=new Date(+a);u.setUTCHours(u.getUTCHours()-1);const d=-new Date(+a).getTimezoneOffset(),m=-new Date(+u).getTimezoneOffset(),h=d-m,p=Date.prototype.getHours.apply(a)!==a.internal.getUTCHours();h&&p&&a.internal.setUTCMinutes(a.internal.getUTCMinutes()+h);const x=d-o;x&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+x);const S=new Date(+a);S.setUTCSeconds(0);const E=d>0?S.getSeconds():(S.getSeconds()-60)%60,v=Math.round(-(ul(a.timeZone,a)*60))%60;(v||E)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+E));const b=ul(a.timeZone,a),D=b>0?Math.floor(b):Math.ceil(b),k=-new Date(+a).getTimezoneOffset()-D,U=D!==o,M=k-x;if(U&&M){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+M);const Y=ul(a.timeZone,a),H=Y>0?Math.floor(Y):Math.ceil(Y),V=D-H;V&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+V),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+V))}}class ua extends Rn{static tz(s,...o){return o.length?new ua(...o,s):new ua(Date.now(),s)}toISOString(){const[s,o,u]=this.tzComponents(),d=`${s}${o}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,o,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${o} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[o,u,d]=this.tzComponents();return`${s} GMT${o}${u}${d} (${p2(this.timeZone,this)})`}toLocaleString(s,o){return Date.prototype.toLocaleString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleDateString(s,o){return Date.prototype.toLocaleDateString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleTimeString(s,o){return Date.prototype.toLocaleTimeString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),o=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[o,u,d]}withTimeZone(s){return new ua(+this,s)}[Symbol.for("constructDateFrom")](s){return new ua(+new Date(s),this.timeZone)}}const Gp=5,v2=4;function b2(a,s){const o=s.startOfMonth(a),u=o.getDay()>0?o.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,Gp*7-1);return s.getMonth(a)===s.getMonth(m)?Gp:v2}function cx(a,s){const o=s.startOfMonth(a),u=o.getDay();return u===1?o:u===0?s.addDays(o,-6):s.addDays(o,-1*(u-1))}function S2(a,s){const o=cx(a,s),u=b2(a,s);return s.addDays(o,u*7-1)}const dx={...ei,labels:{labelDayButton:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ai(h,p,{locale:ei,...o});let m=d(a,"PPPP");return s.today&&(m=`Today, ${m}`),s.selected&&(m=`${m}, selected`),m},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:a=>`Week ${a}`,labelYearDropdown:"Choose the Year",labelGrid:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ai(d,m,{locale:ei,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ai(h,p,{locale:ei,...o});let m=d(a,"PPPP");return s?.today&&(m=`Today, ${m}`),m},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ai(d,m,{locale:ei,...s}),u(a,"cccc")}}};class sn{constructor(s,o){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ua.tz(this.options.timeZone):new this.Date,this.newDate=(u,d,m)=>this.overrides?.newDate?this.overrides.newDate(u,d,m):this.options.timeZone?new ua(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):lb(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):sb(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):ib(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):rb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):ob(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):ub(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):cb(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):db(u),m=new Set(d.map(p=>this.getYear(p)));if(m.size===d.length)return d;const h=[];return m.forEach(p=>{h.push(new Date(p,0,1))}),h},this.endOfBroadcastWeek=u=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(u):S2(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):fb(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):mb(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):hb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):pb(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ai(u,d,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(h):h},this.getISOWeek=u=>this.overrides?.getISOWeek?this.overrides.getISOWeek(u):gb(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):xb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):yb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):vb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):bb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):Sb(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Nb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):jb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Cb(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):wb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Eb(u),this.min=u=>this.overrides?.min?this.overrides.min(u):Mb(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Tb(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):zb(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):cx(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Ob(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Ab(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Db(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):_b(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):kb(u),this.options={locale:dx,...s},this.overrides=o}getDigitMap(){const{numerals:s="latn"}=this.options,o=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=o.format(d);return u}replaceDigits(s){const o=this.getDigitMap();return s.replace(/\d/g,u=>o[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&sn.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:o,timeZone:u,numerals:d}=this.options,m=o?.code;if(m&&sn.yearFirstLocales.has(m))try{return new Intl.DateTimeFormat(m,{month:"long",year:"numeric",timeZone:u,numberingSystem:d}).format(s)}catch{}const h=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(s,h)}}sn.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Un=new sn;class fx{constructor(s,o,u=Un){this.date=s,this.displayMonth=o,this.outside=!!(o&&!u.isSameMonth(s,o)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(o,"yyyy-MM"),this.dateMonthId=u.format(s,"yyyy-MM")}isEqualTo(s){return this.dateLib.isSameDay(s.date,this.date)&&this.dateLib.isSameMonth(s.displayMonth,this.displayMonth)}}class N2{constructor(s,o){this.date=s,this.weeks=o}}class j2{constructor(s,o){this.days=o,this.weekNumber=s}}function C2(a){return P.createElement("button",{...a})}function w2(a){return P.createElement("span",{...a})}function E2(a){const{size:s=24,orientation:o="left",className:u}=a;return P.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},o==="up"&&P.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),o==="down"&&P.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),o==="left"&&P.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),o==="right"&&P.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function M2(a){const{day:s,modifiers:o,...u}=a;return P.createElement("td",{...u})}function T2(a){const{day:s,modifiers:o,...u}=a,d=P.useRef(null);return P.useEffect(()=>{o.focused&&d.current?.focus()},[o.focused]),P.createElement("button",{ref:d,...u})}var oe;(function(a){a.Root="root",a.Chevron="chevron",a.Day="day",a.DayButton="day_button",a.CaptionLabel="caption_label",a.Dropdowns="dropdowns",a.Dropdown="dropdown",a.DropdownRoot="dropdown_root",a.Footer="footer",a.MonthGrid="month_grid",a.MonthCaption="month_caption",a.MonthsDropdown="months_dropdown",a.Month="month",a.Months="months",a.Nav="nav",a.NextMonthButton="button_next",a.PreviousMonthButton="button_previous",a.Week="week",a.Weeks="weeks",a.Weekday="weekday",a.Weekdays="weekdays",a.WeekNumber="week_number",a.WeekNumberHeader="week_number_header",a.YearsDropdown="years_dropdown"})(oe||(oe={}));var lt;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(lt||(lt={}));var Cn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(Cn||(Cn={}));var ln;(function(a){a.weeks_before_enter="weeks_before_enter",a.weeks_before_exit="weeks_before_exit",a.weeks_after_enter="weeks_after_enter",a.weeks_after_exit="weeks_after_exit",a.caption_after_enter="caption_after_enter",a.caption_after_exit="caption_after_exit",a.caption_before_enter="caption_before_enter",a.caption_before_exit="caption_before_exit"})(ln||(ln={}));function z2(a){const{options:s,className:o,components:u,classNames:d,...m}=a,h=[d[oe.Dropdown],o].join(" "),p=s?.find(({value:x})=>x===m.value);return P.createElement("span",{"data-disabled":m.disabled,className:d[oe.DropdownRoot]},P.createElement(u.Select,{className:h,...m},s?.map(({value:x,label:S,disabled:E})=>P.createElement(u.Option,{key:x,value:x,disabled:E},S))),P.createElement("span",{className:d[oe.CaptionLabel],"aria-hidden":!0},p?.label,P.createElement(u.Chevron,{orientation:"down",size:18,className:d[oe.Chevron]})))}function O2(a){return P.createElement("div",{...a})}function A2(a){return P.createElement("div",{...a})}function D2(a){const{calendarMonth:s,displayIndex:o,...u}=a;return P.createElement("div",{...u},a.children)}function _2(a){const{calendarMonth:s,displayIndex:o,...u}=a;return P.createElement("div",{...u})}function k2(a){return P.createElement("table",{...a})}function R2(a){return P.createElement("div",{...a})}const mx=y.createContext(void 0);function xi(){const a=y.useContext(mx);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function U2(a){const{components:s}=xi();return P.createElement(s.Dropdown,{...a})}function q2(a){const{onPreviousClick:s,onNextClick:o,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:x,labelNext:S}}=xi(),E=y.useCallback(b=>{d&&o?.(b)},[d,o]),v=y.useCallback(b=>{u&&s?.(b)},[u,s]);return P.createElement("nav",{...m},P.createElement(h.PreviousMonthButton,{type:"button",className:p[oe.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},P.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[oe.Chevron],orientation:"left"})),P.createElement(h.NextMonthButton,{type:"button",className:p[oe.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":S(d),onClick:E},P.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[oe.Chevron]})))}function B2(a){const{components:s}=xi();return P.createElement(s.Button,{...a})}function H2(a){return P.createElement("option",{...a})}function L2(a){const{components:s}=xi();return P.createElement(s.Button,{...a})}function Y2(a){const{rootRef:s,...o}=a;return P.createElement("div",{...o,ref:s})}function G2(a){return P.createElement("select",{...a})}function K2(a){const{week:s,...o}=a;return P.createElement("tr",{...o})}function Q2(a){return P.createElement("th",{...a})}function V2(a){return P.createElement("thead",{"aria-hidden":!0},P.createElement("tr",{...a}))}function X2(a){const{week:s,...o}=a;return P.createElement("th",{...o})}function Z2(a){return P.createElement("th",{...a})}function W2(a){return P.createElement("tbody",{...a})}function J2(a){const{components:s}=xi();return P.createElement(s.Dropdown,{...a})}const $2=Object.freeze(Object.defineProperty({__proto__:null,Button:C2,CaptionLabel:w2,Chevron:E2,Day:M2,DayButton:T2,Dropdown:z2,DropdownNav:O2,Footer:A2,Month:D2,MonthCaption:_2,MonthGrid:k2,Months:R2,MonthsDropdown:U2,Nav:q2,NextMonthButton:B2,Option:H2,PreviousMonthButton:L2,Root:Y2,Select:G2,Week:K2,WeekNumber:X2,WeekNumberHeader:Z2,Weekday:Q2,Weekdays:V2,Weeks:W2,YearsDropdown:J2},Symbol.toStringTag,{value:"Module"}));function ca(a,s,o=!1,u=Un){let{from:d,to:m}=a;const{differenceInCalendarDays:h,isSameDay:p}=u;return d&&m?(h(m,d)<0&&([d,m]=[m,d]),h(s,d)>=(o?1:0)&&h(m,s)>=(o?1:0)):!o&&m?p(m,s):!o&&d?p(d,s):!1}function cd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function lo(a){return!!(a&&typeof a=="object"&&"from"in a)}function dd(a){return!!(a&&typeof a=="object"&&"after"in a)}function fd(a){return!!(a&&typeof a=="object"&&"before"in a)}function hx(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function px(a,s){return Array.isArray(a)&&a.every(s.isDate)}function da(a,s,o=Un){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:m,isAfter:h}=o;return u.some(p=>{if(typeof p=="boolean")return p;if(o.isDate(p))return d(a,p);if(px(p,o))return p.some(x=>d(a,x));if(lo(p))return ca(p,a,!1,o);if(hx(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(cd(p)){const x=m(p.before,a),S=m(p.after,a),E=x>0,v=S<0;return h(p.before,p.after)?v&&E:E||v}return dd(p)?m(a,p.after)>0:fd(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function F2(a,s,o,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:x,broadcastCalendar:S,today:E=d.today()}=s,{isSameDay:v,isSameMonth:b,startOfMonth:D,isBefore:T,endOfMonth:k,isAfter:U}=d,M=o&&D(o),Y=u&&k(u),H={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},V={};for(const R of a){const{date:j,displayMonth:L}=R,J=!!(L&&!b(j,L)),ee=!!(M&&T(j,M)),de=!!(Y&&U(j,Y)),Se=!!(m&&da(j,m,d)),re=!!(h&&da(j,h,d))||ee||de||!S&&!x&&J||S&&x===!1&&J,Ye=v(j,E);J&&H.outside.push(R),Se&&H.disabled.push(R),re&&H.hidden.push(R),Ye&&H.today.push(R),p&&Object.keys(p).forEach(je=>{const $=p?.[je];$&&da(j,$,d)&&(V[je]?V[je].push(R):V[je]=[R])})}return R=>{const j={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},L={};for(const J in H){const ee=H[J];j[J]=ee.some(de=>de===R)}for(const J in V)L[J]=V[J].some(ee=>ee===R);return{...j,...L}}}function I2(a,s,o={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[m])=>(o[m]?d.push(o[m]):s[lt[m]]?d.push(s[lt[m]]):s[Cn[m]]&&d.push(s[Cn[m]]),d),[s[oe.Day]])}function P2(a){return{...$2,...a}}function eC(a){const s={"data-mode":a.mode??void 0,"data-required":"required"in a?a.required:void 0,"data-multiple-months":a.numberOfMonths&&a.numberOfMonths>1||void 0,"data-week-numbers":a.showWeekNumber||void 0,"data-broadcast-calendar":a.broadcastCalendar||void 0,"data-nav-layout":a.navLayout||void 0};return Object.entries(a).forEach(([o,u])=>{o.startsWith("data-")&&(s[o]=u)}),s}function tC(){const a={};for(const s in oe)a[oe[s]]=`rdp-${oe[s]}`;for(const s in lt)a[lt[s]]=`rdp-${lt[s]}`;for(const s in Cn)a[Cn[s]]=`rdp-${Cn[s]}`;for(const s in ln)a[ln[s]]=`rdp-${ln[s]}`;return a}function gx(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const nC=gx;function aC(a,s,o){return(o??new sn(s)).format(a,"d")}function lC(a,s=Un){return s.format(a,"LLLL")}function sC(a,s,o){return(o??new sn(s)).format(a,"cccccc")}function iC(a,s=Un){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function rC(){return""}function xx(a,s=Un){return s.format(a,"yyyy")}const oC=xx,uC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:gx,formatDay:aC,formatMonthCaption:nC,formatMonthDropdown:lC,formatWeekNumber:iC,formatWeekNumberHeader:rC,formatWeekdayName:sC,formatYearCaption:oC,formatYearDropdown:xx},Symbol.toStringTag,{value:"Module"}));function cC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...uC,...a}}function md(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const dC=md;function hd(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const fC=hd;function yx(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function vx(a){return"Choose the Month"}function bx(){return""}const mC="Go to the Next Month";function Sx(a,s){return mC}function Nx(a){return"Go to the Previous Month"}function jx(a,s,o){return(o??new sn(s)).format(a,"cccc")}function Cx(a,s){return`Week ${a}`}function wx(a){return"Week Number"}function Ex(a){return"Choose the Year"}const hC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:fC,labelDay:dC,labelDayButton:md,labelGrid:hd,labelGridcell:yx,labelMonthDropdown:vx,labelNav:bx,labelNext:Sx,labelPrevious:Nx,labelWeekNumber:Cx,labelWeekNumberHeader:wx,labelWeekday:jx,labelYearDropdown:Ex},Symbol.toStringTag,{value:"Module"})),jn=(a,s,o)=>s||(o?typeof o=="function"?o:(...u)=>o:a);function pC(a,s){const o=s.locale?.labels??{};return{...hC,...a??{},labelDayButton:jn(md,a?.labelDayButton,o.labelDayButton),labelMonthDropdown:jn(vx,a?.labelMonthDropdown,o.labelMonthDropdown),labelNext:jn(Sx,a?.labelNext,o.labelNext),labelPrevious:jn(Nx,a?.labelPrevious,o.labelPrevious),labelWeekNumber:jn(Cx,a?.labelWeekNumber,o.labelWeekNumber),labelYearDropdown:jn(Ex,a?.labelYearDropdown,o.labelYearDropdown),labelGrid:jn(hd,a?.labelGrid,o.labelGrid),labelGridcell:jn(yx,a?.labelGridcell,o.labelGridcell),labelNav:jn(bx,a?.labelNav,o.labelNav),labelWeekNumberHeader:jn(wx,a?.labelWeekNumberHeader,o.labelWeekNumberHeader),labelWeekday:jn(jx,a?.labelWeekday,o.labelWeekday)}}function gC(a,s,o,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:x,getMonth:S}=d;return x({start:h(a),end:p(a)}).map(b=>{const D=u.formatMonthDropdown(b,d),T=S(b),k=s&&b<m(s)||o&&b>m(o)||!1;return{value:T,label:D,disabled:k}})}function xC(a,s={},o={}){let u={...s?.[oe.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...o?.[d]}}),u}function yC(a,s,o,u){const d=u??a.today(),m=o?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),h=[];for(let p=0;p<7;p++){const x=a.addDays(m,p);h.push(x)}return h}function vC(a,s,o,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:x}=u,S=m(a),E=h(s),v=p({start:S,end:E});return d&&v.reverse(),v.map(b=>{const D=o.formatYearDropdown(b,u);return{value:x(b),label:D,disabled:!1}})}const yi=a=>a instanceof HTMLElement?a:null,Ec=a=>[...a.querySelectorAll("[data-animated-month]")??[]],bC=a=>yi(a.querySelector("[data-animated-month]")),Mc=a=>yi(a.querySelector("[data-animated-caption]")),Tc=a=>yi(a.querySelector("[data-animated-weeks]")),SC=a=>yi(a.querySelector("[data-animated-nav]")),NC=a=>yi(a.querySelector("[data-animated-weekdays]"));function jC(a,s,{classNames:o,months:u,focused:d,dateLib:m}){const h=y.useRef(null),p=y.useRef(u),x=y.useRef(!1);y.useLayoutEffect(()=>{const S=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||S.length===0||u.length!==S.length)return;const E=m.isSameMonth(u[0].date,S[0].date),v=m.isAfter(u[0].date,S[0].date),b=v?o[ln.caption_after_enter]:o[ln.caption_before_enter],D=v?o[ln.weeks_after_enter]:o[ln.weeks_before_enter],T=h.current,k=a.current.cloneNode(!0);if(k instanceof HTMLElement?(Ec(k).forEach(H=>{if(!(H instanceof HTMLElement))return;const V=bC(H);V&&H.contains(V)&&H.removeChild(V);const R=Mc(H);R&&R.classList.remove(b);const j=Tc(H);j&&j.classList.remove(D)}),h.current=k):h.current=null,x.current||E||d)return;const U=T instanceof HTMLElement?Ec(T):[],M=Ec(a.current);if(M?.every(Y=>Y instanceof HTMLElement)&&U&&U.every(Y=>Y instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const Y=SC(a.current);Y&&(Y.style.zIndex="1"),M.forEach((H,V)=>{const R=U[V];if(!R)return;H.style.position="relative",H.style.overflow="hidden";const j=Mc(H);j&&j.classList.add(b);const L=Tc(H);L&&L.classList.add(D);const J=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),Y&&(Y.style.zIndex=""),j&&j.classList.remove(b),L&&L.classList.remove(D),H.style.position="",H.style.overflow="",H.contains(R)&&H.removeChild(R)};R.style.pointerEvents="none",R.style.position="absolute",R.style.overflow="hidden",R.setAttribute("aria-hidden","true");const ee=NC(R);ee&&(ee.style.opacity="0");const de=Mc(R);de&&(de.classList.add(v?o[ln.caption_before_exit]:o[ln.caption_after_exit]),de.addEventListener("animationend",J));const Se=Tc(R);Se&&Se.classList.add(v?o[ln.weeks_before_exit]:o[ln.weeks_after_exit]),H.insertBefore(R,H.firstChild)})}})}function CC(a,s,o,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:x}=o??{},{addDays:S,differenceInCalendarDays:E,differenceInCalendarMonths:v,endOfBroadcastWeek:b,endOfISOWeek:D,endOfMonth:T,endOfWeek:k,isAfter:U,startOfBroadcastWeek:M,startOfISOWeek:Y,startOfWeek:H}=u,V=x?M(d,u):h?Y(d):H(d),R=x?b(m):h?D(T(m)):k(T(m)),j=s&&(x?b(s):h?D(s):k(s)),L=j&&U(R,j)?j:R,J=E(L,V),ee=v(m,d)+1,de=[];for(let Ye=0;Ye<=J;Ye++){const je=S(V,Ye);de.push(je)}const re=(x?35:42)*ee;if(p&&de.length<re){const Ye=re-de.length;for(let je=0;je<Ye;je++){const $=S(de[de.length-1],1);de.push($)}}return de}function wC(a){const s=[];return a.reduce((o,u)=>{const d=u.weeks.reduce((m,h)=>m.concat(h.days.slice()),s.slice());return o.concat(d.slice())},s.slice())}function EC(a,s,o,u){const{numberOfMonths:d=1}=o,m=[];for(let h=0;h<d;h++){const p=u.addMonths(a,h);if(s&&p>s)break;m.push(p)}return m}function Kp(a,s,o,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let x=d||m||h;const{differenceInCalendarMonths:S,addMonths:E,startOfMonth:v}=u;if(o&&S(o,x)<p-1){const b=-1*(p-1);x=E(o,b)}return s&&S(x,s)<0&&(x=s),v(x)}function MC(a,s,o,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:x,getISOWeek:S,getWeek:E,startOfBroadcastWeek:v,startOfISOWeek:b,startOfWeek:D}=u,T=a.reduce((k,U)=>{const M=o.broadcastCalendar?v(U,u):o.ISOWeek?b(U):D(U),Y=o.broadcastCalendar?m(U):o.ISOWeek?h(p(U)):x(p(U)),H=s.filter(L=>L>=M&&L<=Y),V=o.broadcastCalendar?35:42;if(o.fixedWeeks&&H.length<V){const L=s.filter(J=>{const ee=V-H.length;return J>Y&&J<=d(Y,ee)});H.push(...L)}const R=H.reduce((L,J)=>{const ee=o.ISOWeek?S(J):E(J),de=L.find(re=>re.weekNumber===ee),Se=new fx(J,U,u);return de?de.days.push(Se):L.push(new j2(ee,[Se])),L},[]),j=new N2(U,R);return k.push(j),k},[]);return o.reverseMonths?T.reverse():T}function TC(a,s){let{startMonth:o,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:x,endOfYear:S,newDate:E,today:v}=s,{fromYear:b,toYear:D,fromMonth:T,toMonth:k}=a;!o&&T&&(o=T),!o&&b&&(o=s.newDate(b,0,1)),!u&&k&&(u=k),!u&&D&&(u=E(D,11,31));const U=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return o?o=h(o):b?o=E(b,0,1):!o&&U&&(o=d(x(a.today??v(),-100))),u?u=p(u):D?u=E(D,11,31):!u&&U&&(u=S(a.today??v())),[o&&m(o),u&&m(u)]}function zC(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,S=d?m:1,E=h(a);if(!s)return p(E,S);if(!(x(s,a)<m))return p(E,S)}function OC(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,S=d?m??1:1,E=h(a);if(!s)return p(E,-S);if(!(x(E,s)<=0))return p(E,-S)}function AC(a){const s=[];return a.reduce((o,u)=>o.concat(u.weeks.slice()),s.slice())}function so(a,s){const[o,u]=y.useState(a);return[s===void 0?o:s,u]}function DC(a,s){const[o,u]=TC(a,s),{startOfMonth:d,endOfMonth:m}=s,h=Kp(a,o,u,s),[p,x]=so(h,a.month?h:void 0);y.useEffect(()=>{const V=Kp(a,o,u,s);x(V)},[a.timeZone]);const{months:S,weeks:E,days:v,previousMonth:b,nextMonth:D}=y.useMemo(()=>{const V=EC(p,u,{numberOfMonths:a.numberOfMonths},s),R=CC(V,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),j=MC(V,R,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),L=AC(j),J=wC(j),ee=OC(p,o,a,s),de=zC(p,u,a,s);return{months:j,weeks:L,days:J,previousMonth:ee,nextMonth:de}},[s,p.getTime(),u?.getTime(),o?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:T,onMonthChange:k}=a,U=V=>E.some(R=>R.days.some(j=>j.isEqualTo(V))),M=V=>{if(T)return;let R=d(V);o&&R<d(o)&&(R=d(o)),u&&R>d(u)&&(R=d(u)),x(R),k?.(R)};return{months:S,weeks:E,days:v,navStart:o,navEnd:u,previousMonth:b,nextMonth:D,goToMonth:M,goToDay:V=>{U(V)||M(V.date)}}}var kn;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(kn||(kn={}));function Qp(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function _C(a,s,o,u){let d,m=-1;for(const h of a){const p=s(h);Qp(p)&&(p[lt.focused]&&m<kn.FocusedModifier?(d=h,m=kn.FocusedModifier):u?.isEqualTo(h)&&m<kn.LastFocused?(d=h,m=kn.LastFocused):o(h.date)&&m<kn.Selected?(d=h,m=kn.Selected):p[lt.today]&&m<kn.Today&&(d=h,m=kn.Today))}return d||(d=a.find(h=>Qp(s(h)))),d}function kC(a,s,o,u,d,m,h){const{ISOWeek:p,broadcastCalendar:x}=m,{addDays:S,addMonths:E,addWeeks:v,addYears:b,endOfBroadcastWeek:D,endOfISOWeek:T,endOfWeek:k,max:U,min:M,startOfBroadcastWeek:Y,startOfISOWeek:H,startOfWeek:V}=h;let j={day:S,week:v,month:E,year:b,startOfWeek:L=>x?Y(L,h):p?H(L):V(L),endOfWeek:L=>x?D(L):p?T(L):k(L)}[a](o,s==="after"?1:-1);return s==="before"&&u?j=U([u,j]):s==="after"&&d&&(j=M([d,j])),j}function Mx(a,s,o,u,d,m,h,p=0){if(p>365)return;const x=kC(a,s,o.date,u,d,m,h),S=!!(m.disabled&&da(x,m.disabled,h)),E=!!(m.hidden&&da(x,m.hidden,h)),v=x,b=new fx(x,v,h);return!S&&!E?b:Mx(a,s,b,u,d,m,h,p+1)}function RC(a,s,o,u,d){const{autoFocus:m}=a,[h,p]=y.useState(),x=_C(s.days,o,u||(()=>!1),h),[S,E]=y.useState(m?x:void 0);return{isFocusTarget:k=>!!x?.isEqualTo(k),setFocused:E,focused:S,blur:()=>{p(S),E(void 0)},moveFocus:(k,U)=>{if(!S)return;const M=Mx(k,U,S,s.navStart,s.navEnd,a,d);M&&(a.disableNavigation&&!s.days.some(H=>H.isEqualTo(M))||(s.goToDay(M),E(M)))}}}function UC(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=so(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s,S=D=>p?.some(T=>x(T,D))??!1,{min:E,max:v}=a;return{selected:p,select:(D,T,k)=>{let U=[...p??[]];if(S(D)){if(p?.length===E||u&&p?.length===1)return;U=p?.filter(M=>!x(M,D))}else p?.length===v?U=[D]:U=[...U,D];return d||h(U),d?.(U,D,T,k),U},isSelected:S}}function qC(a,s,o=0,u=0,d=!1,m=Un){const{from:h,to:p}=s||{},{isSameDay:x,isAfter:S,isBefore:E}=m;let v;if(!h&&!p)v={from:a,to:o>0?void 0:a};else if(h&&!p)x(h,a)?o===0?v={from:h,to:a}:d?v={from:h,to:void 0}:v=void 0:E(a,h)?v={from:a,to:h}:v={from:h,to:a};else if(h&&p)if(x(h,a)&&x(p,a))d?v={from:h,to:p}:v=void 0;else if(x(h,a))v={from:h,to:o>0?void 0:a};else if(x(p,a))v={from:a,to:o>0?void 0:a};else if(E(a,h))v={from:a,to:p};else if(S(a,h))v={from:h,to:a};else if(S(a,p))v={from:h,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const b=m.differenceInCalendarDays(v.to,v.from);u>0&&b>u?v={from:a,to:void 0}:o>1&&b<o&&(v={from:a,to:void 0})}return v}function BC(a,s,o=Un){const u=Array.isArray(s)?s:[s];let d=a.from;const m=o.differenceInCalendarDays(a.to,a.from),h=Math.min(m,6);for(let p=0;p<=h;p++){if(u.includes(d.getDay()))return!0;d=o.addDays(d,1)}return!1}function Vp(a,s,o=Un){return ca(a,s.from,!1,o)||ca(a,s.to,!1,o)||ca(s,a.from,!1,o)||ca(s,a.to,!1,o)}function HC(a,s,o=Un){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:o.isDate(p)?ca(a,p,!1,o):px(p,o)?p.some(x=>ca(a,x,!1,o)):lo(p)?p.from&&p.to?Vp(a,{from:p.from,to:p.to},o):!1:hx(p)?BC(a,p.dayOfWeek,o):cd(p)?o.isAfter(p.before,p.after)?Vp(a,{from:o.addDays(p.after,1),to:o.addDays(p.before,-1)},o):da(a.from,p,o)||da(a.to,p,o):dd(p)||fd(p)?da(a.from,p,o)||da(a.to,p,o):!1))return!0;const h=u.filter(p=>typeof p=="function");if(h.length){let p=a.from;const x=o.differenceInCalendarDays(a.to,a.from);for(let S=0;S<=x;S++){if(h.some(E=>E(p)))return!0;p=o.addDays(p,1)}}return!1}function LC(a,s){const{disabled:o,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,x]=so(d,h?d:void 0),S=h?d:p;return{selected:S,select:(b,D,T)=>{const{min:k,max:U}=a,M=b?qC(b,S,k,U,m,s):void 0;return u&&o&&M?.from&&M.to&&HC({from:M.from,to:M.to},o,s)&&(M.from=b,M.to=void 0),h||x(M),h?.(M,b,D,T),M},isSelected:b=>S&&ca(S,b,!1,s)}}function YC(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=so(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s;return{selected:p,select:(v,b,D)=>{let T=v;return!u&&p&&p&&x(v,p)&&(T=void 0),d||h(T),d?.(T,v,b,D),T},isSelected:v=>p?x(p,v):!1}}function GC(a,s){const o=YC(a,s),u=UC(a,s),d=LC(a,s);switch(a.mode){case"single":return o;case"multiple":return u;case"range":return d;default:return}}function Tt(a,s){return a instanceof ua&&a.timeZone===s?a:new ua(a,s)}function Xp(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Tt(a,s):Array.isArray(a)?a.map(o=>o instanceof Date?Tt(o,s):o):lo(a)?{...a,from:a.from?Tt(a.from,s):a.from,to:a.to?Tt(a.to,s):a.to}:cd(a)?{before:Tt(a.before,s),after:Tt(a.after,s)}:dd(a)?{after:Tt(a.after,s)}:fd(a)?{before:Tt(a.before,s)}:a}function zc(a,s){return a&&(Array.isArray(a)?a.map(o=>Xp(o,s)):Xp(a,s))}function KC(a){let s=a;const o=s.timeZone;if(o&&(s={...a,timeZone:o},s.today&&(s.today=Tt(s.today,o)),s.month&&(s.month=Tt(s.month,o)),s.defaultMonth&&(s.defaultMonth=Tt(s.defaultMonth,o)),s.startMonth&&(s.startMonth=Tt(s.startMonth,o)),s.endMonth&&(s.endMonth=Tt(s.endMonth,o)),s.mode==="single"&&s.selected?s.selected=Tt(s.selected,o):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(ie=>Tt(ie,o)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Tt(s.selected.from,o):s.selected.from,to:s.selected.to?Tt(s.selected.to,o):s.selected.to}),s.disabled!==void 0&&(s.disabled=zc(s.disabled,o)),s.hidden!==void 0&&(s.hidden=zc(s.hidden,o)),s.modifiers)){const ie={};Object.keys(s.modifiers).forEach(Ne=>{ie[Ne]=zc(s.modifiers?.[Ne],o)}),s.modifiers=ie}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:x}=y.useMemo(()=>{const ie={...dx,...s.locale},Ne=new sn({locale:ie,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:Ne,components:P2(s.components),formatters:cC(s.formatters),labels:pC(s.labels,Ne.options),locale:ie,classNames:{...tC(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:h.today()});const{captionLayout:S,mode:E,navLayout:v,numberOfMonths:b=1,onDayBlur:D,onDayClick:T,onDayFocus:k,onDayKeyDown:U,onDayMouseEnter:M,onDayMouseLeave:Y,onNextClick:H,onPrevClick:V,showWeekNumber:R,styles:j}=s,{formatCaption:L,formatDay:J,formatMonthDropdown:ee,formatWeekNumber:de,formatWeekNumberHeader:Se,formatWeekdayName:re,formatYearDropdown:Ye}=d,je=DC(s,h),{days:$,months:z,navStart:Z,navEnd:ae,previousMonth:ye,nextMonth:ve,goToMonth:Ae}=je,ce=F2($,s,Z,ae,h),{isSelected:X,select:F,selected:le}=GC(s,h)??{},{blur:I,focused:ne,isFocusTarget:xe,moveFocus:De,setFocused:Ge}=RC(s,je,ce,X??(()=>!1),h),{labelDayButton:gt,labelGridcell:xt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Qt,labelNext:qn,labelWeekday:Ce,labelWeekNumber:Vt,labelWeekNumberHeader:En,labelYearDropdown:Xt}=m,ma=y.useMemo(()=>yC(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Bn=E!==void 0||T!==void 0,ot=y.useCallback(()=>{ye&&(Ae(ye),V?.(ye))},[ye,Ae,V]),Zt=y.useCallback(()=>{ve&&(Ae(ve),H?.(ve))},[Ae,ve,H]),Hn=y.useCallback((ie,Ne)=>me=>{me.preventDefault(),me.stopPropagation(),Ge(ie),!Ne.disabled&&(F?.(ie.date,Ne,me),T?.(ie.date,Ne,me))},[F,T,Ge]),Ga=y.useCallback((ie,Ne)=>me=>{Ge(ie),k?.(ie.date,Ne,me)},[k,Ge]),Mn=y.useCallback((ie,Ne)=>me=>{I(),D?.(ie.date,Ne,me)},[I,D]),Tn=y.useCallback((ie,Ne)=>me=>{const ze={ArrowLeft:[me.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[me.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[me.shiftKey?"year":"week","after"],ArrowUp:[me.shiftKey?"year":"week","before"],PageUp:[me.shiftKey?"year":"month","before"],PageDown:[me.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ze[me.key]){me.preventDefault(),me.stopPropagation();const[Fe,ge]=ze[me.key];De(Fe,ge)}U?.(ie.date,Ne,me)},[De,U,s.dir]),hl=y.useCallback((ie,Ne)=>me=>{M?.(ie.date,Ne,me)},[M]),ss=y.useCallback((ie,Ne)=>me=>{Y?.(ie.date,Ne,me)},[Y]),is=y.useCallback(ie=>Ne=>{const me=Number(Ne.target.value),ze=h.setMonth(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),Ln=y.useCallback(ie=>Ne=>{const me=Number(Ne.target.value),ze=h.setYear(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),{className:W,style:Me}=y.useMemo(()=>({className:[x[oe.Root],s.className].filter(Boolean).join(" "),style:{...j?.[oe.Root],...s.style}}),[x,s.className,s.style,j]),fe=eC(s),Te=y.useRef(null);jC(Te,!!s.animate,{classNames:x,months:z,focused:ne,dateLib:h});const nt={dayPickerProps:s,selected:le,select:F,isSelected:X,months:z,nextMonth:ve,previousMonth:ye,goToMonth:Ae,getModifiers:ce,components:u,classNames:x,styles:j,labels:m,formatters:d};return P.createElement(mx.Provider,{value:nt},P.createElement(u.Root,{rootRef:s.animate?Te:void 0,className:W,style:Me,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...fe},P.createElement(u.Months,{className:x[oe.Months],style:j?.[oe.Months]},!s.hideNavigation&&!v&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[oe.Nav],style:j?.[oe.Nav],"aria-label":kt(),onPreviousClick:ot,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),z.map((ie,Ne)=>P.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[oe.Month],style:j?.[oe.Month],key:Ne,displayIndex:Ne,calendarMonth:ie},v==="around"&&!s.hideNavigation&&Ne===0&&P.createElement(u.PreviousMonthButton,{type:"button",className:x[oe.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Qt(ye),onClick:ot,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[oe.Chevron],orientation:s.dir==="rtl"?"right":"left"})),P.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[oe.MonthCaption],style:j?.[oe.MonthCaption],calendarMonth:ie,displayIndex:Ne},S?.startsWith("dropdown")?P.createElement(u.DropdownNav,{className:x[oe.Dropdowns],style:j?.[oe.Dropdowns]},(()=>{const me=S==="dropdown"||S==="dropdown-months"?P.createElement(u.MonthsDropdown,{key:"month",className:x[oe.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:is(ie.date),options:gC(ie.date,Z,ae,d,h),style:j?.[oe.Dropdown],value:h.getMonth(ie.date)}):P.createElement("span",{key:"month"},ee(ie.date,h)),ze=S==="dropdown"||S==="dropdown-years"?P.createElement(u.YearsDropdown,{key:"year",className:x[oe.YearsDropdown],"aria-label":Xt(h.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Ln(ie.date),options:vC(Z,ae,d,h,!!s.reverseYears),style:j?.[oe.Dropdown],value:h.getYear(ie.date)}):P.createElement("span",{key:"year"},Ye(ie.date,h));return h.getMonthYearOrder()==="year-first"?[ze,me]:[me,ze]})(),P.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},L(ie.date,h.options,h))):P.createElement(u.CaptionLabel,{className:x[oe.CaptionLabel],role:"status","aria-live":"polite"},L(ie.date,h.options,h))),v==="around"&&!s.hideNavigation&&Ne===b-1&&P.createElement(u.NextMonthButton,{type:"button",className:x[oe.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":qn(ve),onClick:Zt,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[oe.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Ne===b-1&&v==="after"&&!s.hideNavigation&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[oe.Nav],style:j?.[oe.Nav],"aria-label":kt(),onPreviousClick:ot,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),P.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":E==="multiple"||E==="range","aria-label":Qe(ie.date,h.options,h)||void 0,className:x[oe.MonthGrid],style:j?.[oe.MonthGrid]},!s.hideWeekdays&&P.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[oe.Weekdays],style:j?.[oe.Weekdays]},R&&P.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:x[oe.WeekNumberHeader],style:j?.[oe.WeekNumberHeader],scope:"col"},Se()),ma.map(me=>P.createElement(u.Weekday,{"aria-label":Ce(me,h.options,h),className:x[oe.Weekday],key:String(me),style:j?.[oe.Weekday],scope:"col"},re(me,h.options,h)))),P.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[oe.Weeks],style:j?.[oe.Weeks]},ie.weeks.map(me=>P.createElement(u.Week,{className:x[oe.Week],key:me.weekNumber,style:j?.[oe.Week],week:me},R&&P.createElement(u.WeekNumber,{week:me,style:j?.[oe.WeekNumber],"aria-label":Vt(me.weekNumber,{locale:p}),className:x[oe.WeekNumber],scope:"row",role:"rowheader"},de(me.weekNumber,h)),me.days.map(ze=>{const{date:Fe}=ze,ge=ce(ze);if(ge[lt.focused]=!ge.hidden&&!!ne?.isEqualTo(ze),ge[Cn.selected]=X?.(Fe)||ge.selected,lo(le)){const{from:Wt,to:vn}=le;ge[Cn.range_start]=!!(Wt&&vn&&h.isSameDay(Fe,Wt)),ge[Cn.range_end]=!!(Wt&&vn&&h.isSameDay(Fe,vn)),ge[Cn.range_middle]=ca(le,Fe,!0,h)}const At=xC(ge,j,s.modifiersStyles),Yn=I2(ge,x,s.modifiersClassNames),vt=!Bn&&!ge.hidden?xt(Fe,ge,h.options,h):void 0;return P.createElement(u.Day,{key:`${ze.isoDate}_${ze.displayMonthId}`,day:ze,modifiers:ge,className:Yn.join(" "),style:At,role:"gridcell","aria-selected":ge.selected||void 0,"aria-label":vt,"data-day":ze.isoDate,"data-month":ze.outside?ze.dateMonthId:void 0,"data-selected":ge.selected||void 0,"data-disabled":ge.disabled||void 0,"data-hidden":ge.hidden||void 0,"data-outside":ze.outside||void 0,"data-focused":ge.focused||void 0,"data-today":ge.today||void 0},!ge.hidden&&Bn?P.createElement(u.DayButton,{className:x[oe.DayButton],style:j?.[oe.DayButton],type:"button",day:ze,modifiers:ge,disabled:!ge.focused&&ge.disabled||void 0,"aria-disabled":ge.focused&&ge.disabled||void 0,tabIndex:xe(ze)?0:-1,"aria-label":gt(Fe,ge,h.options,h),onClick:Hn(ze,ge),onBlur:Mn(ze,ge),onFocus:Ga(ze,ge),onKeyDown:Tn(ze,ge),onMouseEnter:hl(ze,ge),onMouseLeave:ss(ze,ge)},J(Fe,h.options,h)):!ge.hidden&&J(ze.date,h.options,h))})))))))),s.footer&&P.createElement(u.Footer,{className:x[oe.Footer],style:j?.[oe.Footer],role:"status","aria-live":"polite"},s.footer)))}function QC({className:a,classNames:s,showOutsideDays:o=!0,...u}){return i.jsx(KC,{showOutsideDays:o,className:K("p-2",a),classNames:{root:"relative",months:"flex flex-col sm:flex-row gap-2 sm:gap-4",month:"flex flex-col gap-2",month_caption:"flex justify-center pt-1 relative items-center h-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-2 flex items-center justify-between px-1 z-10",button_previous:K(Rr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:K(Rr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),month_grid:"w-full border-collapse",weekdays:"flex w-full",weekday:"text-muted-foreground w-8 font-normal text-xs text-center",weeks:"flex flex-col",week:"flex w-full",day:K("relative h-8 w-8 p-0 text-center text-xs font-normal focus-within:relative focus-within:z-20","hover:bg-accent hover:text-accent-foreground rounded-full select-none"),day_button:K(Rr({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:K("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-l-full aria-selected:rounded-r-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_end:K("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-r-full aria-selected:rounded-l-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_middle:K("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:K("bg-primary text-primary-foreground rounded-full","hover:bg-primary hover:text-primary-foreground","focus:bg-primary focus:text-primary-foreground"),today:"bg-accent text-accent-foreground rounded-full",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...s},components:{Chevron:({orientation:d,className:m,...h})=>{const p=d==="left"?eb:d==="right"?Kr:d==="up"?Kc:Jr;return i.jsx(p,{className:K("h-4 w-4",m),...h})}},...u})}QC.displayName="Calendar";function VC(){const[a,s]=y.useState(""),[o,u]=y.useState(""),[d,m]=y.useState(null),[h,p]=y.useState(!1),{login:x,authRequired:S,isAuthenticated:E}=Wc(),v=Lc(),D=Hc().state?.from?.pathname||"/";if(y.useEffect(()=>{(E||!S)&&v(D,{replace:!0})},[E,S,v,D]),E||!S)return null;const T=async k=>{k.preventDefault(),m(null),p(!0);try{await x(a,o),v(D,{replace:!0})}catch(U){m(U instanceof Error?U.message:"Login failed")}finally{p(!1)}};return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs(_j,{className:"w-full max-w-sm",children:[i.jsxs(kj,{className:"space-y-1 text-center",children:[i.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:i.jsx(tb,{className:"h-6 w-6 text-primary"})}),i.jsx(Rj,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(Uj,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(qj,{children:i.jsxs("form",{onSubmit:T,className:"space-y-4",children:[d&&i.jsxs(id,{variant:"destructive",children:[i.jsx(Vc,{className:"h-4 w-4"}),i.jsx(rd,{children:d})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"username",children:"Username"}),i.jsx(_n,{id:"username",type:"text",value:a,onChange:k=>s(k.target.value),placeholder:"Enter username",autoComplete:"username",disabled:h,required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"password",children:"Password"}),i.jsx(_n,{id:"password",type:"password",value:o,onChange:k=>u(k.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:h,required:!0})]}),i.jsx(dt,{type:"submit",className:"w-full",disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsx(fa,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const XC=y.lazy(()=>Dt(()=>import("./index-IQ6bFgHE.js"),__vite__mapDeps([15,1,2,4,5,7,16,6,8,9])).then(a=>({default:a.AnalyticsPage}))),ZC=y.lazy(()=>Dt(()=>import("./api-ful0juAi.js"),__vite__mapDeps([17,1,2,5,18,14,6,4,7,8,9])).then(a=>({default:a.ApiPage}))),WC=y.lazy(()=>Dt(()=>import("./cliproxy-CfnF3x1J.js"),__vite__mapDeps([19,1,2,5,6,4,18,14,3,7,8,9])).then(a=>({default:a.CliproxyPage}))),JC=y.lazy(()=>Dt(()=>import("./cliproxy-control-panel-C3-aaKZ4.js"),__vite__mapDeps([20,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),$C=y.lazy(()=>Dt(()=>import("./copilot-DqdZcqhE.js"),__vite__mapDeps([21,1,2,5,18,14,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),FC=y.lazy(()=>Dt(()=>import("./accounts-DjriQaux.js"),__vite__mapDeps([22,1,2,5,14,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),IC=y.lazy(()=>Dt(()=>Promise.resolve().then(()=>m2),void 0).then(a=>({default:a.SettingsPage}))),PC=y.lazy(()=>Dt(()=>import("./health-By7mDK3f.js"),__vite__mapDeps([23,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),ew=y.lazy(()=>Dt(()=>import("./shared-CWZXvj7S.js"),__vite__mapDeps([24,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function ra(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(fa,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function tw(){return i.jsx(wv,{client:Jb,children:i.jsx(Fb,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(Ib,{children:i.jsx(aS,{children:i.jsxs(Nv,{children:[i.jsxs(jv,{children:[i.jsx(nn,{path:"/login",element:i.jsx(VC,{})}),i.jsx(nn,{element:i.jsx(lS,{}),children:i.jsxs(nn,{element:i.jsx(x1,{}),children:[i.jsx(nn,{path:"/",element:i.jsx(oj,{})}),i.jsx(nn,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(XC,{})})}),i.jsx(nn,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(ZC,{})})}),i.jsx(nn,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(WC,{})})}),i.jsx(nn,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(JC,{})})}),i.jsx(nn,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx($C,{})})}),i.jsx(nn,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(FC,{})})}),i.jsx(nn,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(IC,{})})}),i.jsx(nn,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(PC,{})})}),i.jsx(nn,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(ew,{})})})]})})]}),i.jsx(Ev,{position:"top-right"})]})})})})})}const Tx=document.getElementById("root");if(!Tx)throw new Error("Root element not found. Failed to mount React application.");Xb.createRoot(Tx).render(i.jsx(y.StrictMode,{children:i.jsx(tw,{})}));export{Yj as $,bj as A,Ya as B,_j as C,kw as D,BS as E,HS as F,LS as G,Fg as H,_n as I,od as J,La as K,yn as L,Uc as M,qw as N,Uj as O,Cg as P,Hw as Q,Bw as R,Le as S,mi as T,Lw as U,ex as V,Yw as W,Gw as X,Bj as Y,Qw as Z,Hj as _,qj as a,P1 as a0,fw as a1,yw as a2,vw as a3,Jc as a4,$c as a5,Fc as a6,Ic as a7,Pc as a8,bw as a9,Ow as aA,dw as aB,hw as aC,pw as aD,gw as aE,xw as aF,mw as aG,tx as aH,Dt as aI,sj as aJ,Dw as aK,id as aL,$g as aM,rd as aN,rx as aO,e2 as aP,n2 as aQ,Rr as aR,sx as aS,Kw as aa,Lj as ab,l1 as ac,K1 as ad,uS as ae,oS as af,u1 as ag,c1 as ah,d1 as ai,f1 as aj,Ir as ak,Qj as al,iS as am,rS as an,et as ao,Sw as ap,Nw as aq,jw as ar,Cw as as,Vw as at,ww as au,Tw as av,zw as aw,Ew as ax,Mw as ay,Aw as az,dt as b,K as c,Xw as d,Zw as e,h2 as f,QC as g,cw as h,kj as i,Rj as j,U1 as k,q1 as l,ml as m,Ww as n,hi as o,pi as p,_p as q,jj as r,Uw as s,mj as t,Xc as u,vj as v,_w as w,Rw as x,cj as y,xj as z};
|
|
47
|
+
`);return{valid:!1,error:u,line:h.length}}return{valid:!1,error:u}}}function lx({value:a,onChange:s,language:o="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=Tg(),[p,x]=y.useState(!1),[S,E]=y.useState(!0),v=y.useMemo(()=>o==="json"?$j(a):{valid:!0},[a,o]),b=y.useCallback(D=>i.jsx(Yb,{theme:h?mp.nightOwl:mp.github,code:D,language:o,children:({tokens:T,getLineProps:k,getTokenProps:U})=>{let M=!1;return i.jsx(i.Fragment,{children:T.map((Y,H)=>i.jsx("div",{...k({line:Y}),className:K(v.line===H+1&&"bg-destructive/20"),children:Y.map((V,R)=>{let j=!1;if(V.types.includes("property")){const J=V.content.replace(/['"]/g,"");Jj(J)?M=!0:M=!1}else(V.types.includes("string")||V.types.includes("number")||V.types.includes("boolean"))&&M?(j=!0,M=!1):V.types.includes("punctuation")&&V.content!==":"&&V.content!=="["&&V.content!=="{"&&(M=!1);const L=U({token:V});return j&&S&&(L.className=K(L.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...L},R)})},H))})}}),[h,o,v.line,S]);return i.jsxs("div",{className:K("flex flex-col",d),children:[i.jsxs("div",{className:K("relative rounded-md border overflow-hidden","bg-muted/30",p&&"ring-2 ring-ring ring-offset-2 ring-offset-background",u&&"opacity-70 cursor-not-allowed",!v.valid&&"border-destructive"),style:{minHeight:m},children:[i.jsx(Zj,{value:a,onValueChange:u?()=>{}:s,highlight:b,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:K("focus:outline-none font-mono text-sm",u&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:m}},h?"dark-editor":"light-editor"),i.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:i.jsx(dt,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>E(!S),title:S?"Reveal sensitive values":"Mask sensitive values",children:S?i.jsx(Vr,{className:"h-3 w-3"}):i.jsx(Qr,{className:"h-3 w-3"})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[v.valid?i.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[i.jsx(Xr,{className:"w-3 h-3 text-green-500"}),"Valid ",o.toUpperCase()]}):i.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[i.jsx(Vc,{className:"w-3 h-3"}),v.error,v.line&&` (line ${v.line})`]}),u&&i.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const sx=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:lx},Symbol.toStringTag,{value:"Module"})),Fj={webSearchConfig:null,webSearchStatus:null,webSearchLoading:!0,webSearchStatusLoading:!0,webSearchSaving:!1,webSearchError:null,webSearchSuccess:!1,globalEnvConfig:null,globalEnvLoading:!0,globalEnvSaving:!1,globalEnvError:null,globalEnvSuccess:!1,proxyConfig:null,proxyLoading:!0,proxySaving:!1,proxyError:null,proxySuccess:!1,proxyTestResult:null,proxyTesting:!1,rawConfig:null,rawConfigLoading:!1};function Ij(a,s){switch(s.type){case"SET_WEBSEARCH_CONFIG":return{...a,webSearchConfig:s.payload};case"SET_WEBSEARCH_STATUS":return{...a,webSearchStatus:s.payload};case"SET_WEBSEARCH_LOADING":return{...a,webSearchLoading:s.payload};case"SET_WEBSEARCH_STATUS_LOADING":return{...a,webSearchStatusLoading:s.payload};case"SET_WEBSEARCH_SAVING":return{...a,webSearchSaving:s.payload};case"SET_WEBSEARCH_ERROR":return{...a,webSearchError:s.payload};case"SET_WEBSEARCH_SUCCESS":return{...a,webSearchSuccess:s.payload};case"SET_GLOBALENV_CONFIG":return{...a,globalEnvConfig:s.payload};case"SET_GLOBALENV_LOADING":return{...a,globalEnvLoading:s.payload};case"SET_GLOBALENV_SAVING":return{...a,globalEnvSaving:s.payload};case"SET_GLOBALENV_ERROR":return{...a,globalEnvError:s.payload};case"SET_GLOBALENV_SUCCESS":return{...a,globalEnvSuccess:s.payload};case"SET_PROXY_CONFIG":return{...a,proxyConfig:s.payload};case"SET_PROXY_LOADING":return{...a,proxyLoading:s.payload};case"SET_PROXY_SAVING":return{...a,proxySaving:s.payload};case"SET_PROXY_ERROR":return{...a,proxyError:s.payload};case"SET_PROXY_SUCCESS":return{...a,proxySuccess:s.payload};case"SET_PROXY_TEST_RESULT":return{...a,proxyTestResult:s.payload};case"SET_PROXY_TESTING":return{...a,proxyTesting:s.payload};case"SET_RAW_CONFIG":return{...a,rawConfig:s.payload};case"SET_RAW_CONFIG_LOADING":return{...a,rawConfigLoading:s.payload};default:return a}}const ix=y.createContext(null);function Pj({children:a}){const[s,o]=y.useReducer(Ij,Fj);return i.jsx(ix.Provider,{value:{state:s,dispatch:o},children:a})}function rx(){const a=y.useContext(ix);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function e2(){const{dispatch:a}=rx(),s=y.useCallback(j=>a({type:"SET_WEBSEARCH_CONFIG",payload:j}),[a]),o=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS",payload:j}),[a]),u=y.useCallback(j=>a({type:"SET_WEBSEARCH_LOADING",payload:j}),[a]),d=y.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:j}),[a]),m=y.useCallback(j=>a({type:"SET_WEBSEARCH_SAVING",payload:j}),[a]),h=y.useCallback(j=>a({type:"SET_WEBSEARCH_ERROR",payload:j}),[a]),p=y.useCallback(j=>a({type:"SET_WEBSEARCH_SUCCESS",payload:j}),[a]),x=y.useCallback(j=>a({type:"SET_GLOBALENV_CONFIG",payload:j}),[a]),S=y.useCallback(j=>a({type:"SET_GLOBALENV_LOADING",payload:j}),[a]),E=y.useCallback(j=>a({type:"SET_GLOBALENV_SAVING",payload:j}),[a]),v=y.useCallback(j=>a({type:"SET_GLOBALENV_ERROR",payload:j}),[a]),b=y.useCallback(j=>a({type:"SET_GLOBALENV_SUCCESS",payload:j}),[a]),D=y.useCallback(j=>a({type:"SET_PROXY_CONFIG",payload:j}),[a]),T=y.useCallback(j=>a({type:"SET_PROXY_LOADING",payload:j}),[a]),k=y.useCallback(j=>a({type:"SET_PROXY_SAVING",payload:j}),[a]),U=y.useCallback(j=>a({type:"SET_PROXY_ERROR",payload:j}),[a]),M=y.useCallback(j=>a({type:"SET_PROXY_SUCCESS",payload:j}),[a]),Y=y.useCallback(j=>a({type:"SET_PROXY_TEST_RESULT",payload:j}),[a]),H=y.useCallback(j=>a({type:"SET_PROXY_TESTING",payload:j}),[a]),V=y.useCallback(j=>a({type:"SET_RAW_CONFIG",payload:j}),[a]),R=y.useCallback(j=>a({type:"SET_RAW_CONFIG_LOADING",payload:j}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:o,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:S,setGlobalEnvSaving:E,setGlobalEnvError:v,setGlobalEnvSuccess:b,setProxyConfig:D,setProxyLoading:T,setProxySaving:k,setProxyError:U,setProxySuccess:M,setProxyTestResult:Y,setProxyTesting:H,setRawConfig:V,setRawConfigLoading:R}),[s,o,u,d,m,h,p,x,S,E,v,b,D,T,k,U,M,Y,H,V,R])}function t2(){const[a,s]=Sv(),o=a.get("tab")?.toLowerCase(),u=o==="globalenv"?"globalenv":o==="proxy"?"proxy":o==="auth"?"auth":o==="backups"?"backups":"websearch",d=y.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function n2(){const{state:a}=rx(),s=e2(),[o,u]=y.useState(!1),d=y.useCallback(async()=>{try{s.setRawConfigLoading(!0);const h=await fetch("/api/config/raw");if(!h.ok){s.setRawConfig(null);return}const p=await h.text();s.setRawConfig(p)}catch{s.setRawConfig(null)}finally{s.setRawConfigLoading(!1)}},[s]),m=y.useCallback(async()=>{if(a.rawConfig)try{await navigator.clipboard.writeText(a.rawConfig),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[a.rawConfig]);return{rawConfig:a.rawConfig,loading:a.rawConfigLoading,copied:o,fetchRawConfig:d,copyToClipboard:m}}function a2({activeTab:a,onTabChange:s}){return i.jsx(Fg,{value:a,onValueChange:o=>s(o),children:i.jsxs(od,{className:"w-full",children:[i.jsxs(La,{value:"websearch",className:"flex-1 gap-2",children:[i.jsx(Fv,{className:"w-4 h-4"}),"WebSearch"]}),i.jsxs(La,{value:"globalenv",className:"flex-1 gap-2",children:[i.jsx(Qc,{className:"w-4 h-4"}),"Global Env"]}),i.jsxs(La,{value:"proxy",className:"flex-1 gap-2",children:[i.jsx(Iv,{className:"w-4 h-4"}),"Proxy"]}),i.jsxs(La,{value:"auth",className:"flex-1 gap-2",children:[i.jsx(vg,{className:"w-4 h-4"}),"Auth"]}),i.jsxs(La,{value:"backups",className:"flex-1 gap-2",children:[i.jsx(Pv,{className:"w-4 h-4"}),"Backups"]})]})})}function l2(){return i.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[i.jsx(Le,{className:"h-4 w-2/3"}),i.jsx("div",{className:"p-4 rounded-lg border",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-5 w-32"}),i.jsx(Le,{className:"h-4 w-48"})]}),i.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(Le,{className:"h-5 w-24"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}function ox(a,s=3,o=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,o)).then(()=>ox(a,s-1,o*2))})}function gi(a){return y.lazy(()=>ox(a))}const s2=gi(()=>Dt(()=>import("./index-DzAtu2WP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),i2=gi(()=>Dt(()=>import("./globalenv-section-CSL8d808.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),r2=gi(()=>Dt(()=>import("./index-QzEXdM_L.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),o2=gi(()=>Dt(()=>import("./auth-section-Ve_TIR5H.js"),__vite__mapDeps([12,1,2,4,5,6,7,8,9]))),u2=gi(()=>Dt(()=>import("./backups-section-CQtajr1G.js"),__vite__mapDeps([13,1,2,14,4,5,6,7,8,9])));class c2 extends y.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}render(){return this.state.hasError?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center p-6 max-w-md",children:[i.jsx(Vc,{className:"w-12 h-12 mx-auto mb-4 text-destructive"}),i.jsx("p",{className:"font-medium text-foreground mb-2",children:"Failed to load section"}),i.jsx("p",{className:"text-sm mb-4",children:this.state.error?.message||"Unknown error occurred"}),i.jsxs(dt,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(Dc,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function d2(){const{activeTab:a,setActiveTab:s}=t2(),{rawConfig:o,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=n2();y.useEffect(()=>{m()},[m]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsx("div",{className:"h-[calc(100vh-100px)]",children:i.jsxs(ld,{direction:"horizontal",className:"h-full",children:[i.jsx(ui,{defaultSize:40,minSize:30,maxSize:55,children:i.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[i.jsx("div",{className:"p-5 border-b bg-background",children:i.jsx(a2,{activeTab:a,onTabChange:p})}),i.jsx(c2,{children:i.jsxs(y.Suspense,{fallback:i.jsx(l2,{}),children:[a==="websearch"&&i.jsx(s2,{}),a==="globalenv"&&i.jsx(i2,{}),a==="proxy"&&i.jsx(r2,{}),a==="auth"&&i.jsx(o2,{}),a==="backups"&&i.jsx(u2,{})]})})]})}),i.jsx(sd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx(Zr,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(ui,{defaultSize:60,minSize:35,children:i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(cp,{className:"w-5 h-5 text-primary"}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-semibold",children:"config.yaml"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(dt,{variant:"outline",size:"sm",onClick:h,disabled:!o,children:d?i.jsxs(i.Fragment,{children:[i.jsx(ls,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Br,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(dt,{variant:"outline",size:"sm",onClick:m,disabled:u,children:i.jsx(Dc,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),i.jsx("div",{className:"flex-1 overflow-auto",children:u?i.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[i.jsx(Dc,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):o?i.jsx(lx,{value:o,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsxs("div",{className:"text-center",children:[i.jsx(cp,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{children:"Config file not found"}),i.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})})}function f2(){return i.jsx(Pj,{children:i.jsx(d2,{})})}const m2=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:f2},Symbol.toStringTag,{value:"Module"})),Xw=hv,Zw=gv,Ww=pv,h2=y.forwardRef(({className:a,align:s="center",sideOffset:o=4,...u},d)=>i.jsx(mv,{children:i.jsx(fg,{ref:d,align:s,sideOffset:o,className:K("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...u})}));h2.displayName=fg.displayName;function p2(a,s,o="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:o}).format(s).split(/\s/g).slice(2).join(" ")}const g2={},ri={};function ul(a,s){try{const u=(g2[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in ri?ri[u]:Lp(u,u.split(":"))}catch{if(a in ri)return ri[a];const o=a?.match(x2);return o?Lp(a,o.slice(1)):NaN}}const x2=/([+-]\d\d):?(\d\d)?/;function Lp(a,s){const o=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return ri[a]=o*60+u>0?o*60+u+d:o*60-u-d}class Rn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(ul(this.timeZone,this))?this.setTime(NaN):s.length?typeof s[0]=="number"&&(s.length===1||s.length===2&&typeof s[1]!="number")?this.setTime(s[0]):typeof s[0]=="string"?this.setTime(+new Date(s[0])):s[0]instanceof Date?this.setTime(+s[0]):(this.setTime(+new Date(...s)),ux(this),Bc(this)):this.setTime(Date.now())}static tz(s,...o){return o.length?new Rn(...o,s):new Rn(Date.now(),s)}withTimeZone(s){return new Rn(+this,s)}getTimezoneOffset(){const s=-ul(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Bc(this),+this}[Symbol.for("constructDateFrom")](s){return new Rn(+new Date(s),this.timeZone)}}const Yp=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!Yp.test(a))return;const s=a.replace(Yp,"$1UTC");Rn.prototype[s]&&(a.startsWith("get")?Rn.prototype[a]=function(){return this.internal[s]()}:(Rn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),y2(this),+this},Rn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Bc(this),+this}))});function Bc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-ul(a.timeZone,a)*60))}function y2(a){Date.prototype.setFullYear.call(a,a.internal.getUTCFullYear(),a.internal.getUTCMonth(),a.internal.getUTCDate()),Date.prototype.setHours.call(a,a.internal.getUTCHours(),a.internal.getUTCMinutes(),a.internal.getUTCSeconds(),a.internal.getUTCMilliseconds()),ux(a)}function ux(a){const s=ul(a.timeZone,a),o=s>0?Math.floor(s):Math.ceil(s),u=new Date(+a);u.setUTCHours(u.getUTCHours()-1);const d=-new Date(+a).getTimezoneOffset(),m=-new Date(+u).getTimezoneOffset(),h=d-m,p=Date.prototype.getHours.apply(a)!==a.internal.getUTCHours();h&&p&&a.internal.setUTCMinutes(a.internal.getUTCMinutes()+h);const x=d-o;x&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+x);const S=new Date(+a);S.setUTCSeconds(0);const E=d>0?S.getSeconds():(S.getSeconds()-60)%60,v=Math.round(-(ul(a.timeZone,a)*60))%60;(v||E)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+E));const b=ul(a.timeZone,a),D=b>0?Math.floor(b):Math.ceil(b),k=-new Date(+a).getTimezoneOffset()-D,U=D!==o,M=k-x;if(U&&M){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+M);const Y=ul(a.timeZone,a),H=Y>0?Math.floor(Y):Math.ceil(Y),V=D-H;V&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+V),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+V))}}class ua extends Rn{static tz(s,...o){return o.length?new ua(...o,s):new ua(Date.now(),s)}toISOString(){const[s,o,u]=this.tzComponents(),d=`${s}${o}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,o,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${o} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[o,u,d]=this.tzComponents();return`${s} GMT${o}${u}${d} (${p2(this.timeZone,this)})`}toLocaleString(s,o){return Date.prototype.toLocaleString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleDateString(s,o){return Date.prototype.toLocaleDateString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleTimeString(s,o){return Date.prototype.toLocaleTimeString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),o=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[o,u,d]}withTimeZone(s){return new ua(+this,s)}[Symbol.for("constructDateFrom")](s){return new ua(+new Date(s),this.timeZone)}}const Gp=5,v2=4;function b2(a,s){const o=s.startOfMonth(a),u=o.getDay()>0?o.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,Gp*7-1);return s.getMonth(a)===s.getMonth(m)?Gp:v2}function cx(a,s){const o=s.startOfMonth(a),u=o.getDay();return u===1?o:u===0?s.addDays(o,-6):s.addDays(o,-1*(u-1))}function S2(a,s){const o=cx(a,s),u=b2(a,s);return s.addDays(o,u*7-1)}const dx={...ei,labels:{labelDayButton:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ai(h,p,{locale:ei,...o});let m=d(a,"PPPP");return s.today&&(m=`Today, ${m}`),s.selected&&(m=`${m}, selected`),m},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:a=>`Week ${a}`,labelYearDropdown:"Choose the Year",labelGrid:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ai(d,m,{locale:ei,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ai(h,p,{locale:ei,...o});let m=d(a,"PPPP");return s?.today&&(m=`Today, ${m}`),m},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ai(d,m,{locale:ei,...s}),u(a,"cccc")}}};class sn{constructor(s,o){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ua.tz(this.options.timeZone):new this.Date,this.newDate=(u,d,m)=>this.overrides?.newDate?this.overrides.newDate(u,d,m):this.options.timeZone?new ua(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):lb(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):sb(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):ib(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):rb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):ob(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):ub(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):cb(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):db(u),m=new Set(d.map(p=>this.getYear(p)));if(m.size===d.length)return d;const h=[];return m.forEach(p=>{h.push(new Date(p,0,1))}),h},this.endOfBroadcastWeek=u=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(u):S2(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):fb(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):mb(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):hb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):pb(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ai(u,d,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(h):h},this.getISOWeek=u=>this.overrides?.getISOWeek?this.overrides.getISOWeek(u):gb(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):xb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):yb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):vb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):bb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):Sb(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Nb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):jb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Cb(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):wb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Eb(u),this.min=u=>this.overrides?.min?this.overrides.min(u):Mb(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Tb(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):zb(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):cx(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Ob(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Ab(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Db(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):_b(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):kb(u),this.options={locale:dx,...s},this.overrides=o}getDigitMap(){const{numerals:s="latn"}=this.options,o=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=o.format(d);return u}replaceDigits(s){const o=this.getDigitMap();return s.replace(/\d/g,u=>o[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&sn.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:o,timeZone:u,numerals:d}=this.options,m=o?.code;if(m&&sn.yearFirstLocales.has(m))try{return new Intl.DateTimeFormat(m,{month:"long",year:"numeric",timeZone:u,numberingSystem:d}).format(s)}catch{}const h=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(s,h)}}sn.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Un=new sn;class fx{constructor(s,o,u=Un){this.date=s,this.displayMonth=o,this.outside=!!(o&&!u.isSameMonth(s,o)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(o,"yyyy-MM"),this.dateMonthId=u.format(s,"yyyy-MM")}isEqualTo(s){return this.dateLib.isSameDay(s.date,this.date)&&this.dateLib.isSameMonth(s.displayMonth,this.displayMonth)}}class N2{constructor(s,o){this.date=s,this.weeks=o}}class j2{constructor(s,o){this.days=o,this.weekNumber=s}}function C2(a){return P.createElement("button",{...a})}function w2(a){return P.createElement("span",{...a})}function E2(a){const{size:s=24,orientation:o="left",className:u}=a;return P.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},o==="up"&&P.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),o==="down"&&P.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),o==="left"&&P.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),o==="right"&&P.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function M2(a){const{day:s,modifiers:o,...u}=a;return P.createElement("td",{...u})}function T2(a){const{day:s,modifiers:o,...u}=a,d=P.useRef(null);return P.useEffect(()=>{o.focused&&d.current?.focus()},[o.focused]),P.createElement("button",{ref:d,...u})}var oe;(function(a){a.Root="root",a.Chevron="chevron",a.Day="day",a.DayButton="day_button",a.CaptionLabel="caption_label",a.Dropdowns="dropdowns",a.Dropdown="dropdown",a.DropdownRoot="dropdown_root",a.Footer="footer",a.MonthGrid="month_grid",a.MonthCaption="month_caption",a.MonthsDropdown="months_dropdown",a.Month="month",a.Months="months",a.Nav="nav",a.NextMonthButton="button_next",a.PreviousMonthButton="button_previous",a.Week="week",a.Weeks="weeks",a.Weekday="weekday",a.Weekdays="weekdays",a.WeekNumber="week_number",a.WeekNumberHeader="week_number_header",a.YearsDropdown="years_dropdown"})(oe||(oe={}));var lt;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(lt||(lt={}));var Cn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(Cn||(Cn={}));var ln;(function(a){a.weeks_before_enter="weeks_before_enter",a.weeks_before_exit="weeks_before_exit",a.weeks_after_enter="weeks_after_enter",a.weeks_after_exit="weeks_after_exit",a.caption_after_enter="caption_after_enter",a.caption_after_exit="caption_after_exit",a.caption_before_enter="caption_before_enter",a.caption_before_exit="caption_before_exit"})(ln||(ln={}));function z2(a){const{options:s,className:o,components:u,classNames:d,...m}=a,h=[d[oe.Dropdown],o].join(" "),p=s?.find(({value:x})=>x===m.value);return P.createElement("span",{"data-disabled":m.disabled,className:d[oe.DropdownRoot]},P.createElement(u.Select,{className:h,...m},s?.map(({value:x,label:S,disabled:E})=>P.createElement(u.Option,{key:x,value:x,disabled:E},S))),P.createElement("span",{className:d[oe.CaptionLabel],"aria-hidden":!0},p?.label,P.createElement(u.Chevron,{orientation:"down",size:18,className:d[oe.Chevron]})))}function O2(a){return P.createElement("div",{...a})}function A2(a){return P.createElement("div",{...a})}function D2(a){const{calendarMonth:s,displayIndex:o,...u}=a;return P.createElement("div",{...u},a.children)}function _2(a){const{calendarMonth:s,displayIndex:o,...u}=a;return P.createElement("div",{...u})}function k2(a){return P.createElement("table",{...a})}function R2(a){return P.createElement("div",{...a})}const mx=y.createContext(void 0);function xi(){const a=y.useContext(mx);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function U2(a){const{components:s}=xi();return P.createElement(s.Dropdown,{...a})}function q2(a){const{onPreviousClick:s,onNextClick:o,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:x,labelNext:S}}=xi(),E=y.useCallback(b=>{d&&o?.(b)},[d,o]),v=y.useCallback(b=>{u&&s?.(b)},[u,s]);return P.createElement("nav",{...m},P.createElement(h.PreviousMonthButton,{type:"button",className:p[oe.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},P.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[oe.Chevron],orientation:"left"})),P.createElement(h.NextMonthButton,{type:"button",className:p[oe.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":S(d),onClick:E},P.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[oe.Chevron]})))}function B2(a){const{components:s}=xi();return P.createElement(s.Button,{...a})}function H2(a){return P.createElement("option",{...a})}function L2(a){const{components:s}=xi();return P.createElement(s.Button,{...a})}function Y2(a){const{rootRef:s,...o}=a;return P.createElement("div",{...o,ref:s})}function G2(a){return P.createElement("select",{...a})}function K2(a){const{week:s,...o}=a;return P.createElement("tr",{...o})}function Q2(a){return P.createElement("th",{...a})}function V2(a){return P.createElement("thead",{"aria-hidden":!0},P.createElement("tr",{...a}))}function X2(a){const{week:s,...o}=a;return P.createElement("th",{...o})}function Z2(a){return P.createElement("th",{...a})}function W2(a){return P.createElement("tbody",{...a})}function J2(a){const{components:s}=xi();return P.createElement(s.Dropdown,{...a})}const $2=Object.freeze(Object.defineProperty({__proto__:null,Button:C2,CaptionLabel:w2,Chevron:E2,Day:M2,DayButton:T2,Dropdown:z2,DropdownNav:O2,Footer:A2,Month:D2,MonthCaption:_2,MonthGrid:k2,Months:R2,MonthsDropdown:U2,Nav:q2,NextMonthButton:B2,Option:H2,PreviousMonthButton:L2,Root:Y2,Select:G2,Week:K2,WeekNumber:X2,WeekNumberHeader:Z2,Weekday:Q2,Weekdays:V2,Weeks:W2,YearsDropdown:J2},Symbol.toStringTag,{value:"Module"}));function ca(a,s,o=!1,u=Un){let{from:d,to:m}=a;const{differenceInCalendarDays:h,isSameDay:p}=u;return d&&m?(h(m,d)<0&&([d,m]=[m,d]),h(s,d)>=(o?1:0)&&h(m,s)>=(o?1:0)):!o&&m?p(m,s):!o&&d?p(d,s):!1}function cd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function lo(a){return!!(a&&typeof a=="object"&&"from"in a)}function dd(a){return!!(a&&typeof a=="object"&&"after"in a)}function fd(a){return!!(a&&typeof a=="object"&&"before"in a)}function hx(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function px(a,s){return Array.isArray(a)&&a.every(s.isDate)}function da(a,s,o=Un){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:m,isAfter:h}=o;return u.some(p=>{if(typeof p=="boolean")return p;if(o.isDate(p))return d(a,p);if(px(p,o))return p.some(x=>d(a,x));if(lo(p))return ca(p,a,!1,o);if(hx(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(cd(p)){const x=m(p.before,a),S=m(p.after,a),E=x>0,v=S<0;return h(p.before,p.after)?v&&E:E||v}return dd(p)?m(a,p.after)>0:fd(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function F2(a,s,o,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:x,broadcastCalendar:S,today:E=d.today()}=s,{isSameDay:v,isSameMonth:b,startOfMonth:D,isBefore:T,endOfMonth:k,isAfter:U}=d,M=o&&D(o),Y=u&&k(u),H={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},V={};for(const R of a){const{date:j,displayMonth:L}=R,J=!!(L&&!b(j,L)),ee=!!(M&&T(j,M)),de=!!(Y&&U(j,Y)),Se=!!(m&&da(j,m,d)),re=!!(h&&da(j,h,d))||ee||de||!S&&!x&&J||S&&x===!1&&J,Ye=v(j,E);J&&H.outside.push(R),Se&&H.disabled.push(R),re&&H.hidden.push(R),Ye&&H.today.push(R),p&&Object.keys(p).forEach(je=>{const $=p?.[je];$&&da(j,$,d)&&(V[je]?V[je].push(R):V[je]=[R])})}return R=>{const j={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},L={};for(const J in H){const ee=H[J];j[J]=ee.some(de=>de===R)}for(const J in V)L[J]=V[J].some(ee=>ee===R);return{...j,...L}}}function I2(a,s,o={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[m])=>(o[m]?d.push(o[m]):s[lt[m]]?d.push(s[lt[m]]):s[Cn[m]]&&d.push(s[Cn[m]]),d),[s[oe.Day]])}function P2(a){return{...$2,...a}}function eC(a){const s={"data-mode":a.mode??void 0,"data-required":"required"in a?a.required:void 0,"data-multiple-months":a.numberOfMonths&&a.numberOfMonths>1||void 0,"data-week-numbers":a.showWeekNumber||void 0,"data-broadcast-calendar":a.broadcastCalendar||void 0,"data-nav-layout":a.navLayout||void 0};return Object.entries(a).forEach(([o,u])=>{o.startsWith("data-")&&(s[o]=u)}),s}function tC(){const a={};for(const s in oe)a[oe[s]]=`rdp-${oe[s]}`;for(const s in lt)a[lt[s]]=`rdp-${lt[s]}`;for(const s in Cn)a[Cn[s]]=`rdp-${Cn[s]}`;for(const s in ln)a[ln[s]]=`rdp-${ln[s]}`;return a}function gx(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const nC=gx;function aC(a,s,o){return(o??new sn(s)).format(a,"d")}function lC(a,s=Un){return s.format(a,"LLLL")}function sC(a,s,o){return(o??new sn(s)).format(a,"cccccc")}function iC(a,s=Un){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function rC(){return""}function xx(a,s=Un){return s.format(a,"yyyy")}const oC=xx,uC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:gx,formatDay:aC,formatMonthCaption:nC,formatMonthDropdown:lC,formatWeekNumber:iC,formatWeekNumberHeader:rC,formatWeekdayName:sC,formatYearCaption:oC,formatYearDropdown:xx},Symbol.toStringTag,{value:"Module"}));function cC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...uC,...a}}function md(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const dC=md;function hd(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const fC=hd;function yx(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function vx(a){return"Choose the Month"}function bx(){return""}const mC="Go to the Next Month";function Sx(a,s){return mC}function Nx(a){return"Go to the Previous Month"}function jx(a,s,o){return(o??new sn(s)).format(a,"cccc")}function Cx(a,s){return`Week ${a}`}function wx(a){return"Week Number"}function Ex(a){return"Choose the Year"}const hC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:fC,labelDay:dC,labelDayButton:md,labelGrid:hd,labelGridcell:yx,labelMonthDropdown:vx,labelNav:bx,labelNext:Sx,labelPrevious:Nx,labelWeekNumber:Cx,labelWeekNumberHeader:wx,labelWeekday:jx,labelYearDropdown:Ex},Symbol.toStringTag,{value:"Module"})),jn=(a,s,o)=>s||(o?typeof o=="function"?o:(...u)=>o:a);function pC(a,s){const o=s.locale?.labels??{};return{...hC,...a??{},labelDayButton:jn(md,a?.labelDayButton,o.labelDayButton),labelMonthDropdown:jn(vx,a?.labelMonthDropdown,o.labelMonthDropdown),labelNext:jn(Sx,a?.labelNext,o.labelNext),labelPrevious:jn(Nx,a?.labelPrevious,o.labelPrevious),labelWeekNumber:jn(Cx,a?.labelWeekNumber,o.labelWeekNumber),labelYearDropdown:jn(Ex,a?.labelYearDropdown,o.labelYearDropdown),labelGrid:jn(hd,a?.labelGrid,o.labelGrid),labelGridcell:jn(yx,a?.labelGridcell,o.labelGridcell),labelNav:jn(bx,a?.labelNav,o.labelNav),labelWeekNumberHeader:jn(wx,a?.labelWeekNumberHeader,o.labelWeekNumberHeader),labelWeekday:jn(jx,a?.labelWeekday,o.labelWeekday)}}function gC(a,s,o,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:x,getMonth:S}=d;return x({start:h(a),end:p(a)}).map(b=>{const D=u.formatMonthDropdown(b,d),T=S(b),k=s&&b<m(s)||o&&b>m(o)||!1;return{value:T,label:D,disabled:k}})}function xC(a,s={},o={}){let u={...s?.[oe.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...o?.[d]}}),u}function yC(a,s,o,u){const d=u??a.today(),m=o?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),h=[];for(let p=0;p<7;p++){const x=a.addDays(m,p);h.push(x)}return h}function vC(a,s,o,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:x}=u,S=m(a),E=h(s),v=p({start:S,end:E});return d&&v.reverse(),v.map(b=>{const D=o.formatYearDropdown(b,u);return{value:x(b),label:D,disabled:!1}})}const yi=a=>a instanceof HTMLElement?a:null,Ec=a=>[...a.querySelectorAll("[data-animated-month]")??[]],bC=a=>yi(a.querySelector("[data-animated-month]")),Mc=a=>yi(a.querySelector("[data-animated-caption]")),Tc=a=>yi(a.querySelector("[data-animated-weeks]")),SC=a=>yi(a.querySelector("[data-animated-nav]")),NC=a=>yi(a.querySelector("[data-animated-weekdays]"));function jC(a,s,{classNames:o,months:u,focused:d,dateLib:m}){const h=y.useRef(null),p=y.useRef(u),x=y.useRef(!1);y.useLayoutEffect(()=>{const S=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||S.length===0||u.length!==S.length)return;const E=m.isSameMonth(u[0].date,S[0].date),v=m.isAfter(u[0].date,S[0].date),b=v?o[ln.caption_after_enter]:o[ln.caption_before_enter],D=v?o[ln.weeks_after_enter]:o[ln.weeks_before_enter],T=h.current,k=a.current.cloneNode(!0);if(k instanceof HTMLElement?(Ec(k).forEach(H=>{if(!(H instanceof HTMLElement))return;const V=bC(H);V&&H.contains(V)&&H.removeChild(V);const R=Mc(H);R&&R.classList.remove(b);const j=Tc(H);j&&j.classList.remove(D)}),h.current=k):h.current=null,x.current||E||d)return;const U=T instanceof HTMLElement?Ec(T):[],M=Ec(a.current);if(M?.every(Y=>Y instanceof HTMLElement)&&U&&U.every(Y=>Y instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const Y=SC(a.current);Y&&(Y.style.zIndex="1"),M.forEach((H,V)=>{const R=U[V];if(!R)return;H.style.position="relative",H.style.overflow="hidden";const j=Mc(H);j&&j.classList.add(b);const L=Tc(H);L&&L.classList.add(D);const J=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),Y&&(Y.style.zIndex=""),j&&j.classList.remove(b),L&&L.classList.remove(D),H.style.position="",H.style.overflow="",H.contains(R)&&H.removeChild(R)};R.style.pointerEvents="none",R.style.position="absolute",R.style.overflow="hidden",R.setAttribute("aria-hidden","true");const ee=NC(R);ee&&(ee.style.opacity="0");const de=Mc(R);de&&(de.classList.add(v?o[ln.caption_before_exit]:o[ln.caption_after_exit]),de.addEventListener("animationend",J));const Se=Tc(R);Se&&Se.classList.add(v?o[ln.weeks_before_exit]:o[ln.weeks_after_exit]),H.insertBefore(R,H.firstChild)})}})}function CC(a,s,o,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:x}=o??{},{addDays:S,differenceInCalendarDays:E,differenceInCalendarMonths:v,endOfBroadcastWeek:b,endOfISOWeek:D,endOfMonth:T,endOfWeek:k,isAfter:U,startOfBroadcastWeek:M,startOfISOWeek:Y,startOfWeek:H}=u,V=x?M(d,u):h?Y(d):H(d),R=x?b(m):h?D(T(m)):k(T(m)),j=s&&(x?b(s):h?D(s):k(s)),L=j&&U(R,j)?j:R,J=E(L,V),ee=v(m,d)+1,de=[];for(let Ye=0;Ye<=J;Ye++){const je=S(V,Ye);de.push(je)}const re=(x?35:42)*ee;if(p&&de.length<re){const Ye=re-de.length;for(let je=0;je<Ye;je++){const $=S(de[de.length-1],1);de.push($)}}return de}function wC(a){const s=[];return a.reduce((o,u)=>{const d=u.weeks.reduce((m,h)=>m.concat(h.days.slice()),s.slice());return o.concat(d.slice())},s.slice())}function EC(a,s,o,u){const{numberOfMonths:d=1}=o,m=[];for(let h=0;h<d;h++){const p=u.addMonths(a,h);if(s&&p>s)break;m.push(p)}return m}function Kp(a,s,o,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let x=d||m||h;const{differenceInCalendarMonths:S,addMonths:E,startOfMonth:v}=u;if(o&&S(o,x)<p-1){const b=-1*(p-1);x=E(o,b)}return s&&S(x,s)<0&&(x=s),v(x)}function MC(a,s,o,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:x,getISOWeek:S,getWeek:E,startOfBroadcastWeek:v,startOfISOWeek:b,startOfWeek:D}=u,T=a.reduce((k,U)=>{const M=o.broadcastCalendar?v(U,u):o.ISOWeek?b(U):D(U),Y=o.broadcastCalendar?m(U):o.ISOWeek?h(p(U)):x(p(U)),H=s.filter(L=>L>=M&&L<=Y),V=o.broadcastCalendar?35:42;if(o.fixedWeeks&&H.length<V){const L=s.filter(J=>{const ee=V-H.length;return J>Y&&J<=d(Y,ee)});H.push(...L)}const R=H.reduce((L,J)=>{const ee=o.ISOWeek?S(J):E(J),de=L.find(re=>re.weekNumber===ee),Se=new fx(J,U,u);return de?de.days.push(Se):L.push(new j2(ee,[Se])),L},[]),j=new N2(U,R);return k.push(j),k},[]);return o.reverseMonths?T.reverse():T}function TC(a,s){let{startMonth:o,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:x,endOfYear:S,newDate:E,today:v}=s,{fromYear:b,toYear:D,fromMonth:T,toMonth:k}=a;!o&&T&&(o=T),!o&&b&&(o=s.newDate(b,0,1)),!u&&k&&(u=k),!u&&D&&(u=E(D,11,31));const U=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return o?o=h(o):b?o=E(b,0,1):!o&&U&&(o=d(x(a.today??v(),-100))),u?u=p(u):D?u=E(D,11,31):!u&&U&&(u=S(a.today??v())),[o&&m(o),u&&m(u)]}function zC(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,S=d?m:1,E=h(a);if(!s)return p(E,S);if(!(x(s,a)<m))return p(E,S)}function OC(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,S=d?m??1:1,E=h(a);if(!s)return p(E,-S);if(!(x(E,s)<=0))return p(E,-S)}function AC(a){const s=[];return a.reduce((o,u)=>o.concat(u.weeks.slice()),s.slice())}function so(a,s){const[o,u]=y.useState(a);return[s===void 0?o:s,u]}function DC(a,s){const[o,u]=TC(a,s),{startOfMonth:d,endOfMonth:m}=s,h=Kp(a,o,u,s),[p,x]=so(h,a.month?h:void 0);y.useEffect(()=>{const V=Kp(a,o,u,s);x(V)},[a.timeZone]);const{months:S,weeks:E,days:v,previousMonth:b,nextMonth:D}=y.useMemo(()=>{const V=EC(p,u,{numberOfMonths:a.numberOfMonths},s),R=CC(V,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),j=MC(V,R,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),L=AC(j),J=wC(j),ee=OC(p,o,a,s),de=zC(p,u,a,s);return{months:j,weeks:L,days:J,previousMonth:ee,nextMonth:de}},[s,p.getTime(),u?.getTime(),o?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:T,onMonthChange:k}=a,U=V=>E.some(R=>R.days.some(j=>j.isEqualTo(V))),M=V=>{if(T)return;let R=d(V);o&&R<d(o)&&(R=d(o)),u&&R>d(u)&&(R=d(u)),x(R),k?.(R)};return{months:S,weeks:E,days:v,navStart:o,navEnd:u,previousMonth:b,nextMonth:D,goToMonth:M,goToDay:V=>{U(V)||M(V.date)}}}var kn;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(kn||(kn={}));function Qp(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function _C(a,s,o,u){let d,m=-1;for(const h of a){const p=s(h);Qp(p)&&(p[lt.focused]&&m<kn.FocusedModifier?(d=h,m=kn.FocusedModifier):u?.isEqualTo(h)&&m<kn.LastFocused?(d=h,m=kn.LastFocused):o(h.date)&&m<kn.Selected?(d=h,m=kn.Selected):p[lt.today]&&m<kn.Today&&(d=h,m=kn.Today))}return d||(d=a.find(h=>Qp(s(h)))),d}function kC(a,s,o,u,d,m,h){const{ISOWeek:p,broadcastCalendar:x}=m,{addDays:S,addMonths:E,addWeeks:v,addYears:b,endOfBroadcastWeek:D,endOfISOWeek:T,endOfWeek:k,max:U,min:M,startOfBroadcastWeek:Y,startOfISOWeek:H,startOfWeek:V}=h;let j={day:S,week:v,month:E,year:b,startOfWeek:L=>x?Y(L,h):p?H(L):V(L),endOfWeek:L=>x?D(L):p?T(L):k(L)}[a](o,s==="after"?1:-1);return s==="before"&&u?j=U([u,j]):s==="after"&&d&&(j=M([d,j])),j}function Mx(a,s,o,u,d,m,h,p=0){if(p>365)return;const x=kC(a,s,o.date,u,d,m,h),S=!!(m.disabled&&da(x,m.disabled,h)),E=!!(m.hidden&&da(x,m.hidden,h)),v=x,b=new fx(x,v,h);return!S&&!E?b:Mx(a,s,b,u,d,m,h,p+1)}function RC(a,s,o,u,d){const{autoFocus:m}=a,[h,p]=y.useState(),x=_C(s.days,o,u||(()=>!1),h),[S,E]=y.useState(m?x:void 0);return{isFocusTarget:k=>!!x?.isEqualTo(k),setFocused:E,focused:S,blur:()=>{p(S),E(void 0)},moveFocus:(k,U)=>{if(!S)return;const M=Mx(k,U,S,s.navStart,s.navEnd,a,d);M&&(a.disableNavigation&&!s.days.some(H=>H.isEqualTo(M))||(s.goToDay(M),E(M)))}}}function UC(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=so(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s,S=D=>p?.some(T=>x(T,D))??!1,{min:E,max:v}=a;return{selected:p,select:(D,T,k)=>{let U=[...p??[]];if(S(D)){if(p?.length===E||u&&p?.length===1)return;U=p?.filter(M=>!x(M,D))}else p?.length===v?U=[D]:U=[...U,D];return d||h(U),d?.(U,D,T,k),U},isSelected:S}}function qC(a,s,o=0,u=0,d=!1,m=Un){const{from:h,to:p}=s||{},{isSameDay:x,isAfter:S,isBefore:E}=m;let v;if(!h&&!p)v={from:a,to:o>0?void 0:a};else if(h&&!p)x(h,a)?o===0?v={from:h,to:a}:d?v={from:h,to:void 0}:v=void 0:E(a,h)?v={from:a,to:h}:v={from:h,to:a};else if(h&&p)if(x(h,a)&&x(p,a))d?v={from:h,to:p}:v=void 0;else if(x(h,a))v={from:h,to:o>0?void 0:a};else if(x(p,a))v={from:a,to:o>0?void 0:a};else if(E(a,h))v={from:a,to:p};else if(S(a,h))v={from:h,to:a};else if(S(a,p))v={from:h,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const b=m.differenceInCalendarDays(v.to,v.from);u>0&&b>u?v={from:a,to:void 0}:o>1&&b<o&&(v={from:a,to:void 0})}return v}function BC(a,s,o=Un){const u=Array.isArray(s)?s:[s];let d=a.from;const m=o.differenceInCalendarDays(a.to,a.from),h=Math.min(m,6);for(let p=0;p<=h;p++){if(u.includes(d.getDay()))return!0;d=o.addDays(d,1)}return!1}function Vp(a,s,o=Un){return ca(a,s.from,!1,o)||ca(a,s.to,!1,o)||ca(s,a.from,!1,o)||ca(s,a.to,!1,o)}function HC(a,s,o=Un){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:o.isDate(p)?ca(a,p,!1,o):px(p,o)?p.some(x=>ca(a,x,!1,o)):lo(p)?p.from&&p.to?Vp(a,{from:p.from,to:p.to},o):!1:hx(p)?BC(a,p.dayOfWeek,o):cd(p)?o.isAfter(p.before,p.after)?Vp(a,{from:o.addDays(p.after,1),to:o.addDays(p.before,-1)},o):da(a.from,p,o)||da(a.to,p,o):dd(p)||fd(p)?da(a.from,p,o)||da(a.to,p,o):!1))return!0;const h=u.filter(p=>typeof p=="function");if(h.length){let p=a.from;const x=o.differenceInCalendarDays(a.to,a.from);for(let S=0;S<=x;S++){if(h.some(E=>E(p)))return!0;p=o.addDays(p,1)}}return!1}function LC(a,s){const{disabled:o,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,x]=so(d,h?d:void 0),S=h?d:p;return{selected:S,select:(b,D,T)=>{const{min:k,max:U}=a,M=b?qC(b,S,k,U,m,s):void 0;return u&&o&&M?.from&&M.to&&HC({from:M.from,to:M.to},o,s)&&(M.from=b,M.to=void 0),h||x(M),h?.(M,b,D,T),M},isSelected:b=>S&&ca(S,b,!1,s)}}function YC(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=so(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s;return{selected:p,select:(v,b,D)=>{let T=v;return!u&&p&&p&&x(v,p)&&(T=void 0),d||h(T),d?.(T,v,b,D),T},isSelected:v=>p?x(p,v):!1}}function GC(a,s){const o=YC(a,s),u=UC(a,s),d=LC(a,s);switch(a.mode){case"single":return o;case"multiple":return u;case"range":return d;default:return}}function Tt(a,s){return a instanceof ua&&a.timeZone===s?a:new ua(a,s)}function Xp(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Tt(a,s):Array.isArray(a)?a.map(o=>o instanceof Date?Tt(o,s):o):lo(a)?{...a,from:a.from?Tt(a.from,s):a.from,to:a.to?Tt(a.to,s):a.to}:cd(a)?{before:Tt(a.before,s),after:Tt(a.after,s)}:dd(a)?{after:Tt(a.after,s)}:fd(a)?{before:Tt(a.before,s)}:a}function zc(a,s){return a&&(Array.isArray(a)?a.map(o=>Xp(o,s)):Xp(a,s))}function KC(a){let s=a;const o=s.timeZone;if(o&&(s={...a,timeZone:o},s.today&&(s.today=Tt(s.today,o)),s.month&&(s.month=Tt(s.month,o)),s.defaultMonth&&(s.defaultMonth=Tt(s.defaultMonth,o)),s.startMonth&&(s.startMonth=Tt(s.startMonth,o)),s.endMonth&&(s.endMonth=Tt(s.endMonth,o)),s.mode==="single"&&s.selected?s.selected=Tt(s.selected,o):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(ie=>Tt(ie,o)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Tt(s.selected.from,o):s.selected.from,to:s.selected.to?Tt(s.selected.to,o):s.selected.to}),s.disabled!==void 0&&(s.disabled=zc(s.disabled,o)),s.hidden!==void 0&&(s.hidden=zc(s.hidden,o)),s.modifiers)){const ie={};Object.keys(s.modifiers).forEach(Ne=>{ie[Ne]=zc(s.modifiers?.[Ne],o)}),s.modifiers=ie}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:x}=y.useMemo(()=>{const ie={...dx,...s.locale},Ne=new sn({locale:ie,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:Ne,components:P2(s.components),formatters:cC(s.formatters),labels:pC(s.labels,Ne.options),locale:ie,classNames:{...tC(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:h.today()});const{captionLayout:S,mode:E,navLayout:v,numberOfMonths:b=1,onDayBlur:D,onDayClick:T,onDayFocus:k,onDayKeyDown:U,onDayMouseEnter:M,onDayMouseLeave:Y,onNextClick:H,onPrevClick:V,showWeekNumber:R,styles:j}=s,{formatCaption:L,formatDay:J,formatMonthDropdown:ee,formatWeekNumber:de,formatWeekNumberHeader:Se,formatWeekdayName:re,formatYearDropdown:Ye}=d,je=DC(s,h),{days:$,months:z,navStart:Z,navEnd:ae,previousMonth:ye,nextMonth:ve,goToMonth:Ae}=je,ce=F2($,s,Z,ae,h),{isSelected:X,select:F,selected:le}=GC(s,h)??{},{blur:I,focused:ne,isFocusTarget:xe,moveFocus:De,setFocused:Ge}=RC(s,je,ce,X??(()=>!1),h),{labelDayButton:gt,labelGridcell:xt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Qt,labelNext:qn,labelWeekday:Ce,labelWeekNumber:Vt,labelWeekNumberHeader:En,labelYearDropdown:Xt}=m,ma=y.useMemo(()=>yC(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Bn=E!==void 0||T!==void 0,ot=y.useCallback(()=>{ye&&(Ae(ye),V?.(ye))},[ye,Ae,V]),Zt=y.useCallback(()=>{ve&&(Ae(ve),H?.(ve))},[Ae,ve,H]),Hn=y.useCallback((ie,Ne)=>me=>{me.preventDefault(),me.stopPropagation(),Ge(ie),!Ne.disabled&&(F?.(ie.date,Ne,me),T?.(ie.date,Ne,me))},[F,T,Ge]),Ga=y.useCallback((ie,Ne)=>me=>{Ge(ie),k?.(ie.date,Ne,me)},[k,Ge]),Mn=y.useCallback((ie,Ne)=>me=>{I(),D?.(ie.date,Ne,me)},[I,D]),Tn=y.useCallback((ie,Ne)=>me=>{const ze={ArrowLeft:[me.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[me.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[me.shiftKey?"year":"week","after"],ArrowUp:[me.shiftKey?"year":"week","before"],PageUp:[me.shiftKey?"year":"month","before"],PageDown:[me.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ze[me.key]){me.preventDefault(),me.stopPropagation();const[Fe,ge]=ze[me.key];De(Fe,ge)}U?.(ie.date,Ne,me)},[De,U,s.dir]),hl=y.useCallback((ie,Ne)=>me=>{M?.(ie.date,Ne,me)},[M]),ss=y.useCallback((ie,Ne)=>me=>{Y?.(ie.date,Ne,me)},[Y]),is=y.useCallback(ie=>Ne=>{const me=Number(Ne.target.value),ze=h.setMonth(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),Ln=y.useCallback(ie=>Ne=>{const me=Number(Ne.target.value),ze=h.setYear(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),{className:W,style:Me}=y.useMemo(()=>({className:[x[oe.Root],s.className].filter(Boolean).join(" "),style:{...j?.[oe.Root],...s.style}}),[x,s.className,s.style,j]),fe=eC(s),Te=y.useRef(null);jC(Te,!!s.animate,{classNames:x,months:z,focused:ne,dateLib:h});const nt={dayPickerProps:s,selected:le,select:F,isSelected:X,months:z,nextMonth:ve,previousMonth:ye,goToMonth:Ae,getModifiers:ce,components:u,classNames:x,styles:j,labels:m,formatters:d};return P.createElement(mx.Provider,{value:nt},P.createElement(u.Root,{rootRef:s.animate?Te:void 0,className:W,style:Me,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...fe},P.createElement(u.Months,{className:x[oe.Months],style:j?.[oe.Months]},!s.hideNavigation&&!v&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[oe.Nav],style:j?.[oe.Nav],"aria-label":kt(),onPreviousClick:ot,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),z.map((ie,Ne)=>P.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[oe.Month],style:j?.[oe.Month],key:Ne,displayIndex:Ne,calendarMonth:ie},v==="around"&&!s.hideNavigation&&Ne===0&&P.createElement(u.PreviousMonthButton,{type:"button",className:x[oe.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Qt(ye),onClick:ot,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[oe.Chevron],orientation:s.dir==="rtl"?"right":"left"})),P.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[oe.MonthCaption],style:j?.[oe.MonthCaption],calendarMonth:ie,displayIndex:Ne},S?.startsWith("dropdown")?P.createElement(u.DropdownNav,{className:x[oe.Dropdowns],style:j?.[oe.Dropdowns]},(()=>{const me=S==="dropdown"||S==="dropdown-months"?P.createElement(u.MonthsDropdown,{key:"month",className:x[oe.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:is(ie.date),options:gC(ie.date,Z,ae,d,h),style:j?.[oe.Dropdown],value:h.getMonth(ie.date)}):P.createElement("span",{key:"month"},ee(ie.date,h)),ze=S==="dropdown"||S==="dropdown-years"?P.createElement(u.YearsDropdown,{key:"year",className:x[oe.YearsDropdown],"aria-label":Xt(h.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Ln(ie.date),options:vC(Z,ae,d,h,!!s.reverseYears),style:j?.[oe.Dropdown],value:h.getYear(ie.date)}):P.createElement("span",{key:"year"},Ye(ie.date,h));return h.getMonthYearOrder()==="year-first"?[ze,me]:[me,ze]})(),P.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},L(ie.date,h.options,h))):P.createElement(u.CaptionLabel,{className:x[oe.CaptionLabel],role:"status","aria-live":"polite"},L(ie.date,h.options,h))),v==="around"&&!s.hideNavigation&&Ne===b-1&&P.createElement(u.NextMonthButton,{type:"button",className:x[oe.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":qn(ve),onClick:Zt,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[oe.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Ne===b-1&&v==="after"&&!s.hideNavigation&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[oe.Nav],style:j?.[oe.Nav],"aria-label":kt(),onPreviousClick:ot,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),P.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":E==="multiple"||E==="range","aria-label":Qe(ie.date,h.options,h)||void 0,className:x[oe.MonthGrid],style:j?.[oe.MonthGrid]},!s.hideWeekdays&&P.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[oe.Weekdays],style:j?.[oe.Weekdays]},R&&P.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:x[oe.WeekNumberHeader],style:j?.[oe.WeekNumberHeader],scope:"col"},Se()),ma.map(me=>P.createElement(u.Weekday,{"aria-label":Ce(me,h.options,h),className:x[oe.Weekday],key:String(me),style:j?.[oe.Weekday],scope:"col"},re(me,h.options,h)))),P.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[oe.Weeks],style:j?.[oe.Weeks]},ie.weeks.map(me=>P.createElement(u.Week,{className:x[oe.Week],key:me.weekNumber,style:j?.[oe.Week],week:me},R&&P.createElement(u.WeekNumber,{week:me,style:j?.[oe.WeekNumber],"aria-label":Vt(me.weekNumber,{locale:p}),className:x[oe.WeekNumber],scope:"row",role:"rowheader"},de(me.weekNumber,h)),me.days.map(ze=>{const{date:Fe}=ze,ge=ce(ze);if(ge[lt.focused]=!ge.hidden&&!!ne?.isEqualTo(ze),ge[Cn.selected]=X?.(Fe)||ge.selected,lo(le)){const{from:Wt,to:vn}=le;ge[Cn.range_start]=!!(Wt&&vn&&h.isSameDay(Fe,Wt)),ge[Cn.range_end]=!!(Wt&&vn&&h.isSameDay(Fe,vn)),ge[Cn.range_middle]=ca(le,Fe,!0,h)}const At=xC(ge,j,s.modifiersStyles),Yn=I2(ge,x,s.modifiersClassNames),vt=!Bn&&!ge.hidden?xt(Fe,ge,h.options,h):void 0;return P.createElement(u.Day,{key:`${ze.isoDate}_${ze.displayMonthId}`,day:ze,modifiers:ge,className:Yn.join(" "),style:At,role:"gridcell","aria-selected":ge.selected||void 0,"aria-label":vt,"data-day":ze.isoDate,"data-month":ze.outside?ze.dateMonthId:void 0,"data-selected":ge.selected||void 0,"data-disabled":ge.disabled||void 0,"data-hidden":ge.hidden||void 0,"data-outside":ze.outside||void 0,"data-focused":ge.focused||void 0,"data-today":ge.today||void 0},!ge.hidden&&Bn?P.createElement(u.DayButton,{className:x[oe.DayButton],style:j?.[oe.DayButton],type:"button",day:ze,modifiers:ge,disabled:!ge.focused&&ge.disabled||void 0,"aria-disabled":ge.focused&&ge.disabled||void 0,tabIndex:xe(ze)?0:-1,"aria-label":gt(Fe,ge,h.options,h),onClick:Hn(ze,ge),onBlur:Mn(ze,ge),onFocus:Ga(ze,ge),onKeyDown:Tn(ze,ge),onMouseEnter:hl(ze,ge),onMouseLeave:ss(ze,ge)},J(Fe,h.options,h)):!ge.hidden&&J(ze.date,h.options,h))})))))))),s.footer&&P.createElement(u.Footer,{className:x[oe.Footer],style:j?.[oe.Footer],role:"status","aria-live":"polite"},s.footer)))}function QC({className:a,classNames:s,showOutsideDays:o=!0,...u}){return i.jsx(KC,{showOutsideDays:o,className:K("p-2",a),classNames:{root:"relative",months:"flex flex-col sm:flex-row gap-2 sm:gap-4",month:"flex flex-col gap-2",month_caption:"flex justify-center pt-1 relative items-center h-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-2 flex items-center justify-between px-1 z-10",button_previous:K(Rr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:K(Rr({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),month_grid:"w-full border-collapse",weekdays:"flex w-full",weekday:"text-muted-foreground w-8 font-normal text-xs text-center",weeks:"flex flex-col",week:"flex w-full",day:K("relative h-8 w-8 p-0 text-center text-xs font-normal focus-within:relative focus-within:z-20","hover:bg-accent hover:text-accent-foreground rounded-full select-none"),day_button:K(Rr({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:K("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-l-full aria-selected:rounded-r-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_end:K("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-r-full aria-selected:rounded-l-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_middle:K("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:K("bg-primary text-primary-foreground rounded-full","hover:bg-primary hover:text-primary-foreground","focus:bg-primary focus:text-primary-foreground"),today:"bg-accent text-accent-foreground rounded-full",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...s},components:{Chevron:({orientation:d,className:m,...h})=>{const p=d==="left"?eb:d==="right"?Kr:d==="up"?Kc:Jr;return i.jsx(p,{className:K("h-4 w-4",m),...h})}},...u})}QC.displayName="Calendar";function VC(){const[a,s]=y.useState(""),[o,u]=y.useState(""),[d,m]=y.useState(null),[h,p]=y.useState(!1),{login:x,authRequired:S,isAuthenticated:E}=Wc(),v=Lc(),D=Hc().state?.from?.pathname||"/";if(y.useEffect(()=>{(E||!S)&&v(D,{replace:!0})},[E,S,v,D]),E||!S)return null;const T=async k=>{k.preventDefault(),m(null),p(!0);try{await x(a,o),v(D,{replace:!0})}catch(U){m(U instanceof Error?U.message:"Login failed")}finally{p(!1)}};return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs(_j,{className:"w-full max-w-sm",children:[i.jsxs(kj,{className:"space-y-1 text-center",children:[i.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:i.jsx(tb,{className:"h-6 w-6 text-primary"})}),i.jsx(Rj,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(Uj,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(qj,{children:i.jsxs("form",{onSubmit:T,className:"space-y-4",children:[d&&i.jsxs(id,{variant:"destructive",children:[i.jsx(Vc,{className:"h-4 w-4"}),i.jsx(rd,{children:d})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"username",children:"Username"}),i.jsx(_n,{id:"username",type:"text",value:a,onChange:k=>s(k.target.value),placeholder:"Enter username",autoComplete:"username",disabled:h,required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"password",children:"Password"}),i.jsx(_n,{id:"password",type:"password",value:o,onChange:k=>u(k.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:h,required:!0})]}),i.jsx(dt,{type:"submit",className:"w-full",disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsx(fa,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const XC=y.lazy(()=>Dt(()=>import("./index-D3SAzu5s.js"),__vite__mapDeps([15,1,2,4,5,7,16,6,8,9])).then(a=>({default:a.AnalyticsPage}))),ZC=y.lazy(()=>Dt(()=>import("./api-DFeR1iJt.js"),__vite__mapDeps([17,1,2,5,18,14,6,4,7,8,9])).then(a=>({default:a.ApiPage}))),WC=y.lazy(()=>Dt(()=>import("./cliproxy-C9-WQ2K1.js"),__vite__mapDeps([19,1,2,5,6,4,18,14,3,7,8,9])).then(a=>({default:a.CliproxyPage}))),JC=y.lazy(()=>Dt(()=>import("./cliproxy-control-panel-BHNeiJAP.js"),__vite__mapDeps([20,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),$C=y.lazy(()=>Dt(()=>import("./copilot-MbZr8wG3.js"),__vite__mapDeps([21,1,2,5,18,14,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),FC=y.lazy(()=>Dt(()=>import("./accounts-CBHdGCQd.js"),__vite__mapDeps([22,1,2,5,14,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),IC=y.lazy(()=>Dt(()=>Promise.resolve().then(()=>m2),void 0).then(a=>({default:a.SettingsPage}))),PC=y.lazy(()=>Dt(()=>import("./health-DYJGIuhY.js"),__vite__mapDeps([23,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),ew=y.lazy(()=>Dt(()=>import("./shared-BZUOuxLa.js"),__vite__mapDeps([24,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function ra(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(fa,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function tw(){return i.jsx(wv,{client:Jb,children:i.jsx(Fb,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(Ib,{children:i.jsx(aS,{children:i.jsxs(Nv,{children:[i.jsxs(jv,{children:[i.jsx(nn,{path:"/login",element:i.jsx(VC,{})}),i.jsx(nn,{element:i.jsx(lS,{}),children:i.jsxs(nn,{element:i.jsx(x1,{}),children:[i.jsx(nn,{path:"/",element:i.jsx(oj,{})}),i.jsx(nn,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(XC,{})})}),i.jsx(nn,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(ZC,{})})}),i.jsx(nn,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(WC,{})})}),i.jsx(nn,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(JC,{})})}),i.jsx(nn,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx($C,{})})}),i.jsx(nn,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(FC,{})})}),i.jsx(nn,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(IC,{})})}),i.jsx(nn,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(PC,{})})}),i.jsx(nn,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(ra,{}),children:i.jsx(ew,{})})})]})})]}),i.jsx(Ev,{position:"top-right"})]})})})})})}const Tx=document.getElementById("root");if(!Tx)throw new Error("Root element not found. Failed to mount React application.");Xb.createRoot(Tx).render(i.jsx(y.StrictMode,{children:i.jsx(tw,{})}));export{Yj as $,bj as A,Ya as B,_j as C,kw as D,BS as E,HS as F,LS as G,Fg as H,_n as I,od as J,La as K,yn as L,Uc as M,qw as N,Uj as O,Cg as P,Hw as Q,Bw as R,Le as S,mi as T,Lw as U,ex as V,Yw as W,Gw as X,Bj as Y,Qw as Z,Hj as _,qj as a,P1 as a0,fw as a1,yw as a2,vw as a3,Jc as a4,$c as a5,Fc as a6,Ic as a7,Pc as a8,bw as a9,Ow as aA,dw as aB,hw as aC,pw as aD,gw as aE,xw as aF,mw as aG,tx as aH,Dt as aI,sj as aJ,Dw as aK,id as aL,$g as aM,rd as aN,rx as aO,e2 as aP,n2 as aQ,Rr as aR,sx as aS,Kw as aa,Lj as ab,l1 as ac,K1 as ad,uS as ae,oS as af,u1 as ag,c1 as ah,d1 as ai,f1 as aj,Ir as ak,Qj as al,iS as am,rS as an,et as ao,Sw as ap,Nw as aq,jw as ar,Cw as as,Vw as at,ww as au,Tw as av,zw as aw,Ew as ax,Mw as ay,Aw as az,dt as b,K as c,Xw as d,Zw as e,h2 as f,QC as g,cw as h,kj as i,Rj as j,U1 as k,q1 as l,ml as m,Ww as n,hi as o,pi as p,_p as q,jj as r,Uw as s,mj as t,Xc as u,vj as v,_w as w,Rw as x,cj as y,xj as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as f,c as fe}from"./react-vendor-CNOkPC89.js";import{u as M,C as p,a as g,S as h,c as d,P as y,B as I,b as H,d as ee,e as pe,f as se,g as ge,h as te,i as N,j as S,k as je,l as Ne,m as ye,n as be}from"./index-nK4RTWya.js";import{z as we,a6 as ae,a7 as _,a8 as re,x as ne,Y as ve,G as ke,a9 as Ce,a3 as $e,v as Q,U as Se,Z as le,s as Le,a0 as G,aa as De,u as Te,b as Fe,ab as Re,ac as Me}from"./icons-B8zfgpli.js";import{u as Pe,a as P}from"./tanstack-C1q4365B.js";import{K as D,L as Y,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as ie,A as Be,C as Ue,X as qe,Y as V,T as oe,a as Z,P as Ie,b as Oe,c as Ke}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function Ee({data:s,isLoading:t}){const{privacyMode:a}=M();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(o=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},o))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:"Total Tokens",value:s?.totalTokens??0,icon:we,format:o=>R(o),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${R(s?.totalInputTokens??0)} in / ${R(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:o=>`$${o.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:_,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${l.toFixed(2)} (${r}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:o=>`$${o.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${R(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:o=>`$${o.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${R(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:i.map((o,n)=>{const c=o.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:o.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&y),children:o.format(o.value)}),o.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&y),children:o.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",o.bgColor),children:e.jsx(c,{className:d("h-4 w-4",o.color)})})]})})},n)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ge({model:s}){const{privacyMode:t}=M(),a=We(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&y),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:d("space-y-1",t&&y),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:_}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:_})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function W({label:s,tokens:t,cost:a,color:l,icon:r}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:l}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:He(t)})]})]})]})}function We(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function He(s){return s.toLocaleString()}function ze(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const _e="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${t}${a}${l}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),L(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${_e}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||a.statusText)}const l=await a.json();return l.data||l}function Ye(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Qe(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Xe(){const s=Pe();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:D(new Date,30),to:new Date}),[a,l]=f.useState(!1),[r,i]=f.useState(null),[o,n]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{l(!0);try{await u()}finally{l(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:b,isLoading:v}=Ye(j),{data:C,isLoading:$}=Qe(j),{data:A,isLoading:B}=Ve(j),{data:U,isLoading:q}=Ze(j),{data:z,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:D(F,1),to:F}),x("hourly")},[]),de=f.useCallback(F=>{t(F),x("daily")},[]),xe=f.useMemo(()=>K?.lastFetch?Y(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),ue=f.useCallback((F,he)=>{const E=he.currentTarget.getBoundingClientRect();n({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:z,status:K,isSummaryLoading:v,isTrendsLoading:$,isHourlyLoading:B,isModelsLoading:q,isSessionsLoading:O,isLoading:v||$||q||O,handleRefresh:m,handleTodayClick:ce,handleDateRangeChange:de,handleModelClick:ue,handlePopoverClose:me,lastUpdatedText:xe}}function ts({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:D(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:D(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:D(new Date,90),to:new Date}}],className:l}){const[r,i]=fe.useState(!1),o=n=>!s||!s.from||!s.to||!n.from||!n.to?!1:k(s.from,"yyyy-MM-dd")===k(n.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(n.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",l),children:[a.map(n=>e.jsx(H,{variant:o(n.range)?"default":"outline",size:"sm",onClick:()=>t(n.range),children:n.label},n.label)),e.jsxs(ee,{open:r,onOpenChange:i,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:d("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(ge,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:l,isRefreshing:r,lastUpdatedText:i,viewMode:o}){return e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(ts,{value:s,onChange:t,presets:[{label:"7D",range:{from:D(new Date,7),to:new Date}},{label:"30D",range:{from:D(new Date,30),to:new Date}},{label:"Month",range:{from:Ae(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",i]}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:l,disabled:r,children:e.jsx($e,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]})]})}function rs({data:s,isLoading:t,granularity:a="daily",className:l}){const{privacyMode:r}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(c=>{const x="hour"in c?c.hour:c.date;return{...c,dateFormatted:ns(x,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",l)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",l),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:n,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:n,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",r&&"blur-[4px]"),children:m})};return e.jsx("div",{className:d("w-full h-full",l),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Be,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(o,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(o,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:n,payload:c,label:x})=>{if(!n||!c||!c.length)return null;const u=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),c.map((m,j)=>e.jsxs("p",{className:d("text-sm",r&&y),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",r&&y),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ns(s,t){if(t==="hourly"){const[l,r]=s.split(" ");if(l&&r){const i=new Date(`${l}T${r}:00Z`);return k(i,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(n=>({name:n.model,value:n.tokens,cost:n.cost,percentage:n.percentage,fill:te(n.model)})),[s]);if(t)return e.jsx(h,{className:d("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:n,payload:c})=>{if(!n||!c)return null;const x=c;if(!x.length)return null;const u=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:["$",u.cost.toFixed(4)]})]})},o=n=>n.percentage>5?`${n.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Oe,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:o,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((n,c)=>e.jsx(Ke,{fill:n.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(oe,{content:i})]})})})}function is(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function os({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,n=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(n/i.length),u=i.reduce((b,v)=>b+v.cost,0)/i.length,m=i[0],j=m?Y(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:o,avgTokens:c,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):r?e.jsxs(p,{className:d("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",l&&y),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:r.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:i.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",l&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[cs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function cs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ds({className:s,isLoading:t}){const{data:a,isLoading:l}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||l||a?.running&&i)return e.jsxs(p,{className:d("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(p,{className:d("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(o)return e.jsxs(p,{className:d("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=r?.totalRequests??0,x=r?.quotaExceededCount??0,u=c-x,m=c>0?Math.round(u/c*100):100,j=r?.tokens?.total??0,b=Object.entries(r?.requestsByModel??{}).sort((C,$)=>$[1]-C[1]).slice(0,4),v=b.length>0?b[0][1]:1;return e.jsxs(p,{className:d("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:x>0?`${x} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(De,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Te,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:b.map(([C,$])=>{const A=Math.round($/v*100),B=xs(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:B}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:$})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${A}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ms({models:s,isLoading:t,onModelClick:a,privacyMode:l}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>a(r,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(hs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",l&&y),children:us(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",l&&y),children:["$",r.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(fs,{})]})})]})}function hs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function fs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function ps({viewMode:s,trends:t,hourlyData:a,models:l,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:n,isSessionsLoading:c,isSummaryLoading:x,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(p,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(rs,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsx(ms,{models:l,isLoading:n,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:l||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(os,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(ds,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ss(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ls(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:l,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n,summary:c,isSummaryLoading:x,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,handleModelClick:B,selectedModel:U,popoverPosition:q,handlePopoverClose:z}=ss();return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:a,onTodayClick:l,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(ps,{viewMode:n,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,isSummaryLoading:x,onModelClick:B}),e.jsxs(ee,{open:!!U,onOpenChange:O=>!O&&z(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(Ge,{model:U})})]})]})}export{Ls as AnalyticsPage,Ss as AnalyticsSkeleton};
|
|
1
|
+
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as f,c as fe}from"./react-vendor-CNOkPC89.js";import{u as M,C as p,a as g,S as h,c as d,P as y,B as I,b as H,d as ee,e as pe,f as se,g as ge,h as te,i as N,j as S,k as je,l as Ne,m as ye,n as be}from"./index-C1c994wt.js";import{z as we,a6 as ae,a7 as _,a8 as re,x as ne,Y as ve,G as ke,a9 as Ce,a3 as $e,v as Q,U as Se,Z as le,s as Le,a0 as G,aa as De,u as Te,b as Fe,ab as Re,ac as Me}from"./icons-B8zfgpli.js";import{u as Pe,a as P}from"./tanstack-C1q4365B.js";import{K as D,L as Y,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as ie,A as Be,C as Ue,X as qe,Y as V,T as oe,a as Z,P as Ie,b as Oe,c as Ke}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function Ee({data:s,isLoading:t}){const{privacyMode:a}=M();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(o=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},o))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:"Total Tokens",value:s?.totalTokens??0,icon:we,format:o=>R(o),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${R(s?.totalInputTokens??0)} in / ${R(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:o=>`$${o.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:_,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${l.toFixed(2)} (${r}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:o=>`$${o.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${R(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:o=>`$${o.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${R(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:i.map((o,n)=>{const c=o.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:o.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&y),children:o.format(o.value)}),o.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&y),children:o.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",o.bgColor),children:e.jsx(c,{className:d("h-4 w-4",o.color)})})]})})},n)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ge({model:s}){const{privacyMode:t}=M(),a=We(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&y),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:d("space-y-1",t&&y),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:_}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:_})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function W({label:s,tokens:t,cost:a,color:l,icon:r}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:l}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:He(t)})]})]})]})}function We(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function He(s){return s.toLocaleString()}function ze(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const _e="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${t}${a}${l}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),L(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${_e}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||a.statusText)}const l=await a.json();return l.data||l}function Ye(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Qe(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Xe(){const s=Pe();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:D(new Date,30),to:new Date}),[a,l]=f.useState(!1),[r,i]=f.useState(null),[o,n]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{l(!0);try{await u()}finally{l(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:b,isLoading:v}=Ye(j),{data:C,isLoading:$}=Qe(j),{data:A,isLoading:B}=Ve(j),{data:U,isLoading:q}=Ze(j),{data:z,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:D(F,1),to:F}),x("hourly")},[]),de=f.useCallback(F=>{t(F),x("daily")},[]),xe=f.useMemo(()=>K?.lastFetch?Y(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),ue=f.useCallback((F,he)=>{const E=he.currentTarget.getBoundingClientRect();n({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:z,status:K,isSummaryLoading:v,isTrendsLoading:$,isHourlyLoading:B,isModelsLoading:q,isSessionsLoading:O,isLoading:v||$||q||O,handleRefresh:m,handleTodayClick:ce,handleDateRangeChange:de,handleModelClick:ue,handlePopoverClose:me,lastUpdatedText:xe}}function ts({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:D(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:D(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:D(new Date,90),to:new Date}}],className:l}){const[r,i]=fe.useState(!1),o=n=>!s||!s.from||!s.to||!n.from||!n.to?!1:k(s.from,"yyyy-MM-dd")===k(n.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(n.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",l),children:[a.map(n=>e.jsx(H,{variant:o(n.range)?"default":"outline",size:"sm",onClick:()=>t(n.range),children:n.label},n.label)),e.jsxs(ee,{open:r,onOpenChange:i,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:d("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(ge,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:l,isRefreshing:r,lastUpdatedText:i,viewMode:o}){return e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(ts,{value:s,onChange:t,presets:[{label:"7D",range:{from:D(new Date,7),to:new Date}},{label:"30D",range:{from:D(new Date,30),to:new Date}},{label:"Month",range:{from:Ae(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",i]}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:l,disabled:r,children:e.jsx($e,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]})]})}function rs({data:s,isLoading:t,granularity:a="daily",className:l}){const{privacyMode:r}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(c=>{const x="hour"in c?c.hour:c.date;return{...c,dateFormatted:ns(x,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",l)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",l),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:n,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:n,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",r&&"blur-[4px]"),children:m})};return e.jsx("div",{className:d("w-full h-full",l),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Be,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(o,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(o,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:n,payload:c,label:x})=>{if(!n||!c||!c.length)return null;const u=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),c.map((m,j)=>e.jsxs("p",{className:d("text-sm",r&&y),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",r&&y),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ns(s,t){if(t==="hourly"){const[l,r]=s.split(" ");if(l&&r){const i=new Date(`${l}T${r}:00Z`);return k(i,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(n=>({name:n.model,value:n.tokens,cost:n.cost,percentage:n.percentage,fill:te(n.model)})),[s]);if(t)return e.jsx(h,{className:d("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:n,payload:c})=>{if(!n||!c)return null;const x=c;if(!x.length)return null;const u=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:["$",u.cost.toFixed(4)]})]})},o=n=>n.percentage>5?`${n.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Oe,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:o,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((n,c)=>e.jsx(Ke,{fill:n.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(oe,{content:i})]})})})}function is(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function os({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,n=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(n/i.length),u=i.reduce((b,v)=>b+v.cost,0)/i.length,m=i[0],j=m?Y(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:o,avgTokens:c,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):r?e.jsxs(p,{className:d("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",l&&y),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:r.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:i.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",l&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[cs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function cs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ds({className:s,isLoading:t}){const{data:a,isLoading:l}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||l||a?.running&&i)return e.jsxs(p,{className:d("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(p,{className:d("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(o)return e.jsxs(p,{className:d("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=r?.totalRequests??0,x=r?.quotaExceededCount??0,u=c-x,m=c>0?Math.round(u/c*100):100,j=r?.tokens?.total??0,b=Object.entries(r?.requestsByModel??{}).sort((C,$)=>$[1]-C[1]).slice(0,4),v=b.length>0?b[0][1]:1;return e.jsxs(p,{className:d("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:x>0?`${x} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(De,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Te,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:b.map(([C,$])=>{const A=Math.round($/v*100),B=xs(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:B}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:$})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${A}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ms({models:s,isLoading:t,onModelClick:a,privacyMode:l}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>a(r,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(hs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",l&&y),children:us(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",l&&y),children:["$",r.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(fs,{})]})})]})}function hs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function fs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function ps({viewMode:s,trends:t,hourlyData:a,models:l,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:n,isSessionsLoading:c,isSummaryLoading:x,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(p,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(rs,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsx(ms,{models:l,isLoading:n,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:l||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(os,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(ds,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ss(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ls(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:l,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n,summary:c,isSummaryLoading:x,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,handleModelClick:B,selectedModel:U,popoverPosition:q,handlePopoverClose:z}=ss();return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:a,onTodayClick:l,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(ps,{viewMode:n,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,isSummaryLoading:x,onModelClick:B}),e.jsxs(ee,{open:!!U,onOpenChange:O=>!O&&z(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(Ge,{model:U})})]})]})}export{Ls as AnalyticsPage,Ss as AnalyticsSkeleton};
|