@kaitranntt/ccs 7.37.1-dev.5 → 7.37.1-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cliproxy/config/generator.d.ts +3 -2
  2. package/dist/cliproxy/config/generator.d.ts.map +1 -1
  3. package/dist/cliproxy/config/generator.js +87 -5
  4. package/dist/cliproxy/config/generator.js.map +1 -1
  5. package/dist/cliproxy/model-catalog.d.ts.map +1 -1
  6. package/dist/cliproxy/model-catalog.js +15 -2
  7. package/dist/cliproxy/model-catalog.js.map +1 -1
  8. package/dist/cliproxy/platform-detector.d.ts +4 -4
  9. package/dist/cliproxy/platform-detector.d.ts.map +1 -1
  10. package/dist/cliproxy/platform-detector.js +2 -2
  11. package/dist/cliproxy/platform-detector.js.map +1 -1
  12. package/dist/ui/assets/{accounts-CGO2ohEG.js → accounts-ResKjvou.js} +1 -1
  13. package/dist/ui/assets/{alert-dialog-6R5Pi5Cc.js → alert-dialog-BnSvEwhd.js} +1 -1
  14. package/dist/ui/assets/{api-BMhxtrFX.js → api-ClPWraVr.js} +1 -1
  15. package/dist/ui/assets/{auth-section-pzW5V_lL.js → auth-section-CZmgtezT.js} +1 -1
  16. package/dist/ui/assets/{backups-section-3MlLTjjt.js → backups-section-CcQsXemH.js} +1 -1
  17. package/dist/ui/assets/{cliproxy-BMlmKo8O.js → cliproxy-C0JgtLfO.js} +1 -1
  18. package/dist/ui/assets/{cliproxy-control-panel-CpqCbUD-.js → cliproxy-control-panel-CBO7xTqe.js} +1 -1
  19. package/dist/ui/assets/{confirm-dialog-CKOO979H.js → confirm-dialog-Cjs1FPCy.js} +1 -1
  20. package/dist/ui/assets/{copilot-YcRs-dpA.js → copilot-DCA0pQV3.js} +2 -2
  21. package/dist/ui/assets/{globalenv-section-DbFrItxR.js → globalenv-section-D_GVHsDN.js} +1 -1
  22. package/dist/ui/assets/{health-BoF1pfCd.js → health-riN3OSz-.js} +1 -1
  23. package/dist/ui/assets/{index-DMVmIdhk.js → index-7gcYb5Oq.js} +2 -2
  24. package/dist/ui/assets/{index-BkS1PcE3.js → index-BXTtPkoG.js} +1 -1
  25. package/dist/ui/assets/{index-B8vZ3mdL.js → index-BjiZGSfI.js} +1 -1
  26. package/dist/ui/assets/{index-dKV_gFuv.js → index-CK0URaBN.js} +1 -1
  27. package/dist/ui/assets/{index-BjQ_pRzR.js → index-sdtPg8Gr.js} +1 -1
  28. package/dist/ui/assets/{proxy-status-widget-B26Bjz-k.js → proxy-status-widget-B-LQxeOH.js} +1 -1
  29. package/dist/ui/assets/{shared-Bl5j6dWI.js → shared-PuUIRrgy.js} +1 -1
  30. package/dist/ui/assets/{switch-CM7sGtMc.js → switch-CCYYFslZ.js} +1 -1
  31. package/dist/ui/index.html +1 -1
  32. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-dKV_gFuv.js","assets/radix-ui-qEZD5MMp.js","assets/react-vendor-CNOkPC89.js","assets/switch-CM7sGtMc.js","assets/icons-D5eAI-GR.js","assets/tanstack-De4wvi8X.js","assets/notifications-B2HqRBj7.js","assets/utils-CzKF5WmX.js","assets/form-utils-C-pVd1--.js","assets/code-highlight-BRUf_pqB.js","assets/globalenv-section-DbFrItxR.js","assets/index-BjQ_pRzR.js","assets/index-B8vZ3mdL.js","assets/proxy-status-widget-B26Bjz-k.js","assets/alert-dialog-6R5Pi5Cc.js","assets/auth-section-pzW5V_lL.js","assets/backups-section-3MlLTjjt.js","assets/index-BkS1PcE3.js","assets/charts-BBPXh0Ar.js","assets/api-BMhxtrFX.js","assets/confirm-dialog-CKOO979H.js","assets/cliproxy-BMlmKo8O.js","assets/cliproxy-control-panel-CpqCbUD-.js","assets/copilot-YcRs-dpA.js","assets/accounts-CGO2ohEG.js","assets/health-BoF1pfCd.js","assets/shared-Bl5j6dWI.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CK0URaBN.js","assets/radix-ui-qEZD5MMp.js","assets/react-vendor-CNOkPC89.js","assets/switch-CCYYFslZ.js","assets/icons-D5eAI-GR.js","assets/tanstack-De4wvi8X.js","assets/notifications-B2HqRBj7.js","assets/utils-CzKF5WmX.js","assets/form-utils-C-pVd1--.js","assets/code-highlight-BRUf_pqB.js","assets/globalenv-section-D_GVHsDN.js","assets/index-sdtPg8Gr.js","assets/index-BjiZGSfI.js","assets/proxy-status-widget-B-LQxeOH.js","assets/alert-dialog-BnSvEwhd.js","assets/auth-section-CZmgtezT.js","assets/backups-section-CcQsXemH.js","assets/index-BXTtPkoG.js","assets/charts-BBPXh0Ar.js","assets/api-ClPWraVr.js","assets/confirm-dialog-Cjs1FPCy.js","assets/cliproxy-C0JgtLfO.js","assets/cliproxy-control-panel-CBO7xTqe.js","assets/copilot-DCA0pQV3.js","assets/accounts-ResKjvou.js","assets/health-riN3OSz-.js","assets/shared-PuUIRrgy.js"])))=>i.map(i=>d[i]);
2
2
  import{j as i,S as Qr,R as ug,C as cg,a as dg,T as fg,D as mg,P as hg,O as pg,b as nv,c as av,d as lv,e as sv,f as iv,A as rv,g as ov,h as uv,i as cv,k as dv,l as fv,m as mv,n as hv,I as pv,o as gg,V as gv,p as xv,q as xg,r as yv,L as yg,s as vg,t as bg,u as vv,v as bv,w as Sg,x as Sv,y as jg,z as Ng,B as jv,E as Cg,F as Nv,G as wg,H as Eg,J as Cv,K as wv,M as Mg,N as Ev,Q as Mv,U as Tv,W as Ov,X as Tg,Y as Av,Z as zv,_ as Dv}from"./radix-ui-qEZD5MMp.js";import{e as Og,f as _v,r as y,u as Yc,O as _c,N as kv,h as Gc,L as kc,R as Rv,g as Uv,i as qv,c as I,B as Bv,j as Hv,k as nn}from"./react-vendor-CNOkPC89.js";import{Q as Lv,u as At,a as ut,b as mt,c as Yv}from"./tanstack-De4wvi8X.js";import{t as le,T as Gv}from"./notifications-B2HqRBj7.js";import{L as Un,X as xi,P as Kv,H as Qv,C as Vv,K as Ag,G as Xv,Z as zg,a as Dg,F as _g,U as kg,A as fi,S as Zv,b as Vr,c as Wv,M as $v,E as Xr,d as Zr,B as Jv,R as mi,W as Pv,e as Fv,f as Iv,g as eb,h as mp,i as hp,j as rs,k as Kc,l as Hr,m as Rg,n as tb,o as nb,p as Qc,q as Wr,r as Vc,s as ab,t as lb,u as $r,v as sb,T as Qa,w as ib,x as rb,I as Jr,y as ob,z as ub,D as cb,J as db,N as fb,O as mb,Q as hb,V as Xc,Y as Pr,_ as Zc,$ as pp,a0 as pb,a1 as Wc,a2 as gb,a3 as xb,a4 as yb,a5 as vb,a6 as gp,a7 as bb,a8 as Sb}from"./icons-D5eAI-GR.js";import{t as jb,c as Nb,a as Fr,e as li,f as ri,b as Cb,d as wb,g as Eb,h as Mb,i as Tb,j as Ob,k as Ab,l as zb,m as Db,n as _b,o as kb,p as Rb,q as Ub,r as qb,s as Bb,u as Hb,v as Lb,w as Yb,x as Gb,y as Kb,z as Qb,A as Vb,B as Xb,C as Zb,D as Wb,E as $b,F as Jb,G as Pb,H as Fb,I as Ib,J as eS}from"./utils-CzKF5WmX.js";import{o as xp,s as yp,p as tS,a as nS,$ as aS,b as Ug,c as lS,d as cl,u as sS,e as iS}from"./form-utils-C-pVd1--.js";import{H as rS,t as vp}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 xc={exports:{}},si={},yc={exports:{}},vc={};var bp;function oS(){return bp||(bp=1,(function(a){function s(O,W){var se=O.length;O.push(W);e:for(;0<se;){var ye=se-1>>>1,ve=O[ye];if(0<d(ve,W))O[ye]=W,O[se]=ve,se=ye;else break e}}function o(O){return O.length===0?null:O[0]}function u(O){if(O.length===0)return null;var W=O[0],se=O.pop();if(se!==W){O[0]=se;e:for(var ye=0,ve=O.length,De=ve>>>1;ye<De;){var ze=2*(ye+1)-1,X=O[ze],J=ze+1,ne=O[J];if(0>d(X,se))J<ve&&0>d(ne,X)?(O[ye]=ne,O[J]=se,ye=J):(O[ye]=X,O[ze]=se,ye=ze);else if(J<ve&&0>d(ne,se))O[ye]=ne,O[J]=se,ye=J;else break e}}return W}function d(O,W){var se=O.sortIndex-W.sortIndex;return se!==0?se:O.id-W.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=[],b=[],w=1,v=null,S=3,M=!1,A=!1,U=!1,_=!1,T=typeof setTimeout=="function"?setTimeout:null,K=typeof clearTimeout=="function"?clearTimeout:null,B=typeof setImmediate<"u"?setImmediate:null;function L(O){for(var W=o(b);W!==null;){if(W.callback===null)u(b);else if(W.startTime<=O)u(b),W.sortIndex=W.expirationTime,s(x,W);else break;W=o(b)}}function k(O){if(U=!1,L(O),!A)if(o(x)!==null)A=!0,N||(N=!0,oe());else{var W=o(b);W!==null&&P(k,W.startTime-O)}}var N=!1,H=-1,Z=5,te=-1;function ce(){return _?!0:!(a.unstable_now()-te<Z)}function be(){if(_=!1,N){var O=a.unstable_now();te=O;var W=!0;try{e:{A=!1,U&&(U=!1,K(H),H=-1),M=!0;var se=S;try{t:{for(L(O),v=o(x);v!==null&&!(v.expirationTime>O&&ce());){var ye=v.callback;if(typeof ye=="function"){v.callback=null,S=v.priorityLevel;var ve=ye(v.expirationTime<=O);if(O=a.unstable_now(),typeof ve=="function"){v.callback=ve,L(O),W=!0;break t}v===o(x)&&u(x),L(O)}else u(x);v=o(x)}if(v!==null)W=!0;else{var De=o(b);De!==null&&P(k,De.startTime-O),W=!1}}break e}finally{v=null,S=se,M=!1}W=void 0}}finally{W?oe():N=!1}}}var oe;if(typeof B=="function")oe=function(){B(be)};else if(typeof MessageChannel<"u"){var Ye=new MessageChannel,je=Ye.port2;Ye.port1.onmessage=be,oe=function(){je.postMessage(null)}}else oe=function(){T(be,0)};function P(O,W){H=T(function(){O(a.unstable_now())},W)}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(O){O.callback=null},a.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Z=0<O?Math.floor(1e3/O):5},a.unstable_getCurrentPriorityLevel=function(){return S},a.unstable_next=function(O){switch(S){case 1:case 2:case 3:var W=3;break;default:W=S}var se=S;S=W;try{return O()}finally{S=se}},a.unstable_requestPaint=function(){_=!0},a.unstable_runWithPriority=function(O,W){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var se=S;S=O;try{return W()}finally{S=se}},a.unstable_scheduleCallback=function(O,W,se){var ye=a.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0<se?ye+se:ye):se=ye,O){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=se+ve,O={id:w++,callback:W,priorityLevel:O,startTime:se,expirationTime:ve,sortIndex:-1},se>ye?(O.sortIndex=se,s(b,O),o(x)===null&&O===o(b)&&(U?(K(H),H=-1):U=!0,P(k,se-ye))):(O.sortIndex=ve,s(x,O),A||M||(A=!0,N||(N=!0,oe()))),O},a.unstable_shouldYield=ce,a.unstable_wrapCallback=function(O){var W=S;return function(){var se=S;S=W;try{return O.apply(this,arguments)}finally{S=se}}}})(vc)),vc}var Sp;function uS(){return Sp||(Sp=1,yc.exports=oS()),yc.exports}var jp;function cS(){if(jp)return si;jp=1;var a=uS(),s=Og(),o=_v();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 b(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 w(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=w(e),t!==null)return t;e=e.sibling}return null}var v=Object.assign,S=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),U=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),K=Symbol.for("react.consumer"),B=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),te=Symbol.for("react.activity"),ce=Symbol.for("react.memo_cache_sentinel"),be=Symbol.iterator;function oe(e){return e===null||typeof e!="object"?null:(e=be&&e[be]||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 U:return"Fragment";case T:return"Profiler";case _:return"StrictMode";case k:return"Suspense";case N:return"SuspenseList";case te:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case A:return"Portal";case B:return e.displayName||"Context";case K:return(e._context.displayName||"Context")+".Consumer";case L:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return t=e.displayName||null,t!==null?t:je(e.type)||"Memo";case Z:t=e._payload,e=e._init;try{return je(e(t))}catch{}}return null}var P=Array.isArray,O=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ye=[],ve=-1;function De(e){return{current:e}}function ze(e){0>ve||(e.current=ye[ve],ye[ve]=null,ve--)}function X(e,t){ve++,ye[ve]=e.current,e.current=t}var J=De(null),ne=De(null),F=De(null),ee=De(null);function fe(e,t){switch(X(F,t),X(ne,e),X(J,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Uh(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Uh(t),e=qh(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ze(J),X(J,e)}function Ae(){ze(J),ze(ne),ze(F)}function Ge(e){e.memoizedState!==null&&X(ee,e);var t=J.current,n=qh(t,e.type);t!==n&&(X(ne,e),X(J,n))}function yt(e){ne.current===e&&(ze(J),ze(ne)),ee.current===e&&(ze(ee),ei._currentValue=se)}var vt,Qe;function tt(e){if(vt===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);vt=t&&t[1]||"",Qe=-1<n.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+vt+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 V=function(){throw Error()};if(Object.defineProperty(V.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(V,[])}catch(q){var R=q}Reflect.construct(e,[],V)}else{try{V.call()}catch(q){R=q}e.call(V.prototype)}}else{try{throw Error()}catch(q){R=q}(V=e())&&typeof V.catch=="function"&&V.catch(function(){})}}catch(q){if(q&&R&&typeof q.stack=="string")return[q.stack,R.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 j=f.split(`
@@ -44,4 +44,4 @@ Error generating stack: `+l.message+`
44
44
  `).map(function(ms,hs){return hs>=Dt&&hs<=Gn?re+ms:ms}).join(`
45
45
  `),selectionStart:xe&&/\S/.test(xe)?Me+re.length:Me,selectionEnd:nt+re.length*(Gn-Dt+1)})}else{var St=Me+re.length;Tn({value:me.substring(0,Me)+re+me.substring(nt),selectionStart:St,selectionEnd:St})}else if($.key==="Backspace"){var Wt=Me!==nt,vn=me.substring(0,Me);if(vn.endsWith(re)&&!Wt){$.preventDefault();var St=Me-re.length;Tn({value:me.substring(0,Me-re.length)+me.substring(nt),selectionStart:St,selectionEnd:St})}}else if($.key==="Enter"){if(Me===nt){var ds=Zt(me,Me).pop(),Xa=ds?.match(/^\s+/);if(Xa?.[0]){$.preventDefault();var fs=`
46
46
  `+Xa[0],St=Me+fs.length;Tn({value:me.substring(0,Me)+fs+me.substring(nt),selectionStart:St,selectionEnd:St})}}}else if($.keyCode===b||$.keyCode===w||$.keyCode===v||$.keyCode===S){var rn=void 0;$.keyCode===b&&$.shiftKey?rn=["(",")"]:$.keyCode===w?$.shiftKey?rn=["{","}"]:rn=["[","]"]:$.keyCode===v?$.shiftKey?rn=['"','"']:rn=["'","'"]:$.keyCode===S&&!$.shiftKey&&(rn=["`","`"]),Me!==nt&&rn&&($.preventDefault(),Tn({value:me.substring(0,Me)+rn[0]+me.substring(Me,nt)+rn[1]+me.substring(nt),selectionStart:Me,selectionEnd:nt+2}))}else(_?$.metaKey&&$.keyCode===p:$.ctrlKey&&$.keyCode===p)&&!$.shiftKey&&!$.altKey?($.preventDefault(),xl()):(_?$.metaKey&&$.keyCode===p&&$.shiftKey:U?$.ctrlKey&&$.keyCode===h:$.ctrlKey&&$.keyCode===p&&$.shiftKey)&&!$.altKey?($.preventDefault(),us()):$.keyCode===x&&$.ctrlKey&&(!_||$.shiftKey)&&($.preventDefault(),ma(function(Kn){return!Kn}))}},Yn=function($){var Ee=$.currentTarget,me=Ee.value,Me=Ee.selectionStart,nt=Ee.selectionEnd;Ln({value:me,selectionStart:Me,selectionEnd:nt},!0),J(me)};return m.useEffect(function(){Va()},[Va]),m.useImperativeHandle(H,function(){return{get session(){return{history:Ne.current}},set session($){Ne.current=$.history}}},[]),m.createElement("div",a({},Bn,{style:a(a({},L.container),yt)}),m.createElement("pre",a({className:fe,"aria-hidden":"true",style:a(a(a({},L.editor),L.highlight),Hn)},typeof ct=="string"?{dangerouslySetInnerHTML:{__html:ct+"<br />"}}:{children:ct})),m.createElement("textarea",{ref:function($){return Vt.current=$},style:a(a(a({},L.editor),L.textarea),Hn),className:T+(tt?" ".concat(tt):""),id:kt,value:Qt,onChange:Yn,onKeyDown:cs,onClick:ve,onKeyUp:X,onFocus:De,onBlur:ye,disabled:te,form:ce,maxLength:O,minLength:W,name:se,placeholder:ee,readOnly:Ae,required:Ge,autoFocus:Z,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),m.createElement("style",{dangerouslySetInnerHTML:{__html:K}}))}),L={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=B,Gt}var D2=z2();const _2=Uv(D2),k2=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function R2(a){return k2.some(s=>s.test(a))}function U2(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 bx({value:a,onChange:s,language:o="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=Kg(),[p,x]=y.useState(!1),[b,w]=y.useState(!0),v=y.useMemo(()=>o==="json"?U2(a):{valid:!0},[a,o]),S=y.useCallback(M=>i.jsx(rS,{theme:h?vp.nightOwl:vp.github,code:M,language:o,children:({tokens:A,getLineProps:U,getTokenProps:_})=>{let T=!1;return i.jsx(i.Fragment,{children:A.map((K,B)=>i.jsx("div",{...U({line:K}),className:G(v.line===B+1&&"bg-destructive/20"),children:K.map((L,k)=>{let N=!1;if(L.types.includes("property")){const Z=L.content.replace(/['"]/g,"");R2(Z)?T=!0:T=!1}else(L.types.includes("string")||L.types.includes("number")||L.types.includes("boolean"))&&T?(N=!0,T=!1):L.types.includes("punctuation")&&L.content!==":"&&L.content!=="["&&L.content!=="{"&&(T=!1);const H=_({token:L});return N&&b&&(H.className=G(H.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...H},k)})},B))})}}),[h,o,v.line,b]);return i.jsxs("div",{className:G("flex flex-col",d),children:[i.jsxs("div",{className:G("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(_2,{value:a,onValueChange:u?()=>{}:s,highlight:S,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:G("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(ot,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>w(!b),title:b?"Reveal sensitive values":"Mask sensitive values",children:b?i.jsx(Zr,{className:"h-3 w-3"}):i.jsx(Xr,{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(Wr,{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(Wc,{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:bx},Symbol.toStringTag,{value:"Module"})),q2={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 B2(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 jx=y.createContext(null);function H2({children:a}){const[s,o]=y.useReducer(B2,q2);return i.jsx(jx.Provider,{value:{state:s,dispatch:o},children:a})}function Nx(){const a=y.useContext(jx);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function L2(){const{dispatch:a}=Nx(),s=y.useCallback(N=>a({type:"SET_WEBSEARCH_CONFIG",payload:N}),[a]),o=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS",payload:N}),[a]),u=y.useCallback(N=>a({type:"SET_WEBSEARCH_LOADING",payload:N}),[a]),d=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:N}),[a]),m=y.useCallback(N=>a({type:"SET_WEBSEARCH_SAVING",payload:N}),[a]),h=y.useCallback(N=>a({type:"SET_WEBSEARCH_ERROR",payload:N}),[a]),p=y.useCallback(N=>a({type:"SET_WEBSEARCH_SUCCESS",payload:N}),[a]),x=y.useCallback(N=>a({type:"SET_GLOBALENV_CONFIG",payload:N}),[a]),b=y.useCallback(N=>a({type:"SET_GLOBALENV_LOADING",payload:N}),[a]),w=y.useCallback(N=>a({type:"SET_GLOBALENV_SAVING",payload:N}),[a]),v=y.useCallback(N=>a({type:"SET_GLOBALENV_ERROR",payload:N}),[a]),S=y.useCallback(N=>a({type:"SET_GLOBALENV_SUCCESS",payload:N}),[a]),M=y.useCallback(N=>a({type:"SET_PROXY_CONFIG",payload:N}),[a]),A=y.useCallback(N=>a({type:"SET_PROXY_LOADING",payload:N}),[a]),U=y.useCallback(N=>a({type:"SET_PROXY_SAVING",payload:N}),[a]),_=y.useCallback(N=>a({type:"SET_PROXY_ERROR",payload:N}),[a]),T=y.useCallback(N=>a({type:"SET_PROXY_SUCCESS",payload:N}),[a]),K=y.useCallback(N=>a({type:"SET_PROXY_TEST_RESULT",payload:N}),[a]),B=y.useCallback(N=>a({type:"SET_PROXY_TESTING",payload:N}),[a]),L=y.useCallback(N=>a({type:"SET_RAW_CONFIG",payload:N}),[a]),k=y.useCallback(N=>a({type:"SET_RAW_CONFIG_LOADING",payload:N}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:o,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:b,setGlobalEnvSaving:w,setGlobalEnvError:v,setGlobalEnvSuccess:S,setProxyConfig:M,setProxyLoading:A,setProxySaving:U,setProxyError:_,setProxySuccess:T,setProxyTestResult:K,setProxyTesting:B,setRawConfig:L,setRawConfigLoading:k}),[s,o,u,d,m,h,p,x,b,w,v,S,M,A,U,_,T,K,B,L,k])}function Y2(){const[a,s]=qv(),o=a.get("tab")?.toLowerCase(),u=o==="globalenv"?"globalenv":o==="proxy"?"proxy":o==="auth"?"auth":o==="thinking"?"thinking":o==="backups"?"backups":"websearch",d=y.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function G2(){const{state:a}=Nx(),s=L2(),[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}}const K2=[{value:"websearch",label:"Web",icon:gb},{value:"globalenv",label:"Env",icon:Zc},{value:"thinking",label:"Think",icon:xb},{value:"proxy",label:"Proxy",icon:yb},{value:"auth",label:"Auth",icon:Kc},{value:"backups",label:"Backup",icon:vb}];function Zp({activeTab:a,onTabChange:s}){return i.jsx(mx,{value:a,onValueChange:o=>s(o),children:i.jsx(pd,{className:"grid w-full grid-cols-6",children:K2.map(({value:o,label:u,icon:d})=>i.jsxs(Kr,{value:o,className:"gap-1.5 px-1 text-xs",children:[i.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:u})]},o))})})}function Wp(){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 Cx(a,s=3,o=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,o)).then(()=>Cx(a,s-1,o*2))})}function os(a){return y.lazy(()=>Cx(a))}const $p=os(()=>zt(()=>import("./index-dKV_gFuv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Jp=os(()=>zt(()=>import("./globalenv-section-DbFrItxR.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),Pp=os(()=>zt(()=>import("./index-BjQ_pRzR.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),Fp=os(()=>zt(()=>import("./index-B8vZ3mdL.js"),__vite__mapDeps([12,1,2,3,4,13,14,5,6,7,8,9]))),Ip=os(()=>zt(()=>import("./auth-section-pzW5V_lL.js"),__vite__mapDeps([15,1,2,4,5,6,7,8,9]))),eg=os(()=>zt(()=>import("./backups-section-3MlLTjjt.js"),__vite__mapDeps([16,1,2,14,4,5,6,7,8,9])));class tg 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(Wc,{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(ot,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(mi,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function Q2(){const{activeTab:a,setActiveTab:s}=Y2(),{rawConfig:o,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=G2();y.useEffect(()=>{m()},[m]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsxs("div",{className:"h-[calc(100vh-100px)]",children:[i.jsxs("div",{className:"md:hidden h-full flex flex-col",children:[i.jsx("div",{className:"border-b bg-background p-4",children:i.jsx(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]}),i.jsxs(dd,{direction:"horizontal",className:"h-full hidden md:flex",children:[i.jsx(hi,{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(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]})}),i.jsx(fd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx($r,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(hi,{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(gp,{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(ot,{variant:"outline",size:"sm",onClick:h,disabled:!o,children:d?i.jsxs(i.Fragment,{children:[i.jsx(rs,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Hr,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(ot,{variant:"outline",size:"sm",onClick:m,disabled:u,children:i.jsx(mi,{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(mi,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):o?i.jsx(bx,{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(gp,{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 V2(){return i.jsx(H2,{children:i.jsx(Q2,{})})}const X2=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:V2},Symbol.toStringTag,{value:"Module"})),AE=Av,zE=Dv,DE=zv,Z2=y.forwardRef(({className:a,align:s="center",sideOffset:o=4,...u},d)=>i.jsx(Ov,{children:i.jsx(Tg,{ref:d,align:s,sideOffset:o,className:G("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})}));Z2.displayName=Tg.displayName;function W2(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 $2={},di={};function fl(a,s){try{const u=($2[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in di?di[u]:ng(u,u.split(":"))}catch{if(a in di)return di[a];const o=a?.match(J2);return o?ng(a,o.slice(1)):NaN}}const J2=/([+-]\d\d):?(\d\d)?/;function ng(a,s){const o=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return di[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(fl(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)),wx(this),Lc(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=-fl(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Lc(this),+this}[Symbol.for("constructDateFrom")](s){return new Rn(+new Date(s),this.timeZone)}}const ag=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!ag.test(a))return;const s=a.replace(ag,"$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),P2(this),+this},Rn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Lc(this),+this}))});function Lc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-fl(a.timeZone,a)*60))}function P2(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()),wx(a)}function wx(a){const s=fl(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 b=new Date(+a);b.setUTCSeconds(0);const w=d>0?b.getSeconds():(b.getSeconds()-60)%60,v=Math.round(-(fl(a.timeZone,a)*60))%60;(v||w)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+w));const S=fl(a.timeZone,a),M=S>0?Math.floor(S):Math.ceil(S),U=-new Date(+a).getTimezoneOffset()-M,_=M!==o,T=U-x;if(_&&T){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+T);const K=fl(a.timeZone,a),B=K>0?Math.floor(K):Math.ceil(K),L=M-B;L&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+L),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+L))}}class ca extends Rn{static tz(s,...o){return o.length?new ca(...o,s):new ca(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} (${W2(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 ca(+this,s)}[Symbol.for("constructDateFrom")](s){return new ca(+new Date(s),this.timeZone)}}const lg=5,F2=4;function I2(a,s){const o=s.startOfMonth(a),u=o.getDay()>0?o.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,lg*7-1);return s.getMonth(a)===s.getMonth(m)?lg:F2}function Ex(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 eC(a,s){const o=Ex(a,s),u=I2(a,s);return s.addDays(o,u*7-1)}const Mx={...li,labels:{labelDayButton:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ri(h,p,{locale:li,...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)=>ri(d,m,{locale:li,...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)=>ri(h,p,{locale:li,...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)=>ri(d,m,{locale:li,...s}),u(a,"cccc")}}};class sn{constructor(s,o){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ca.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 ca(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):Cb(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):wb(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):Eb(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):Mb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):Tb(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):Ob(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Ab(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):zb(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):eC(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Db(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):_b(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):kb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Rb(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ri(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):Ub(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):qb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Bb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Hb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Lb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):Yb(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Gb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Kb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Qb(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Vb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Xb(u),this.min=u=>this.overrides?.min?this.overrides.min(u):Zb(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Wb(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):$b(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):Ex(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Jb(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Pb(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Fb(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):Ib(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):eS(u),this.options={locale:Mx,...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 qn=new sn;class Tx{constructor(s,o,u=qn){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 tC{constructor(s,o){this.date=s,this.weeks=o}}class nC{constructor(s,o){this.days=o,this.weekNumber=s}}function aC(a){return I.createElement("button",{...a})}function lC(a){return I.createElement("span",{...a})}function sC(a){const{size:s=24,orientation:o="left",className:u}=a;return I.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},o==="up"&&I.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),o==="down"&&I.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),o==="left"&&I.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),o==="right"&&I.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function iC(a){const{day:s,modifiers:o,...u}=a;return I.createElement("td",{...u})}function rC(a){const{day:s,modifiers:o,...u}=a,d=I.useRef(null);return I.useEffect(()=>{o.focused&&d.current?.focus()},[o.focused]),I.createElement("button",{ref:d,...u})}var ue;(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"})(ue||(ue={}));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 oC(a){const{options:s,className:o,components:u,classNames:d,...m}=a,h=[d[ue.Dropdown],o].join(" "),p=s?.find(({value:x})=>x===m.value);return I.createElement("span",{"data-disabled":m.disabled,className:d[ue.DropdownRoot]},I.createElement(u.Select,{className:h,...m},s?.map(({value:x,label:b,disabled:w})=>I.createElement(u.Option,{key:x,value:x,disabled:w},b))),I.createElement("span",{className:d[ue.CaptionLabel],"aria-hidden":!0},p?.label,I.createElement(u.Chevron,{orientation:"down",size:18,className:d[ue.Chevron]})))}function uC(a){return I.createElement("div",{...a})}function cC(a){return I.createElement("div",{...a})}function dC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u},a.children)}function fC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u})}function mC(a){return I.createElement("table",{...a})}function hC(a){return I.createElement("div",{...a})}const Ox=y.createContext(void 0);function yi(){const a=y.useContext(Ox);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function pC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}function gC(a){const{onPreviousClick:s,onNextClick:o,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:x,labelNext:b}}=yi(),w=y.useCallback(S=>{d&&o?.(S)},[d,o]),v=y.useCallback(S=>{u&&s?.(S)},[u,s]);return I.createElement("nav",{...m},I.createElement(h.PreviousMonthButton,{type:"button",className:p[ue.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},I.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[ue.Chevron],orientation:"left"})),I.createElement(h.NextMonthButton,{type:"button",className:p[ue.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":b(d),onClick:w},I.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[ue.Chevron]})))}function xC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function yC(a){return I.createElement("option",{...a})}function vC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function bC(a){const{rootRef:s,...o}=a;return I.createElement("div",{...o,ref:s})}function SC(a){return I.createElement("select",{...a})}function jC(a){const{week:s,...o}=a;return I.createElement("tr",{...o})}function NC(a){return I.createElement("th",{...a})}function CC(a){return I.createElement("thead",{"aria-hidden":!0},I.createElement("tr",{...a}))}function wC(a){const{week:s,...o}=a;return I.createElement("th",{...o})}function EC(a){return I.createElement("th",{...a})}function MC(a){return I.createElement("tbody",{...a})}function TC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}const OC=Object.freeze(Object.defineProperty({__proto__:null,Button:aC,CaptionLabel:lC,Chevron:sC,Day:iC,DayButton:rC,Dropdown:oC,DropdownNav:uC,Footer:cC,Month:dC,MonthCaption:fC,MonthGrid:mC,Months:hC,MonthsDropdown:pC,Nav:gC,NextMonthButton:xC,Option:yC,PreviousMonthButton:vC,Root:bC,Select:SC,Week:jC,WeekNumber:wC,WeekNumberHeader:EC,Weekday:NC,Weekdays:CC,Weeks:MC,YearsDropdown:TC},Symbol.toStringTag,{value:"Module"}));function da(a,s,o=!1,u=qn){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 xd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function so(a){return!!(a&&typeof a=="object"&&"from"in a)}function yd(a){return!!(a&&typeof a=="object"&&"after"in a)}function vd(a){return!!(a&&typeof a=="object"&&"before"in a)}function Ax(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function zx(a,s){return Array.isArray(a)&&a.every(s.isDate)}function fa(a,s,o=qn){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(zx(p,o))return p.some(x=>d(a,x));if(so(p))return da(p,a,!1,o);if(Ax(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(xd(p)){const x=m(p.before,a),b=m(p.after,a),w=x>0,v=b<0;return h(p.before,p.after)?v&&w:w||v}return yd(p)?m(a,p.after)>0:vd(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function AC(a,s,o,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:x,broadcastCalendar:b,today:w=d.today()}=s,{isSameDay:v,isSameMonth:S,startOfMonth:M,isBefore:A,endOfMonth:U,isAfter:_}=d,T=o&&M(o),K=u&&U(u),B={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},L={};for(const k of a){const{date:N,displayMonth:H}=k,Z=!!(H&&!S(N,H)),te=!!(T&&A(N,T)),ce=!!(K&&_(N,K)),be=!!(m&&fa(N,m,d)),oe=!!(h&&fa(N,h,d))||te||ce||!b&&!x&&Z||b&&x===!1&&Z,Ye=v(N,w);Z&&B.outside.push(k),be&&B.disabled.push(k),oe&&B.hidden.push(k),Ye&&B.today.push(k),p&&Object.keys(p).forEach(je=>{const P=p?.[je];P&&fa(N,P,d)&&(L[je]?L[je].push(k):L[je]=[k])})}return k=>{const N={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},H={};for(const Z in B){const te=B[Z];N[Z]=te.some(ce=>ce===k)}for(const Z in L)H[Z]=L[Z].some(te=>te===k);return{...N,...H}}}function zC(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[ue.Day]])}function DC(a){return{...OC,...a}}function _C(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 kC(){const a={};for(const s in ue)a[ue[s]]=`rdp-${ue[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 Dx(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const RC=Dx;function UC(a,s,o){return(o??new sn(s)).format(a,"d")}function qC(a,s=qn){return s.format(a,"LLLL")}function BC(a,s,o){return(o??new sn(s)).format(a,"cccccc")}function HC(a,s=qn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function LC(){return""}function _x(a,s=qn){return s.format(a,"yyyy")}const YC=_x,GC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Dx,formatDay:UC,formatMonthCaption:RC,formatMonthDropdown:qC,formatWeekNumber:HC,formatWeekNumberHeader:LC,formatWeekdayName:BC,formatYearCaption:YC,formatYearDropdown:_x},Symbol.toStringTag,{value:"Module"}));function KC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...GC,...a}}function bd(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 QC=bd;function Sd(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const VC=Sd;function kx(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function Rx(a){return"Choose the Month"}function Ux(){return""}const XC="Go to the Next Month";function qx(a,s){return XC}function Bx(a){return"Go to the Previous Month"}function Hx(a,s,o){return(o??new sn(s)).format(a,"cccc")}function Lx(a,s){return`Week ${a}`}function Yx(a){return"Week Number"}function Gx(a){return"Choose the Year"}const ZC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:VC,labelDay:QC,labelDayButton:bd,labelGrid:Sd,labelGridcell:kx,labelMonthDropdown:Rx,labelNav:Ux,labelNext:qx,labelPrevious:Bx,labelWeekNumber:Lx,labelWeekNumberHeader:Yx,labelWeekday:Hx,labelYearDropdown:Gx},Symbol.toStringTag,{value:"Module"})),Nn=(a,s,o)=>s||(o?typeof o=="function"?o:(...u)=>o:a);function WC(a,s){const o=s.locale?.labels??{};return{...ZC,...a??{},labelDayButton:Nn(bd,a?.labelDayButton,o.labelDayButton),labelMonthDropdown:Nn(Rx,a?.labelMonthDropdown,o.labelMonthDropdown),labelNext:Nn(qx,a?.labelNext,o.labelNext),labelPrevious:Nn(Bx,a?.labelPrevious,o.labelPrevious),labelWeekNumber:Nn(Lx,a?.labelWeekNumber,o.labelWeekNumber),labelYearDropdown:Nn(Gx,a?.labelYearDropdown,o.labelYearDropdown),labelGrid:Nn(Sd,a?.labelGrid,o.labelGrid),labelGridcell:Nn(kx,a?.labelGridcell,o.labelGridcell),labelNav:Nn(Ux,a?.labelNav,o.labelNav),labelWeekNumberHeader:Nn(Yx,a?.labelWeekNumberHeader,o.labelWeekNumberHeader),labelWeekday:Nn(Hx,a?.labelWeekday,o.labelWeekday)}}function $C(a,s,o,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:x,getMonth:b}=d;return x({start:h(a),end:p(a)}).map(S=>{const M=u.formatMonthDropdown(S,d),A=b(S),U=s&&S<m(s)||o&&S>m(o)||!1;return{value:A,label:M,disabled:U}})}function JC(a,s={},o={}){let u={...s?.[ue.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...o?.[d]}}),u}function PC(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 FC(a,s,o,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:x}=u,b=m(a),w=h(s),v=p({start:b,end:w});return d&&v.reverse(),v.map(S=>{const M=o.formatYearDropdown(S,u);return{value:x(S),label:M,disabled:!1}})}const vi=a=>a instanceof HTMLElement?a:null,Oc=a=>[...a.querySelectorAll("[data-animated-month]")??[]],IC=a=>vi(a.querySelector("[data-animated-month]")),Ac=a=>vi(a.querySelector("[data-animated-caption]")),zc=a=>vi(a.querySelector("[data-animated-weeks]")),ew=a=>vi(a.querySelector("[data-animated-nav]")),tw=a=>vi(a.querySelector("[data-animated-weekdays]"));function nw(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 b=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||b.length===0||u.length!==b.length)return;const w=m.isSameMonth(u[0].date,b[0].date),v=m.isAfter(u[0].date,b[0].date),S=v?o[ln.caption_after_enter]:o[ln.caption_before_enter],M=v?o[ln.weeks_after_enter]:o[ln.weeks_before_enter],A=h.current,U=a.current.cloneNode(!0);if(U instanceof HTMLElement?(Oc(U).forEach(B=>{if(!(B instanceof HTMLElement))return;const L=IC(B);L&&B.contains(L)&&B.removeChild(L);const k=Ac(B);k&&k.classList.remove(S);const N=zc(B);N&&N.classList.remove(M)}),h.current=U):h.current=null,x.current||w||d)return;const _=A instanceof HTMLElement?Oc(A):[],T=Oc(a.current);if(T?.every(K=>K instanceof HTMLElement)&&_&&_.every(K=>K instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const K=ew(a.current);K&&(K.style.zIndex="1"),T.forEach((B,L)=>{const k=_[L];if(!k)return;B.style.position="relative",B.style.overflow="hidden";const N=Ac(B);N&&N.classList.add(S);const H=zc(B);H&&H.classList.add(M);const Z=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),K&&(K.style.zIndex=""),N&&N.classList.remove(S),H&&H.classList.remove(M),B.style.position="",B.style.overflow="",B.contains(k)&&B.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const te=tw(k);te&&(te.style.opacity="0");const ce=Ac(k);ce&&(ce.classList.add(v?o[ln.caption_before_exit]:o[ln.caption_after_exit]),ce.addEventListener("animationend",Z));const be=zc(k);be&&be.classList.add(v?o[ln.weeks_before_exit]:o[ln.weeks_after_exit]),B.insertBefore(k,B.firstChild)})}})}function aw(a,s,o,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:x}=o??{},{addDays:b,differenceInCalendarDays:w,differenceInCalendarMonths:v,endOfBroadcastWeek:S,endOfISOWeek:M,endOfMonth:A,endOfWeek:U,isAfter:_,startOfBroadcastWeek:T,startOfISOWeek:K,startOfWeek:B}=u,L=x?T(d,u):h?K(d):B(d),k=x?S(m):h?M(A(m)):U(A(m)),N=s&&(x?S(s):h?M(s):U(s)),H=N&&_(k,N)?N:k,Z=w(H,L),te=v(m,d)+1,ce=[];for(let Ye=0;Ye<=Z;Ye++){const je=b(L,Ye);ce.push(je)}const oe=(x?35:42)*te;if(p&&ce.length<oe){const Ye=oe-ce.length;for(let je=0;je<Ye;je++){const P=b(ce[ce.length-1],1);ce.push(P)}}return ce}function lw(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 sw(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 sg(a,s,o,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let x=d||m||h;const{differenceInCalendarMonths:b,addMonths:w,startOfMonth:v}=u;if(o&&b(o,x)<p-1){const S=-1*(p-1);x=w(o,S)}return s&&b(x,s)<0&&(x=s),v(x)}function iw(a,s,o,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:x,getISOWeek:b,getWeek:w,startOfBroadcastWeek:v,startOfISOWeek:S,startOfWeek:M}=u,A=a.reduce((U,_)=>{const T=o.broadcastCalendar?v(_,u):o.ISOWeek?S(_):M(_),K=o.broadcastCalendar?m(_):o.ISOWeek?h(p(_)):x(p(_)),B=s.filter(H=>H>=T&&H<=K),L=o.broadcastCalendar?35:42;if(o.fixedWeeks&&B.length<L){const H=s.filter(Z=>{const te=L-B.length;return Z>K&&Z<=d(K,te)});B.push(...H)}const k=B.reduce((H,Z)=>{const te=o.ISOWeek?b(Z):w(Z),ce=H.find(oe=>oe.weekNumber===te),be=new Tx(Z,_,u);return ce?ce.days.push(be):H.push(new nC(te,[be])),H},[]),N=new tC(_,k);return U.push(N),U},[]);return o.reverseMonths?A.reverse():A}function rw(a,s){let{startMonth:o,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:x,endOfYear:b,newDate:w,today:v}=s,{fromYear:S,toYear:M,fromMonth:A,toMonth:U}=a;!o&&A&&(o=A),!o&&S&&(o=s.newDate(S,0,1)),!u&&U&&(u=U),!u&&M&&(u=w(M,11,31));const _=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return o?o=h(o):S?o=w(S,0,1):!o&&_&&(o=d(x(a.today??v(),-100))),u?u=p(u):M?u=w(M,11,31):!u&&_&&(u=b(a.today??v())),[o&&m(o),u&&m(u)]}function ow(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m:1,w=h(a);if(!s)return p(w,b);if(!(x(s,a)<m))return p(w,b)}function uw(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m??1:1,w=h(a);if(!s)return p(w,-b);if(!(x(w,s)<=0))return p(w,-b)}function cw(a){const s=[];return a.reduce((o,u)=>o.concat(u.weeks.slice()),s.slice())}function io(a,s){const[o,u]=y.useState(a);return[s===void 0?o:s,u]}function dw(a,s){const[o,u]=rw(a,s),{startOfMonth:d,endOfMonth:m}=s,h=sg(a,o,u,s),[p,x]=io(h,a.month?h:void 0);y.useEffect(()=>{const L=sg(a,o,u,s);x(L)},[a.timeZone]);const{months:b,weeks:w,days:v,previousMonth:S,nextMonth:M}=y.useMemo(()=>{const L=sw(p,u,{numberOfMonths:a.numberOfMonths},s),k=aw(L,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),N=iw(L,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),H=cw(N),Z=lw(N),te=uw(p,o,a,s),ce=ow(p,u,a,s);return{months:N,weeks:H,days:Z,previousMonth:te,nextMonth:ce}},[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:A,onMonthChange:U}=a,_=L=>w.some(k=>k.days.some(N=>N.isEqualTo(L))),T=L=>{if(A)return;let k=d(L);o&&k<d(o)&&(k=d(o)),u&&k>d(u)&&(k=d(u)),x(k),U?.(k)};return{months:b,weeks:w,days:v,navStart:o,navEnd:u,previousMonth:S,nextMonth:M,goToMonth:T,goToDay:L=>{_(L)||T(L.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 ig(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function fw(a,s,o,u){let d,m=-1;for(const h of a){const p=s(h);ig(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=>ig(s(h)))),d}function mw(a,s,o,u,d,m,h){const{ISOWeek:p,broadcastCalendar:x}=m,{addDays:b,addMonths:w,addWeeks:v,addYears:S,endOfBroadcastWeek:M,endOfISOWeek:A,endOfWeek:U,max:_,min:T,startOfBroadcastWeek:K,startOfISOWeek:B,startOfWeek:L}=h;let N={day:b,week:v,month:w,year:S,startOfWeek:H=>x?K(H,h):p?B(H):L(H),endOfWeek:H=>x?M(H):p?A(H):U(H)}[a](o,s==="after"?1:-1);return s==="before"&&u?N=_([u,N]):s==="after"&&d&&(N=T([d,N])),N}function Kx(a,s,o,u,d,m,h,p=0){if(p>365)return;const x=mw(a,s,o.date,u,d,m,h),b=!!(m.disabled&&fa(x,m.disabled,h)),w=!!(m.hidden&&fa(x,m.hidden,h)),v=x,S=new Tx(x,v,h);return!b&&!w?S:Kx(a,s,S,u,d,m,h,p+1)}function hw(a,s,o,u,d){const{autoFocus:m}=a,[h,p]=y.useState(),x=fw(s.days,o,u||(()=>!1),h),[b,w]=y.useState(m?x:void 0);return{isFocusTarget:U=>!!x?.isEqualTo(U),setFocused:w,focused:b,blur:()=>{p(b),w(void 0)},moveFocus:(U,_)=>{if(!b)return;const T=Kx(U,_,b,s.navStart,s.navEnd,a,d);T&&(a.disableNavigation&&!s.days.some(B=>B.isEqualTo(T))||(s.goToDay(T),w(T)))}}}function pw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s,b=M=>p?.some(A=>x(A,M))??!1,{min:w,max:v}=a;return{selected:p,select:(M,A,U)=>{let _=[...p??[]];if(b(M)){if(p?.length===w||u&&p?.length===1)return;_=p?.filter(T=>!x(T,M))}else p?.length===v?_=[M]:_=[..._,M];return d||h(_),d?.(_,M,A,U),_},isSelected:b}}function gw(a,s,o=0,u=0,d=!1,m=qn){const{from:h,to:p}=s||{},{isSameDay:x,isAfter:b,isBefore:w}=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:w(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(w(a,h))v={from:a,to:p};else if(b(a,h))v={from:h,to:a};else if(b(a,p))v={from:h,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const S=m.differenceInCalendarDays(v.to,v.from);u>0&&S>u?v={from:a,to:void 0}:o>1&&S<o&&(v={from:a,to:void 0})}return v}function xw(a,s,o=qn){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 rg(a,s,o=qn){return da(a,s.from,!1,o)||da(a,s.to,!1,o)||da(s,a.from,!1,o)||da(s,a.to,!1,o)}function yw(a,s,o=qn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:o.isDate(p)?da(a,p,!1,o):zx(p,o)?p.some(x=>da(a,x,!1,o)):so(p)?p.from&&p.to?rg(a,{from:p.from,to:p.to},o):!1:Ax(p)?xw(a,p.dayOfWeek,o):xd(p)?o.isAfter(p.before,p.after)?rg(a,{from:o.addDays(p.after,1),to:o.addDays(p.before,-1)},o):fa(a.from,p,o)||fa(a.to,p,o):yd(p)||vd(p)?fa(a.from,p,o)||fa(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 b=0;b<=x;b++){if(h.some(w=>w(p)))return!0;p=o.addDays(p,1)}}return!1}function vw(a,s){const{disabled:o,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,x]=io(d,h?d:void 0),b=h?d:p;return{selected:b,select:(S,M,A)=>{const{min:U,max:_}=a,T=S?gw(S,b,U,_,m,s):void 0;return u&&o&&T?.from&&T.to&&yw({from:T.from,to:T.to},o,s)&&(T.from=S,T.to=void 0),h||x(T),h?.(T,S,M,A),T},isSelected:S=>b&&da(b,S,!1,s)}}function bw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s;return{selected:p,select:(v,S,M)=>{let A=v;return!u&&p&&p&&x(v,p)&&(A=void 0),d||h(A),d?.(A,v,S,M),A},isSelected:v=>p?x(p,v):!1}}function Sw(a,s){const o=bw(a,s),u=pw(a,s),d=vw(a,s);switch(a.mode){case"single":return o;case"multiple":return u;case"range":return d;default:return}}function Ot(a,s){return a instanceof ca&&a.timeZone===s?a:new ca(a,s)}function og(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Ot(a,s):Array.isArray(a)?a.map(o=>o instanceof Date?Ot(o,s):o):so(a)?{...a,from:a.from?Ot(a.from,s):a.from,to:a.to?Ot(a.to,s):a.to}:xd(a)?{before:Ot(a.before,s),after:Ot(a.after,s)}:yd(a)?{after:Ot(a.after,s)}:vd(a)?{before:Ot(a.before,s)}:a}function Dc(a,s){return a&&(Array.isArray(a)?a.map(o=>og(o,s)):og(a,s))}function jw(a){let s=a;const o=s.timeZone;if(o&&(s={...a,timeZone:o},s.today&&(s.today=Ot(s.today,o)),s.month&&(s.month=Ot(s.month,o)),s.defaultMonth&&(s.defaultMonth=Ot(s.defaultMonth,o)),s.startMonth&&(s.startMonth=Ot(s.startMonth,o)),s.endMonth&&(s.endMonth=Ot(s.endMonth,o)),s.mode==="single"&&s.selected?s.selected=Ot(s.selected,o):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(re=>Ot(re,o)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Ot(s.selected.from,o):s.selected.from,to:s.selected.to?Ot(s.selected.to,o):s.selected.to}),s.disabled!==void 0&&(s.disabled=Dc(s.disabled,o)),s.hidden!==void 0&&(s.hidden=Dc(s.hidden,o)),s.modifiers)){const re={};Object.keys(s.modifiers).forEach(Se=>{re[Se]=Dc(s.modifiers?.[Se],o)}),s.modifiers=re}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:x}=y.useMemo(()=>{const re={...Mx,...s.locale},Se=new sn({locale:re,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:Se,components:DC(s.components),formatters:KC(s.formatters),labels:WC(s.labels,Se.options),locale:re,classNames:{...kC(),...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:b,mode:w,navLayout:v,numberOfMonths:S=1,onDayBlur:M,onDayClick:A,onDayFocus:U,onDayKeyDown:_,onDayMouseEnter:T,onDayMouseLeave:K,onNextClick:B,onPrevClick:L,showWeekNumber:k,styles:N}=s,{formatCaption:H,formatDay:Z,formatMonthDropdown:te,formatWeekNumber:ce,formatWeekNumberHeader:be,formatWeekdayName:oe,formatYearDropdown:Ye}=d,je=dw(s,h),{days:P,months:O,navStart:W,navEnd:se,previousMonth:ye,nextMonth:ve,goToMonth:De}=je,ze=AC(P,s,W,se,h),{isSelected:X,select:J,selected:ne}=Sw(s,h)??{},{blur:F,focused:ee,isFocusTarget:fe,moveFocus:Ae,setFocused:Ge}=hw(s,je,ze,X??(()=>!1),h),{labelDayButton:yt,labelGridcell:vt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Qt,labelNext:Bn,labelWeekday:Ne,labelWeekNumber:Vt,labelWeekNumberHeader:En,labelYearDropdown:Xt}=m,ma=y.useMemo(()=>PC(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Hn=w!==void 0||A!==void 0,ct=y.useCallback(()=>{ye&&(De(ye),L?.(ye))},[ye,De,L]),Zt=y.useCallback(()=>{ve&&(De(ve),B?.(ve))},[De,ve,B]),Ln=y.useCallback((re,Se)=>he=>{he.preventDefault(),he.stopPropagation(),Ge(re),!Se.disabled&&(J?.(re.date,Se,he),A?.(re.date,Se,he))},[J,A,Ge]),Va=y.useCallback((re,Se)=>he=>{Ge(re),U?.(re.date,Se,he)},[U,Ge]),Mn=y.useCallback((re,Se)=>he=>{F(),M?.(re.date,Se,he)},[F,M]),Tn=y.useCallback((re,Se)=>he=>{const Te={ArrowLeft:[he.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[he.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[he.shiftKey?"year":"week","after"],ArrowUp:[he.shiftKey?"year":"week","before"],PageUp:[he.shiftKey?"year":"month","before"],PageDown:[he.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Te[he.key]){he.preventDefault(),he.stopPropagation();const[Fe,xe]=Te[he.key];Ae(Fe,xe)}_?.(re.date,Se,he)},[Ae,_,s.dir]),xl=y.useCallback((re,Se)=>he=>{T?.(re.date,Se,he)},[T]),us=y.useCallback((re,Se)=>he=>{K?.(re.date,Se,he)},[K]),cs=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setMonth(h.startOfMonth(re),he);De(Te)},[h,De]),Yn=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setYear(h.startOfMonth(re),he);De(Te)},[h,De]),{className:$,style:Ee}=y.useMemo(()=>({className:[x[ue.Root],s.className].filter(Boolean).join(" "),style:{...N?.[ue.Root],...s.style}}),[x,s.className,s.style,N]),me=_C(s),Me=y.useRef(null);nw(Me,!!s.animate,{classNames:x,months:O,focused:ee,dateLib:h});const nt={dayPickerProps:s,selected:ne,select:J,isSelected:X,months:O,nextMonth:ve,previousMonth:ye,goToMonth:De,getModifiers:ze,components:u,classNames:x,styles:N,labels:m,formatters:d};return I.createElement(Ox.Provider,{value:nt},I.createElement(u.Root,{rootRef:s.animate?Me:void 0,className:$,style:Ee,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"],...me},I.createElement(u.Months,{className:x[ue.Months],style:N?.[ue.Months]},!s.hideNavigation&&!v&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),O.map((re,Se)=>I.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[ue.Month],style:N?.[ue.Month],key:Se,displayIndex:Se,calendarMonth:re},v==="around"&&!s.hideNavigation&&Se===0&&I.createElement(u.PreviousMonthButton,{type:"button",className:x[ue.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Qt(ye),onClick:ct,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"right":"left"})),I.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[ue.MonthCaption],style:N?.[ue.MonthCaption],calendarMonth:re,displayIndex:Se},b?.startsWith("dropdown")?I.createElement(u.DropdownNav,{className:x[ue.Dropdowns],style:N?.[ue.Dropdowns]},(()=>{const he=b==="dropdown"||b==="dropdown-months"?I.createElement(u.MonthsDropdown,{key:"month",className:x[ue.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:cs(re.date),options:$C(re.date,W,se,d,h),style:N?.[ue.Dropdown],value:h.getMonth(re.date)}):I.createElement("span",{key:"month"},te(re.date,h)),Te=b==="dropdown"||b==="dropdown-years"?I.createElement(u.YearsDropdown,{key:"year",className:x[ue.YearsDropdown],"aria-label":Xt(h.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Yn(re.date),options:FC(W,se,d,h,!!s.reverseYears),style:N?.[ue.Dropdown],value:h.getYear(re.date)}):I.createElement("span",{key:"year"},Ye(re.date,h));return h.getMonthYearOrder()==="year-first"?[Te,he]:[he,Te]})(),I.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"}},H(re.date,h.options,h))):I.createElement(u.CaptionLabel,{className:x[ue.CaptionLabel],role:"status","aria-live":"polite"},H(re.date,h.options,h))),v==="around"&&!s.hideNavigation&&Se===S-1&&I.createElement(u.NextMonthButton,{type:"button",className:x[ue.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":Bn(ve),onClick:Zt,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Se===S-1&&v==="after"&&!s.hideNavigation&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),I.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":w==="multiple"||w==="range","aria-label":Qe(re.date,h.options,h)||void 0,className:x[ue.MonthGrid],style:N?.[ue.MonthGrid]},!s.hideWeekdays&&I.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[ue.Weekdays],style:N?.[ue.Weekdays]},k&&I.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:x[ue.WeekNumberHeader],style:N?.[ue.WeekNumberHeader],scope:"col"},be()),ma.map(he=>I.createElement(u.Weekday,{"aria-label":Ne(he,h.options,h),className:x[ue.Weekday],key:String(he),style:N?.[ue.Weekday],scope:"col"},oe(he,h.options,h)))),I.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[ue.Weeks],style:N?.[ue.Weeks]},re.weeks.map(he=>I.createElement(u.Week,{className:x[ue.Week],key:he.weekNumber,style:N?.[ue.Week],week:he},k&&I.createElement(u.WeekNumber,{week:he,style:N?.[ue.WeekNumber],"aria-label":Vt(he.weekNumber,{locale:p}),className:x[ue.WeekNumber],scope:"row",role:"rowheader"},ce(he.weekNumber,h)),he.days.map(Te=>{const{date:Fe}=Te,xe=ze(Te);if(xe[lt.focused]=!xe.hidden&&!!ee?.isEqualTo(Te),xe[Cn.selected]=X?.(Fe)||xe.selected,so(ne)){const{from:Wt,to:vn}=ne;xe[Cn.range_start]=!!(Wt&&vn&&h.isSameDay(Fe,Wt)),xe[Cn.range_end]=!!(Wt&&vn&&h.isSameDay(Fe,vn)),xe[Cn.range_middle]=da(ne,Fe,!0,h)}const Dt=JC(xe,N,s.modifiersStyles),Gn=zC(xe,x,s.modifiersClassNames),St=!Hn&&!xe.hidden?vt(Fe,xe,h.options,h):void 0;return I.createElement(u.Day,{key:`${Te.isoDate}_${Te.displayMonthId}`,day:Te,modifiers:xe,className:Gn.join(" "),style:Dt,role:"gridcell","aria-selected":xe.selected||void 0,"aria-label":St,"data-day":Te.isoDate,"data-month":Te.outside?Te.dateMonthId:void 0,"data-selected":xe.selected||void 0,"data-disabled":xe.disabled||void 0,"data-hidden":xe.hidden||void 0,"data-outside":Te.outside||void 0,"data-focused":xe.focused||void 0,"data-today":xe.today||void 0},!xe.hidden&&Hn?I.createElement(u.DayButton,{className:x[ue.DayButton],style:N?.[ue.DayButton],type:"button",day:Te,modifiers:xe,disabled:!xe.focused&&xe.disabled||void 0,"aria-disabled":xe.focused&&xe.disabled||void 0,tabIndex:fe(Te)?0:-1,"aria-label":yt(Fe,xe,h.options,h),onClick:Ln(Te,xe),onBlur:Mn(Te,xe),onFocus:Va(Te,xe),onKeyDown:Tn(Te,xe),onMouseEnter:xl(Te,xe),onMouseLeave:us(Te,xe)},Z(Fe,h.options,h)):!xe.hidden&&Z(Te.date,h.options,h))})))))))),s.footer&&I.createElement(u.Footer,{className:x[ue.Footer],style:N?.[ue.Footer],role:"status","aria-live":"polite"},s.footer)))}function Nw({className:a,classNames:s,showOutsideDays:o=!0,...u}){return i.jsx(jw,{showOutsideDays:o,className:G("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:G(Ur({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:G(Ur({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:G("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:G(Ur({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:G("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:G("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:G("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:G("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"?bb:d==="right"?Vr:d==="up"?Xc:Pr;return i.jsx(p,{className:G("h-4 w-4",m),...h})}},...u})}Nw.displayName="Calendar";function Cw(){const[a,s]=y.useState(""),[o,u]=y.useState(""),[d,m]=y.useState(null),[h,p]=y.useState(!1),{login:x,authRequired:b,isAuthenticated:w}=Pc(),v=Gc(),M=Yc().state?.from?.pathname||"/";if(y.useEffect(()=>{(w||!b)&&v(M,{replace:!0})},[w,b,v,M]),w||!b)return null;const A=async U=>{U.preventDefault(),m(null),p(!0);try{await x(a,o),v(M,{replace:!0})}catch(_){m(_ instanceof Error?_.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(x2,{className:"w-full max-w-sm",children:[i.jsxs(y2,{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(Sb,{className:"h-6 w-6 text-primary"})}),i.jsx(v2,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(b2,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(S2,{children:i.jsxs("form",{onSubmit:A,className:"space-y-4",children:[d&&i.jsxs(md,{variant:"destructive",children:[i.jsx(Wc,{className:"h-4 w-4"}),i.jsx(hd,{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:U=>s(U.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:U=>u(U.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:h,required:!0})]}),i.jsx(ot,{type:"submit",className:"w-full",disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsx(Un,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const ww=y.lazy(()=>zt(()=>import("./index-BkS1PcE3.js"),__vite__mapDeps([17,1,2,4,5,7,18,6,8,9])).then(a=>({default:a.AnalyticsPage}))),Ew=y.lazy(()=>zt(()=>import("./api-BMhxtrFX.js"),__vite__mapDeps([19,1,2,5,20,14,6,4,7,8,9])).then(a=>({default:a.ApiPage}))),Mw=y.lazy(()=>zt(()=>import("./cliproxy-BMlmKo8O.js"),__vite__mapDeps([21,1,2,5,6,4,20,14,3,13,7,8,9])).then(a=>({default:a.CliproxyPage}))),Tw=y.lazy(()=>zt(()=>import("./cliproxy-control-panel-CpqCbUD-.js"),__vite__mapDeps([22,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),Ow=y.lazy(()=>zt(()=>import("./copilot-YcRs-dpA.js"),__vite__mapDeps([23,1,2,5,20,14,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),Aw=y.lazy(()=>zt(()=>import("./accounts-CGO2ohEG.js"),__vite__mapDeps([24,1,2,5,14,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),zw=y.lazy(()=>zt(()=>Promise.resolve().then(()=>X2),void 0).then(a=>({default:a.SettingsPage}))),Dw=y.lazy(()=>zt(()=>import("./health-BoF1pfCd.js"),__vite__mapDeps([25,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),_w=y.lazy(()=>zt(()=>import("./shared-Bl5j6dWI.js"),__vite__mapDeps([26,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function oa(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(Un,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function kw(){return i.jsx(Yv,{client:pS,children:i.jsx(xS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(yS,{children:i.jsx(NS,{children:i.jsxs(Bv,{children:[i.jsxs(Hv,{children:[i.jsx(nn,{path:"/login",element:i.jsx(Cw,{})}),i.jsx(nn,{element:i.jsx(CS,{}),children:i.jsxs(nn,{element:i.jsx(J1,{}),children:[i.jsx(nn,{path:"/",element:i.jsx(XN,{})}),i.jsx(nn,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(ww,{})})}),i.jsx(nn,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ew,{})})}),i.jsx(nn,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Mw,{})})}),i.jsx(nn,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Tw,{})})}),i.jsx(nn,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ow,{})})}),i.jsx(nn,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Aw,{})})}),i.jsx(nn,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(zw,{})})}),i.jsx(nn,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Dw,{})})}),i.jsx(nn,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(_w,{})})})]})})]}),i.jsx(Gv,{position:"top-right"})]})})})})})}const Qx=document.getElementById("root");if(!Qx)throw new Error("Root element not found. Failed to mount React application.");fS.createRoot(Qx).render(i.jsx(y.StrictMode,{children:i.jsx(kw,{})}));export{M2 as $,l2 as A,La as B,x2 as C,gE as D,x1 as E,y1 as F,v1 as G,mx as H,_n as I,pd as J,Kr as K,yn as L,Bc as M,vE as N,b2 as O,Hg as P,SE as Q,bE as R,Le as S,Ya as T,jE as U,gx as V,NE as W,EE as X,C2 as Y,TE as Z,w2 as _,S2 as a,Sx as a$,m1 as a0,Vw as a1,Fw as a2,Iw as a3,nd as a4,ad as a5,ld as a6,sd as a7,id as a8,CE as a9,g1 as aA,Zw as aB,Ww as aC,h1 as aD,p1 as aE,$w as aF,Jw as aG,Pw as aH,Xw as aI,xx as aJ,zt as aK,KN as aL,hE as aM,md as aN,fx as aO,hd as aP,Nx as aQ,L2 as aR,G2 as aS,oE as aT,sE as aU,uE as aV,iE as aW,rE as aX,dE as aY,cE as aZ,Ur as a_,N2 as aa,wE as ab,fE as ac,mE as ad,Ze as ae,eE as af,ME as ag,E2 as ah,q1 as ai,Mj as aj,qS as ak,BS as al,ml as am,G1 as an,K1 as ao,Q1 as ap,V1 as aq,A2 as ar,Tj as as,Vg as at,tE as au,nE as av,aE as aw,lE as ax,OE as ay,Qw as az,ot as b,G as c,AE as d,zE as e,Z2 as f,Nw as g,Kw as h,y2 as i,v2 as j,xj as k,yj as l,gl as m,DE as n,Ga as o,Ka as p,Hp as q,r2 as r,yE as s,PN as t,$c as u,a2 as v,pE as w,xE as x,WN as y,t2 as z};
47
+ `);return{valid:!1,error:u,line:h.length}}return{valid:!1,error:u}}}function bx({value:a,onChange:s,language:o="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=Kg(),[p,x]=y.useState(!1),[b,w]=y.useState(!0),v=y.useMemo(()=>o==="json"?U2(a):{valid:!0},[a,o]),S=y.useCallback(M=>i.jsx(rS,{theme:h?vp.nightOwl:vp.github,code:M,language:o,children:({tokens:A,getLineProps:U,getTokenProps:_})=>{let T=!1;return i.jsx(i.Fragment,{children:A.map((K,B)=>i.jsx("div",{...U({line:K}),className:G(v.line===B+1&&"bg-destructive/20"),children:K.map((L,k)=>{let N=!1;if(L.types.includes("property")){const Z=L.content.replace(/['"]/g,"");R2(Z)?T=!0:T=!1}else(L.types.includes("string")||L.types.includes("number")||L.types.includes("boolean"))&&T?(N=!0,T=!1):L.types.includes("punctuation")&&L.content!==":"&&L.content!=="["&&L.content!=="{"&&(T=!1);const H=_({token:L});return N&&b&&(H.className=G(H.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...H},k)})},B))})}}),[h,o,v.line,b]);return i.jsxs("div",{className:G("flex flex-col",d),children:[i.jsxs("div",{className:G("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(_2,{value:a,onValueChange:u?()=>{}:s,highlight:S,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:G("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(ot,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>w(!b),title:b?"Reveal sensitive values":"Mask sensitive values",children:b?i.jsx(Zr,{className:"h-3 w-3"}):i.jsx(Xr,{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(Wr,{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(Wc,{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:bx},Symbol.toStringTag,{value:"Module"})),q2={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 B2(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 jx=y.createContext(null);function H2({children:a}){const[s,o]=y.useReducer(B2,q2);return i.jsx(jx.Provider,{value:{state:s,dispatch:o},children:a})}function Nx(){const a=y.useContext(jx);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function L2(){const{dispatch:a}=Nx(),s=y.useCallback(N=>a({type:"SET_WEBSEARCH_CONFIG",payload:N}),[a]),o=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS",payload:N}),[a]),u=y.useCallback(N=>a({type:"SET_WEBSEARCH_LOADING",payload:N}),[a]),d=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:N}),[a]),m=y.useCallback(N=>a({type:"SET_WEBSEARCH_SAVING",payload:N}),[a]),h=y.useCallback(N=>a({type:"SET_WEBSEARCH_ERROR",payload:N}),[a]),p=y.useCallback(N=>a({type:"SET_WEBSEARCH_SUCCESS",payload:N}),[a]),x=y.useCallback(N=>a({type:"SET_GLOBALENV_CONFIG",payload:N}),[a]),b=y.useCallback(N=>a({type:"SET_GLOBALENV_LOADING",payload:N}),[a]),w=y.useCallback(N=>a({type:"SET_GLOBALENV_SAVING",payload:N}),[a]),v=y.useCallback(N=>a({type:"SET_GLOBALENV_ERROR",payload:N}),[a]),S=y.useCallback(N=>a({type:"SET_GLOBALENV_SUCCESS",payload:N}),[a]),M=y.useCallback(N=>a({type:"SET_PROXY_CONFIG",payload:N}),[a]),A=y.useCallback(N=>a({type:"SET_PROXY_LOADING",payload:N}),[a]),U=y.useCallback(N=>a({type:"SET_PROXY_SAVING",payload:N}),[a]),_=y.useCallback(N=>a({type:"SET_PROXY_ERROR",payload:N}),[a]),T=y.useCallback(N=>a({type:"SET_PROXY_SUCCESS",payload:N}),[a]),K=y.useCallback(N=>a({type:"SET_PROXY_TEST_RESULT",payload:N}),[a]),B=y.useCallback(N=>a({type:"SET_PROXY_TESTING",payload:N}),[a]),L=y.useCallback(N=>a({type:"SET_RAW_CONFIG",payload:N}),[a]),k=y.useCallback(N=>a({type:"SET_RAW_CONFIG_LOADING",payload:N}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:o,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:b,setGlobalEnvSaving:w,setGlobalEnvError:v,setGlobalEnvSuccess:S,setProxyConfig:M,setProxyLoading:A,setProxySaving:U,setProxyError:_,setProxySuccess:T,setProxyTestResult:K,setProxyTesting:B,setRawConfig:L,setRawConfigLoading:k}),[s,o,u,d,m,h,p,x,b,w,v,S,M,A,U,_,T,K,B,L,k])}function Y2(){const[a,s]=qv(),o=a.get("tab")?.toLowerCase(),u=o==="globalenv"?"globalenv":o==="proxy"?"proxy":o==="auth"?"auth":o==="thinking"?"thinking":o==="backups"?"backups":"websearch",d=y.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function G2(){const{state:a}=Nx(),s=L2(),[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}}const K2=[{value:"websearch",label:"Web",icon:gb},{value:"globalenv",label:"Env",icon:Zc},{value:"thinking",label:"Think",icon:xb},{value:"proxy",label:"Proxy",icon:yb},{value:"auth",label:"Auth",icon:Kc},{value:"backups",label:"Backup",icon:vb}];function Zp({activeTab:a,onTabChange:s}){return i.jsx(mx,{value:a,onValueChange:o=>s(o),children:i.jsx(pd,{className:"grid w-full grid-cols-6",children:K2.map(({value:o,label:u,icon:d})=>i.jsxs(Kr,{value:o,className:"gap-1.5 px-1 text-xs",children:[i.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:u})]},o))})})}function Wp(){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 Cx(a,s=3,o=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,o)).then(()=>Cx(a,s-1,o*2))})}function os(a){return y.lazy(()=>Cx(a))}const $p=os(()=>zt(()=>import("./index-CK0URaBN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Jp=os(()=>zt(()=>import("./globalenv-section-D_GVHsDN.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),Pp=os(()=>zt(()=>import("./index-sdtPg8Gr.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),Fp=os(()=>zt(()=>import("./index-BjiZGSfI.js"),__vite__mapDeps([12,1,2,3,4,13,14,5,6,7,8,9]))),Ip=os(()=>zt(()=>import("./auth-section-CZmgtezT.js"),__vite__mapDeps([15,1,2,4,5,6,7,8,9]))),eg=os(()=>zt(()=>import("./backups-section-CcQsXemH.js"),__vite__mapDeps([16,1,2,14,4,5,6,7,8,9])));class tg 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(Wc,{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(ot,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(mi,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function Q2(){const{activeTab:a,setActiveTab:s}=Y2(),{rawConfig:o,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=G2();y.useEffect(()=>{m()},[m]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsxs("div",{className:"h-[calc(100vh-100px)]",children:[i.jsxs("div",{className:"md:hidden h-full flex flex-col",children:[i.jsx("div",{className:"border-b bg-background p-4",children:i.jsx(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]}),i.jsxs(dd,{direction:"horizontal",className:"h-full hidden md:flex",children:[i.jsx(hi,{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(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]})}),i.jsx(fd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx($r,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(hi,{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(gp,{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(ot,{variant:"outline",size:"sm",onClick:h,disabled:!o,children:d?i.jsxs(i.Fragment,{children:[i.jsx(rs,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Hr,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(ot,{variant:"outline",size:"sm",onClick:m,disabled:u,children:i.jsx(mi,{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(mi,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):o?i.jsx(bx,{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(gp,{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 V2(){return i.jsx(H2,{children:i.jsx(Q2,{})})}const X2=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:V2},Symbol.toStringTag,{value:"Module"})),AE=Av,zE=Dv,DE=zv,Z2=y.forwardRef(({className:a,align:s="center",sideOffset:o=4,...u},d)=>i.jsx(Ov,{children:i.jsx(Tg,{ref:d,align:s,sideOffset:o,className:G("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})}));Z2.displayName=Tg.displayName;function W2(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 $2={},di={};function fl(a,s){try{const u=($2[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in di?di[u]:ng(u,u.split(":"))}catch{if(a in di)return di[a];const o=a?.match(J2);return o?ng(a,o.slice(1)):NaN}}const J2=/([+-]\d\d):?(\d\d)?/;function ng(a,s){const o=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return di[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(fl(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)),wx(this),Lc(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=-fl(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Lc(this),+this}[Symbol.for("constructDateFrom")](s){return new Rn(+new Date(s),this.timeZone)}}const ag=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!ag.test(a))return;const s=a.replace(ag,"$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),P2(this),+this},Rn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Lc(this),+this}))});function Lc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-fl(a.timeZone,a)*60))}function P2(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()),wx(a)}function wx(a){const s=fl(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 b=new Date(+a);b.setUTCSeconds(0);const w=d>0?b.getSeconds():(b.getSeconds()-60)%60,v=Math.round(-(fl(a.timeZone,a)*60))%60;(v||w)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+w));const S=fl(a.timeZone,a),M=S>0?Math.floor(S):Math.ceil(S),U=-new Date(+a).getTimezoneOffset()-M,_=M!==o,T=U-x;if(_&&T){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+T);const K=fl(a.timeZone,a),B=K>0?Math.floor(K):Math.ceil(K),L=M-B;L&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+L),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+L))}}class ca extends Rn{static tz(s,...o){return o.length?new ca(...o,s):new ca(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} (${W2(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 ca(+this,s)}[Symbol.for("constructDateFrom")](s){return new ca(+new Date(s),this.timeZone)}}const lg=5,F2=4;function I2(a,s){const o=s.startOfMonth(a),u=o.getDay()>0?o.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,lg*7-1);return s.getMonth(a)===s.getMonth(m)?lg:F2}function Ex(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 eC(a,s){const o=Ex(a,s),u=I2(a,s);return s.addDays(o,u*7-1)}const Mx={...li,labels:{labelDayButton:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ri(h,p,{locale:li,...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)=>ri(d,m,{locale:li,...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)=>ri(h,p,{locale:li,...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)=>ri(d,m,{locale:li,...s}),u(a,"cccc")}}};class sn{constructor(s,o){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ca.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 ca(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):Cb(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):wb(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):Eb(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):Mb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):Tb(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):Ob(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Ab(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):zb(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):eC(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Db(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):_b(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):kb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Rb(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ri(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):Ub(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):qb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Bb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Hb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Lb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):Yb(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Gb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Kb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Qb(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Vb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Xb(u),this.min=u=>this.overrides?.min?this.overrides.min(u):Zb(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Wb(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):$b(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):Ex(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Jb(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Pb(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Fb(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):Ib(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):eS(u),this.options={locale:Mx,...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 qn=new sn;class Tx{constructor(s,o,u=qn){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 tC{constructor(s,o){this.date=s,this.weeks=o}}class nC{constructor(s,o){this.days=o,this.weekNumber=s}}function aC(a){return I.createElement("button",{...a})}function lC(a){return I.createElement("span",{...a})}function sC(a){const{size:s=24,orientation:o="left",className:u}=a;return I.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},o==="up"&&I.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),o==="down"&&I.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),o==="left"&&I.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),o==="right"&&I.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function iC(a){const{day:s,modifiers:o,...u}=a;return I.createElement("td",{...u})}function rC(a){const{day:s,modifiers:o,...u}=a,d=I.useRef(null);return I.useEffect(()=>{o.focused&&d.current?.focus()},[o.focused]),I.createElement("button",{ref:d,...u})}var ue;(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"})(ue||(ue={}));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 oC(a){const{options:s,className:o,components:u,classNames:d,...m}=a,h=[d[ue.Dropdown],o].join(" "),p=s?.find(({value:x})=>x===m.value);return I.createElement("span",{"data-disabled":m.disabled,className:d[ue.DropdownRoot]},I.createElement(u.Select,{className:h,...m},s?.map(({value:x,label:b,disabled:w})=>I.createElement(u.Option,{key:x,value:x,disabled:w},b))),I.createElement("span",{className:d[ue.CaptionLabel],"aria-hidden":!0},p?.label,I.createElement(u.Chevron,{orientation:"down",size:18,className:d[ue.Chevron]})))}function uC(a){return I.createElement("div",{...a})}function cC(a){return I.createElement("div",{...a})}function dC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u},a.children)}function fC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u})}function mC(a){return I.createElement("table",{...a})}function hC(a){return I.createElement("div",{...a})}const Ox=y.createContext(void 0);function yi(){const a=y.useContext(Ox);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function pC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}function gC(a){const{onPreviousClick:s,onNextClick:o,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:x,labelNext:b}}=yi(),w=y.useCallback(S=>{d&&o?.(S)},[d,o]),v=y.useCallback(S=>{u&&s?.(S)},[u,s]);return I.createElement("nav",{...m},I.createElement(h.PreviousMonthButton,{type:"button",className:p[ue.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},I.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[ue.Chevron],orientation:"left"})),I.createElement(h.NextMonthButton,{type:"button",className:p[ue.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":b(d),onClick:w},I.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[ue.Chevron]})))}function xC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function yC(a){return I.createElement("option",{...a})}function vC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function bC(a){const{rootRef:s,...o}=a;return I.createElement("div",{...o,ref:s})}function SC(a){return I.createElement("select",{...a})}function jC(a){const{week:s,...o}=a;return I.createElement("tr",{...o})}function NC(a){return I.createElement("th",{...a})}function CC(a){return I.createElement("thead",{"aria-hidden":!0},I.createElement("tr",{...a}))}function wC(a){const{week:s,...o}=a;return I.createElement("th",{...o})}function EC(a){return I.createElement("th",{...a})}function MC(a){return I.createElement("tbody",{...a})}function TC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}const OC=Object.freeze(Object.defineProperty({__proto__:null,Button:aC,CaptionLabel:lC,Chevron:sC,Day:iC,DayButton:rC,Dropdown:oC,DropdownNav:uC,Footer:cC,Month:dC,MonthCaption:fC,MonthGrid:mC,Months:hC,MonthsDropdown:pC,Nav:gC,NextMonthButton:xC,Option:yC,PreviousMonthButton:vC,Root:bC,Select:SC,Week:jC,WeekNumber:wC,WeekNumberHeader:EC,Weekday:NC,Weekdays:CC,Weeks:MC,YearsDropdown:TC},Symbol.toStringTag,{value:"Module"}));function da(a,s,o=!1,u=qn){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 xd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function so(a){return!!(a&&typeof a=="object"&&"from"in a)}function yd(a){return!!(a&&typeof a=="object"&&"after"in a)}function vd(a){return!!(a&&typeof a=="object"&&"before"in a)}function Ax(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function zx(a,s){return Array.isArray(a)&&a.every(s.isDate)}function fa(a,s,o=qn){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(zx(p,o))return p.some(x=>d(a,x));if(so(p))return da(p,a,!1,o);if(Ax(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(xd(p)){const x=m(p.before,a),b=m(p.after,a),w=x>0,v=b<0;return h(p.before,p.after)?v&&w:w||v}return yd(p)?m(a,p.after)>0:vd(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function AC(a,s,o,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:x,broadcastCalendar:b,today:w=d.today()}=s,{isSameDay:v,isSameMonth:S,startOfMonth:M,isBefore:A,endOfMonth:U,isAfter:_}=d,T=o&&M(o),K=u&&U(u),B={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},L={};for(const k of a){const{date:N,displayMonth:H}=k,Z=!!(H&&!S(N,H)),te=!!(T&&A(N,T)),ce=!!(K&&_(N,K)),be=!!(m&&fa(N,m,d)),oe=!!(h&&fa(N,h,d))||te||ce||!b&&!x&&Z||b&&x===!1&&Z,Ye=v(N,w);Z&&B.outside.push(k),be&&B.disabled.push(k),oe&&B.hidden.push(k),Ye&&B.today.push(k),p&&Object.keys(p).forEach(je=>{const P=p?.[je];P&&fa(N,P,d)&&(L[je]?L[je].push(k):L[je]=[k])})}return k=>{const N={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},H={};for(const Z in B){const te=B[Z];N[Z]=te.some(ce=>ce===k)}for(const Z in L)H[Z]=L[Z].some(te=>te===k);return{...N,...H}}}function zC(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[ue.Day]])}function DC(a){return{...OC,...a}}function _C(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 kC(){const a={};for(const s in ue)a[ue[s]]=`rdp-${ue[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 Dx(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const RC=Dx;function UC(a,s,o){return(o??new sn(s)).format(a,"d")}function qC(a,s=qn){return s.format(a,"LLLL")}function BC(a,s,o){return(o??new sn(s)).format(a,"cccccc")}function HC(a,s=qn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function LC(){return""}function _x(a,s=qn){return s.format(a,"yyyy")}const YC=_x,GC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Dx,formatDay:UC,formatMonthCaption:RC,formatMonthDropdown:qC,formatWeekNumber:HC,formatWeekNumberHeader:LC,formatWeekdayName:BC,formatYearCaption:YC,formatYearDropdown:_x},Symbol.toStringTag,{value:"Module"}));function KC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...GC,...a}}function bd(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 QC=bd;function Sd(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const VC=Sd;function kx(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function Rx(a){return"Choose the Month"}function Ux(){return""}const XC="Go to the Next Month";function qx(a,s){return XC}function Bx(a){return"Go to the Previous Month"}function Hx(a,s,o){return(o??new sn(s)).format(a,"cccc")}function Lx(a,s){return`Week ${a}`}function Yx(a){return"Week Number"}function Gx(a){return"Choose the Year"}const ZC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:VC,labelDay:QC,labelDayButton:bd,labelGrid:Sd,labelGridcell:kx,labelMonthDropdown:Rx,labelNav:Ux,labelNext:qx,labelPrevious:Bx,labelWeekNumber:Lx,labelWeekNumberHeader:Yx,labelWeekday:Hx,labelYearDropdown:Gx},Symbol.toStringTag,{value:"Module"})),Nn=(a,s,o)=>s||(o?typeof o=="function"?o:(...u)=>o:a);function WC(a,s){const o=s.locale?.labels??{};return{...ZC,...a??{},labelDayButton:Nn(bd,a?.labelDayButton,o.labelDayButton),labelMonthDropdown:Nn(Rx,a?.labelMonthDropdown,o.labelMonthDropdown),labelNext:Nn(qx,a?.labelNext,o.labelNext),labelPrevious:Nn(Bx,a?.labelPrevious,o.labelPrevious),labelWeekNumber:Nn(Lx,a?.labelWeekNumber,o.labelWeekNumber),labelYearDropdown:Nn(Gx,a?.labelYearDropdown,o.labelYearDropdown),labelGrid:Nn(Sd,a?.labelGrid,o.labelGrid),labelGridcell:Nn(kx,a?.labelGridcell,o.labelGridcell),labelNav:Nn(Ux,a?.labelNav,o.labelNav),labelWeekNumberHeader:Nn(Yx,a?.labelWeekNumberHeader,o.labelWeekNumberHeader),labelWeekday:Nn(Hx,a?.labelWeekday,o.labelWeekday)}}function $C(a,s,o,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:x,getMonth:b}=d;return x({start:h(a),end:p(a)}).map(S=>{const M=u.formatMonthDropdown(S,d),A=b(S),U=s&&S<m(s)||o&&S>m(o)||!1;return{value:A,label:M,disabled:U}})}function JC(a,s={},o={}){let u={...s?.[ue.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...o?.[d]}}),u}function PC(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 FC(a,s,o,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:x}=u,b=m(a),w=h(s),v=p({start:b,end:w});return d&&v.reverse(),v.map(S=>{const M=o.formatYearDropdown(S,u);return{value:x(S),label:M,disabled:!1}})}const vi=a=>a instanceof HTMLElement?a:null,Oc=a=>[...a.querySelectorAll("[data-animated-month]")??[]],IC=a=>vi(a.querySelector("[data-animated-month]")),Ac=a=>vi(a.querySelector("[data-animated-caption]")),zc=a=>vi(a.querySelector("[data-animated-weeks]")),ew=a=>vi(a.querySelector("[data-animated-nav]")),tw=a=>vi(a.querySelector("[data-animated-weekdays]"));function nw(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 b=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||b.length===0||u.length!==b.length)return;const w=m.isSameMonth(u[0].date,b[0].date),v=m.isAfter(u[0].date,b[0].date),S=v?o[ln.caption_after_enter]:o[ln.caption_before_enter],M=v?o[ln.weeks_after_enter]:o[ln.weeks_before_enter],A=h.current,U=a.current.cloneNode(!0);if(U instanceof HTMLElement?(Oc(U).forEach(B=>{if(!(B instanceof HTMLElement))return;const L=IC(B);L&&B.contains(L)&&B.removeChild(L);const k=Ac(B);k&&k.classList.remove(S);const N=zc(B);N&&N.classList.remove(M)}),h.current=U):h.current=null,x.current||w||d)return;const _=A instanceof HTMLElement?Oc(A):[],T=Oc(a.current);if(T?.every(K=>K instanceof HTMLElement)&&_&&_.every(K=>K instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const K=ew(a.current);K&&(K.style.zIndex="1"),T.forEach((B,L)=>{const k=_[L];if(!k)return;B.style.position="relative",B.style.overflow="hidden";const N=Ac(B);N&&N.classList.add(S);const H=zc(B);H&&H.classList.add(M);const Z=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),K&&(K.style.zIndex=""),N&&N.classList.remove(S),H&&H.classList.remove(M),B.style.position="",B.style.overflow="",B.contains(k)&&B.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const te=tw(k);te&&(te.style.opacity="0");const ce=Ac(k);ce&&(ce.classList.add(v?o[ln.caption_before_exit]:o[ln.caption_after_exit]),ce.addEventListener("animationend",Z));const be=zc(k);be&&be.classList.add(v?o[ln.weeks_before_exit]:o[ln.weeks_after_exit]),B.insertBefore(k,B.firstChild)})}})}function aw(a,s,o,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:x}=o??{},{addDays:b,differenceInCalendarDays:w,differenceInCalendarMonths:v,endOfBroadcastWeek:S,endOfISOWeek:M,endOfMonth:A,endOfWeek:U,isAfter:_,startOfBroadcastWeek:T,startOfISOWeek:K,startOfWeek:B}=u,L=x?T(d,u):h?K(d):B(d),k=x?S(m):h?M(A(m)):U(A(m)),N=s&&(x?S(s):h?M(s):U(s)),H=N&&_(k,N)?N:k,Z=w(H,L),te=v(m,d)+1,ce=[];for(let Ye=0;Ye<=Z;Ye++){const je=b(L,Ye);ce.push(je)}const oe=(x?35:42)*te;if(p&&ce.length<oe){const Ye=oe-ce.length;for(let je=0;je<Ye;je++){const P=b(ce[ce.length-1],1);ce.push(P)}}return ce}function lw(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 sw(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 sg(a,s,o,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let x=d||m||h;const{differenceInCalendarMonths:b,addMonths:w,startOfMonth:v}=u;if(o&&b(o,x)<p-1){const S=-1*(p-1);x=w(o,S)}return s&&b(x,s)<0&&(x=s),v(x)}function iw(a,s,o,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:x,getISOWeek:b,getWeek:w,startOfBroadcastWeek:v,startOfISOWeek:S,startOfWeek:M}=u,A=a.reduce((U,_)=>{const T=o.broadcastCalendar?v(_,u):o.ISOWeek?S(_):M(_),K=o.broadcastCalendar?m(_):o.ISOWeek?h(p(_)):x(p(_)),B=s.filter(H=>H>=T&&H<=K),L=o.broadcastCalendar?35:42;if(o.fixedWeeks&&B.length<L){const H=s.filter(Z=>{const te=L-B.length;return Z>K&&Z<=d(K,te)});B.push(...H)}const k=B.reduce((H,Z)=>{const te=o.ISOWeek?b(Z):w(Z),ce=H.find(oe=>oe.weekNumber===te),be=new Tx(Z,_,u);return ce?ce.days.push(be):H.push(new nC(te,[be])),H},[]),N=new tC(_,k);return U.push(N),U},[]);return o.reverseMonths?A.reverse():A}function rw(a,s){let{startMonth:o,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:x,endOfYear:b,newDate:w,today:v}=s,{fromYear:S,toYear:M,fromMonth:A,toMonth:U}=a;!o&&A&&(o=A),!o&&S&&(o=s.newDate(S,0,1)),!u&&U&&(u=U),!u&&M&&(u=w(M,11,31));const _=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return o?o=h(o):S?o=w(S,0,1):!o&&_&&(o=d(x(a.today??v(),-100))),u?u=p(u):M?u=w(M,11,31):!u&&_&&(u=b(a.today??v())),[o&&m(o),u&&m(u)]}function ow(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m:1,w=h(a);if(!s)return p(w,b);if(!(x(s,a)<m))return p(w,b)}function uw(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m??1:1,w=h(a);if(!s)return p(w,-b);if(!(x(w,s)<=0))return p(w,-b)}function cw(a){const s=[];return a.reduce((o,u)=>o.concat(u.weeks.slice()),s.slice())}function io(a,s){const[o,u]=y.useState(a);return[s===void 0?o:s,u]}function dw(a,s){const[o,u]=rw(a,s),{startOfMonth:d,endOfMonth:m}=s,h=sg(a,o,u,s),[p,x]=io(h,a.month?h:void 0);y.useEffect(()=>{const L=sg(a,o,u,s);x(L)},[a.timeZone]);const{months:b,weeks:w,days:v,previousMonth:S,nextMonth:M}=y.useMemo(()=>{const L=sw(p,u,{numberOfMonths:a.numberOfMonths},s),k=aw(L,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),N=iw(L,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),H=cw(N),Z=lw(N),te=uw(p,o,a,s),ce=ow(p,u,a,s);return{months:N,weeks:H,days:Z,previousMonth:te,nextMonth:ce}},[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:A,onMonthChange:U}=a,_=L=>w.some(k=>k.days.some(N=>N.isEqualTo(L))),T=L=>{if(A)return;let k=d(L);o&&k<d(o)&&(k=d(o)),u&&k>d(u)&&(k=d(u)),x(k),U?.(k)};return{months:b,weeks:w,days:v,navStart:o,navEnd:u,previousMonth:S,nextMonth:M,goToMonth:T,goToDay:L=>{_(L)||T(L.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 ig(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function fw(a,s,o,u){let d,m=-1;for(const h of a){const p=s(h);ig(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=>ig(s(h)))),d}function mw(a,s,o,u,d,m,h){const{ISOWeek:p,broadcastCalendar:x}=m,{addDays:b,addMonths:w,addWeeks:v,addYears:S,endOfBroadcastWeek:M,endOfISOWeek:A,endOfWeek:U,max:_,min:T,startOfBroadcastWeek:K,startOfISOWeek:B,startOfWeek:L}=h;let N={day:b,week:v,month:w,year:S,startOfWeek:H=>x?K(H,h):p?B(H):L(H),endOfWeek:H=>x?M(H):p?A(H):U(H)}[a](o,s==="after"?1:-1);return s==="before"&&u?N=_([u,N]):s==="after"&&d&&(N=T([d,N])),N}function Kx(a,s,o,u,d,m,h,p=0){if(p>365)return;const x=mw(a,s,o.date,u,d,m,h),b=!!(m.disabled&&fa(x,m.disabled,h)),w=!!(m.hidden&&fa(x,m.hidden,h)),v=x,S=new Tx(x,v,h);return!b&&!w?S:Kx(a,s,S,u,d,m,h,p+1)}function hw(a,s,o,u,d){const{autoFocus:m}=a,[h,p]=y.useState(),x=fw(s.days,o,u||(()=>!1),h),[b,w]=y.useState(m?x:void 0);return{isFocusTarget:U=>!!x?.isEqualTo(U),setFocused:w,focused:b,blur:()=>{p(b),w(void 0)},moveFocus:(U,_)=>{if(!b)return;const T=Kx(U,_,b,s.navStart,s.navEnd,a,d);T&&(a.disableNavigation&&!s.days.some(B=>B.isEqualTo(T))||(s.goToDay(T),w(T)))}}}function pw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s,b=M=>p?.some(A=>x(A,M))??!1,{min:w,max:v}=a;return{selected:p,select:(M,A,U)=>{let _=[...p??[]];if(b(M)){if(p?.length===w||u&&p?.length===1)return;_=p?.filter(T=>!x(T,M))}else p?.length===v?_=[M]:_=[..._,M];return d||h(_),d?.(_,M,A,U),_},isSelected:b}}function gw(a,s,o=0,u=0,d=!1,m=qn){const{from:h,to:p}=s||{},{isSameDay:x,isAfter:b,isBefore:w}=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:w(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(w(a,h))v={from:a,to:p};else if(b(a,h))v={from:h,to:a};else if(b(a,p))v={from:h,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const S=m.differenceInCalendarDays(v.to,v.from);u>0&&S>u?v={from:a,to:void 0}:o>1&&S<o&&(v={from:a,to:void 0})}return v}function xw(a,s,o=qn){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 rg(a,s,o=qn){return da(a,s.from,!1,o)||da(a,s.to,!1,o)||da(s,a.from,!1,o)||da(s,a.to,!1,o)}function yw(a,s,o=qn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:o.isDate(p)?da(a,p,!1,o):zx(p,o)?p.some(x=>da(a,x,!1,o)):so(p)?p.from&&p.to?rg(a,{from:p.from,to:p.to},o):!1:Ax(p)?xw(a,p.dayOfWeek,o):xd(p)?o.isAfter(p.before,p.after)?rg(a,{from:o.addDays(p.after,1),to:o.addDays(p.before,-1)},o):fa(a.from,p,o)||fa(a.to,p,o):yd(p)||vd(p)?fa(a.from,p,o)||fa(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 b=0;b<=x;b++){if(h.some(w=>w(p)))return!0;p=o.addDays(p,1)}}return!1}function vw(a,s){const{disabled:o,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,x]=io(d,h?d:void 0),b=h?d:p;return{selected:b,select:(S,M,A)=>{const{min:U,max:_}=a,T=S?gw(S,b,U,_,m,s):void 0;return u&&o&&T?.from&&T.to&&yw({from:T.from,to:T.to},o,s)&&(T.from=S,T.to=void 0),h||x(T),h?.(T,S,M,A),T},isSelected:S=>b&&da(b,S,!1,s)}}function bw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s;return{selected:p,select:(v,S,M)=>{let A=v;return!u&&p&&p&&x(v,p)&&(A=void 0),d||h(A),d?.(A,v,S,M),A},isSelected:v=>p?x(p,v):!1}}function Sw(a,s){const o=bw(a,s),u=pw(a,s),d=vw(a,s);switch(a.mode){case"single":return o;case"multiple":return u;case"range":return d;default:return}}function Ot(a,s){return a instanceof ca&&a.timeZone===s?a:new ca(a,s)}function og(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Ot(a,s):Array.isArray(a)?a.map(o=>o instanceof Date?Ot(o,s):o):so(a)?{...a,from:a.from?Ot(a.from,s):a.from,to:a.to?Ot(a.to,s):a.to}:xd(a)?{before:Ot(a.before,s),after:Ot(a.after,s)}:yd(a)?{after:Ot(a.after,s)}:vd(a)?{before:Ot(a.before,s)}:a}function Dc(a,s){return a&&(Array.isArray(a)?a.map(o=>og(o,s)):og(a,s))}function jw(a){let s=a;const o=s.timeZone;if(o&&(s={...a,timeZone:o},s.today&&(s.today=Ot(s.today,o)),s.month&&(s.month=Ot(s.month,o)),s.defaultMonth&&(s.defaultMonth=Ot(s.defaultMonth,o)),s.startMonth&&(s.startMonth=Ot(s.startMonth,o)),s.endMonth&&(s.endMonth=Ot(s.endMonth,o)),s.mode==="single"&&s.selected?s.selected=Ot(s.selected,o):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(re=>Ot(re,o)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Ot(s.selected.from,o):s.selected.from,to:s.selected.to?Ot(s.selected.to,o):s.selected.to}),s.disabled!==void 0&&(s.disabled=Dc(s.disabled,o)),s.hidden!==void 0&&(s.hidden=Dc(s.hidden,o)),s.modifiers)){const re={};Object.keys(s.modifiers).forEach(Se=>{re[Se]=Dc(s.modifiers?.[Se],o)}),s.modifiers=re}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:x}=y.useMemo(()=>{const re={...Mx,...s.locale},Se=new sn({locale:re,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:Se,components:DC(s.components),formatters:KC(s.formatters),labels:WC(s.labels,Se.options),locale:re,classNames:{...kC(),...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:b,mode:w,navLayout:v,numberOfMonths:S=1,onDayBlur:M,onDayClick:A,onDayFocus:U,onDayKeyDown:_,onDayMouseEnter:T,onDayMouseLeave:K,onNextClick:B,onPrevClick:L,showWeekNumber:k,styles:N}=s,{formatCaption:H,formatDay:Z,formatMonthDropdown:te,formatWeekNumber:ce,formatWeekNumberHeader:be,formatWeekdayName:oe,formatYearDropdown:Ye}=d,je=dw(s,h),{days:P,months:O,navStart:W,navEnd:se,previousMonth:ye,nextMonth:ve,goToMonth:De}=je,ze=AC(P,s,W,se,h),{isSelected:X,select:J,selected:ne}=Sw(s,h)??{},{blur:F,focused:ee,isFocusTarget:fe,moveFocus:Ae,setFocused:Ge}=hw(s,je,ze,X??(()=>!1),h),{labelDayButton:yt,labelGridcell:vt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Qt,labelNext:Bn,labelWeekday:Ne,labelWeekNumber:Vt,labelWeekNumberHeader:En,labelYearDropdown:Xt}=m,ma=y.useMemo(()=>PC(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Hn=w!==void 0||A!==void 0,ct=y.useCallback(()=>{ye&&(De(ye),L?.(ye))},[ye,De,L]),Zt=y.useCallback(()=>{ve&&(De(ve),B?.(ve))},[De,ve,B]),Ln=y.useCallback((re,Se)=>he=>{he.preventDefault(),he.stopPropagation(),Ge(re),!Se.disabled&&(J?.(re.date,Se,he),A?.(re.date,Se,he))},[J,A,Ge]),Va=y.useCallback((re,Se)=>he=>{Ge(re),U?.(re.date,Se,he)},[U,Ge]),Mn=y.useCallback((re,Se)=>he=>{F(),M?.(re.date,Se,he)},[F,M]),Tn=y.useCallback((re,Se)=>he=>{const Te={ArrowLeft:[he.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[he.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[he.shiftKey?"year":"week","after"],ArrowUp:[he.shiftKey?"year":"week","before"],PageUp:[he.shiftKey?"year":"month","before"],PageDown:[he.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Te[he.key]){he.preventDefault(),he.stopPropagation();const[Fe,xe]=Te[he.key];Ae(Fe,xe)}_?.(re.date,Se,he)},[Ae,_,s.dir]),xl=y.useCallback((re,Se)=>he=>{T?.(re.date,Se,he)},[T]),us=y.useCallback((re,Se)=>he=>{K?.(re.date,Se,he)},[K]),cs=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setMonth(h.startOfMonth(re),he);De(Te)},[h,De]),Yn=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setYear(h.startOfMonth(re),he);De(Te)},[h,De]),{className:$,style:Ee}=y.useMemo(()=>({className:[x[ue.Root],s.className].filter(Boolean).join(" "),style:{...N?.[ue.Root],...s.style}}),[x,s.className,s.style,N]),me=_C(s),Me=y.useRef(null);nw(Me,!!s.animate,{classNames:x,months:O,focused:ee,dateLib:h});const nt={dayPickerProps:s,selected:ne,select:J,isSelected:X,months:O,nextMonth:ve,previousMonth:ye,goToMonth:De,getModifiers:ze,components:u,classNames:x,styles:N,labels:m,formatters:d};return I.createElement(Ox.Provider,{value:nt},I.createElement(u.Root,{rootRef:s.animate?Me:void 0,className:$,style:Ee,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"],...me},I.createElement(u.Months,{className:x[ue.Months],style:N?.[ue.Months]},!s.hideNavigation&&!v&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),O.map((re,Se)=>I.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[ue.Month],style:N?.[ue.Month],key:Se,displayIndex:Se,calendarMonth:re},v==="around"&&!s.hideNavigation&&Se===0&&I.createElement(u.PreviousMonthButton,{type:"button",className:x[ue.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Qt(ye),onClick:ct,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"right":"left"})),I.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[ue.MonthCaption],style:N?.[ue.MonthCaption],calendarMonth:re,displayIndex:Se},b?.startsWith("dropdown")?I.createElement(u.DropdownNav,{className:x[ue.Dropdowns],style:N?.[ue.Dropdowns]},(()=>{const he=b==="dropdown"||b==="dropdown-months"?I.createElement(u.MonthsDropdown,{key:"month",className:x[ue.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:cs(re.date),options:$C(re.date,W,se,d,h),style:N?.[ue.Dropdown],value:h.getMonth(re.date)}):I.createElement("span",{key:"month"},te(re.date,h)),Te=b==="dropdown"||b==="dropdown-years"?I.createElement(u.YearsDropdown,{key:"year",className:x[ue.YearsDropdown],"aria-label":Xt(h.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Yn(re.date),options:FC(W,se,d,h,!!s.reverseYears),style:N?.[ue.Dropdown],value:h.getYear(re.date)}):I.createElement("span",{key:"year"},Ye(re.date,h));return h.getMonthYearOrder()==="year-first"?[Te,he]:[he,Te]})(),I.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"}},H(re.date,h.options,h))):I.createElement(u.CaptionLabel,{className:x[ue.CaptionLabel],role:"status","aria-live":"polite"},H(re.date,h.options,h))),v==="around"&&!s.hideNavigation&&Se===S-1&&I.createElement(u.NextMonthButton,{type:"button",className:x[ue.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":Bn(ve),onClick:Zt,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Se===S-1&&v==="after"&&!s.hideNavigation&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),I.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":w==="multiple"||w==="range","aria-label":Qe(re.date,h.options,h)||void 0,className:x[ue.MonthGrid],style:N?.[ue.MonthGrid]},!s.hideWeekdays&&I.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[ue.Weekdays],style:N?.[ue.Weekdays]},k&&I.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:x[ue.WeekNumberHeader],style:N?.[ue.WeekNumberHeader],scope:"col"},be()),ma.map(he=>I.createElement(u.Weekday,{"aria-label":Ne(he,h.options,h),className:x[ue.Weekday],key:String(he),style:N?.[ue.Weekday],scope:"col"},oe(he,h.options,h)))),I.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[ue.Weeks],style:N?.[ue.Weeks]},re.weeks.map(he=>I.createElement(u.Week,{className:x[ue.Week],key:he.weekNumber,style:N?.[ue.Week],week:he},k&&I.createElement(u.WeekNumber,{week:he,style:N?.[ue.WeekNumber],"aria-label":Vt(he.weekNumber,{locale:p}),className:x[ue.WeekNumber],scope:"row",role:"rowheader"},ce(he.weekNumber,h)),he.days.map(Te=>{const{date:Fe}=Te,xe=ze(Te);if(xe[lt.focused]=!xe.hidden&&!!ee?.isEqualTo(Te),xe[Cn.selected]=X?.(Fe)||xe.selected,so(ne)){const{from:Wt,to:vn}=ne;xe[Cn.range_start]=!!(Wt&&vn&&h.isSameDay(Fe,Wt)),xe[Cn.range_end]=!!(Wt&&vn&&h.isSameDay(Fe,vn)),xe[Cn.range_middle]=da(ne,Fe,!0,h)}const Dt=JC(xe,N,s.modifiersStyles),Gn=zC(xe,x,s.modifiersClassNames),St=!Hn&&!xe.hidden?vt(Fe,xe,h.options,h):void 0;return I.createElement(u.Day,{key:`${Te.isoDate}_${Te.displayMonthId}`,day:Te,modifiers:xe,className:Gn.join(" "),style:Dt,role:"gridcell","aria-selected":xe.selected||void 0,"aria-label":St,"data-day":Te.isoDate,"data-month":Te.outside?Te.dateMonthId:void 0,"data-selected":xe.selected||void 0,"data-disabled":xe.disabled||void 0,"data-hidden":xe.hidden||void 0,"data-outside":Te.outside||void 0,"data-focused":xe.focused||void 0,"data-today":xe.today||void 0},!xe.hidden&&Hn?I.createElement(u.DayButton,{className:x[ue.DayButton],style:N?.[ue.DayButton],type:"button",day:Te,modifiers:xe,disabled:!xe.focused&&xe.disabled||void 0,"aria-disabled":xe.focused&&xe.disabled||void 0,tabIndex:fe(Te)?0:-1,"aria-label":yt(Fe,xe,h.options,h),onClick:Ln(Te,xe),onBlur:Mn(Te,xe),onFocus:Va(Te,xe),onKeyDown:Tn(Te,xe),onMouseEnter:xl(Te,xe),onMouseLeave:us(Te,xe)},Z(Fe,h.options,h)):!xe.hidden&&Z(Te.date,h.options,h))})))))))),s.footer&&I.createElement(u.Footer,{className:x[ue.Footer],style:N?.[ue.Footer],role:"status","aria-live":"polite"},s.footer)))}function Nw({className:a,classNames:s,showOutsideDays:o=!0,...u}){return i.jsx(jw,{showOutsideDays:o,className:G("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:G(Ur({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:G(Ur({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:G("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:G(Ur({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:G("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:G("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:G("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:G("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"?bb:d==="right"?Vr:d==="up"?Xc:Pr;return i.jsx(p,{className:G("h-4 w-4",m),...h})}},...u})}Nw.displayName="Calendar";function Cw(){const[a,s]=y.useState(""),[o,u]=y.useState(""),[d,m]=y.useState(null),[h,p]=y.useState(!1),{login:x,authRequired:b,isAuthenticated:w}=Pc(),v=Gc(),M=Yc().state?.from?.pathname||"/";if(y.useEffect(()=>{(w||!b)&&v(M,{replace:!0})},[w,b,v,M]),w||!b)return null;const A=async U=>{U.preventDefault(),m(null),p(!0);try{await x(a,o),v(M,{replace:!0})}catch(_){m(_ instanceof Error?_.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(x2,{className:"w-full max-w-sm",children:[i.jsxs(y2,{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(Sb,{className:"h-6 w-6 text-primary"})}),i.jsx(v2,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(b2,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(S2,{children:i.jsxs("form",{onSubmit:A,className:"space-y-4",children:[d&&i.jsxs(md,{variant:"destructive",children:[i.jsx(Wc,{className:"h-4 w-4"}),i.jsx(hd,{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:U=>s(U.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:U=>u(U.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:h,required:!0})]}),i.jsx(ot,{type:"submit",className:"w-full",disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsx(Un,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const ww=y.lazy(()=>zt(()=>import("./index-BXTtPkoG.js"),__vite__mapDeps([17,1,2,4,5,7,18,6,8,9])).then(a=>({default:a.AnalyticsPage}))),Ew=y.lazy(()=>zt(()=>import("./api-ClPWraVr.js"),__vite__mapDeps([19,1,2,5,20,14,6,4,7,8,9])).then(a=>({default:a.ApiPage}))),Mw=y.lazy(()=>zt(()=>import("./cliproxy-C0JgtLfO.js"),__vite__mapDeps([21,1,2,5,6,4,20,14,3,13,7,8,9])).then(a=>({default:a.CliproxyPage}))),Tw=y.lazy(()=>zt(()=>import("./cliproxy-control-panel-CBO7xTqe.js"),__vite__mapDeps([22,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),Ow=y.lazy(()=>zt(()=>import("./copilot-DCA0pQV3.js"),__vite__mapDeps([23,1,2,5,20,14,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),Aw=y.lazy(()=>zt(()=>import("./accounts-ResKjvou.js"),__vite__mapDeps([24,1,2,5,14,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),zw=y.lazy(()=>zt(()=>Promise.resolve().then(()=>X2),void 0).then(a=>({default:a.SettingsPage}))),Dw=y.lazy(()=>zt(()=>import("./health-riN3OSz-.js"),__vite__mapDeps([25,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),_w=y.lazy(()=>zt(()=>import("./shared-PuUIRrgy.js"),__vite__mapDeps([26,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function oa(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(Un,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function kw(){return i.jsx(Yv,{client:pS,children:i.jsx(xS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(yS,{children:i.jsx(NS,{children:i.jsxs(Bv,{children:[i.jsxs(Hv,{children:[i.jsx(nn,{path:"/login",element:i.jsx(Cw,{})}),i.jsx(nn,{element:i.jsx(CS,{}),children:i.jsxs(nn,{element:i.jsx(J1,{}),children:[i.jsx(nn,{path:"/",element:i.jsx(XN,{})}),i.jsx(nn,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(ww,{})})}),i.jsx(nn,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ew,{})})}),i.jsx(nn,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Mw,{})})}),i.jsx(nn,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Tw,{})})}),i.jsx(nn,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ow,{})})}),i.jsx(nn,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Aw,{})})}),i.jsx(nn,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(zw,{})})}),i.jsx(nn,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Dw,{})})}),i.jsx(nn,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(_w,{})})})]})})]}),i.jsx(Gv,{position:"top-right"})]})})})})})}const Qx=document.getElementById("root");if(!Qx)throw new Error("Root element not found. Failed to mount React application.");fS.createRoot(Qx).render(i.jsx(y.StrictMode,{children:i.jsx(kw,{})}));export{M2 as $,l2 as A,La as B,x2 as C,gE as D,x1 as E,y1 as F,v1 as G,mx as H,_n as I,pd as J,Kr as K,yn as L,Bc as M,vE as N,b2 as O,Hg as P,SE as Q,bE as R,Le as S,Ya as T,jE as U,gx as V,NE as W,EE as X,C2 as Y,TE as Z,w2 as _,S2 as a,Sx as a$,m1 as a0,Vw as a1,Fw as a2,Iw as a3,nd as a4,ad as a5,ld as a6,sd as a7,id as a8,CE as a9,g1 as aA,Zw as aB,Ww as aC,h1 as aD,p1 as aE,$w as aF,Jw as aG,Pw as aH,Xw as aI,xx as aJ,zt as aK,KN as aL,hE as aM,md as aN,fx as aO,hd as aP,Nx as aQ,L2 as aR,G2 as aS,oE as aT,sE as aU,uE as aV,iE as aW,rE as aX,dE as aY,cE as aZ,Ur as a_,N2 as aa,wE as ab,fE as ac,mE as ad,Ze as ae,eE as af,ME as ag,E2 as ah,q1 as ai,Mj as aj,qS as ak,BS as al,ml as am,G1 as an,K1 as ao,Q1 as ap,V1 as aq,A2 as ar,Tj as as,Vg as at,tE as au,nE as av,aE as aw,lE as ax,OE as ay,Qw as az,ot as b,G as c,AE as d,zE as e,Z2 as f,Nw as g,Kw as h,y2 as i,v2 as j,xj as k,yj as l,gl as m,DE as n,Ga as o,Ka as p,Hp as q,r2 as r,yE as s,PN as t,$c as u,a2 as v,pE as w,xE as x,WN as y,t2 as z};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.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-DMVmIdhk.js";import{N as we,a9 as ae,aa as z,ab as re,D as ne,a0 as ve,G as ke,ac as Ce,R as $e,y as Q,U as Se,Z as le,p as De,a4 as G,ad as Le,x as Te,b as Fe,ae as Re,af as Me}from"./icons-D5eAI-GR.js";import{a as Pe,u as P}from"./tanstack-De4wvi8X.js";import{K as L,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 n=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(n/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:z,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${n.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,l)=>{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)})})]})})},l)})})}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:_e(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:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),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:n,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:n}}),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 _e(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 ze="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${a}${n}`}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),D(`/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),D(`/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)),D(`/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),D(`/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()),D(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),D(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${ze}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>D("/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),D(`/usage/insights?${t}`)}};async function D(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 n=await a.json();return n.data||n}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:L(new Date,30),to:new Date}),[a,n]=f.useState(!1),[r,i]=f.useState(null),[o,l]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{n(!0);try{await u()}finally{n(!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:_,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:L(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();l({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),l(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:_,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:L(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:L(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:L(new Date,90),to:new Date}}],className:n}){const[r,i]=fe.useState(!1),o=l=>!s||!s.from||!s.to||!l.from||!l.to?!1:k(s.from,"yyyy-MM-dd")===k(l.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(l.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",n),children:[a.map(l=>e.jsx(H,{variant:o(l.range)?"default":"outline",size:"sm",onClick:()=>t(l.range),children:l.label},l.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:n,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:L(new Date,7),to:new Date}},{label:"30D",range:{from:L(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:n,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:n}){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",n)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:l,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:l,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",n),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:l=>e.jsx(o,{...l,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:l=>e.jsx(o,{...l,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:l,payload:c,label:x})=>{if(!l||!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[n,r]=s.split(" ");if(n&&r){const i=new Date(`${n}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:n}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(l=>({name:l.model,value:l.tokens,cost:l.cost,percentage:l.percentage,fill:te(l.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:l,payload:c})=>{if(!l||!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",n&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",n&&y),children:["$",u.cost.toFixed(4)]})]})},o=l=>l.percentage>5?`${l.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((l,c)=>e.jsx(Ke,{fill:l.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(s){if(!s)return"";const a=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return a[a.length-1]||""}function cs({data:s,isLoading:t,className:a}){const{privacyMode:n}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,l=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(l/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",n&&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(De,{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:os(i.projectPath)}),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",n&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ds(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 ds(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 xs({className:s,isLoading:t}){const{data:a,isLoading:n}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||n||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(Le,{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=us(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 us(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 ms(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 hs({models:s,isLoading:t,onModelClick:a,privacyMode:n}){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(fs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&y),children:ms(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",n&&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(ps,{})]})})]})}function fs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=n=>s.cost>0?n/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 ps(){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:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function gs({viewMode:s,trends:t,hourlyData:a,models:n,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:l,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(hs,{models:n,isLoading:l,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:n||[],isLoading:l,className:"h-full w-full"})})]}),e.jsx(cs,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(xs,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ds(){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:n,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:l,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:_}=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:n,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:l}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(gs,{viewMode:l,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&&_(),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,Ds as AnalyticsSkeleton};
1
+ import{j as e}from"./radix-ui-qEZD5MMp.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-7gcYb5Oq.js";import{N as we,a9 as ae,aa as z,ab as re,D as ne,a0 as ve,G as ke,ac as Ce,R as $e,y as Q,U as Se,Z as le,p as De,a4 as G,ad as Le,x as Te,b as Fe,ae as Re,af as Me}from"./icons-D5eAI-GR.js";import{a as Pe,u as P}from"./tanstack-De4wvi8X.js";import{K as L,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 n=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(n/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:z,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${n.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,l)=>{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)})})]})})},l)})})}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:_e(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:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),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:n,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:n}}),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 _e(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 ze="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${a}${n}`}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),D(`/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),D(`/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)),D(`/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),D(`/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()),D(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),D(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${ze}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>D("/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),D(`/usage/insights?${t}`)}};async function D(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 n=await a.json();return n.data||n}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:L(new Date,30),to:new Date}),[a,n]=f.useState(!1),[r,i]=f.useState(null),[o,l]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{n(!0);try{await u()}finally{n(!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:_,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:L(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();l({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),l(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:_,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:L(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:L(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:L(new Date,90),to:new Date}}],className:n}){const[r,i]=fe.useState(!1),o=l=>!s||!s.from||!s.to||!l.from||!l.to?!1:k(s.from,"yyyy-MM-dd")===k(l.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(l.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",n),children:[a.map(l=>e.jsx(H,{variant:o(l.range)?"default":"outline",size:"sm",onClick:()=>t(l.range),children:l.label},l.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:n,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:L(new Date,7),to:new Date}},{label:"30D",range:{from:L(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:n,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:n}){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",n)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:l,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:l,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",n),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:l=>e.jsx(o,{...l,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:l=>e.jsx(o,{...l,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:l,payload:c,label:x})=>{if(!l||!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[n,r]=s.split(" ");if(n&&r){const i=new Date(`${n}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:n}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(l=>({name:l.model,value:l.tokens,cost:l.cost,percentage:l.percentage,fill:te(l.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:l,payload:c})=>{if(!l||!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",n&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",n&&y),children:["$",u.cost.toFixed(4)]})]})},o=l=>l.percentage>5?`${l.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((l,c)=>e.jsx(Ke,{fill:l.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(s){if(!s)return"";const a=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return a[a.length-1]||""}function cs({data:s,isLoading:t,className:a}){const{privacyMode:n}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,l=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(l/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",n&&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(De,{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:os(i.projectPath)}),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",n&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ds(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 ds(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 xs({className:s,isLoading:t}){const{data:a,isLoading:n}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||n||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(Le,{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=us(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 us(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 ms(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 hs({models:s,isLoading:t,onModelClick:a,privacyMode:n}){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(fs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&y),children:ms(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",n&&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(ps,{})]})})]})}function fs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=n=>s.cost>0?n/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 ps(){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:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function gs({viewMode:s,trends:t,hourlyData:a,models:n,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:l,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(hs,{models:n,isLoading:l,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:n||[],isLoading:l,className:"h-full w-full"})})]}),e.jsx(cs,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(xs,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ds(){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:n,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:l,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:_}=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:n,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:l}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(gs,{viewMode:l,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&&_(),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,Ds as AnalyticsSkeleton};