@kaitranntt/ccs 7.12.2-dev.1 → 7.12.2-dev.2

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 (31) hide show
  1. package/config/base-mm.settings.json +10 -0
  2. package/dist/api/services/provider-presets.js +3 -3
  3. package/dist/api/services/provider-presets.js.map +1 -1
  4. package/dist/ccs.js +20 -1
  5. package/dist/ccs.js.map +1 -1
  6. package/dist/ui/assets/{accounts-C8We5aGM.js → accounts-CYPk9fa-.js} +1 -1
  7. package/dist/ui/assets/{alert-dialog-DkKAElfe.js → alert-dialog-BrIFqgMZ.js} +1 -1
  8. package/dist/ui/assets/{api-9506vRxR.js → api-Bi24p47r.js} +1 -1
  9. package/dist/ui/assets/{auth-section-3uaw-usA.js → auth-section-3fqp84IR.js} +1 -1
  10. package/dist/ui/assets/{card-Cuha2Jzb.js → card-ClMztcJ3.js} +1 -1
  11. package/dist/ui/assets/{cliproxy-BXDGSpjs.js → cliproxy-CsE7HKWc.js} +1 -1
  12. package/dist/ui/assets/{cliproxy-control-panel-Dr76Wi8D.js → cliproxy-control-panel-Cahd6g6e.js} +1 -1
  13. package/dist/ui/assets/{confirm-dialog-BURgygNf.js → confirm-dialog-ByvRv_aE.js} +1 -1
  14. package/dist/ui/assets/{copilot-CVl7HYuu.js → copilot-B4AE6FGx.js} +2 -2
  15. package/dist/ui/assets/{globalenv-section-DTzNIABc.js → globalenv-section-CGdnlj1K.js} +1 -1
  16. package/dist/ui/assets/{health-BP6tpJjs.js → health-BINs7JKH.js} +1 -1
  17. package/dist/ui/assets/{index-9Z6zaaYU.js → index-4FYBhG16.js} +1 -1
  18. package/dist/ui/assets/{index-DrXzuIu0.js → index-CV_o8KZD.js} +1 -1
  19. package/dist/ui/assets/{index-Bb7TSGy0.js → index-Cf72mW4U.js} +1 -1
  20. package/dist/ui/assets/{index-DUdATQub.js → index-DXF1Z58h.js} +3 -3
  21. package/dist/ui/assets/{shared-1FiVmFEu.js → shared-bCN7WjG_.js} +1 -1
  22. package/dist/ui/assets/{switch-2sZL1mqB.js → switch-Big41pQ7.js} +1 -1
  23. package/dist/ui/index.html +1 -1
  24. package/dist/utils/api-key-validator.d.ts +1 -7
  25. package/dist/utils/api-key-validator.d.ts.map +1 -1
  26. package/dist/utils/api-key-validator.js +45 -36
  27. package/dist/utils/api-key-validator.js.map +1 -1
  28. package/dist/web-server/model-pricing.d.ts.map +1 -1
  29. package/dist/web-server/model-pricing.js +21 -0
  30. package/dist/web-server/model-pricing.js.map +1 -1
  31. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bb7TSGy0.js","assets/radix-ui-uXQB-q0u.js","assets/react-vendor-B_CU-WTZ.js","assets/switch-2sZL1mqB.js","assets/icons-CwFZAiDB.js","assets/tanstack-Coed0rqz.js","assets/notifications-dJQY2-U6.js","assets/utils-CzKF5WmX.js","assets/form-utils-kUVlZZAO.js","assets/code-highlight-DKN39ySy.js","assets/globalenv-section-DTzNIABc.js","assets/index-9Z6zaaYU.js","assets/auth-section-3uaw-usA.js","assets/index-DrXzuIu0.js","assets/card-Cuha2Jzb.js","assets/charts-CJC4bH8P.js","assets/api-9506vRxR.js","assets/confirm-dialog-BURgygNf.js","assets/alert-dialog-DkKAElfe.js","assets/cliproxy-BXDGSpjs.js","assets/cliproxy-control-panel-Dr76Wi8D.js","assets/copilot-CVl7HYuu.js","assets/accounts-C8We5aGM.js","assets/health-BP6tpJjs.js","assets/shared-1FiVmFEu.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Cf72mW4U.js","assets/radix-ui-uXQB-q0u.js","assets/react-vendor-B_CU-WTZ.js","assets/switch-Big41pQ7.js","assets/icons-CwFZAiDB.js","assets/tanstack-Coed0rqz.js","assets/notifications-dJQY2-U6.js","assets/utils-CzKF5WmX.js","assets/form-utils-kUVlZZAO.js","assets/code-highlight-DKN39ySy.js","assets/globalenv-section-CGdnlj1K.js","assets/index-4FYBhG16.js","assets/auth-section-3fqp84IR.js","assets/index-CV_o8KZD.js","assets/card-ClMztcJ3.js","assets/charts-CJC4bH8P.js","assets/api-Bi24p47r.js","assets/confirm-dialog-ByvRv_aE.js","assets/alert-dialog-BrIFqgMZ.js","assets/cliproxy-CsE7HKWc.js","assets/cliproxy-control-panel-Cahd6g6e.js","assets/copilot-B4AE6FGx.js","assets/accounts-CYPk9fa-.js","assets/health-BINs7JKH.js","assets/shared-bCN7WjG_.js"])))=>i.map(i=>d[i]);
2
2
  import{j as o,S as Yo,R as Bp,C as Hp,a as qp,T as Lp,D as Yp,P as Gp,O as Kp,b as Ox,c as Ax,d as Dx,e as _x,f as kx,A as Rx,g as Ux,h as Bx,i as Hx,k as Qp,V as qx,l as Lx,m as Vp,n as Yx,L as Xp,o as Zp,p as Wp,q as Gx,r as Kx,s as Jp,I as Qx,t as $p,u as Fp,v as Vx,w as Ip,x as Xx,y as Pp,z as eg,B as Zx,E as Wx,F as tg,G as Jx,H as $x,J as Fx,K as Ix,M as ng,N as Px,Q as ev,U as tv}from"./radix-ui-uXQB-q0u.js";import{e as ag,f as nv,r as v,u as av,L as Tc,O as lv,R as sv,h as iv,g as ov,i as rv,c as P,B as uv,j as cv,k as Sn}from"./react-vendor-B_CU-WTZ.js";import{Q as dv,u as Gt,a as zt,b as ln,c as fv}from"./tanstack-Coed0rqz.js";import{t as Ne,T as mv}from"./notifications-dJQY2-U6.js";import{t as hv,c as pv,a as Go,e as Ps,f as ni,b as gv,d as yv,g as xv,h as vv,i as bv,j as Sv,k as Nv,l as jv,m as Cv,n as Ev,o as wv,p as Mv,q as Tv,r as zv,s as Ov,u as Av,v as Dv,w as _v,x as kv,y as Rv,z as Uv,A as Bv,B as Hv,C as qv,D as Lv,E as Yv,F as Gv,G as Kv,H as Qv,I as Vv,J as Xv}from"./utils-CzKF5WmX.js";import{X as di,P as Zv,H as Wv,C as Jv,K as lg,G as $v,Z as sg,a as ig,F as og,U as rg,A as oi,S as Fv,b as Ko,c as Iv,M as Pv,E as Qo,d as Vo,B as eb,W as tb,e as Jh,f as nb,g as ab,h as $h,i as Fh,L as as,j as ns,k as ug,l as Bo,m as cg,n as Xo,o as Rc,p as Zo,q as Uc,R as lb,r as sb,s as ib,T as ul,I as Wo,t as ob,u as rb,v as ub,w as cb,x as db,y as fb,z as mb,D as Bc,J as Jo,N as Hc,O as Ih,Q as hb,V as pb,Y as gb,_ as yb,$ as Ph,a0 as ep,a1 as xb}from"./icons-CwFZAiDB.js";import{o as tp,s as np,p as vb,a as bb,$ as Sb,b as dg,c as Nb,d as ll,u as jb,e as Cb}from"./form-utils-kUVlZZAO.js";import{H as Eb,t as ap}from"./code-highlight-DKN39ySy.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 r(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=r(d);fetch(d.href,m)}})();var hc={exports:{}},ei={},pc={exports:{}},gc={};var lp;function wb(){return lp||(lp=1,(function(a){function s(T,Z){var ae=T.length;T.push(Z);e:for(;0<ae;){var ye=ae-1>>>1,xe=T[ye];if(0<d(xe,Z))T[ye]=Z,T[ae]=xe,ae=ye;else break e}}function r(T){return T.length===0?null:T[0]}function u(T){if(T.length===0)return null;var Z=T[0],ae=T.pop();if(ae!==Z){T[0]=ae;e:for(var ye=0,xe=T.length,Ae=xe>>>1;ye<Ae;){var ce=2*(ye+1)-1,X=T[ce],F=ce+1,le=T[F];if(0>d(X,ae))F<xe&&0>d(le,X)?(T[ye]=le,T[F]=ae,ye=F):(T[ye]=X,T[ce]=ae,ye=ce);else if(F<xe&&0>d(le,ae))T[ye]=le,T[F]=ae,ye=F;else break e}}return Z}function d(T,Z){var ae=T.sortIndex-Z.sortIndex;return ae!==0?ae:T.id-Z.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;a.unstable_now=function(){return m.now()}}else{var h=Date,p=h.now();a.unstable_now=function(){return h.now()-p}}var y=[],S=[],M=1,x=null,b=3,_=!1,A=!1,R=!1,B=!1,w=typeof setTimeout=="function"?setTimeout:null,Y=typeof clearTimeout=="function"?clearTimeout:null,q=typeof setImmediate<"u"?setImmediate:null;function Q(T){for(var Z=r(S);Z!==null;){if(Z.callback===null)u(S);else if(Z.startTime<=T)u(S),Z.sortIndex=Z.expirationTime,s(y,Z);else break;Z=r(S)}}function k(T){if(R=!1,Q(T),!A)if(r(y)!==null)A=!0,j||(j=!0,oe());else{var Z=r(S);Z!==null&&$(k,Z.startTime-T)}}var j=!1,L=-1,J=5,ee=-1;function de(){return B?!0:!(a.unstable_now()-ee<J)}function ve(){if(B=!1,j){var T=a.unstable_now();ee=T;var Z=!0;try{e:{A=!1,R&&(R=!1,Y(L),L=-1),_=!0;var ae=b;try{t:{for(Q(T),x=r(y);x!==null&&!(x.expirationTime>T&&de());){var ye=x.callback;if(typeof ye=="function"){x.callback=null,b=x.priorityLevel;var xe=ye(x.expirationTime<=T);if(T=a.unstable_now(),typeof xe=="function"){x.callback=xe,Q(T),Z=!0;break t}x===r(y)&&u(y),Q(T)}else u(y);x=r(y)}if(x!==null)Z=!0;else{var Ae=r(S);Ae!==null&&$(k,Ae.startTime-T),Z=!1}}break e}finally{x=null,b=ae,_=!1}Z=void 0}}finally{Z?oe():j=!1}}}var oe;if(typeof q=="function")oe=function(){q(ve)};else if(typeof MessageChannel<"u"){var Ye=new MessageChannel,Se=Ye.port2;Ye.port1.onmessage=ve,oe=function(){Se.postMessage(null)}}else oe=function(){w(ve,0)};function $(T,Z){L=w(function(){T(a.unstable_now())},Z)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(T){T.callback=null},a.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<T?Math.floor(1e3/T):5},a.unstable_getCurrentPriorityLevel=function(){return b},a.unstable_next=function(T){switch(b){case 1:case 2:case 3:var Z=3;break;default:Z=b}var ae=b;b=Z;try{return T()}finally{b=ae}},a.unstable_requestPaint=function(){B=!0},a.unstable_runWithPriority=function(T,Z){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var ae=b;b=T;try{return Z()}finally{b=ae}},a.unstable_scheduleCallback=function(T,Z,ae){var ye=a.unstable_now();switch(typeof ae=="object"&&ae!==null?(ae=ae.delay,ae=typeof ae=="number"&&0<ae?ye+ae:ye):ae=ye,T){case 1:var xe=-1;break;case 2:xe=250;break;case 5:xe=1073741823;break;case 4:xe=1e4;break;default:xe=5e3}return xe=ae+xe,T={id:M++,callback:Z,priorityLevel:T,startTime:ae,expirationTime:xe,sortIndex:-1},ae>ye?(T.sortIndex=ae,s(S,T),r(y)===null&&T===r(S)&&(R?(Y(L),L=-1):R=!0,$(k,ae-ye))):(T.sortIndex=xe,s(y,T),A||_||(A=!0,j||(j=!0,oe()))),T},a.unstable_shouldYield=de,a.unstable_wrapCallback=function(T){var Z=b;return function(){var ae=b;b=Z;try{return T.apply(this,arguments)}finally{b=ae}}}})(gc)),gc}var sp;function Mb(){return sp||(sp=1,pc.exports=wb()),pc.exports}var ip;function Tb(){if(ip)return ei;ip=1;var a=Mb(),s=ag(),r=nv();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 y(e){if(m(e)!==e)throw Error(u(188))}function S(e){var t=e.alternate;if(!t){if(t=m(e),t===null)throw Error(u(188));return t!==e?null:e}for(var n=e,l=t;;){var i=n.return;if(i===null)break;var c=i.alternate;if(c===null){if(l=i.return,l!==null){n=l;continue}break}if(i.child===c.child){for(c=i.child;c;){if(c===n)return y(i),e;if(c===l)return y(i),t;c=c.sibling}throw Error(u(188))}if(n.return!==l.return)n=i,l=c;else{for(var f=!1,g=i.child;g;){if(g===n){f=!0,n=i,l=c;break}if(g===l){f=!0,l=i,n=c;break}g=g.sibling}if(!f){for(g=c.child;g;){if(g===n){f=!0,n=c,l=i;break}if(g===l){f=!0,l=c,n=i;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 M(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=M(e),t!==null)return t;e=e.sibling}return null}var x=Object.assign,b=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),q=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),de=Symbol.for("react.memo_cache_sentinel"),ve=Symbol.iterator;function oe(e){return e===null||typeof e!="object"?null:(e=ve&&e[ve]||e["@@iterator"],typeof e=="function"?e:null)}var Ye=Symbol.for("react.client.reference");function Se(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 R:return"Fragment";case w:return"Profiler";case B:return"StrictMode";case k:return"Suspense";case j:return"SuspenseList";case ee:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case A:return"Portal";case q:return e.displayName||"Context";case Y:return(e._context.displayName||"Context")+".Consumer";case Q:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return t=e.displayName||null,t!==null?t:Se(e.type)||"Memo";case J:t=e._payload,e=e._init;try{return Se(e(t))}catch{}}return null}var $=Array.isArray,T=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},ye=[],xe=-1;function Ae(e){return{current:e}}function ce(e){0>xe||(e.current=ye[xe],ye[xe]=null,xe--)}function X(e,t){xe++,ye[xe]=e.current,e.current=t}var F=Ae(null),le=Ae(null),I=Ae(null),ne=Ae(null);function ge(e,t){switch(X(I,t),X(le,e),X(F,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xh(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xh(t),e=vh(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ce(F),X(F,e)}function De(){ce(F),ce(le),ce(I)}function Ge(e){e.memoizedState!==null&&X(ne,e);var t=F.current,n=vh(t,e.type);t!==n&&(X(le,e),X(F,n))}function pt(e){le.current===e&&(ce(F),ce(le)),ne.current===e&&(ce(ne),Js._currentValue=ae)}var gt,Qe;function et(e){if(gt===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);gt=t&&t[1]||"",Qe=-1<n.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+gt+e+Qe}var Dt=!1;function Kt(e,t){if(!e||Dt)return"";Dt=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(U){var D=U}Reflect.construct(e,[],K)}else{try{K.call()}catch(U){D=U}e.call(K.prototype)}}else{try{throw Error()}catch(U){D=U}(K=e())&&typeof K.catch=="function"&&K.catch(function(){})}}catch(U){if(U&&D&&typeof U.stack=="string")return[U.stack,D.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var i=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");i&&i.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=l.DetermineComponentFrameRoot(),f=c[0],g=c[1];if(f&&g){var N=f.split(`
@@ -11,7 +11,7 @@ Error generating stack: `+l.message+`
11
11
  `);for(const u of r){const[d,...m]=u.split(":"),h=m.join(":").trim();switch(d?.trim()?.toLowerCase()){case"version":s.version=h;break;case"url":s.url=h;break;case"method":s.method=h;break;case"timestamp":s.timestamp=h;break}}}function dN(a){const s={},r=a.split(`
12
12
  `);for(const u of r){const d=u.indexOf(":");if(d>0){const m=u.slice(0,d).trim(),h=u.slice(d+1).trim();m&&(s[m]=h)}}return s}function fN(a,s){const r=a.split(`
13
13
  `);let u=!1;const d=[];for(const m of r){if(m.startsWith("Status:")){const p=m.replace("Status:","").trim().split(/\s+/);s.statusCode=parseInt(p[0],10)||0,s.statusText=p.slice(1).join(" ")||gN(s.statusCode);continue}if(m.trim()===""&&!u){u=!0;continue}if(u)d.push(m);else{const h=m.indexOf(":");if(h>0){const p=m.slice(0,h).trim(),y=m.slice(h+1).trim();p&&(s.responseHeaders[p]=y)}}}s.responseBody=d.join(`
14
- `).trim()}function mN(a){const s=a.url.match(/\/api\/provider\/([^/]+)/);s&&(a.provider=s[1]);const r=a.url.match(/\/api\/provider\/[^/]+\/(.+?)(?:\?|$)/);r&&(a.endpoint=r[1]),a.isClientError=a.statusCode>=400&&a.statusCode<500,a.isServerError=a.statusCode>=500,a.statusCode===429?a.errorType="rate_limit":a.statusCode===401||a.statusCode===403?a.errorType="auth":a.statusCode===404?a.errorType="not_found":a.statusCode>=500?a.errorType="server":(a.statusCode===408||a.statusCode===504)&&(a.errorType="timeout"),hN(a),a.statusCode===429&&pN(a)}function hN(a){if(a.requestBody)try{const s=JSON.parse(a.requestBody);typeof s.model=="string"&&(a.model=s.model)}catch{}}function pN(a){if(a.responseBody)try{const s=JSON.parse(a.responseBody),r=Oc(s);r!==null&&(a.quotaResetDelay=r);const u=Ac(s);u&&(a.quotaResetTimestamp=u)}catch{}}function Oc(a){if(typeof a!="object"||a===null)return null;const s=a;if("quotaResetDelay"in s){const r=s.quotaResetDelay;if(typeof r=="number")return r;if(typeof r=="string"){const u=r.match(/^(\d+)s?$/);if(u)return parseInt(u[1],10)}}if("error"in s&&typeof s.error=="object"){const r=Oc(s.error);if(r!==null)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Oc(r);if(u!==null)return u}return null}function Ac(a){if(typeof a!="object"||a===null)return null;const s=a;for(const r of["quotaResetTimeStamp","quotaResetTimestamp","resetTime","reset_time"])if(r in s&&typeof s[r]=="string")return s[r];if("error"in s&&typeof s.error=="object"){const r=Ac(s.error);if(r)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Ac(r);if(u)return u}return null}function gN(a){return{400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Request Timeout",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"}[a]||""}function yN(a){const s=Date.now(),r=a*1e3,u=s-r,d=Math.floor(u/1e3),m=Math.floor(d/60),h=Math.floor(m/60),p=Math.floor(h/24);return d<60?"just now":m<60?`${m}m ago`:h<24?`${h}h ago`:p<7?`${p}d ago`:new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function xN(a){return a>=500?"text-red-500":a===429?"text-orange-500":a>=400?"text-yellow-500":"text-gray-500"}function vN(a){return{rate_limit:"Rate Limited",auth:"Auth Error",not_found:"Not Found",server:"Server Error",timeout:"Timeout",unknown:"Error"}[a]||"Error"}function bN(a){if(a===null||a<=0)return null;if(a<60)return`${a}s`;if(a<3600)return`${Math.floor(a/60)}m`;const s=Math.floor(a/3600),r=Math.floor(a%3600/60);return r>0?`${s}h ${r}m`:`${s}h`}function SN(a){if(!a)return null;try{const s=new Date(a),r=new Date,u=s.getTime()-r.getTime();if(u<=0)return"now";const d=Math.floor(u/1e3);if(d<60)return`${d}s`;if(d<3600)return`${Math.floor(d/60)}m`;const m=Math.floor(d/3600),h=Math.floor(d%3600/60);return h>0?`${m}h ${h}m`:`${m}h`}catch{return null}}function NN(a){return a?a===429?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":a>=500?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":a>=400?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-gray-100 text-gray-600":"bg-gray-100 text-gray-600"}function jN(a){return a||""}function CN({name:a,size:s,modified:r,isSelected:u,onClick:d,statusCode:m,model:h}){const p=v.useMemo(()=>rN(a),[a]),y=v.useMemo(()=>jN(h),[h]);return o.jsxs("button",{onClick:d,className:V("w-full px-2.5 py-2 flex items-center gap-2 text-left transition-colors","hover:bg-muted/40 border-l-[3px]",u?"bg-muted/50 border-l-red-500":"border-l-transparent"),children:[o.jsx("span",{className:V("shrink-0 text-[10px] font-bold px-1.5 py-0.5 rounded min-w-[32px] text-center",NN(m)),children:m||"???"}),o.jsx(Vc,{provider:p.provider,size:18,withBackground:!0,className:"shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[o.jsx("span",{className:"text-[11px] font-medium text-foreground truncate",children:p.endpoint||"unknown"}),y&&o.jsx("span",{className:"text-[10px] text-muted-foreground truncate",title:y,children:y}),o.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-muted-foreground/60",children:[o.jsx(Uc,{className:"w-2.5 h-2.5"}),o.jsx("span",{children:yN(r)})]})]})]})}function jp({value:a,className:s,variant:r="outline",size:u="icon",label:d="Copy to clipboard"}){const[m,h]=v.useState(!1),p=()=>{navigator.clipboard.writeText(a),h(!0),setTimeout(()=>h(!1),2e3)};return o.jsx(Fo,{children:o.jsxs(fi,{children:[o.jsx(mi,{asChild:!0,children:o.jsxs(St,{size:u,variant:r,className:V("relative z-10 text-muted-foreground hover:text-foreground",s),onClick:y=>{y.stopPropagation(),p()},children:[m?o.jsx(ns,{className:"h-3.5 w-3.5 text-green-500"}):o.jsx(Bo,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"sr-only",children:d})]})}),o.jsx(hi,{children:o.jsx("p",{children:m?"Copied!":d})})]})})}function ti({active:a,onClick:s,children:r,icon:u}){return o.jsxs("button",{onClick:s,className:V("px-2.5 py-1.5 text-xs font-medium rounded transition-colors flex items-center gap-1.5",a?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[u&&o.jsx(u,{className:"w-3.5 h-3.5"}),r]})}function Hg({code:a}){const s=xN(a);return o.jsx("span",{className:V("inline-flex items-center justify-center min-w-[36px] px-2 py-0.5 rounded text-xs font-bold","bg-current/10 border border-current/20",s),children:a})}function EN({parsed:a}){const s=bN(a.quotaResetDelay)||SN(a.quotaResetTimestamp);return o.jsx(dl,{className:"h-full",children:o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Hg,{code:a.statusCode}),o.jsx("span",{className:"text-sm font-medium",children:a.statusText}),o.jsx("span",{className:"text-xs text-muted-foreground px-2 py-0.5 rounded bg-muted/50",children:vN(a.errorType)})]}),a.model&&o.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-violet-500/10 border border-violet-500/20",children:[o.jsx(ib,{className:"w-4 h-4 text-violet-500 shrink-0"}),o.jsxs("div",{className:"text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Model: "}),o.jsx("span",{className:"font-semibold text-violet-600 dark:text-violet-400",children:a.model})]})]}),a.errorType==="rate_limit"&&s&&o.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[o.jsx(Uc,{className:"w-4 h-4 text-amber-500 shrink-0"}),o.jsxs("div",{className:"text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Quota resets in "}),o.jsx("span",{className:"font-semibold text-amber-600 dark:text-amber-400",children:s})]})]}),o.jsxs("div",{className:"grid grid-cols-4 gap-3 text-xs",children:[o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Method"}),o.jsx("div",{className:"font-medium",children:a.method||"N/A"})]}),o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Provider"}),o.jsx("div",{className:"font-medium",children:a.provider||"N/A"})]}),o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Version"}),o.jsx("div",{className:"font-medium",children:a.version||"N/A"})]}),o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Endpoint"}),o.jsx("div",{className:"font-medium truncate",title:a.endpoint,children:a.endpoint||"N/A"})]})]}),o.jsxs("div",{className:"text-xs",children:[o.jsx("div",{className:"text-muted-foreground mb-1.5",children:"URL"}),o.jsx("div",{className:"font-mono p-2.5 rounded bg-muted/30 border border-border/50 break-all leading-relaxed",children:a.url||"N/A"})]}),o.jsxs("div",{className:"text-xs",children:[o.jsx("div",{className:"text-muted-foreground mb-1.5",children:"Timestamp"}),o.jsx("div",{className:"font-mono",children:a.timestamp||"N/A"})]}),a.errorType!=="unknown"&&o.jsxs("div",{className:V("flex items-start gap-3 p-3 rounded text-xs",a.errorType==="rate_limit"?"bg-amber-500/10 border border-amber-500/20":a.errorType==="auth"?"bg-red-500/10 border border-red-500/20":"bg-blue-500/10 border border-blue-500/20"),children:[a.errorType==="rate_limit"?o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}):a.errorType==="auth"?o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-red-500 shrink-0"}):o.jsx(Wo,{className:"w-4 h-4 mt-0.5 text-blue-500 shrink-0"}),o.jsxs("div",{className:V("leading-relaxed",a.errorType==="rate_limit"?"text-amber-600 dark:text-amber-400":a.errorType==="auth"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),children:[a.errorType==="rate_limit"&&o.jsxs(o.Fragment,{children:[o.jsx("strong",{children:"Rate Limited."})," Switch to a different account or wait for quota reset.",a.model&&o.jsxs(o.Fragment,{children:[" ","Model ",o.jsx("code",{className:"font-mono text-[11px]",children:a.model})," has exhausted quota."]})]}),a.errorType==="auth"&&"Authentication failed. Re-authenticate via CLIProxy Settings or check API key.",a.errorType==="not_found"&&"Endpoint not found. This endpoint may not exist on this provider.",a.errorType==="server"&&"Server error from upstream. Retry later or check provider status page.",a.errorType==="timeout"&&"Request timed out. Check network connection or increase timeout settings."]})]})]})})}function wN({headers:a}){const s=Object.entries(a);return s.length===0?o.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No headers available"}):o.jsx(dl,{className:"h-full",children:o.jsx("div",{className:"p-4 space-y-1",children:s.map(([r,u])=>o.jsxs("div",{className:"flex gap-3 text-xs font-mono py-1.5 border-b border-border/30 last:border-0",children:[o.jsxs("span",{className:"text-muted-foreground shrink-0 min-w-[140px]",children:[r,":"]}),o.jsx("span",{className:"break-all",children:u})]},r))})})}function Cp({content:a,label:s}){if(!a||a.trim()==="")return o.jsxs("div",{className:"p-4 text-xs text-muted-foreground",children:["No ",s.toLowerCase()," body"]});let r=a,u=!1;try{const d=JSON.parse(a);r=JSON.stringify(d,null,2),u=!0}catch{}return o.jsx(dl,{className:"h-full",children:o.jsx("pre",{className:V("p-4 text-xs font-mono whitespace-pre-wrap break-all leading-relaxed",u?"text-emerald-700 dark:text-green-400":"text-zinc-700 dark:text-muted-foreground"),children:r})})}function MN({content:a}){return o.jsx(dl,{className:"h-full",children:o.jsx("pre",{className:"p-4 text-xs font-mono text-zinc-700 dark:text-muted-foreground whitespace-pre-wrap break-all leading-relaxed",children:a})})}function TN({name:a,absolutePath:s}){const[r,u]=v.useState("overview"),{data:d,isLoading:m,error:h}=h1(a),p=v.useMemo(()=>d?uN(d):null,[d]);return a?m?o.jsxs("div",{className:"flex-1 p-6 space-y-3",children:[o.jsx(Le,{className:"h-5 w-full"}),o.jsx(Le,{className:"h-5 w-3/4"}),o.jsx(Le,{className:"h-5 w-5/6"}),o.jsx(Le,{className:"h-5 w-2/3"})]}):h||!d||!p?o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:o.jsx("p",{className:"text-sm",children:"Failed to load log content"})}):o.jsxs("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:[o.jsxs("div",{className:"px-4 py-3 border-b border-border bg-muted/30 flex items-center justify-between gap-3 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx(Hg,{code:p.statusCode}),o.jsxs("span",{className:"text-xs font-semibold truncate text-foreground",children:[p.provider,"/",p.endpoint||"unknown"]}),a&&o.jsx(jp,{value:s||a,label:"Copy absolute path",size:"icon-sm",className:"ml-1 text-muted-foreground hover:text-foreground opacity-50 hover:opacity-100 transition-opacity"})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d&&o.jsx(jp,{value:d,label:"Copy raw log content",variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono bg-muted px-1.5 py-0.5 rounded border border-border/50",children:p.method})]})]}),o.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-1 bg-muted/10 shrink-0 overflow-x-auto",children:[o.jsx(ti,{active:r==="overview",onClick:()=>u("overview"),icon:Wo,children:"Overview"}),o.jsx(ti,{active:r==="headers",onClick:()=>u("headers"),icon:rb,children:"Headers"}),o.jsx(ti,{active:r==="request",onClick:()=>u("request"),icon:ub,children:"Request"}),o.jsx(ti,{active:r==="response",onClick:()=>u("response"),icon:cb,children:"Response"}),o.jsx(ti,{active:r==="raw",onClick:()=>u("raw"),icon:db,children:"Raw"})]}),o.jsxs("div",{className:"flex-1 overflow-hidden bg-card/30",children:[r==="overview"&&o.jsx(EN,{parsed:p}),r==="headers"&&o.jsx(wN,{headers:p.requestHeaders}),r==="request"&&o.jsx(Cp,{content:p.requestBody,label:"Request"}),r==="response"&&o.jsx(Cp,{content:p.responseBody,label:"Response"}),r==="raw"&&o.jsx(MN,{content:d})]})]}):o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx(ob,{className:"w-10 h-10 mx-auto opacity-40"}),o.jsx("p",{className:"text-sm",children:"Select a log to view details"})]})})}function zN(){const{data:a,isLoading:s}=u1(),{data:r,isLoading:u,error:d}=m1(a?.running??!1),[m,h]=v.useState(500),[p,y]=v.useState(!1),S=v.useRef(null),M=v.useRef(null),x=()=>{M.current&&(clearInterval(M.current),M.current=null)};v.useEffect(()=>{if(!p)return;const q=k=>{const j=S.current;if(!j)return;const J=j.getBoundingClientRect().top+window.scrollY,ee=k.pageY-J;h(Math.max(300,ee));const ve=window.innerHeight-k.clientY,oe=15;x(),ve<50?M.current=setInterval(()=>{window.scrollBy(0,oe)},16):k.clientY<50&&(M.current=setInterval(()=>{window.scrollBy(0,-oe)},16))},Q=()=>{y(!1),x(),document.body.style.cursor="default",document.body.style.userSelect="auto"};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",Q),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Q),document.body.style.cursor="default",document.body.style.userSelect="auto",x()}},[p]);const b=q=>{q.preventDefault(),y(!0)},_=v.useMemo(()=>r?.[0]?.name??null,[r]),[A,R]=v.useState(null),B=A??_,w=v.useMemo(()=>!B||!r?void 0:r.find(Q=>Q.name===B)?.absolutePath,[B,r]);if(s||!a?.running)return null;if(u)return o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden font-mono text-sm bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm h-[500px]",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[o.jsx(Le,{className:"h-4 w-32"}),o.jsx(Le,{className:"h-4 w-20"})]}),o.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(q=>o.jsx(Le,{className:"h-12 w-full rounded-lg"},q))})]});if(!r||r.length===0)return null;const Y=r.length;return o.jsxs("div",{ref:S,className:"rounded-xl border border-border overflow-hidden font-mono text-sm text-foreground bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm flex flex-col shadow-sm transition-[height] duration-0 ease-linear relative group/container",style:{height:m},children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-gradient-to-r from-amber-500/10 via-transparent to-transparent dark:from-amber-500/15 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(ul,{className:"w-4 h-4 text-amber-500"}),o.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Error Logs"}),o.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[Y," failed request",Y!==1?"s":""]})]}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(fb,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"CLIProxy Diagnostics"})]})]}),o.jsx("div",{className:"flex-1 min-h-0",children:o.jsxs(Jc,{direction:"horizontal",children:[o.jsx(ri,{defaultSize:30,minSize:20,maxSize:50,className:"flex flex-col min-w-0",children:o.jsxs(dl,{className:"h-full",children:[o.jsx("div",{className:"divide-y divide-border/50",children:r.slice(0,50).map(q=>o.jsx(CN,{name:q.name,size:q.size,modified:q.modified,isSelected:B===q.name,onClick:()=>R(q.name),statusCode:q.statusCode,model:q.model},q.name))}),r.length>50&&o.jsxs("div",{className:"px-3 py-3 text-center text-[10px] text-muted-foreground border-t border-border/50",children:["Showing 50 of ",r.length," logs"]})]})}),o.jsxs($c,{className:"w-[1px] bg-border hover:bg-primary/50 transition-colors flex items-center justify-center group relative z-10 w-2 -ml-1 flex items-center justify-center outline-none",children:[o.jsx("div",{className:"w-[1px] h-full bg-border group-hover:bg-primary/50 transition-colors"}),o.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-4 h-8 rounded-sm flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-muted border border-border",children:o.jsx(Zo,{className:"h-4 w-4 text-muted-foreground"})})]}),o.jsx(ri,{className:"flex flex-col min-w-0 bg-background/50",children:o.jsx(TN,{name:B,absolutePath:w})})]})}),d?o.jsx("div",{className:"px-4 py-2 border-t border-border text-xs text-destructive bg-destructive/5 shrink-0",children:d.message}):o.jsx("div",{className:"h-2 bg-border/10 border-t border-border/30 hover:bg-primary/10 transition-colors cursor-row-resize flex items-center justify-center group/handle shrink-0",onMouseDown:b,children:o.jsx(mb,{className:"w-8 h-3 text-border group-hover:text-primary/50 transition-colors"})})]})}const ON=Go("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",warning:"border-yellow-200 bg-yellow-50 text-yellow-900 dark:border-yellow-900/50 dark:bg-yellow-900/20 dark:text-yellow-200 [&>svg]:text-yellow-600 dark:[&>svg]:text-yellow-500",info:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-200 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-500",success:"border-green-200 bg-green-50 text-green-900 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-200 [&>svg]:text-green-600 dark:[&>svg]:text-green-500"}},defaultVariants:{variant:"default"}}),qg=v.forwardRef(({className:a,variant:s,...r},u)=>o.jsx("div",{ref:u,role:"alert",className:V(ON({variant:s}),a),...r}));qg.displayName="Alert";const Lg=v.forwardRef(({className:a,...s},r)=>o.jsx("h5",{ref:r,className:V("mb-1 font-medium leading-none tracking-tight",a),...s}));Lg.displayName="AlertTitle";const Yg=v.forwardRef(({className:a,...s},r)=>o.jsx("div",{ref:r,className:V("text-sm [&_p]:leading-relaxed",a),...s}));Yg.displayName="AlertDescription";function AN(){return zt({queryKey:["overview"],queryFn:async()=>(await fetch("/api/overview")).json()})}function DN(){return zt({queryKey:["shared","summary"],queryFn:async()=>(await fetch("/api/shared/summary")).json()})}function XC(a){return zt({queryKey:["shared",a],queryFn:async()=>(await fetch(`/api/shared/${a}`)).json()})}const _N={ok:"success",warning:"warning",error:"error"},kN={default:{iconBg:"bg-muted",iconColor:"text-muted-foreground"},success:{iconBg:"bg-green-600/15",iconColor:"text-green-700 dark:text-green-500"},warning:{iconBg:"bg-amber-500/15",iconColor:"text-amber-700 dark:text-amber-400"},error:{iconBg:"bg-red-600/15",iconColor:"text-red-700 dark:text-red-500"},accent:{iconBg:"bg-accent/15",iconColor:"text-accent"}};function Do({title:a,value:s,icon:r,variant:u="default",onClick:d}){const m=kN[u];return o.jsxs("button",{onClick:d,className:V("flex items-center gap-3 px-4 py-2.5 rounded-lg border bg-card/50","transition-all hover:bg-card hover:shadow-sm hover:-translate-y-0.5","active:scale-[0.98]"),children:[o.jsx("div",{className:V("flex items-center justify-center w-9 h-9 rounded-md",m.iconBg),children:o.jsx(r,{className:V("w-4 h-4",m.iconColor)})}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a}),o.jsx("p",{className:V("text-lg font-bold font-mono leading-tight",m.iconColor),children:s})]})]})}function RN(){const a=iv(),{data:s,isLoading:r}=AN(),{data:u,isLoading:d}=DN();if(r||d)return o.jsxs("div",{className:"p-6 space-y-6",children:[o.jsxs("div",{className:"rounded-xl border p-6 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(Le,{className:"h-12 w-12 rounded-lg"}),o.jsxs("div",{children:[o.jsx(Le,{className:"h-7 w-[180px] mb-2"}),o.jsx(Le,{className:"h-4 w-[220px]"})]})]}),o.jsx("div",{className:"flex items-center gap-3",children:[1,2,3,4].map(h=>o.jsx(Le,{className:"h-14 w-28 rounded-lg"},h))})]}),o.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[o.jsxs("div",{className:"px-4 py-2.5 border-b flex items-center justify-between",children:[o.jsx(Le,{className:"h-4 w-32"}),o.jsx(Le,{className:"h-4 w-20"})]}),o.jsx("div",{className:"px-4 py-3 border-b",children:o.jsx(Le,{className:"h-2 w-full rounded-full"})}),[1,2,3].map(h=>o.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-3 border-b last:border-b-0",children:[o.jsx(Le,{className:"w-2.5 h-2.5 rounded-full"}),o.jsx(Le,{className:"h-4 flex-1"}),o.jsx(Le,{className:"h-1.5 w-24 rounded-full"}),o.jsx(Le,{className:"h-4 w-16"})]},h))]})]});const m=s?.health?_N[s.health.status]:void 0;return o.jsxs("div",{className:"p-6 space-y-6",children:[o.jsxs("div",{className:"relative overflow-hidden rounded-xl border bg-gradient-to-br from-background via-background to-muted/30",children:[o.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:o.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),o.jsxs("div",{className:"relative p-6 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[o.jsx(XS,{version:s?.version}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(Do,{title:"Profiles",value:s?.profiles??0,icon:lg,variant:"accent",onClick:()=>a("/providers")}),o.jsx(Do,{title:"CLIProxy",value:s?.cliproxy??0,icon:sg,variant:"accent",onClick:()=>a("/cliproxy")}),o.jsx(Do,{title:"Accounts",value:s?.accounts??0,icon:rg,variant:"default",onClick:()=>a("/accounts")}),o.jsx(Do,{title:"Health",value:s?.health?`${s.health.passed}/${s.health.total}`:"-",icon:oi,variant:m,onClick:()=>a("/health")})]})]})]}),u?.symlinkStatus&&!u.symlinkStatus.valid&&o.jsxs(qg,{variant:"warning",children:[o.jsx(ul,{className:"h-4 w-4"}),o.jsx(Lg,{children:"Configuration Required"}),o.jsx(Yg,{children:u.symlinkStatus.message})]}),o.jsx(_1,{}),o.jsx(zN,{})]})}const Gg=Gx,Fc=v.forwardRef(({className:a,...s},r)=>o.jsx(Xp,{ref:r,className:V("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",a),...s}));Fc.displayName=Xp.displayName;const il=v.forwardRef(({className:a,...s},r)=>o.jsx(Zp,{ref:r,className:V("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",a),...s}));il.displayName=Zp.displayName;const Dc=v.forwardRef(({className:a,...s},r)=>o.jsx(Wp,{ref:r,className:V("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...s}));Dc.displayName=Wp.displayName;function Dn({className:a,...s}){return o.jsx(Kx,{"data-slot":"label",className:V("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",a),...s})}const Ic="ccs:openrouter-models",UN=1440*60*1e3,Kg="1";function _c(a){const s=parseFloat(a);return isNaN(s)||s===0?0:s*1e6}function Ep(a){const s=_c(a);return s===0?"Free":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:`$${s.toFixed(s<10?2:0)}`}function BN(a){const s=Ep(a.prompt),r=Ep(a.completion);return s==="Free"&&r==="Free"?"Free":`${s}/${r}`}function HN(a){const s=a.id.toLowerCase();return s.startsWith("anthropic/")?"anthropic":s.startsWith("openai/")?"openai":s.startsWith("google/")?"google":s.startsWith("meta-llama/")||s.startsWith("meta/")?"meta":s.startsWith("mistralai/")?"mistral":s.includes(":free")||s.includes("qwen")||s.includes("deepseek")?"opensource":"other"}function qN(a){return{...a,category:HN(a),pricePerMillionPrompt:_c(a.pricing.prompt),pricePerMillionCompletion:_c(a.pricing.completion),isFree:a.pricing.prompt==="0"&&a.pricing.completion==="0",isExacto:a.id.includes(":exacto")}}function LN(a,s,r){const u=s.toLowerCase().trim();return a.filter(d=>r?.category&&d.category!==r.category||r?.freeOnly&&!d.isFree||r?.minContext&&d.context_length<r.minContext?!1:u?d.id.toLowerCase().includes(u)||d.name.toLowerCase().includes(u)||d.description?.toLowerCase().includes(u):!0)}function ZC(a){return[...a].sort((s,r)=>{if(s.isFree&&!r.isFree)return-1;if(!s.isFree&&r.isFree)return 1;if(!s.isFree&&!r.isFree){if(s.isExacto&&!r.isExacto)return-1;if(!s.isExacto&&r.isExacto)return 1}return s.name.localeCompare(r.name)})}function YN(){try{const a=localStorage.getItem(Ic);if(!a)return null;const s=JSON.parse(a);return s.version!==Kg||Date.now()-s.fetchedAt>UN?null:s.models}catch{return null}}function GN(a){try{localStorage.setItem(Ic,JSON.stringify({models:a,fetchedAt:Date.now(),version:Kg}))}catch{}}function KN(){localStorage.removeItem(Ic)}function WC(a,s){const[r]=a.split("/");if(!r)return{};const u=s.filter(h=>h.id.startsWith(`${r}/`));if(u.length===0)return{};const d=[...u].sort((h,p)=>p.pricePerMillionPrompt-h.pricePerMillionPrompt),m=Math.ceil(d.length/3);return{opus:d[0]?.id,sonnet:d[Math.min(m,d.length-1)]?.id,haiku:d[d.length-1]?.id}}function QN(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${Math.round(a/1e3)}K`:String(a)}const JC={anthropic:"Anthropic (Claude)",openai:"OpenAI (GPT)",google:"Google (Gemini)",meta:"Meta (Llama)",mistral:"Mistral",opensource:"Open Source",other:"Other"},VN={anthropic:["anthropic/"],openai:["openai/"],google:["google/"],meta:["meta-llama/","meta/"],mistral:["mistralai/"],opensource:["deepseek/","qwen/","cohere/"],other:[]};function XN(a,s=2){const r=[],u=["anthropic","openai","google","meta","mistral","opensource"];for(const d of u){const m=VN[d];if(m.length===0)continue;const p=[...a.filter(y=>m.some(S=>y.id.toLowerCase().startsWith(S)))].sort((y,S)=>(S.created??0)-(y.created??0));r.push(...p.slice(0,s))}return r.sort((d,m)=>(m.created??0)-(d.created??0))}function ZN(a){const r=Date.now()/1e3-a;return r<86400?"Today":r<172800?"Yesterday":r<604800?`${Math.floor(r/86400)}d ago`:r<2592e3?`${Math.floor(r/604800)}w ago`:r<31536e3?`${Math.floor(r/2592e3)}mo ago`:`${Math.floor(r/31536e3)}y ago`}const WN="https://openrouter.ai/api/v1/models",Qg=["openrouter-models"],wp=1440*60*1e3;async function JN(){const a=await fetch(WN);if(!a.ok)throw new Error(`Failed to fetch OpenRouter models: ${a.status}`);const r=(await a.json()).data;return GN(r),r}function Vg(){return zt({queryKey:Qg,queryFn:JN,staleTime:wp,gcTime:wp,initialData:()=>YN()??void 0,refetchOnWindowFocus:!1})}function $N(){const a=Vg(),s=(a.data??[]).map(qN);return{...a,models:s}}function $C(){const a=Gt();return()=>(KN(),a.invalidateQueries({queryKey:Qg}))}function FC(){const{data:a,isLoading:s,isError:r}=Vg();return{isReady:!!a&&a.length>0,isLoading:s,isError:r,modelCount:a?.length??0}}function Xg({profileEnv:a={}}){const[s,r]=v.useState(null),[u,d]=v.useState(!0),[m,h]=v.useState(!1);v.useEffect(()=>{p()},[]);const p=async()=>{try{d(!0);const b=await fetch("/api/global-env");if(!b.ok)throw new Error("Failed to load");const _=await b.json();r(_)}catch{r(null)}finally{d(!1)}};if(u||!s?.enabled)return null;const y=s.env||{},S=Object.keys(y);if(S.length===0)return null;const M=S.filter(b=>!(b in a)),x=S.filter(b=>b in a);return o.jsxs("div",{className:"border-t bg-muted/20",children:[o.jsxs("button",{onClick:()=>h(!m),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",children:[o.jsx(Wo,{className:"w-4 h-4 text-blue-500"}),o.jsxs("span",{className:"text-xs text-muted-foreground flex-1 text-left",children:[o.jsx("span",{className:"font-medium text-foreground",children:M.length})," global env var",M.length!==1?"s":""," will be injected at runtime",x.length>0&&o.jsxs("span",{className:"text-amber-600 dark:text-amber-400 ml-1",children:["(",x.length," overridden by profile)"]})]}),m?o.jsx(Bc,{className:"w-4 h-4 text-muted-foreground"}):o.jsx(Jo,{className:"w-4 h-4 text-muted-foreground"})]}),m&&o.jsxs("div",{className:"px-4 pb-3 space-y-2",children:[M.length>0&&o.jsx("div",{className:"space-y-1",children:M.map(b=>o.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-green-500/10 text-green-700 dark:text-green-400 px-2 py-1 rounded",children:[o.jsx("span",{className:"text-green-500",children:"+"}),o.jsxs("span",{className:"truncate",children:[b,"=",y[b]]})]},b))}),x.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Skipped (profile already defines):"}),x.map(b=>o.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-amber-500/10 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[o.jsx("span",{className:"text-amber-500",children:"~"}),o.jsx("span",{className:"truncate",children:b})]},b))]}),o.jsx("div",{className:"pt-2 border-t border-border/50",children:o.jsx(St,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 text-xs gap-1.5 -ml-2",children:o.jsxs(Tc,{to:"/settings?tab=globalenv",children:[o.jsx(Hc,{className:"w-3.5 h-3.5"}),"Configure in Settings",o.jsx(cg,{className:"w-3 h-3 opacity-50"})]})})})]})]})}const FN=v.lazy(()=>At(()=>Promise.resolve().then(()=>$g),void 0).then(a=>({default:a.CodeEditor})));function IC({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,settings:u,onChange:d,missingRequiredFields:m=[]}){const h=m.length>0;return o.jsx(v.Suspense,{fallback:o.jsxs("div",{className:"flex items-center justify-center h-full",children:[o.jsx(as,{className:"w-6 h-6 animate-spin text-muted-foreground"}),o.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:o.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[o.jsx(di,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",o.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),o.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:o.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:o.jsx(FN,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),o.jsx("div",{className:"mx-6 mb-4",children:o.jsx("div",{className:"border rounded-md overflow-hidden",children:o.jsx(Xg,{profileEnv:u?.env})})})]})})}function Mp(a,s){try{var r=a()}catch(u){return s(u)}return r&&r.then?r.then(void 0,s):r}function IN(a,s){for(var r={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!r[h])if("unionErrors"in u){var p=u.unionErrors[0].errors[0];r[h]={message:p.message,type:p.code}}else r[h]={message:m,type:d};if("unionErrors"in u&&u.unionErrors.forEach(function(M){return M.errors.forEach(function(x){return a.push(x)})}),s){var y=r[h].types,S=y&&y[u.code];r[h]=dg(h,s,r,d,S?[].concat(S,u.message):u.message)}a.shift()}return r}function PN(a,s){for(var r={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!r[h])if(u.code==="invalid_union"&&u.errors.length>0){var p=u.errors[0][0];r[h]={message:p.message,type:p.code}}else r[h]={message:m,type:d};if(u.code==="invalid_union"&&u.errors.forEach(function(M){return M.forEach(function(x){return a.push(x)})}),s){var y=r[h].types,S=y&&y[u.code];r[h]=dg(h,s,r,d,S?[].concat(S,u.message):u.message)}a.shift()}return r}function ej(a,s,r){if(r===void 0&&(r={}),(function(u){return"_def"in u&&typeof u._def=="object"&&"typeName"in u._def})(a))return function(u,d,m){try{return Promise.resolve(Mp(function(){return Promise.resolve(a[r.mode==="sync"?"parse":"parseAsync"](u,s)).then(function(h){return m.shouldUseNativeValidation&&tp({},m),{errors:{},values:r.raw?Object.assign({},u):h}})},function(h){if((function(p){return Array.isArray(p?.issues)})(h))return{values:{},errors:np(IN(h.errors,!m.shouldUseNativeValidation&&m.criteriaMode==="all"),m)};throw h}))}catch(h){return Promise.reject(h)}};if((function(u){return"_zod"in u&&typeof u._zod=="object"})(a))return function(u,d,m){try{return Promise.resolve(Mp(function(){return Promise.resolve((r.mode==="sync"?vb:bb)(a,u,s)).then(function(h){return m.shouldUseNativeValidation&&tp({},m),{errors:{},values:r.raw?Object.assign({},u):h}})},function(h){if((function(p){return p instanceof Sb})(h))return{values:{},errors:np(PN(h.issues,!m.shouldUseNativeValidation&&m.criteriaMode==="all"),m)};throw h}))}catch(h){return Promise.reject(h)}};throw new Error("Invalid input: not a Zod schema")}function PC(){return zt({queryKey:["profiles"],queryFn:()=>ht.profiles.list()})}function tj(){const a=Gt();return ln({mutationFn:s=>ht.profiles.create(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),Ne.success("Profile created successfully")},onError:s=>{Ne.error(s.message)}})}function eE(){const a=Gt();return ln({mutationFn:s=>ht.profiles.delete(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),Ne.success("Profile deleted successfully")},onError:s=>{Ne.error(s.message)}})}const nj="https://openrouter.ai/api",Uo=[{id:"openrouter",name:"OpenRouter",description:"349+ models from OpenAI, Anthropic, Google, Meta",baseUrl:nj,defaultProfileName:"openrouter",badge:"349+ models",featured:!0,icon:"/icons/openrouter.svg",defaultModel:"anthropic/claude-opus-4.5",requiresApiKey:!0,apiKeyPlaceholder:"sk-or-...",apiKeyHint:"Get your API key at openrouter.ai/keys",category:"recommended"},{id:"glm",name:"GLM",description:"Claude via Z.AI",baseUrl:"https://api.z.ai/api/anthropic",defaultProfileName:"glm",badge:"Z.AI",defaultModel:"glm-4.7",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Get your API key from Z.AI",category:"alternative"},{id:"glmt",name:"GLMT",description:"GLM with Thinking mode support",baseUrl:"https://api.z.ai/api/coding/paas/v4/chat/completions",defaultProfileName:"glmt",badge:"Thinking",defaultModel:"glm-4.7",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Same API key as GLM",category:"alternative"},{id:"kimi",name:"Kimi",description:"Moonshot AI - Fast reasoning model",baseUrl:"https://api.kimi.com/coding/",defaultProfileName:"kimi",badge:"Reasoning",defaultModel:"kimi-k2-thinking-turbo",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Moonshot AI",category:"alternative"},{id:"foundry",name:"Azure Foundry",description:"Claude via Microsoft Azure AI Foundry",baseUrl:"https://<your-resource>.services.ai.azure.com/api/anthropic",defaultProfileName:"foundry",badge:"Azure",defaultModel:"claude-sonnet-4-5",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_AZURE_API_KEY",apiKeyHint:"Create resource at ai.azure.com, get API key from Keys tab",category:"alternative"},{id:"minimax",name:"Minimax",description:"M2.1/M2.1-lightning/M2 - multilang coding (1M context)",baseUrl:"https://api.minimax.io/anthropic",defaultProfileName:"minimax",badge:"1M context",defaultModel:"MiniMax-M2.1",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_MINIMAX_API_KEY",apiKeyHint:"Get your API key at platform.minimax.io",category:"alternative"},{id:"deepseek",name:"DeepSeek",description:"V3.2 and R1 reasoning model (128K context)",baseUrl:"https://api.deepseek.com/anthropic",defaultProfileName:"deepseek",badge:"Reasoning",defaultModel:"deepseek-chat",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key at platform.deepseek.com",category:"alternative"},{id:"qwen",name:"Qwen",description:"Alibaba Cloud - qwen3-coder-plus (256K context)",baseUrl:"https://dashscope-intl.aliyuncs.com/apps/anthropic",defaultProfileName:"qwen",badge:"Alibaba",defaultModel:"qwen3-coder-plus",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Alibaba Cloud Model Studio",category:"alternative"}];function _o(a){return Uo.filter(s=>s.category===a)}const aj=Nb({name:ll().min(1,"Name is required").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Must start with letter, only letters/numbers/.-_"),baseUrl:ll().url("Invalid URL format"),apiKey:ll().min(1,"API key is required"),model:ll().optional(),opusModel:ll().optional(),sonnetModel:ll().optional(),haikuModel:ll().optional()}),lj=["/chat/completions","/v1/messages","/messages","/completions"];function tE({open:a,onOpenChange:s,onSuccess:r,initialMode:u="openrouter"}){const d=tj(),[m,h]=v.useState("basic"),[p,y]=v.useState(null),[S,M]=v.useState(!1),[x,b]=v.useState("openrouter"),[_,A]=v.useState(""),{models:R}=$N(),{register:B,handleSubmit:w,formState:{errors:Y},control:q,reset:Q,setValue:k}=jb({resolver:ej(aj),defaultValues:{name:"",baseUrl:"",apiKey:"",model:"",opusModel:"",sonnetModel:"",haikuModel:""}}),j=Cb({control:q,name:"baseUrl"}),L=v.useMemo(()=>!x||x==="custom"?null:Uo.find($=>$.id===x),[x]),J=v.useMemo(()=>_.trim()?[...LN(R,_)].sort((T,Z)=>(Z.created??0)-(T.created??0)).slice(0,20):XN(R,2),[R,_]);v.useEffect(()=>{if(a)if(Q(),h("basic"),y(null),M(!1),A(""),u==="normal")b("custom"),setTimeout(()=>{k("name",""),k("baseUrl","")},0);else{b("openrouter");const $=Uo.find(T=>T.id==="openrouter");$&&setTimeout(()=>{k("name",$.defaultProfileName),k("baseUrl",$.baseUrl)},0)}},[a,Q,k,u]);const ee=$=>{b($);const T=Uo.find(Z=>Z.id===$);T?(k("name",T.defaultProfileName),k("baseUrl",T.baseUrl),T.defaultModel&&(k("model",T.defaultModel),k("opusModel",T.defaultModel),k("sonnetModel",T.defaultModel),k("haikuModel",T.defaultModel))):(k("name",""),k("baseUrl",""),k("model",""))},de=$=>{k("model",$.id),k("opusModel",$.id),k("sonnetModel",$.id),k("haikuModel",$.id),A($.name),Ne.success(`Applied "${$.name}" to all model tiers`,{duration:2e3})};v.useEffect(()=>{if(j&&x==="custom"){const T=j.toLowerCase();for(const Z of lj)if(T.endsWith(Z)){const ae=j.replace(new RegExp(Z+"$","i"),"");y(`URL ends with "${Z}" - Claude appends this automatically. You likely want: ${ae}`);return}}y(null)},[j,x]);const ve=async $=>{const T={...$};try{await d.mutateAsync(T),Ne.success(`Profile "${T.name}" created`),r(T.name),s(!1)}catch(Z){Ne.error(Z.message||"Failed to create profile")}},oe=!!Y.name||!!Y.baseUrl||!!Y.apiKey,Ye=!!Y.model||!!Y.opusModel||!!Y.sonnetModel||!!Y.haikuModel,Se=x==="openrouter";return o.jsx(Lc,{open:a,onOpenChange:s,children:o.jsxs(Yc,{className:"sm:max-w-[700px] p-0 gap-0 overflow-hidden max-h-[90vh]",children:[o.jsxs(Gc,{className:"p-6 pb-4 border-b",children:[o.jsxs(Kc,{className:"flex items-center gap-2",children:[o.jsx(Ih,{className:"w-5 h-5 text-primary"}),"Create API Profile"]}),o.jsx(Qc,{children:"Choose a provider or configure a custom API endpoint."})]}),o.jsxs("form",{onSubmit:w(ve),className:"flex flex-col overflow-hidden",children:[o.jsxs("div",{className:"px-6 py-3 border-b bg-muted/30 space-y-2",children:[o.jsxs("div",{children:[o.jsx(Dn,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Provider"}),o.jsxs("div",{className:"flex gap-2",children:[_o("recommended").map($=>o.jsx(Tp,{preset:$,isSelected:x===$.id,onClick:()=>ee($.id)},$.id)),o.jsxs("button",{type:"button",onClick:()=>ee("custom"),className:V("flex items-center gap-2 px-4 py-2 rounded-md border-2 transition-all text-sm font-medium",x==="custom"||_o("alternative").some($=>$.id===x)?"border-primary bg-primary/10 text-primary dark:bg-primary/20":"border-dashed border-muted-foreground/40 hover:border-primary/50 hover:bg-muted/50 text-muted-foreground hover:text-foreground"),children:[o.jsx(Hc,{className:"w-4 h-4"}),o.jsx("span",{children:"Custom"})]})]})]}),(x==="custom"||_o("alternative").some($=>$.id===x))&&o.jsxs("div",{className:"pt-3 mt-2 border-t border-dashed border-muted-foreground/30",children:[o.jsx(Dn,{className:"text-xs font-medium text-foreground/70 mb-2 block",children:"Quick Templates"}),o.jsx("div",{className:"flex gap-2 flex-wrap",children:_o("alternative").map($=>o.jsx(Tp,{preset:$,isSelected:x===$.id,onClick:()=>ee($.id)},$.id))})]})]}),o.jsxs(Gg,{value:m,onValueChange:h,className:"flex flex-col flex-1 overflow-hidden",children:[o.jsx("div",{className:"px-6 pt-4",children:o.jsxs(Fc,{className:"grid w-full grid-cols-2",children:[o.jsxs(il,{value:"basic",className:"relative",children:["Basic Information",oe&&o.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]}),o.jsxs(il,{value:"models",className:"relative",children:["Model Configuration",Ye&&o.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]})]})}),o.jsxs(dl,{className:"flex-1",children:[o.jsxs(Dc,{value:"basic",className:"p-6 space-y-4 mt-0",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"name",children:["Profile Name ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ra,{id:"name",...B("name"),placeholder:"my-api",className:"font-mono"}),Y.name?o.jsx("p",{className:"text-xs text-destructive",children:Y.name.message}):o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in CLI:"," ",o.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:'ccs my-api "prompt"'})]})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"baseUrl",children:["API Base URL ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ra,{id:"baseUrl",...B("baseUrl"),placeholder:"https://api.example.com/v1"}),Y.baseUrl?o.jsx("p",{className:"text-xs text-destructive",children:Y.baseUrl.message}):p?o.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-600 bg-yellow-50 dark:bg-yellow-900/20 p-2 rounded",children:[o.jsx(ul,{className:"w-4 h-4 shrink-0 mt-0.5"}),o.jsx("span",{children:p})]}):L?o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Pre-filled from ",L.name,". You can customize if needed."]}):o.jsx("p",{className:"text-xs text-muted-foreground",children:"The endpoint that accepts OpenAI-compatible and Anthropic requests"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"apiKey",children:["API Key ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsxs("div",{className:"relative",children:[o.jsx(Ra,{id:"apiKey",type:S?"text":"password",...B("apiKey"),placeholder:L?.apiKeyPlaceholder??"sk-...",className:"pr-10"}),o.jsx(St,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-9 w-9 text-muted-foreground hover:text-foreground",onClick:()=>M(!S),tabIndex:-1,children:S?o.jsx(Qo,{className:"h-4 w-4"}):o.jsx(Vo,{className:"h-4 w-4"})})]}),Y.apiKey?o.jsx("p",{className:"text-xs text-destructive",children:Y.apiKey.message}):L?.apiKeyHint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:L.apiKeyHint})]})]}),o.jsxs(Dc,{value:"models",className:"p-6 mt-0 space-y-4",children:[o.jsxs("div",{className:"flex items-start gap-3 p-3 bg-blue-50 dark:bg-blue-950/20 text-blue-800 dark:text-blue-300 rounded-md text-sm border border-blue-100 dark:border-blue-900/30",children:[o.jsx(Wo,{className:"w-5 h-5 shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium mb-1",children:"Model Mapping"}),o.jsx("p",{className:"text-xs opacity-90",children:"Map Claude Code tiers (Opus/Sonnet/Haiku) to models supported by your provider."})]})]}),Se&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Dn,{children:"Search Models"}),o.jsx(Ra,{value:_,onChange:$=>A($.target.value),placeholder:"Type to search (e.g., opus, sonnet, gpt-4o)...",onKeyDown:$=>{$.key==="Enter"&&J.length>0&&($.preventDefault(),de(J[0]))}}),o.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:J.length===0?o.jsx("p",{className:"text-sm text-muted-foreground p-3 text-center",children:_?`No models found for "${_}"`:"Loading models..."}):o.jsxs("div",{className:"p-1",children:[!_&&o.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground",children:[o.jsx(hb,{className:"w-3 h-3 text-accent"}),o.jsx("span",{children:"Newest Models"})]}),J.map($=>o.jsx(sj,{model:$,onClick:()=>de($),showAge:!_},$.id))]})})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"model",children:["Default Model",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"ANTHROPIC_MODEL"})]}),o.jsx(Ra,{id:"model",...B("model"),placeholder:L?.defaultModel??"claude-sonnet-4",className:"font-mono text-sm"})]}),o.jsxs("div",{className:"grid gap-3 pt-2 border-t",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"sonnetModel",className:"text-sm",children:["Sonnet Mapping",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_SONNET"})]}),o.jsx(Ra,{id:"sonnetModel",...B("sonnetModel"),placeholder:"e.g. gpt-4o, claude-sonnet-4",className:"font-mono text-sm h-9"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"opusModel",className:"text-sm",children:["Opus Mapping",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_OPUS"})]}),o.jsx(Ra,{id:"opusModel",...B("opusModel"),placeholder:"e.g. o1, claude-opus-4.5",className:"font-mono text-sm h-9"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"haikuModel",className:"text-sm",children:["Haiku Mapping",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_HAIKU"})]}),o.jsx(Ra,{id:"haikuModel",...B("haikuModel"),placeholder:"e.g. gpt-4o-mini, claude-3.5-haiku",className:"font-mono text-sm h-9"})]})]})]})]})]}),o.jsxs(US,{className:"p-6 pt-4 border-t bg-muted/10",children:[o.jsx(St,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),o.jsx(St,{type:"submit",disabled:d.isPending,className:V(d.isPending&&"opacity-80"),children:d.isPending?o.jsxs(o.Fragment,{children:[o.jsx(as,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ih,{className:"w-4 h-4 mr-2"}),"Create Profile"]})})]})]})]})]})})}function Tp({preset:a,isSelected:s,onClick:r}){return o.jsxs("button",{type:"button",onClick:r,className:V("flex items-center gap-2 px-3 py-2 rounded-md border transition-all text-sm",s?a.featured?"border-accent bg-accent/10 dark:bg-accent/20 font-medium":"border-primary bg-primary/10 dark:bg-primary/20 font-medium":"border-muted-foreground/20 hover:border-muted-foreground/40 hover:bg-muted/50"),children:[a.icon?o.jsx("img",{src:a.icon,alt:"",className:"w-4 h-4"}):o.jsx("div",{className:"w-4 h-4 rounded-full bg-muted-foreground/20 flex items-center justify-center text-[9px] font-bold text-foreground/70",children:a.name.charAt(0)}),o.jsx("span",{className:"font-medium",children:a.name}),a.badge&&o.jsx(Ha,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-0.5 bg-muted-foreground/10 text-muted-foreground",children:a.badge})]})}function sj({model:a,onClick:s,showAge:r}){return o.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:[o.jsx("span",{className:"flex-1 truncate",children:a.name}),o.jsxs("span",{className:"text-muted-foreground group-hover:text-accent-foreground/80 ml-2 flex items-center gap-2 text-xs",children:[r&&a.created&&o.jsx(Ha,{variant:"outline",className:"text-[10px] text-accent group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30",children:ZN(a.created)}),a.isFree?o.jsx(Ha,{variant:"secondary",className:"text-xs group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground",children:"Free"}):o.jsx("span",{children:BN(a.pricing)}),o.jsx("span",{children:QN(a.context_length)})]})]})}const nE=Jx,aE=Fx,lE=$x,ij=v.forwardRef(({className:a,children:s,...r},u)=>o.jsxs(Jp,{ref:u,className:V("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...r,children:[s,o.jsx(Qx,{asChild:!0,children:o.jsx(Jo,{className:"h-4 w-4 opacity-50"})})]}));ij.displayName=Jp.displayName;const Zg=v.forwardRef(({className:a,...s},r)=>o.jsx($p,{ref:r,className:V("flex cursor-default items-center justify-center py-1",a),...s,children:o.jsx(Bc,{className:"h-4 w-4"})}));Zg.displayName=$p.displayName;const Wg=v.forwardRef(({className:a,...s},r)=>o.jsx(Fp,{ref:r,className:V("flex cursor-default items-center justify-center py-1",a),...s,children:o.jsx(Jo,{className:"h-4 w-4"})}));Wg.displayName=Fp.displayName;const oj=v.forwardRef(({className:a,children:s,position:r="popper",...u},d)=>o.jsx(Vx,{children:o.jsxs(Ip,{ref:d,className:V("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:r,...u,children:[o.jsx(Zg,{}),o.jsx(Xx,{className:V("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),o.jsx(Wg,{})]})}));oj.displayName=Ip.displayName;const rj=v.forwardRef(({className:a,...s},r)=>o.jsx(Pp,{ref:r,className:V("px-2 py-1.5 text-sm font-semibold",a),...s}));rj.displayName=Pp.displayName;const uj=v.forwardRef(({className:a,children:s,...r},u)=>o.jsxs(eg,{ref:u,className:V("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...r,children:[o.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(Zx,{children:o.jsx(ns,{className:"h-4 w-4"})})}),o.jsx(Wx,{children:s})]}));uj.displayName=eg.displayName;const cj=v.forwardRef(({className:a,...s},r)=>o.jsx(tg,{ref:r,className:V("-mx-1 my-1 h-px bg-muted",a),...s}));cj.displayName=tg.displayName;const dj=v.lazy(()=>At(()=>Promise.resolve().then(()=>$g),void 0).then(a=>({default:a.CodeEditor})));function sE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,onRawJsonChange:u,profileEnv:d,missingRequiredFields:m=[]}){const h=m.length>0;return o.jsx(v.Suspense,{fallback:o.jsxs("div",{className:"flex items-center justify-center h-full",children:[o.jsx(as,{className:"w-6 h-6 animate-spin text-muted-foreground"}),o.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:o.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[o.jsx(di,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",o.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Apply a preset from Model Config tab or add these fields manually. Without them, Claude Code will fail with 404 errors."})]})]}),o.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:o.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:o.jsx(dj,{value:a,onChange:u,language:"json",minHeight:"100%"})})}),o.jsx("div",{className:"mx-6 mb-4",children:o.jsx("div",{className:"border rounded-md overflow-hidden",children:o.jsx(Xg,{profileEnv:d})})})]})})}const fj=v.forwardRef(({className:a,value:s=0,max:r=100,indicatorClassName:u,...d},m)=>{const h=Math.min(Math.max(s/r*100,0),100);return o.jsx("div",{ref:m,role:"progressbar","aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":s,className:V("relative h-2 w-full overflow-hidden rounded-full bg-secondary",a),...d,children:o.jsx("div",{className:V("h-full transition-all",u||"bg-primary"),style:{width:`${h}%`}})})});fj.displayName="Progress";var Lt={},zp;function mj(){if(zp)return Lt;zp=1;var a=Lt&&Lt.__assign||function(){return a=Object.assign||function(k){for(var j,L=1,J=arguments.length;L<J;L++){j=arguments[L];for(var ee in j)Object.prototype.hasOwnProperty.call(j,ee)&&(k[ee]=j[ee])}return k},a.apply(this,arguments)},s=Lt&&Lt.__createBinding||(Object.create?(function(k,j,L,J){J===void 0&&(J=L);var ee=Object.getOwnPropertyDescriptor(j,L);(!ee||("get"in ee?!j.__esModule:ee.writable||ee.configurable))&&(ee={enumerable:!0,get:function(){return j[L]}}),Object.defineProperty(k,J,ee)}):(function(k,j,L,J){J===void 0&&(J=L),k[J]=j[L]})),r=Lt&&Lt.__setModuleDefault||(Object.create?(function(k,j){Object.defineProperty(k,"default",{enumerable:!0,value:j})}):function(k,j){k.default=j}),u=Lt&&Lt.__importStar||function(k){if(k&&k.__esModule)return k;var j={};if(k!=null)for(var L in k)L!=="default"&&Object.prototype.hasOwnProperty.call(k,L)&&s(j,k,L);return r(j,k),j},d=Lt&&Lt.__rest||function(k,j){var L={};for(var J in k)Object.prototype.hasOwnProperty.call(k,J)&&j.indexOf(J)<0&&(L[J]=k[J]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ee=0,J=Object.getOwnPropertySymbols(k);ee<J.length;ee++)j.indexOf(J[ee])<0&&Object.prototype.propertyIsEnumerable.call(k,J[ee])&&(L[J[ee]]=k[J[ee]]);return L};Object.defineProperty(Lt,"__esModule",{value:!0});var m=u(ag()),h=89,p=90,y=77,S=57,M=219,x=222,b=192,_=100,A=3e3,R=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),B=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),w="npm__react-simple-code-editor__textarea",Y=`
14
+ `).trim()}function mN(a){const s=a.url.match(/\/api\/provider\/([^/]+)/);s&&(a.provider=s[1]);const r=a.url.match(/\/api\/provider\/[^/]+\/(.+?)(?:\?|$)/);r&&(a.endpoint=r[1]),a.isClientError=a.statusCode>=400&&a.statusCode<500,a.isServerError=a.statusCode>=500,a.statusCode===429?a.errorType="rate_limit":a.statusCode===401||a.statusCode===403?a.errorType="auth":a.statusCode===404?a.errorType="not_found":a.statusCode>=500?a.errorType="server":(a.statusCode===408||a.statusCode===504)&&(a.errorType="timeout"),hN(a),a.statusCode===429&&pN(a)}function hN(a){if(a.requestBody)try{const s=JSON.parse(a.requestBody);typeof s.model=="string"&&(a.model=s.model)}catch{}}function pN(a){if(a.responseBody)try{const s=JSON.parse(a.responseBody),r=Oc(s);r!==null&&(a.quotaResetDelay=r);const u=Ac(s);u&&(a.quotaResetTimestamp=u)}catch{}}function Oc(a){if(typeof a!="object"||a===null)return null;const s=a;if("quotaResetDelay"in s){const r=s.quotaResetDelay;if(typeof r=="number")return r;if(typeof r=="string"){const u=r.match(/^(\d+)s?$/);if(u)return parseInt(u[1],10)}}if("error"in s&&typeof s.error=="object"){const r=Oc(s.error);if(r!==null)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Oc(r);if(u!==null)return u}return null}function Ac(a){if(typeof a!="object"||a===null)return null;const s=a;for(const r of["quotaResetTimeStamp","quotaResetTimestamp","resetTime","reset_time"])if(r in s&&typeof s[r]=="string")return s[r];if("error"in s&&typeof s.error=="object"){const r=Ac(s.error);if(r)return r}if("details"in s&&Array.isArray(s.details))for(const r of s.details){const u=Ac(r);if(u)return u}return null}function gN(a){return{400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Request Timeout",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"}[a]||""}function yN(a){const s=Date.now(),r=a*1e3,u=s-r,d=Math.floor(u/1e3),m=Math.floor(d/60),h=Math.floor(m/60),p=Math.floor(h/24);return d<60?"just now":m<60?`${m}m ago`:h<24?`${h}h ago`:p<7?`${p}d ago`:new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function xN(a){return a>=500?"text-red-500":a===429?"text-orange-500":a>=400?"text-yellow-500":"text-gray-500"}function vN(a){return{rate_limit:"Rate Limited",auth:"Auth Error",not_found:"Not Found",server:"Server Error",timeout:"Timeout",unknown:"Error"}[a]||"Error"}function bN(a){if(a===null||a<=0)return null;if(a<60)return`${a}s`;if(a<3600)return`${Math.floor(a/60)}m`;const s=Math.floor(a/3600),r=Math.floor(a%3600/60);return r>0?`${s}h ${r}m`:`${s}h`}function SN(a){if(!a)return null;try{const s=new Date(a),r=new Date,u=s.getTime()-r.getTime();if(u<=0)return"now";const d=Math.floor(u/1e3);if(d<60)return`${d}s`;if(d<3600)return`${Math.floor(d/60)}m`;const m=Math.floor(d/3600),h=Math.floor(d%3600/60);return h>0?`${m}h ${h}m`:`${m}h`}catch{return null}}function NN(a){return a?a===429?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":a>=500?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":a>=400?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-gray-100 text-gray-600":"bg-gray-100 text-gray-600"}function jN(a){return a||""}function CN({name:a,size:s,modified:r,isSelected:u,onClick:d,statusCode:m,model:h}){const p=v.useMemo(()=>rN(a),[a]),y=v.useMemo(()=>jN(h),[h]);return o.jsxs("button",{onClick:d,className:V("w-full px-2.5 py-2 flex items-center gap-2 text-left transition-colors","hover:bg-muted/40 border-l-[3px]",u?"bg-muted/50 border-l-red-500":"border-l-transparent"),children:[o.jsx("span",{className:V("shrink-0 text-[10px] font-bold px-1.5 py-0.5 rounded min-w-[32px] text-center",NN(m)),children:m||"???"}),o.jsx(Vc,{provider:p.provider,size:18,withBackground:!0,className:"shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[o.jsx("span",{className:"text-[11px] font-medium text-foreground truncate",children:p.endpoint||"unknown"}),y&&o.jsx("span",{className:"text-[10px] text-muted-foreground truncate",title:y,children:y}),o.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-muted-foreground/60",children:[o.jsx(Uc,{className:"w-2.5 h-2.5"}),o.jsx("span",{children:yN(r)})]})]})]})}function jp({value:a,className:s,variant:r="outline",size:u="icon",label:d="Copy to clipboard"}){const[m,h]=v.useState(!1),p=()=>{navigator.clipboard.writeText(a),h(!0),setTimeout(()=>h(!1),2e3)};return o.jsx(Fo,{children:o.jsxs(fi,{children:[o.jsx(mi,{asChild:!0,children:o.jsxs(St,{size:u,variant:r,className:V("relative z-10 text-muted-foreground hover:text-foreground",s),onClick:y=>{y.stopPropagation(),p()},children:[m?o.jsx(ns,{className:"h-3.5 w-3.5 text-green-500"}):o.jsx(Bo,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"sr-only",children:d})]})}),o.jsx(hi,{children:o.jsx("p",{children:m?"Copied!":d})})]})})}function ti({active:a,onClick:s,children:r,icon:u}){return o.jsxs("button",{onClick:s,className:V("px-2.5 py-1.5 text-xs font-medium rounded transition-colors flex items-center gap-1.5",a?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[u&&o.jsx(u,{className:"w-3.5 h-3.5"}),r]})}function Hg({code:a}){const s=xN(a);return o.jsx("span",{className:V("inline-flex items-center justify-center min-w-[36px] px-2 py-0.5 rounded text-xs font-bold","bg-current/10 border border-current/20",s),children:a})}function EN({parsed:a}){const s=bN(a.quotaResetDelay)||SN(a.quotaResetTimestamp);return o.jsx(dl,{className:"h-full",children:o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Hg,{code:a.statusCode}),o.jsx("span",{className:"text-sm font-medium",children:a.statusText}),o.jsx("span",{className:"text-xs text-muted-foreground px-2 py-0.5 rounded bg-muted/50",children:vN(a.errorType)})]}),a.model&&o.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-violet-500/10 border border-violet-500/20",children:[o.jsx(ib,{className:"w-4 h-4 text-violet-500 shrink-0"}),o.jsxs("div",{className:"text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Model: "}),o.jsx("span",{className:"font-semibold text-violet-600 dark:text-violet-400",children:a.model})]})]}),a.errorType==="rate_limit"&&s&&o.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[o.jsx(Uc,{className:"w-4 h-4 text-amber-500 shrink-0"}),o.jsxs("div",{className:"text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Quota resets in "}),o.jsx("span",{className:"font-semibold text-amber-600 dark:text-amber-400",children:s})]})]}),o.jsxs("div",{className:"grid grid-cols-4 gap-3 text-xs",children:[o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Method"}),o.jsx("div",{className:"font-medium",children:a.method||"N/A"})]}),o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Provider"}),o.jsx("div",{className:"font-medium",children:a.provider||"N/A"})]}),o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Version"}),o.jsx("div",{className:"font-medium",children:a.version||"N/A"})]}),o.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[o.jsx("div",{className:"text-muted-foreground mb-1",children:"Endpoint"}),o.jsx("div",{className:"font-medium truncate",title:a.endpoint,children:a.endpoint||"N/A"})]})]}),o.jsxs("div",{className:"text-xs",children:[o.jsx("div",{className:"text-muted-foreground mb-1.5",children:"URL"}),o.jsx("div",{className:"font-mono p-2.5 rounded bg-muted/30 border border-border/50 break-all leading-relaxed",children:a.url||"N/A"})]}),o.jsxs("div",{className:"text-xs",children:[o.jsx("div",{className:"text-muted-foreground mb-1.5",children:"Timestamp"}),o.jsx("div",{className:"font-mono",children:a.timestamp||"N/A"})]}),a.errorType!=="unknown"&&o.jsxs("div",{className:V("flex items-start gap-3 p-3 rounded text-xs",a.errorType==="rate_limit"?"bg-amber-500/10 border border-amber-500/20":a.errorType==="auth"?"bg-red-500/10 border border-red-500/20":"bg-blue-500/10 border border-blue-500/20"),children:[a.errorType==="rate_limit"?o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}):a.errorType==="auth"?o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-red-500 shrink-0"}):o.jsx(Wo,{className:"w-4 h-4 mt-0.5 text-blue-500 shrink-0"}),o.jsxs("div",{className:V("leading-relaxed",a.errorType==="rate_limit"?"text-amber-600 dark:text-amber-400":a.errorType==="auth"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),children:[a.errorType==="rate_limit"&&o.jsxs(o.Fragment,{children:[o.jsx("strong",{children:"Rate Limited."})," Switch to a different account or wait for quota reset.",a.model&&o.jsxs(o.Fragment,{children:[" ","Model ",o.jsx("code",{className:"font-mono text-[11px]",children:a.model})," has exhausted quota."]})]}),a.errorType==="auth"&&"Authentication failed. Re-authenticate via CLIProxy Settings or check API key.",a.errorType==="not_found"&&"Endpoint not found. This endpoint may not exist on this provider.",a.errorType==="server"&&"Server error from upstream. Retry later or check provider status page.",a.errorType==="timeout"&&"Request timed out. Check network connection or increase timeout settings."]})]})]})})}function wN({headers:a}){const s=Object.entries(a);return s.length===0?o.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No headers available"}):o.jsx(dl,{className:"h-full",children:o.jsx("div",{className:"p-4 space-y-1",children:s.map(([r,u])=>o.jsxs("div",{className:"flex gap-3 text-xs font-mono py-1.5 border-b border-border/30 last:border-0",children:[o.jsxs("span",{className:"text-muted-foreground shrink-0 min-w-[140px]",children:[r,":"]}),o.jsx("span",{className:"break-all",children:u})]},r))})})}function Cp({content:a,label:s}){if(!a||a.trim()==="")return o.jsxs("div",{className:"p-4 text-xs text-muted-foreground",children:["No ",s.toLowerCase()," body"]});let r=a,u=!1;try{const d=JSON.parse(a);r=JSON.stringify(d,null,2),u=!0}catch{}return o.jsx(dl,{className:"h-full",children:o.jsx("pre",{className:V("p-4 text-xs font-mono whitespace-pre-wrap break-all leading-relaxed",u?"text-emerald-700 dark:text-green-400":"text-zinc-700 dark:text-muted-foreground"),children:r})})}function MN({content:a}){return o.jsx(dl,{className:"h-full",children:o.jsx("pre",{className:"p-4 text-xs font-mono text-zinc-700 dark:text-muted-foreground whitespace-pre-wrap break-all leading-relaxed",children:a})})}function TN({name:a,absolutePath:s}){const[r,u]=v.useState("overview"),{data:d,isLoading:m,error:h}=h1(a),p=v.useMemo(()=>d?uN(d):null,[d]);return a?m?o.jsxs("div",{className:"flex-1 p-6 space-y-3",children:[o.jsx(Le,{className:"h-5 w-full"}),o.jsx(Le,{className:"h-5 w-3/4"}),o.jsx(Le,{className:"h-5 w-5/6"}),o.jsx(Le,{className:"h-5 w-2/3"})]}):h||!d||!p?o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:o.jsx("p",{className:"text-sm",children:"Failed to load log content"})}):o.jsxs("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:[o.jsxs("div",{className:"px-4 py-3 border-b border-border bg-muted/30 flex items-center justify-between gap-3 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx(Hg,{code:p.statusCode}),o.jsxs("span",{className:"text-xs font-semibold truncate text-foreground",children:[p.provider,"/",p.endpoint||"unknown"]}),a&&o.jsx(jp,{value:s||a,label:"Copy absolute path",size:"icon-sm",className:"ml-1 text-muted-foreground hover:text-foreground opacity-50 hover:opacity-100 transition-opacity"})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d&&o.jsx(jp,{value:d,label:"Copy raw log content",variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono bg-muted px-1.5 py-0.5 rounded border border-border/50",children:p.method})]})]}),o.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-1 bg-muted/10 shrink-0 overflow-x-auto",children:[o.jsx(ti,{active:r==="overview",onClick:()=>u("overview"),icon:Wo,children:"Overview"}),o.jsx(ti,{active:r==="headers",onClick:()=>u("headers"),icon:rb,children:"Headers"}),o.jsx(ti,{active:r==="request",onClick:()=>u("request"),icon:ub,children:"Request"}),o.jsx(ti,{active:r==="response",onClick:()=>u("response"),icon:cb,children:"Response"}),o.jsx(ti,{active:r==="raw",onClick:()=>u("raw"),icon:db,children:"Raw"})]}),o.jsxs("div",{className:"flex-1 overflow-hidden bg-card/30",children:[r==="overview"&&o.jsx(EN,{parsed:p}),r==="headers"&&o.jsx(wN,{headers:p.requestHeaders}),r==="request"&&o.jsx(Cp,{content:p.requestBody,label:"Request"}),r==="response"&&o.jsx(Cp,{content:p.responseBody,label:"Response"}),r==="raw"&&o.jsx(MN,{content:d})]})]}):o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx(ob,{className:"w-10 h-10 mx-auto opacity-40"}),o.jsx("p",{className:"text-sm",children:"Select a log to view details"})]})})}function zN(){const{data:a,isLoading:s}=u1(),{data:r,isLoading:u,error:d}=m1(a?.running??!1),[m,h]=v.useState(500),[p,y]=v.useState(!1),S=v.useRef(null),M=v.useRef(null),x=()=>{M.current&&(clearInterval(M.current),M.current=null)};v.useEffect(()=>{if(!p)return;const q=k=>{const j=S.current;if(!j)return;const J=j.getBoundingClientRect().top+window.scrollY,ee=k.pageY-J;h(Math.max(300,ee));const ve=window.innerHeight-k.clientY,oe=15;x(),ve<50?M.current=setInterval(()=>{window.scrollBy(0,oe)},16):k.clientY<50&&(M.current=setInterval(()=>{window.scrollBy(0,-oe)},16))},Q=()=>{y(!1),x(),document.body.style.cursor="default",document.body.style.userSelect="auto"};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",Q),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Q),document.body.style.cursor="default",document.body.style.userSelect="auto",x()}},[p]);const b=q=>{q.preventDefault(),y(!0)},_=v.useMemo(()=>r?.[0]?.name??null,[r]),[A,R]=v.useState(null),B=A??_,w=v.useMemo(()=>!B||!r?void 0:r.find(Q=>Q.name===B)?.absolutePath,[B,r]);if(s||!a?.running)return null;if(u)return o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden font-mono text-sm bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm h-[500px]",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[o.jsx(Le,{className:"h-4 w-32"}),o.jsx(Le,{className:"h-4 w-20"})]}),o.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(q=>o.jsx(Le,{className:"h-12 w-full rounded-lg"},q))})]});if(!r||r.length===0)return null;const Y=r.length;return o.jsxs("div",{ref:S,className:"rounded-xl border border-border overflow-hidden font-mono text-sm text-foreground bg-card/50 dark:bg-zinc-900/60 backdrop-blur-sm flex flex-col shadow-sm transition-[height] duration-0 ease-linear relative group/container",style:{height:m},children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-gradient-to-r from-amber-500/10 via-transparent to-transparent dark:from-amber-500/15 shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(ul,{className:"w-4 h-4 text-amber-500"}),o.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Error Logs"}),o.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[Y," failed request",Y!==1?"s":""]})]}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(fb,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:"CLIProxy Diagnostics"})]})]}),o.jsx("div",{className:"flex-1 min-h-0",children:o.jsxs(Jc,{direction:"horizontal",children:[o.jsx(ri,{defaultSize:30,minSize:20,maxSize:50,className:"flex flex-col min-w-0",children:o.jsxs(dl,{className:"h-full",children:[o.jsx("div",{className:"divide-y divide-border/50",children:r.slice(0,50).map(q=>o.jsx(CN,{name:q.name,size:q.size,modified:q.modified,isSelected:B===q.name,onClick:()=>R(q.name),statusCode:q.statusCode,model:q.model},q.name))}),r.length>50&&o.jsxs("div",{className:"px-3 py-3 text-center text-[10px] text-muted-foreground border-t border-border/50",children:["Showing 50 of ",r.length," logs"]})]})}),o.jsxs($c,{className:"w-[1px] bg-border hover:bg-primary/50 transition-colors flex items-center justify-center group relative z-10 w-2 -ml-1 flex items-center justify-center outline-none",children:[o.jsx("div",{className:"w-[1px] h-full bg-border group-hover:bg-primary/50 transition-colors"}),o.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-4 h-8 rounded-sm flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-muted border border-border",children:o.jsx(Zo,{className:"h-4 w-4 text-muted-foreground"})})]}),o.jsx(ri,{className:"flex flex-col min-w-0 bg-background/50",children:o.jsx(TN,{name:B,absolutePath:w})})]})}),d?o.jsx("div",{className:"px-4 py-2 border-t border-border text-xs text-destructive bg-destructive/5 shrink-0",children:d.message}):o.jsx("div",{className:"h-2 bg-border/10 border-t border-border/30 hover:bg-primary/10 transition-colors cursor-row-resize flex items-center justify-center group/handle shrink-0",onMouseDown:b,children:o.jsx(mb,{className:"w-8 h-3 text-border group-hover:text-primary/50 transition-colors"})})]})}const ON=Go("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",warning:"border-yellow-200 bg-yellow-50 text-yellow-900 dark:border-yellow-900/50 dark:bg-yellow-900/20 dark:text-yellow-200 [&>svg]:text-yellow-600 dark:[&>svg]:text-yellow-500",info:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-200 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-500",success:"border-green-200 bg-green-50 text-green-900 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-200 [&>svg]:text-green-600 dark:[&>svg]:text-green-500"}},defaultVariants:{variant:"default"}}),qg=v.forwardRef(({className:a,variant:s,...r},u)=>o.jsx("div",{ref:u,role:"alert",className:V(ON({variant:s}),a),...r}));qg.displayName="Alert";const Lg=v.forwardRef(({className:a,...s},r)=>o.jsx("h5",{ref:r,className:V("mb-1 font-medium leading-none tracking-tight",a),...s}));Lg.displayName="AlertTitle";const Yg=v.forwardRef(({className:a,...s},r)=>o.jsx("div",{ref:r,className:V("text-sm [&_p]:leading-relaxed",a),...s}));Yg.displayName="AlertDescription";function AN(){return zt({queryKey:["overview"],queryFn:async()=>(await fetch("/api/overview")).json()})}function DN(){return zt({queryKey:["shared","summary"],queryFn:async()=>(await fetch("/api/shared/summary")).json()})}function XC(a){return zt({queryKey:["shared",a],queryFn:async()=>(await fetch(`/api/shared/${a}`)).json()})}const _N={ok:"success",warning:"warning",error:"error"},kN={default:{iconBg:"bg-muted",iconColor:"text-muted-foreground"},success:{iconBg:"bg-green-600/15",iconColor:"text-green-700 dark:text-green-500"},warning:{iconBg:"bg-amber-500/15",iconColor:"text-amber-700 dark:text-amber-400"},error:{iconBg:"bg-red-600/15",iconColor:"text-red-700 dark:text-red-500"},accent:{iconBg:"bg-accent/15",iconColor:"text-accent"}};function Do({title:a,value:s,icon:r,variant:u="default",onClick:d}){const m=kN[u];return o.jsxs("button",{onClick:d,className:V("flex items-center gap-3 px-4 py-2.5 rounded-lg border bg-card/50","transition-all hover:bg-card hover:shadow-sm hover:-translate-y-0.5","active:scale-[0.98]"),children:[o.jsx("div",{className:V("flex items-center justify-center w-9 h-9 rounded-md",m.iconBg),children:o.jsx(r,{className:V("w-4 h-4",m.iconColor)})}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a}),o.jsx("p",{className:V("text-lg font-bold font-mono leading-tight",m.iconColor),children:s})]})]})}function RN(){const a=iv(),{data:s,isLoading:r}=AN(),{data:u,isLoading:d}=DN();if(r||d)return o.jsxs("div",{className:"p-6 space-y-6",children:[o.jsxs("div",{className:"rounded-xl border p-6 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(Le,{className:"h-12 w-12 rounded-lg"}),o.jsxs("div",{children:[o.jsx(Le,{className:"h-7 w-[180px] mb-2"}),o.jsx(Le,{className:"h-4 w-[220px]"})]})]}),o.jsx("div",{className:"flex items-center gap-3",children:[1,2,3,4].map(h=>o.jsx(Le,{className:"h-14 w-28 rounded-lg"},h))})]}),o.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[o.jsxs("div",{className:"px-4 py-2.5 border-b flex items-center justify-between",children:[o.jsx(Le,{className:"h-4 w-32"}),o.jsx(Le,{className:"h-4 w-20"})]}),o.jsx("div",{className:"px-4 py-3 border-b",children:o.jsx(Le,{className:"h-2 w-full rounded-full"})}),[1,2,3].map(h=>o.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-3 border-b last:border-b-0",children:[o.jsx(Le,{className:"w-2.5 h-2.5 rounded-full"}),o.jsx(Le,{className:"h-4 flex-1"}),o.jsx(Le,{className:"h-1.5 w-24 rounded-full"}),o.jsx(Le,{className:"h-4 w-16"})]},h))]})]});const m=s?.health?_N[s.health.status]:void 0;return o.jsxs("div",{className:"p-6 space-y-6",children:[o.jsxs("div",{className:"relative overflow-hidden rounded-xl border bg-gradient-to-br from-background via-background to-muted/30",children:[o.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:o.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),o.jsxs("div",{className:"relative p-6 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[o.jsx(XS,{version:s?.version}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(Do,{title:"Profiles",value:s?.profiles??0,icon:lg,variant:"accent",onClick:()=>a("/providers")}),o.jsx(Do,{title:"CLIProxy",value:s?.cliproxy??0,icon:sg,variant:"accent",onClick:()=>a("/cliproxy")}),o.jsx(Do,{title:"Accounts",value:s?.accounts??0,icon:rg,variant:"default",onClick:()=>a("/accounts")}),o.jsx(Do,{title:"Health",value:s?.health?`${s.health.passed}/${s.health.total}`:"-",icon:oi,variant:m,onClick:()=>a("/health")})]})]})]}),u?.symlinkStatus&&!u.symlinkStatus.valid&&o.jsxs(qg,{variant:"warning",children:[o.jsx(ul,{className:"h-4 w-4"}),o.jsx(Lg,{children:"Configuration Required"}),o.jsx(Yg,{children:u.symlinkStatus.message})]}),o.jsx(_1,{}),o.jsx(zN,{})]})}const Gg=Gx,Fc=v.forwardRef(({className:a,...s},r)=>o.jsx(Xp,{ref:r,className:V("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",a),...s}));Fc.displayName=Xp.displayName;const il=v.forwardRef(({className:a,...s},r)=>o.jsx(Zp,{ref:r,className:V("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",a),...s}));il.displayName=Zp.displayName;const Dc=v.forwardRef(({className:a,...s},r)=>o.jsx(Wp,{ref:r,className:V("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...s}));Dc.displayName=Wp.displayName;function Dn({className:a,...s}){return o.jsx(Kx,{"data-slot":"label",className:V("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",a),...s})}const Ic="ccs:openrouter-models",UN=1440*60*1e3,Kg="1";function _c(a){const s=parseFloat(a);return isNaN(s)||s===0?0:s*1e6}function Ep(a){const s=_c(a);return s===0?"Free":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:`$${s.toFixed(s<10?2:0)}`}function BN(a){const s=Ep(a.prompt),r=Ep(a.completion);return s==="Free"&&r==="Free"?"Free":`${s}/${r}`}function HN(a){const s=a.id.toLowerCase();return s.startsWith("anthropic/")?"anthropic":s.startsWith("openai/")?"openai":s.startsWith("google/")?"google":s.startsWith("meta-llama/")||s.startsWith("meta/")?"meta":s.startsWith("mistralai/")?"mistral":s.includes(":free")||s.includes("qwen")||s.includes("deepseek")?"opensource":"other"}function qN(a){return{...a,category:HN(a),pricePerMillionPrompt:_c(a.pricing.prompt),pricePerMillionCompletion:_c(a.pricing.completion),isFree:a.pricing.prompt==="0"&&a.pricing.completion==="0",isExacto:a.id.includes(":exacto")}}function LN(a,s,r){const u=s.toLowerCase().trim();return a.filter(d=>r?.category&&d.category!==r.category||r?.freeOnly&&!d.isFree||r?.minContext&&d.context_length<r.minContext?!1:u?d.id.toLowerCase().includes(u)||d.name.toLowerCase().includes(u)||d.description?.toLowerCase().includes(u):!0)}function ZC(a){return[...a].sort((s,r)=>{if(s.isFree&&!r.isFree)return-1;if(!s.isFree&&r.isFree)return 1;if(!s.isFree&&!r.isFree){if(s.isExacto&&!r.isExacto)return-1;if(!s.isExacto&&r.isExacto)return 1}return s.name.localeCompare(r.name)})}function YN(){try{const a=localStorage.getItem(Ic);if(!a)return null;const s=JSON.parse(a);return s.version!==Kg||Date.now()-s.fetchedAt>UN?null:s.models}catch{return null}}function GN(a){try{localStorage.setItem(Ic,JSON.stringify({models:a,fetchedAt:Date.now(),version:Kg}))}catch{}}function KN(){localStorage.removeItem(Ic)}function WC(a,s){const[r]=a.split("/");if(!r)return{};const u=s.filter(h=>h.id.startsWith(`${r}/`));if(u.length===0)return{};const d=[...u].sort((h,p)=>p.pricePerMillionPrompt-h.pricePerMillionPrompt),m=Math.ceil(d.length/3);return{opus:d[0]?.id,sonnet:d[Math.min(m,d.length-1)]?.id,haiku:d[d.length-1]?.id}}function QN(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${Math.round(a/1e3)}K`:String(a)}const JC={anthropic:"Anthropic (Claude)",openai:"OpenAI (GPT)",google:"Google (Gemini)",meta:"Meta (Llama)",mistral:"Mistral",opensource:"Open Source",other:"Other"},VN={anthropic:["anthropic/"],openai:["openai/"],google:["google/"],meta:["meta-llama/","meta/"],mistral:["mistralai/"],opensource:["deepseek/","qwen/","cohere/"],other:[]};function XN(a,s=2){const r=[],u=["anthropic","openai","google","meta","mistral","opensource"];for(const d of u){const m=VN[d];if(m.length===0)continue;const p=[...a.filter(y=>m.some(S=>y.id.toLowerCase().startsWith(S)))].sort((y,S)=>(S.created??0)-(y.created??0));r.push(...p.slice(0,s))}return r.sort((d,m)=>(m.created??0)-(d.created??0))}function ZN(a){const r=Date.now()/1e3-a;return r<86400?"Today":r<172800?"Yesterday":r<604800?`${Math.floor(r/86400)}d ago`:r<2592e3?`${Math.floor(r/604800)}w ago`:r<31536e3?`${Math.floor(r/2592e3)}mo ago`:`${Math.floor(r/31536e3)}y ago`}const WN="https://openrouter.ai/api/v1/models",Qg=["openrouter-models"],wp=1440*60*1e3;async function JN(){const a=await fetch(WN);if(!a.ok)throw new Error(`Failed to fetch OpenRouter models: ${a.status}`);const r=(await a.json()).data;return GN(r),r}function Vg(){return zt({queryKey:Qg,queryFn:JN,staleTime:wp,gcTime:wp,initialData:()=>YN()??void 0,refetchOnWindowFocus:!1})}function $N(){const a=Vg(),s=(a.data??[]).map(qN);return{...a,models:s}}function $C(){const a=Gt();return()=>(KN(),a.invalidateQueries({queryKey:Qg}))}function FC(){const{data:a,isLoading:s,isError:r}=Vg();return{isReady:!!a&&a.length>0,isLoading:s,isError:r,modelCount:a?.length??0}}function Xg({profileEnv:a={}}){const[s,r]=v.useState(null),[u,d]=v.useState(!0),[m,h]=v.useState(!1);v.useEffect(()=>{p()},[]);const p=async()=>{try{d(!0);const b=await fetch("/api/global-env");if(!b.ok)throw new Error("Failed to load");const _=await b.json();r(_)}catch{r(null)}finally{d(!1)}};if(u||!s?.enabled)return null;const y=s.env||{},S=Object.keys(y);if(S.length===0)return null;const M=S.filter(b=>!(b in a)),x=S.filter(b=>b in a);return o.jsxs("div",{className:"border-t bg-muted/20",children:[o.jsxs("button",{onClick:()=>h(!m),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",children:[o.jsx(Wo,{className:"w-4 h-4 text-blue-500"}),o.jsxs("span",{className:"text-xs text-muted-foreground flex-1 text-left",children:[o.jsx("span",{className:"font-medium text-foreground",children:M.length})," global env var",M.length!==1?"s":""," will be injected at runtime",x.length>0&&o.jsxs("span",{className:"text-amber-600 dark:text-amber-400 ml-1",children:["(",x.length," overridden by profile)"]})]}),m?o.jsx(Bc,{className:"w-4 h-4 text-muted-foreground"}):o.jsx(Jo,{className:"w-4 h-4 text-muted-foreground"})]}),m&&o.jsxs("div",{className:"px-4 pb-3 space-y-2",children:[M.length>0&&o.jsx("div",{className:"space-y-1",children:M.map(b=>o.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-green-500/10 text-green-700 dark:text-green-400 px-2 py-1 rounded",children:[o.jsx("span",{className:"text-green-500",children:"+"}),o.jsxs("span",{className:"truncate",children:[b,"=",y[b]]})]},b))}),x.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Skipped (profile already defines):"}),x.map(b=>o.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono bg-amber-500/10 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[o.jsx("span",{className:"text-amber-500",children:"~"}),o.jsx("span",{className:"truncate",children:b})]},b))]}),o.jsx("div",{className:"pt-2 border-t border-border/50",children:o.jsx(St,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 text-xs gap-1.5 -ml-2",children:o.jsxs(Tc,{to:"/settings?tab=globalenv",children:[o.jsx(Hc,{className:"w-3.5 h-3.5"}),"Configure in Settings",o.jsx(cg,{className:"w-3 h-3 opacity-50"})]})})})]})]})}const FN=v.lazy(()=>At(()=>Promise.resolve().then(()=>$g),void 0).then(a=>({default:a.CodeEditor})));function IC({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,settings:u,onChange:d,missingRequiredFields:m=[]}){const h=m.length>0;return o.jsx(v.Suspense,{fallback:o.jsxs("div",{className:"flex items-center justify-center h-full",children:[o.jsx(as,{className:"w-6 h-6 animate-spin text-muted-foreground"}),o.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:o.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[o.jsx(di,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",o.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),o.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:o.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:o.jsx(FN,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),o.jsx("div",{className:"mx-6 mb-4",children:o.jsx("div",{className:"border rounded-md overflow-hidden",children:o.jsx(Xg,{profileEnv:u?.env})})})]})})}function Mp(a,s){try{var r=a()}catch(u){return s(u)}return r&&r.then?r.then(void 0,s):r}function IN(a,s){for(var r={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!r[h])if("unionErrors"in u){var p=u.unionErrors[0].errors[0];r[h]={message:p.message,type:p.code}}else r[h]={message:m,type:d};if("unionErrors"in u&&u.unionErrors.forEach(function(M){return M.errors.forEach(function(x){return a.push(x)})}),s){var y=r[h].types,S=y&&y[u.code];r[h]=dg(h,s,r,d,S?[].concat(S,u.message):u.message)}a.shift()}return r}function PN(a,s){for(var r={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!r[h])if(u.code==="invalid_union"&&u.errors.length>0){var p=u.errors[0][0];r[h]={message:p.message,type:p.code}}else r[h]={message:m,type:d};if(u.code==="invalid_union"&&u.errors.forEach(function(M){return M.forEach(function(x){return a.push(x)})}),s){var y=r[h].types,S=y&&y[u.code];r[h]=dg(h,s,r,d,S?[].concat(S,u.message):u.message)}a.shift()}return r}function ej(a,s,r){if(r===void 0&&(r={}),(function(u){return"_def"in u&&typeof u._def=="object"&&"typeName"in u._def})(a))return function(u,d,m){try{return Promise.resolve(Mp(function(){return Promise.resolve(a[r.mode==="sync"?"parse":"parseAsync"](u,s)).then(function(h){return m.shouldUseNativeValidation&&tp({},m),{errors:{},values:r.raw?Object.assign({},u):h}})},function(h){if((function(p){return Array.isArray(p?.issues)})(h))return{values:{},errors:np(IN(h.errors,!m.shouldUseNativeValidation&&m.criteriaMode==="all"),m)};throw h}))}catch(h){return Promise.reject(h)}};if((function(u){return"_zod"in u&&typeof u._zod=="object"})(a))return function(u,d,m){try{return Promise.resolve(Mp(function(){return Promise.resolve((r.mode==="sync"?vb:bb)(a,u,s)).then(function(h){return m.shouldUseNativeValidation&&tp({},m),{errors:{},values:r.raw?Object.assign({},u):h}})},function(h){if((function(p){return p instanceof Sb})(h))return{values:{},errors:np(PN(h.issues,!m.shouldUseNativeValidation&&m.criteriaMode==="all"),m)};throw h}))}catch(h){return Promise.reject(h)}};throw new Error("Invalid input: not a Zod schema")}function PC(){return zt({queryKey:["profiles"],queryFn:()=>ht.profiles.list()})}function tj(){const a=Gt();return ln({mutationFn:s=>ht.profiles.create(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),Ne.success("Profile created successfully")},onError:s=>{Ne.error(s.message)}})}function eE(){const a=Gt();return ln({mutationFn:s=>ht.profiles.delete(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),Ne.success("Profile deleted successfully")},onError:s=>{Ne.error(s.message)}})}const nj="https://openrouter.ai/api",Uo=[{id:"openrouter",name:"OpenRouter",description:"349+ models from OpenAI, Anthropic, Google, Meta",baseUrl:nj,defaultProfileName:"openrouter",badge:"349+ models",featured:!0,icon:"/icons/openrouter.svg",defaultModel:"anthropic/claude-opus-4.5",requiresApiKey:!0,apiKeyPlaceholder:"sk-or-...",apiKeyHint:"Get your API key at openrouter.ai/keys",category:"recommended"},{id:"glm",name:"GLM",description:"Claude via Z.AI",baseUrl:"https://api.z.ai/api/anthropic",defaultProfileName:"glm",badge:"Z.AI",defaultModel:"glm-4.7",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Get your API key from Z.AI",category:"alternative"},{id:"glmt",name:"GLMT",description:"GLM with Thinking mode support",baseUrl:"https://api.z.ai/api/coding/paas/v4/chat/completions",defaultProfileName:"glmt",badge:"Thinking",defaultModel:"glm-4.7",requiresApiKey:!0,apiKeyPlaceholder:"ghp_...",apiKeyHint:"Same API key as GLM",category:"alternative"},{id:"kimi",name:"Kimi",description:"Moonshot AI - Fast reasoning model",baseUrl:"https://api.kimi.com/coding/",defaultProfileName:"kimi",badge:"Reasoning",defaultModel:"kimi-k2-thinking-turbo",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Moonshot AI",category:"alternative"},{id:"foundry",name:"Azure Foundry",description:"Claude via Microsoft Azure AI Foundry",baseUrl:"https://<your-resource>.services.ai.azure.com/api/anthropic",defaultProfileName:"foundry",badge:"Azure",defaultModel:"claude-sonnet-4-5",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_AZURE_API_KEY",apiKeyHint:"Create resource at ai.azure.com, get API key from Keys tab",category:"alternative"},{id:"mm",name:"Minimax",description:"M2.1/M2.1-lightning/M2 - multilang coding (1M context)",baseUrl:"https://api.minimax.io/anthropic",defaultProfileName:"mm",badge:"1M context",defaultModel:"MiniMax-M2.1",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_MINIMAX_API_KEY_HERE",apiKeyHint:"Get your API key at platform.minimax.io",category:"alternative"},{id:"deepseek",name:"DeepSeek",description:"V3.2 and R1 reasoning model (128K context)",baseUrl:"https://api.deepseek.com/anthropic",defaultProfileName:"deepseek",badge:"Reasoning",defaultModel:"deepseek-chat",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key at platform.deepseek.com",category:"alternative"},{id:"qwen",name:"Qwen",description:"Alibaba Cloud - qwen3-coder-plus (256K context)",baseUrl:"https://dashscope-intl.aliyuncs.com/apps/anthropic",defaultProfileName:"qwen",badge:"Alibaba",defaultModel:"qwen3-coder-plus",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Alibaba Cloud Model Studio",category:"alternative"}];function _o(a){return Uo.filter(s=>s.category===a)}const aj=Nb({name:ll().min(1,"Name is required").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Must start with letter, only letters/numbers/.-_"),baseUrl:ll().url("Invalid URL format"),apiKey:ll().min(1,"API key is required"),model:ll().optional(),opusModel:ll().optional(),sonnetModel:ll().optional(),haikuModel:ll().optional()}),lj=["/chat/completions","/v1/messages","/messages","/completions"];function tE({open:a,onOpenChange:s,onSuccess:r,initialMode:u="openrouter"}){const d=tj(),[m,h]=v.useState("basic"),[p,y]=v.useState(null),[S,M]=v.useState(!1),[x,b]=v.useState("openrouter"),[_,A]=v.useState(""),{models:R}=$N(),{register:B,handleSubmit:w,formState:{errors:Y},control:q,reset:Q,setValue:k}=jb({resolver:ej(aj),defaultValues:{name:"",baseUrl:"",apiKey:"",model:"",opusModel:"",sonnetModel:"",haikuModel:""}}),j=Cb({control:q,name:"baseUrl"}),L=v.useMemo(()=>!x||x==="custom"?null:Uo.find($=>$.id===x),[x]),J=v.useMemo(()=>_.trim()?[...LN(R,_)].sort((T,Z)=>(Z.created??0)-(T.created??0)).slice(0,20):XN(R,2),[R,_]);v.useEffect(()=>{if(a)if(Q(),h("basic"),y(null),M(!1),A(""),u==="normal")b("custom"),setTimeout(()=>{k("name",""),k("baseUrl","")},0);else{b("openrouter");const $=Uo.find(T=>T.id==="openrouter");$&&setTimeout(()=>{k("name",$.defaultProfileName),k("baseUrl",$.baseUrl)},0)}},[a,Q,k,u]);const ee=$=>{b($);const T=Uo.find(Z=>Z.id===$);T?(k("name",T.defaultProfileName),k("baseUrl",T.baseUrl),T.defaultModel&&(k("model",T.defaultModel),k("opusModel",T.defaultModel),k("sonnetModel",T.defaultModel),k("haikuModel",T.defaultModel))):(k("name",""),k("baseUrl",""),k("model",""))},de=$=>{k("model",$.id),k("opusModel",$.id),k("sonnetModel",$.id),k("haikuModel",$.id),A($.name),Ne.success(`Applied "${$.name}" to all model tiers`,{duration:2e3})};v.useEffect(()=>{if(j&&x==="custom"){const T=j.toLowerCase();for(const Z of lj)if(T.endsWith(Z)){const ae=j.replace(new RegExp(Z+"$","i"),"");y(`URL ends with "${Z}" - Claude appends this automatically. You likely want: ${ae}`);return}}y(null)},[j,x]);const ve=async $=>{const T={...$};try{await d.mutateAsync(T),Ne.success(`Profile "${T.name}" created`),r(T.name),s(!1)}catch(Z){Ne.error(Z.message||"Failed to create profile")}},oe=!!Y.name||!!Y.baseUrl||!!Y.apiKey,Ye=!!Y.model||!!Y.opusModel||!!Y.sonnetModel||!!Y.haikuModel,Se=x==="openrouter";return o.jsx(Lc,{open:a,onOpenChange:s,children:o.jsxs(Yc,{className:"sm:max-w-[700px] p-0 gap-0 overflow-hidden max-h-[90vh]",children:[o.jsxs(Gc,{className:"p-6 pb-4 border-b",children:[o.jsxs(Kc,{className:"flex items-center gap-2",children:[o.jsx(Ih,{className:"w-5 h-5 text-primary"}),"Create API Profile"]}),o.jsx(Qc,{children:"Choose a provider or configure a custom API endpoint."})]}),o.jsxs("form",{onSubmit:w(ve),className:"flex flex-col overflow-hidden",children:[o.jsxs("div",{className:"px-6 py-3 border-b bg-muted/30 space-y-2",children:[o.jsxs("div",{children:[o.jsx(Dn,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Provider"}),o.jsxs("div",{className:"flex gap-2",children:[_o("recommended").map($=>o.jsx(Tp,{preset:$,isSelected:x===$.id,onClick:()=>ee($.id)},$.id)),o.jsxs("button",{type:"button",onClick:()=>ee("custom"),className:V("flex items-center gap-2 px-4 py-2 rounded-md border-2 transition-all text-sm font-medium",x==="custom"||_o("alternative").some($=>$.id===x)?"border-primary bg-primary/10 text-primary dark:bg-primary/20":"border-dashed border-muted-foreground/40 hover:border-primary/50 hover:bg-muted/50 text-muted-foreground hover:text-foreground"),children:[o.jsx(Hc,{className:"w-4 h-4"}),o.jsx("span",{children:"Custom"})]})]})]}),(x==="custom"||_o("alternative").some($=>$.id===x))&&o.jsxs("div",{className:"pt-3 mt-2 border-t border-dashed border-muted-foreground/30",children:[o.jsx(Dn,{className:"text-xs font-medium text-foreground/70 mb-2 block",children:"Quick Templates"}),o.jsx("div",{className:"flex gap-2 flex-wrap",children:_o("alternative").map($=>o.jsx(Tp,{preset:$,isSelected:x===$.id,onClick:()=>ee($.id)},$.id))})]})]}),o.jsxs(Gg,{value:m,onValueChange:h,className:"flex flex-col flex-1 overflow-hidden",children:[o.jsx("div",{className:"px-6 pt-4",children:o.jsxs(Fc,{className:"grid w-full grid-cols-2",children:[o.jsxs(il,{value:"basic",className:"relative",children:["Basic Information",oe&&o.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]}),o.jsxs(il,{value:"models",className:"relative",children:["Model Configuration",Ye&&o.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]})]})}),o.jsxs(dl,{className:"flex-1",children:[o.jsxs(Dc,{value:"basic",className:"p-6 space-y-4 mt-0",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"name",children:["Profile Name ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ra,{id:"name",...B("name"),placeholder:"my-api",className:"font-mono"}),Y.name?o.jsx("p",{className:"text-xs text-destructive",children:Y.name.message}):o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in CLI:"," ",o.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:'ccs my-api "prompt"'})]})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"baseUrl",children:["API Base URL ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ra,{id:"baseUrl",...B("baseUrl"),placeholder:"https://api.example.com/v1"}),Y.baseUrl?o.jsx("p",{className:"text-xs text-destructive",children:Y.baseUrl.message}):p?o.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-600 bg-yellow-50 dark:bg-yellow-900/20 p-2 rounded",children:[o.jsx(ul,{className:"w-4 h-4 shrink-0 mt-0.5"}),o.jsx("span",{children:p})]}):L?o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Pre-filled from ",L.name,". You can customize if needed."]}):o.jsx("p",{className:"text-xs text-muted-foreground",children:"The endpoint that accepts OpenAI-compatible and Anthropic requests"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"apiKey",children:["API Key ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsxs("div",{className:"relative",children:[o.jsx(Ra,{id:"apiKey",type:S?"text":"password",...B("apiKey"),placeholder:L?.apiKeyPlaceholder??"sk-...",className:"pr-10"}),o.jsx(St,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-9 w-9 text-muted-foreground hover:text-foreground",onClick:()=>M(!S),tabIndex:-1,children:S?o.jsx(Qo,{className:"h-4 w-4"}):o.jsx(Vo,{className:"h-4 w-4"})})]}),Y.apiKey?o.jsx("p",{className:"text-xs text-destructive",children:Y.apiKey.message}):L?.apiKeyHint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:L.apiKeyHint})]})]}),o.jsxs(Dc,{value:"models",className:"p-6 mt-0 space-y-4",children:[o.jsxs("div",{className:"flex items-start gap-3 p-3 bg-blue-50 dark:bg-blue-950/20 text-blue-800 dark:text-blue-300 rounded-md text-sm border border-blue-100 dark:border-blue-900/30",children:[o.jsx(Wo,{className:"w-5 h-5 shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium mb-1",children:"Model Mapping"}),o.jsx("p",{className:"text-xs opacity-90",children:"Map Claude Code tiers (Opus/Sonnet/Haiku) to models supported by your provider."})]})]}),Se&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Dn,{children:"Search Models"}),o.jsx(Ra,{value:_,onChange:$=>A($.target.value),placeholder:"Type to search (e.g., opus, sonnet, gpt-4o)...",onKeyDown:$=>{$.key==="Enter"&&J.length>0&&($.preventDefault(),de(J[0]))}}),o.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:J.length===0?o.jsx("p",{className:"text-sm text-muted-foreground p-3 text-center",children:_?`No models found for "${_}"`:"Loading models..."}):o.jsxs("div",{className:"p-1",children:[!_&&o.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground",children:[o.jsx(hb,{className:"w-3 h-3 text-accent"}),o.jsx("span",{children:"Newest Models"})]}),J.map($=>o.jsx(sj,{model:$,onClick:()=>de($),showAge:!_},$.id))]})})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"model",children:["Default Model",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"ANTHROPIC_MODEL"})]}),o.jsx(Ra,{id:"model",...B("model"),placeholder:L?.defaultModel??"claude-sonnet-4",className:"font-mono text-sm"})]}),o.jsxs("div",{className:"grid gap-3 pt-2 border-t",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"sonnetModel",className:"text-sm",children:["Sonnet Mapping",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_SONNET"})]}),o.jsx(Ra,{id:"sonnetModel",...B("sonnetModel"),placeholder:"e.g. gpt-4o, claude-sonnet-4",className:"font-mono text-sm h-9"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"opusModel",className:"text-sm",children:["Opus Mapping",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_OPUS"})]}),o.jsx(Ra,{id:"opusModel",...B("opusModel"),placeholder:"e.g. o1, claude-opus-4.5",className:"font-mono text-sm h-9"})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs(Dn,{htmlFor:"haikuModel",className:"text-sm",children:["Haiku Mapping",o.jsx(Ha,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_HAIKU"})]}),o.jsx(Ra,{id:"haikuModel",...B("haikuModel"),placeholder:"e.g. gpt-4o-mini, claude-3.5-haiku",className:"font-mono text-sm h-9"})]})]})]})]})]}),o.jsxs(US,{className:"p-6 pt-4 border-t bg-muted/10",children:[o.jsx(St,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),o.jsx(St,{type:"submit",disabled:d.isPending,className:V(d.isPending&&"opacity-80"),children:d.isPending?o.jsxs(o.Fragment,{children:[o.jsx(as,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ih,{className:"w-4 h-4 mr-2"}),"Create Profile"]})})]})]})]})]})})}function Tp({preset:a,isSelected:s,onClick:r}){return o.jsxs("button",{type:"button",onClick:r,className:V("flex items-center gap-2 px-3 py-2 rounded-md border transition-all text-sm",s?a.featured?"border-accent bg-accent/10 dark:bg-accent/20 font-medium":"border-primary bg-primary/10 dark:bg-primary/20 font-medium":"border-muted-foreground/20 hover:border-muted-foreground/40 hover:bg-muted/50"),children:[a.icon?o.jsx("img",{src:a.icon,alt:"",className:"w-4 h-4"}):o.jsx("div",{className:"w-4 h-4 rounded-full bg-muted-foreground/20 flex items-center justify-center text-[9px] font-bold text-foreground/70",children:a.name.charAt(0)}),o.jsx("span",{className:"font-medium",children:a.name}),a.badge&&o.jsx(Ha,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-0.5 bg-muted-foreground/10 text-muted-foreground",children:a.badge})]})}function sj({model:a,onClick:s,showAge:r}){return o.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:[o.jsx("span",{className:"flex-1 truncate",children:a.name}),o.jsxs("span",{className:"text-muted-foreground group-hover:text-accent-foreground/80 ml-2 flex items-center gap-2 text-xs",children:[r&&a.created&&o.jsx(Ha,{variant:"outline",className:"text-[10px] text-accent group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30",children:ZN(a.created)}),a.isFree?o.jsx(Ha,{variant:"secondary",className:"text-xs group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground",children:"Free"}):o.jsx("span",{children:BN(a.pricing)}),o.jsx("span",{children:QN(a.context_length)})]})]})}const nE=Jx,aE=Fx,lE=$x,ij=v.forwardRef(({className:a,children:s,...r},u)=>o.jsxs(Jp,{ref:u,className:V("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...r,children:[s,o.jsx(Qx,{asChild:!0,children:o.jsx(Jo,{className:"h-4 w-4 opacity-50"})})]}));ij.displayName=Jp.displayName;const Zg=v.forwardRef(({className:a,...s},r)=>o.jsx($p,{ref:r,className:V("flex cursor-default items-center justify-center py-1",a),...s,children:o.jsx(Bc,{className:"h-4 w-4"})}));Zg.displayName=$p.displayName;const Wg=v.forwardRef(({className:a,...s},r)=>o.jsx(Fp,{ref:r,className:V("flex cursor-default items-center justify-center py-1",a),...s,children:o.jsx(Jo,{className:"h-4 w-4"})}));Wg.displayName=Fp.displayName;const oj=v.forwardRef(({className:a,children:s,position:r="popper",...u},d)=>o.jsx(Vx,{children:o.jsxs(Ip,{ref:d,className:V("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:r,...u,children:[o.jsx(Zg,{}),o.jsx(Xx,{className:V("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),o.jsx(Wg,{})]})}));oj.displayName=Ip.displayName;const rj=v.forwardRef(({className:a,...s},r)=>o.jsx(Pp,{ref:r,className:V("px-2 py-1.5 text-sm font-semibold",a),...s}));rj.displayName=Pp.displayName;const uj=v.forwardRef(({className:a,children:s,...r},u)=>o.jsxs(eg,{ref:u,className:V("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...r,children:[o.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(Zx,{children:o.jsx(ns,{className:"h-4 w-4"})})}),o.jsx(Wx,{children:s})]}));uj.displayName=eg.displayName;const cj=v.forwardRef(({className:a,...s},r)=>o.jsx(tg,{ref:r,className:V("-mx-1 my-1 h-px bg-muted",a),...s}));cj.displayName=tg.displayName;const dj=v.lazy(()=>At(()=>Promise.resolve().then(()=>$g),void 0).then(a=>({default:a.CodeEditor})));function sE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:r,onRawJsonChange:u,profileEnv:d,missingRequiredFields:m=[]}){const h=m.length>0;return o.jsx(v.Suspense,{fallback:o.jsxs("div",{className:"flex items-center justify-center h-full",children:[o.jsx(as,{className:"w-6 h-6 animate-spin text-muted-foreground"}),o.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:o.jsxs("div",{className:"h-full flex flex-col",children:[!s&&r!==null&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[o.jsx(di,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&o.jsxs("div",{className:"mb-2 px-3 py-2 bg-warning/10 text-warning-foreground text-sm rounded-md flex items-start gap-2 mx-6 mt-4 shrink-0 border border-warning/20",children:[o.jsx(ul,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",o.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Apply a preset from Model Config tab or add these fields manually. Without them, Claude Code will fail with 404 errors."})]})]}),o.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:o.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:o.jsx(dj,{value:a,onChange:u,language:"json",minHeight:"100%"})})}),o.jsx("div",{className:"mx-6 mb-4",children:o.jsx("div",{className:"border rounded-md overflow-hidden",children:o.jsx(Xg,{profileEnv:d})})})]})})}const fj=v.forwardRef(({className:a,value:s=0,max:r=100,indicatorClassName:u,...d},m)=>{const h=Math.min(Math.max(s/r*100,0),100);return o.jsx("div",{ref:m,role:"progressbar","aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":s,className:V("relative h-2 w-full overflow-hidden rounded-full bg-secondary",a),...d,children:o.jsx("div",{className:V("h-full transition-all",u||"bg-primary"),style:{width:`${h}%`}})})});fj.displayName="Progress";var Lt={},zp;function mj(){if(zp)return Lt;zp=1;var a=Lt&&Lt.__assign||function(){return a=Object.assign||function(k){for(var j,L=1,J=arguments.length;L<J;L++){j=arguments[L];for(var ee in j)Object.prototype.hasOwnProperty.call(j,ee)&&(k[ee]=j[ee])}return k},a.apply(this,arguments)},s=Lt&&Lt.__createBinding||(Object.create?(function(k,j,L,J){J===void 0&&(J=L);var ee=Object.getOwnPropertyDescriptor(j,L);(!ee||("get"in ee?!j.__esModule:ee.writable||ee.configurable))&&(ee={enumerable:!0,get:function(){return j[L]}}),Object.defineProperty(k,J,ee)}):(function(k,j,L,J){J===void 0&&(J=L),k[J]=j[L]})),r=Lt&&Lt.__setModuleDefault||(Object.create?(function(k,j){Object.defineProperty(k,"default",{enumerable:!0,value:j})}):function(k,j){k.default=j}),u=Lt&&Lt.__importStar||function(k){if(k&&k.__esModule)return k;var j={};if(k!=null)for(var L in k)L!=="default"&&Object.prototype.hasOwnProperty.call(k,L)&&s(j,k,L);return r(j,k),j},d=Lt&&Lt.__rest||function(k,j){var L={};for(var J in k)Object.prototype.hasOwnProperty.call(k,J)&&j.indexOf(J)<0&&(L[J]=k[J]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ee=0,J=Object.getOwnPropertySymbols(k);ee<J.length;ee++)j.indexOf(J[ee])<0&&Object.prototype.propertyIsEnumerable.call(k,J[ee])&&(L[J[ee]]=k[J[ee]]);return L};Object.defineProperty(Lt,"__esModule",{value:!0});var m=u(ag()),h=89,p=90,y=77,S=57,M=219,x=222,b=192,_=100,A=3e3,R=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),B=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),w="npm__react-simple-code-editor__textarea",Y=`
15
15
  /**
16
16
  * Reset the text fill color so that placeholder is visible
17
17
  */
@@ -44,4 +44,4 @@ Error generating stack: `+l.message+`
44
44
  `).map(function(rs,us){return us>=Tt&&us<=Ln?ie+rs:rs}).join(`
45
45
  `),selectionStart:pe&&/\S/.test(pe)?Te+ie.length:Te,selectionEnd:tt+ie.length*(Ln-Tt+1)})}else{var xt=Te+ie.length;Mn({value:fe.substring(0,Te)+ie+fe.substring(tt),selectionStart:xt,selectionEnd:xt})}else if(W.key==="Backspace"){var Zt=Te!==tt,yn=fe.substring(0,Te);if(yn.endsWith(ie)&&!Zt){W.preventDefault();var xt=Te-ie.length;Mn({value:fe.substring(0,Te-ie.length)+fe.substring(tt),selectionStart:xt,selectionEnd:xt})}}else if(W.key==="Enter"){if(Te===tt){var is=Xt(fe,Te).pop(),La=is?.match(/^\s+/);if(La?.[0]){W.preventDefault();var os=`
46
46
  `+La[0],xt=Te+os.length;Mn({value:fe.substring(0,Te)+os+fe.substring(tt),selectionStart:xt,selectionEnd:xt})}}}else if(W.keyCode===S||W.keyCode===M||W.keyCode===x||W.keyCode===b){var sn=void 0;W.keyCode===S&&W.shiftKey?sn=["(",")"]:W.keyCode===M?W.shiftKey?sn=["{","}"]:sn=["[","]"]:W.keyCode===x?W.shiftKey?sn=['"','"']:sn=["'","'"]:W.keyCode===b&&!W.shiftKey&&(sn=["`","`"]),Te!==tt&&sn&&(W.preventDefault(),Mn({value:fe.substring(0,Te)+sn[0]+fe.substring(Te,tt)+sn[1]+fe.substring(tt),selectionStart:Te,selectionEnd:tt+2}))}else(B?W.metaKey&&W.keyCode===p:W.ctrlKey&&W.keyCode===p)&&!W.shiftKey&&!W.altKey?(W.preventDefault(),fl()):(B?W.metaKey&&W.keyCode===p&&W.shiftKey:R?W.ctrlKey&&W.keyCode===h:W.ctrlKey&&W.keyCode===p&&W.shiftKey)&&!W.altKey?(W.preventDefault(),ls()):W.keyCode===y&&W.ctrlKey&&(!B||W.shiftKey)&&(W.preventDefault(),ca(function(Yn){return!Yn}))}},qn=function(W){var Me=W.currentTarget,fe=Me.value,Te=Me.selectionStart,tt=Me.selectionEnd;Hn({value:fe,selectionStart:Te,selectionEnd:tt},!0),F(fe)};return m.useEffect(function(){qa()},[qa]),m.useImperativeHandle(L,function(){return{get session(){return{history:je.current}},set session(W){je.current=W.history}}},[]),m.createElement("div",a({},Un,{style:a(a({},Q.container),pt)}),m.createElement("pre",a({className:ge,"aria-hidden":"true",style:a(a(a({},Q.editor),Q.highlight),Bn)},typeof ot=="string"?{dangerouslySetInnerHTML:{__html:ot+"<br />"}}:{children:ot})),m.createElement("textarea",{ref:function(W){return Qt.current=W},style:a(a(a({},Q.editor),Q.textarea),Bn),className:w+(et?" ".concat(et):""),id:Dt,value:Kt,onChange:qn,onKeyDown:ss,onClick:xe,onKeyUp:X,onFocus:Ae,onBlur:ye,disabled:ee,form:de,maxLength:T,minLength:Z,name:ae,placeholder:ne,readOnly:De,required:Ge,autoFocus:J,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),m.createElement("style",{dangerouslySetInnerHTML:{__html:Y}}))}),Q={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 Lt.default=q,Lt}var hj=mj();const pj=ov(hj),gj=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function yj(a){return gj.some(s=>s.test(a))}function xj(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 Jg({value:a,onChange:s,language:r="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=yg(),[p,y]=v.useState(!1),[S,M]=v.useState(!0),x=v.useMemo(()=>r==="json"?xj(a):{valid:!0},[a,r]),b=v.useCallback(_=>o.jsx(Eb,{theme:h?ap.nightOwl:ap.github,code:_,language:r,children:({tokens:A,getLineProps:R,getTokenProps:B})=>{let w=!1;return o.jsx(o.Fragment,{children:A.map((Y,q)=>o.jsx("div",{...R({line:Y}),className:V(x.line===q+1&&"bg-destructive/20"),children:Y.map((Q,k)=>{let j=!1;if(Q.types.includes("property")){const J=Q.content.replace(/['"]/g,"");yj(J)?w=!0:w=!1}else(Q.types.includes("string")||Q.types.includes("number")||Q.types.includes("boolean"))&&w?(j=!0,w=!1):Q.types.includes("punctuation")&&Q.content!==":"&&Q.content!=="["&&Q.content!=="{"&&(w=!1);const L=B({token:Q});return j&&S&&(L.className=V(L.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),o.jsx("span",{...L},k)})},q))})}}),[h,r,x.line,S]);return o.jsxs("div",{className:V("flex flex-col",d),children:[o.jsxs("div",{className:V("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",!x.valid&&"border-destructive"),style:{minHeight:m},children:[o.jsx(pj,{value:a,onValueChange:u?()=>{}:s,highlight:b,padding:12,disabled:u,onFocus:()=>y(!0),onBlur:()=>y(!1),textareaClassName:V("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"),o.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:o.jsx(St,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>M(!S),title:S?"Reveal sensitive values":"Mask sensitive values",children:S?o.jsx(Vo,{className:"h-3 w-3"}):o.jsx(Qo,{className:"h-3 w-3"})})})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[x.valid?o.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[o.jsx(Xo,{className:"w-3 h-3 text-green-500"}),"Valid ",r.toUpperCase()]}):o.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[o.jsx(pb,{className:"w-3 h-3"}),x.error,x.line&&` (line ${x.line})`]}),u&&o.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const $g=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:Jg},Symbol.toStringTag,{value:"Module"})),vj={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 bj(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 Fg=v.createContext(null);function Sj({children:a}){const[s,r]=v.useReducer(bj,vj);return o.jsx(Fg.Provider,{value:{state:s,dispatch:r},children:a})}function Ig(){const a=v.useContext(Fg);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function Nj(){const{dispatch:a}=Ig(),s=v.useCallback(j=>a({type:"SET_WEBSEARCH_CONFIG",payload:j}),[a]),r=v.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS",payload:j}),[a]),u=v.useCallback(j=>a({type:"SET_WEBSEARCH_LOADING",payload:j}),[a]),d=v.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:j}),[a]),m=v.useCallback(j=>a({type:"SET_WEBSEARCH_SAVING",payload:j}),[a]),h=v.useCallback(j=>a({type:"SET_WEBSEARCH_ERROR",payload:j}),[a]),p=v.useCallback(j=>a({type:"SET_WEBSEARCH_SUCCESS",payload:j}),[a]),y=v.useCallback(j=>a({type:"SET_GLOBALENV_CONFIG",payload:j}),[a]),S=v.useCallback(j=>a({type:"SET_GLOBALENV_LOADING",payload:j}),[a]),M=v.useCallback(j=>a({type:"SET_GLOBALENV_SAVING",payload:j}),[a]),x=v.useCallback(j=>a({type:"SET_GLOBALENV_ERROR",payload:j}),[a]),b=v.useCallback(j=>a({type:"SET_GLOBALENV_SUCCESS",payload:j}),[a]),_=v.useCallback(j=>a({type:"SET_PROXY_CONFIG",payload:j}),[a]),A=v.useCallback(j=>a({type:"SET_PROXY_LOADING",payload:j}),[a]),R=v.useCallback(j=>a({type:"SET_PROXY_SAVING",payload:j}),[a]),B=v.useCallback(j=>a({type:"SET_PROXY_ERROR",payload:j}),[a]),w=v.useCallback(j=>a({type:"SET_PROXY_SUCCESS",payload:j}),[a]),Y=v.useCallback(j=>a({type:"SET_PROXY_TEST_RESULT",payload:j}),[a]),q=v.useCallback(j=>a({type:"SET_PROXY_TESTING",payload:j}),[a]),Q=v.useCallback(j=>a({type:"SET_RAW_CONFIG",payload:j}),[a]),k=v.useCallback(j=>a({type:"SET_RAW_CONFIG_LOADING",payload:j}),[a]);return v.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:r,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:y,setGlobalEnvLoading:S,setGlobalEnvSaving:M,setGlobalEnvError:x,setGlobalEnvSuccess:b,setProxyConfig:_,setProxyLoading:A,setProxySaving:R,setProxyError:B,setProxySuccess:w,setProxyTestResult:Y,setProxyTesting:q,setRawConfig:Q,setRawConfigLoading:k}),[s,r,u,d,m,h,p,y,S,M,x,b,_,A,R,B,w,Y,q,Q,k])}function jj(){const[a,s]=rv(),r=a.get("tab"),u=r==="globalenv"?"globalenv":r==="proxy"?"proxy":r==="auth"?"auth":"websearch",d=v.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function Cj(){const{state:a}=Ig(),s=Nj(),[r,u]=v.useState(!1),d=v.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=v.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:r,fetchRawConfig:d,copyToClipboard:m}}function Ej({activeTab:a,onTabChange:s}){return o.jsx(Gg,{value:a,onValueChange:r=>s(r),children:o.jsxs(Fc,{className:"w-full",children:[o.jsxs(il,{value:"websearch",className:"flex-1 gap-2",children:[o.jsx(gb,{className:"w-4 h-4"}),"WebSearch"]}),o.jsxs(il,{value:"globalenv",className:"flex-1 gap-2",children:[o.jsx(Hc,{className:"w-4 h-4"}),"Global Env"]}),o.jsxs(il,{value:"proxy",className:"flex-1 gap-2",children:[o.jsx(yb,{className:"w-4 h-4"}),"Proxy"]}),o.jsxs(il,{value:"auth",className:"flex-1 gap-2",children:[o.jsx(ug,{className:"w-4 h-4"}),"Auth"]})]})})}function wj(){return o.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[o.jsx(Le,{className:"h-4 w-2/3"}),o.jsx("div",{className:"p-4 rounded-lg border",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Le,{className:"h-5 w-32"}),o.jsx(Le,{className:"h-4 w-48"})]}),o.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),o.jsxs("div",{className:"space-y-3",children:[o.jsx(Le,{className:"h-5 w-24"}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Le,{className:"h-20 w-full rounded-lg"}),o.jsx(Le,{className:"h-20 w-full rounded-lg"}),o.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}const Mj=v.lazy(()=>At(()=>import("./index-Bb7TSGy0.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Tj=v.lazy(()=>At(()=>import("./globalenv-section-DTzNIABc.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),zj=v.lazy(()=>At(()=>import("./index-9Z6zaaYU.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),Oj=v.lazy(()=>At(()=>import("./auth-section-3uaw-usA.js"),__vite__mapDeps([12,1,2,4,5,6,7,8,9])));function Aj(){const{activeTab:a,setActiveTab:s}=jj(),{rawConfig:r,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=Cj();v.useEffect(()=>{m()},[m]);const p=y=>{v.startTransition(()=>{s(y)})};return o.jsx("div",{className:"h-[calc(100vh-100px)]",children:o.jsxs(Jc,{direction:"horizontal",className:"h-full",children:[o.jsx(ri,{defaultSize:40,minSize:30,maxSize:55,children:o.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[o.jsx("div",{className:"p-5 border-b bg-background",children:o.jsx(Ej,{activeTab:a,onTabChange:p})}),o.jsxs(v.Suspense,{fallback:o.jsx(wj,{}),children:[a==="websearch"&&o.jsx(Mj,{}),a==="globalenv"&&o.jsx(Tj,{}),a==="proxy"&&o.jsx(zj,{}),a==="auth"&&o.jsx(Oj,{})]})]})}),o.jsx($c,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:o.jsx(Zo,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),o.jsx(ri,{defaultSize:60,minSize:35,children:o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ph,{className:"w-5 h-5 text-primary"}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold",children:"config.yaml"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(St,{variant:"outline",size:"sm",onClick:h,disabled:!r,children:d?o.jsxs(o.Fragment,{children:[o.jsx(ns,{className:"w-4 h-4 mr-1"}),"Copied"]}):o.jsxs(o.Fragment,{children:[o.jsx(Bo,{className:"w-4 h-4 mr-1"}),"Copy"]})}),o.jsx(St,{variant:"outline",size:"sm",onClick:m,disabled:u,children:o.jsx(ep,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:u?o.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[o.jsx(ep,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):r?o.jsx(Jg,{value:r,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):o.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:o.jsxs("div",{className:"text-center",children:[o.jsx(Ph,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{children:"Config file not found"}),o.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})})}function Dj(){return o.jsx(Sj,{children:o.jsx(Aj,{})})}const _j=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:Dj},Symbol.toStringTag,{value:"Module"})),iE=Px,oE=tv,rE=ev,kj=v.forwardRef(({className:a,align:s="center",sideOffset:r=4,...u},d)=>o.jsx(Ix,{children:o.jsx(ng,{ref:d,align:s,sideOffset:r,className:V("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})}));kj.displayName=ng.displayName;function Rj(a,s,r="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:r}).format(s).split(/\s/g).slice(2).join(" ")}const Uj={},ii={};function ol(a,s){try{const u=(Uj[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in ii?ii[u]:Op(u,u.split(":"))}catch{if(a in ii)return ii[a];const r=a?.match(Bj);return r?Op(a,r.slice(1)):NaN}}const Bj=/([+-]\d\d):?(\d\d)?/;function Op(a,s){const r=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return ii[a]=r*60+u>0?r*60+u+d:r*60-u-d}class kn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(ol(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)),Pg(this),kc(this)):this.setTime(Date.now())}static tz(s,...r){return r.length?new kn(...r,s):new kn(Date.now(),s)}withTimeZone(s){return new kn(+this,s)}getTimezoneOffset(){const s=-ol(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),kc(this),+this}[Symbol.for("constructDateFrom")](s){return new kn(+new Date(s),this.timeZone)}}const Ap=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!Ap.test(a))return;const s=a.replace(Ap,"$1UTC");kn.prototype[s]&&(a.startsWith("get")?kn.prototype[a]=function(){return this.internal[s]()}:(kn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),Hj(this),+this},kn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),kc(this),+this}))});function kc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-ol(a.timeZone,a)*60))}function Hj(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()),Pg(a)}function Pg(a){const s=ol(a.timeZone,a),r=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 y=d-r;y&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+y);const S=new Date(+a);S.setUTCSeconds(0);const M=d>0?S.getSeconds():(S.getSeconds()-60)%60,x=Math.round(-(ol(a.timeZone,a)*60))%60;(x||M)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+x),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+x+M));const b=ol(a.timeZone,a),_=b>0?Math.floor(b):Math.ceil(b),R=-new Date(+a).getTimezoneOffset()-_,B=_!==r,w=R-y;if(B&&w){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+w);const Y=ol(a.timeZone,a),q=Y>0?Math.floor(Y):Math.ceil(Y),Q=_-q;Q&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+Q),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+Q))}}class oa extends kn{static tz(s,...r){return r.length?new oa(...r,s):new oa(Date.now(),s)}toISOString(){const[s,r,u]=this.tzComponents(),d=`${s}${r}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,r,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${r} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[r,u,d]=this.tzComponents();return`${s} GMT${r}${u}${d} (${Rj(this.timeZone,this)})`}toLocaleString(s,r){return Date.prototype.toLocaleString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleDateString(s,r){return Date.prototype.toLocaleDateString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleTimeString(s,r){return Date.prototype.toLocaleTimeString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),r=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[r,u,d]}withTimeZone(s){return new oa(+this,s)}[Symbol.for("constructDateFrom")](s){return new oa(+new Date(s),this.timeZone)}}const Dp=5,qj=4;function Lj(a,s){const r=s.startOfMonth(a),u=r.getDay()>0?r.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,Dp*7-1);return s.getMonth(a)===s.getMonth(m)?Dp:qj}function ey(a,s){const r=s.startOfMonth(a),u=r.getDay();return u===1?r:u===0?s.addDays(r,-6):s.addDays(r,-1*(u-1))}function Yj(a,s){const r=ey(a,s),u=Lj(a,s);return s.addDays(r,u*7-1)}const ty={...Ps,labels:{labelDayButton:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ni(h,p,{locale:Ps,...r});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,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,m)=>ni(d,m,{locale:Ps,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ni(h,p,{locale:Ps,...r});let m=d(a,"PPPP");return s?.today&&(m=`Today, ${m}`),m},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,m)=>ni(d,m,{locale:Ps,...s}),u(a,"cccc")}}};class an{constructor(s,r){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?oa.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 oa(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):gv(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):yv(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):xv(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):vv(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):bv(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):Sv(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Nv(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):jv(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):Yj(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Cv(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):Ev(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):wv(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Mv(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ni(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):Tv(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):zv(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Ov(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Av(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Dv(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):_v(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):kv(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Rv(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Uv(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Bv(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Hv(u),this.min=u=>this.overrides?.min?this.overrides.min(u):qv(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Lv(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):Yv(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):ey(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Gv(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Kv(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Qv(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):Vv(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):Xv(u),this.options={locale:ty,...s},this.overrides=r}getDigitMap(){const{numerals:s="latn"}=this.options,r=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=r.format(d);return u}replaceDigits(s){const r=this.getDigitMap();return s.replace(/\d/g,u=>r[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&an.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:r,timeZone:u,numerals:d}=this.options,m=r?.code;if(m&&an.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)}}an.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 Rn=new an;class ny{constructor(s,r,u=Rn){this.date=s,this.displayMonth=r,this.outside=!!(r&&!u.isSameMonth(s,r)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(r,"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 Gj{constructor(s,r){this.date=s,this.weeks=r}}class Kj{constructor(s,r){this.days=r,this.weekNumber=s}}function Qj(a){return P.createElement("button",{...a})}function Vj(a){return P.createElement("span",{...a})}function Xj(a){const{size:s=24,orientation:r="left",className:u}=a;return P.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},r==="up"&&P.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),r==="down"&&P.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),r==="left"&&P.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),r==="right"&&P.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Zj(a){const{day:s,modifiers:r,...u}=a;return P.createElement("td",{...u})}function Wj(a){const{day:s,modifiers:r,...u}=a,d=P.useRef(null);return P.useEffect(()=>{r.focused&&d.current?.focus()},[r.focused]),P.createElement("button",{ref:d,...u})}var re;(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"})(re||(re={}));var at;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(at||(at={}));var jn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(jn||(jn={}));var nn;(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"})(nn||(nn={}));function Jj(a){const{options:s,className:r,components:u,classNames:d,...m}=a,h=[d[re.Dropdown],r].join(" "),p=s?.find(({value:y})=>y===m.value);return P.createElement("span",{"data-disabled":m.disabled,className:d[re.DropdownRoot]},P.createElement(u.Select,{className:h,...m},s?.map(({value:y,label:S,disabled:M})=>P.createElement(u.Option,{key:y,value:y,disabled:M},S))),P.createElement("span",{className:d[re.CaptionLabel],"aria-hidden":!0},p?.label,P.createElement(u.Chevron,{orientation:"down",size:18,className:d[re.Chevron]})))}function $j(a){return P.createElement("div",{...a})}function Fj(a){return P.createElement("div",{...a})}function Ij(a){const{calendarMonth:s,displayIndex:r,...u}=a;return P.createElement("div",{...u},a.children)}function Pj(a){const{calendarMonth:s,displayIndex:r,...u}=a;return P.createElement("div",{...u})}function e2(a){return P.createElement("table",{...a})}function t2(a){return P.createElement("div",{...a})}const ay=v.createContext(void 0);function pi(){const a=v.useContext(ay);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function n2(a){const{components:s}=pi();return P.createElement(s.Dropdown,{...a})}function a2(a){const{onPreviousClick:s,onNextClick:r,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:y,labelNext:S}}=pi(),M=v.useCallback(b=>{d&&r?.(b)},[d,r]),x=v.useCallback(b=>{u&&s?.(b)},[u,s]);return P.createElement("nav",{...m},P.createElement(h.PreviousMonthButton,{type:"button",className:p[re.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":y(u),onClick:x},P.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[re.Chevron],orientation:"left"})),P.createElement(h.NextMonthButton,{type:"button",className:p[re.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":S(d),onClick:M},P.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[re.Chevron]})))}function l2(a){const{components:s}=pi();return P.createElement(s.Button,{...a})}function s2(a){return P.createElement("option",{...a})}function i2(a){const{components:s}=pi();return P.createElement(s.Button,{...a})}function o2(a){const{rootRef:s,...r}=a;return P.createElement("div",{...r,ref:s})}function r2(a){return P.createElement("select",{...a})}function u2(a){const{week:s,...r}=a;return P.createElement("tr",{...r})}function c2(a){return P.createElement("th",{...a})}function d2(a){return P.createElement("thead",{"aria-hidden":!0},P.createElement("tr",{...a}))}function f2(a){const{week:s,...r}=a;return P.createElement("th",{...r})}function m2(a){return P.createElement("th",{...a})}function h2(a){return P.createElement("tbody",{...a})}function p2(a){const{components:s}=pi();return P.createElement(s.Dropdown,{...a})}const g2=Object.freeze(Object.defineProperty({__proto__:null,Button:Qj,CaptionLabel:Vj,Chevron:Xj,Day:Zj,DayButton:Wj,Dropdown:Jj,DropdownNav:$j,Footer:Fj,Month:Ij,MonthCaption:Pj,MonthGrid:e2,Months:t2,MonthsDropdown:n2,Nav:a2,NextMonthButton:l2,Option:s2,PreviousMonthButton:i2,Root:o2,Select:r2,Week:u2,WeekNumber:f2,WeekNumberHeader:m2,Weekday:c2,Weekdays:d2,Weeks:h2,YearsDropdown:p2},Symbol.toStringTag,{value:"Module"}));function ra(a,s,r=!1,u=Rn){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)>=(r?1:0)&&h(m,s)>=(r?1:0)):!r&&m?p(m,s):!r&&d?p(d,s):!1}function Pc(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function ar(a){return!!(a&&typeof a=="object"&&"from"in a)}function ed(a){return!!(a&&typeof a=="object"&&"after"in a)}function td(a){return!!(a&&typeof a=="object"&&"before"in a)}function ly(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function sy(a,s){return Array.isArray(a)&&a.every(s.isDate)}function ua(a,s,r=Rn){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:m,isAfter:h}=r;return u.some(p=>{if(typeof p=="boolean")return p;if(r.isDate(p))return d(a,p);if(sy(p,r))return p.some(y=>d(a,y));if(ar(p))return ra(p,a,!1,r);if(ly(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(Pc(p)){const y=m(p.before,a),S=m(p.after,a),M=y>0,x=S<0;return h(p.before,p.after)?x&&M:M||x}return ed(p)?m(a,p.after)>0:td(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function y2(a,s,r,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:y,broadcastCalendar:S,today:M=d.today()}=s,{isSameDay:x,isSameMonth:b,startOfMonth:_,isBefore:A,endOfMonth:R,isAfter:B}=d,w=r&&_(r),Y=u&&R(u),q={[at.focused]:[],[at.outside]:[],[at.disabled]:[],[at.hidden]:[],[at.today]:[]},Q={};for(const k of a){const{date:j,displayMonth:L}=k,J=!!(L&&!b(j,L)),ee=!!(w&&A(j,w)),de=!!(Y&&B(j,Y)),ve=!!(m&&ua(j,m,d)),oe=!!(h&&ua(j,h,d))||ee||de||!S&&!y&&J||S&&y===!1&&J,Ye=x(j,M);J&&q.outside.push(k),ve&&q.disabled.push(k),oe&&q.hidden.push(k),Ye&&q.today.push(k),p&&Object.keys(p).forEach(Se=>{const $=p?.[Se];$&&ua(j,$,d)&&(Q[Se]?Q[Se].push(k):Q[Se]=[k])})}return k=>{const j={[at.focused]:!1,[at.disabled]:!1,[at.hidden]:!1,[at.outside]:!1,[at.today]:!1},L={};for(const J in q){const ee=q[J];j[J]=ee.some(de=>de===k)}for(const J in Q)L[J]=Q[J].some(ee=>ee===k);return{...j,...L}}}function x2(a,s,r={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[m])=>(r[m]?d.push(r[m]):s[at[m]]?d.push(s[at[m]]):s[jn[m]]&&d.push(s[jn[m]]),d),[s[re.Day]])}function v2(a){return{...g2,...a}}function b2(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(([r,u])=>{r.startsWith("data-")&&(s[r]=u)}),s}function S2(){const a={};for(const s in re)a[re[s]]=`rdp-${re[s]}`;for(const s in at)a[at[s]]=`rdp-${at[s]}`;for(const s in jn)a[jn[s]]=`rdp-${jn[s]}`;for(const s in nn)a[nn[s]]=`rdp-${nn[s]}`;return a}function iy(a,s,r){return(r??new an(s)).formatMonthYear(a)}const N2=iy;function j2(a,s,r){return(r??new an(s)).format(a,"d")}function C2(a,s=Rn){return s.format(a,"LLLL")}function E2(a,s,r){return(r??new an(s)).format(a,"cccccc")}function w2(a,s=Rn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function M2(){return""}function oy(a,s=Rn){return s.format(a,"yyyy")}const T2=oy,z2=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:iy,formatDay:j2,formatMonthCaption:N2,formatMonthDropdown:C2,formatWeekNumber:w2,formatWeekNumberHeader:M2,formatWeekdayName:E2,formatYearCaption:T2,formatYearDropdown:oy},Symbol.toStringTag,{value:"Module"}));function O2(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...z2,...a}}function nd(a,s,r,u){let d=(u??new an(r)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const A2=nd;function ad(a,s,r){return(r??new an(s)).formatMonthYear(a)}const D2=ad;function ry(a,s,r,u){let d=(u??new an(r)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function uy(a){return"Choose the Month"}function cy(){return""}const _2="Go to the Next Month";function dy(a,s){return _2}function fy(a){return"Go to the Previous Month"}function my(a,s,r){return(r??new an(s)).format(a,"cccc")}function hy(a,s){return`Week ${a}`}function py(a){return"Week Number"}function gy(a){return"Choose the Year"}const k2=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:D2,labelDay:A2,labelDayButton:nd,labelGrid:ad,labelGridcell:ry,labelMonthDropdown:uy,labelNav:cy,labelNext:dy,labelPrevious:fy,labelWeekNumber:hy,labelWeekNumberHeader:py,labelWeekday:my,labelYearDropdown:gy},Symbol.toStringTag,{value:"Module"})),Nn=(a,s,r)=>s||(r?typeof r=="function"?r:(...u)=>r:a);function R2(a,s){const r=s.locale?.labels??{};return{...k2,...a??{},labelDayButton:Nn(nd,a?.labelDayButton,r.labelDayButton),labelMonthDropdown:Nn(uy,a?.labelMonthDropdown,r.labelMonthDropdown),labelNext:Nn(dy,a?.labelNext,r.labelNext),labelPrevious:Nn(fy,a?.labelPrevious,r.labelPrevious),labelWeekNumber:Nn(hy,a?.labelWeekNumber,r.labelWeekNumber),labelYearDropdown:Nn(gy,a?.labelYearDropdown,r.labelYearDropdown),labelGrid:Nn(ad,a?.labelGrid,r.labelGrid),labelGridcell:Nn(ry,a?.labelGridcell,r.labelGridcell),labelNav:Nn(cy,a?.labelNav,r.labelNav),labelWeekNumberHeader:Nn(py,a?.labelWeekNumberHeader,r.labelWeekNumberHeader),labelWeekday:Nn(my,a?.labelWeekday,r.labelWeekday)}}function U2(a,s,r,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:y,getMonth:S}=d;return y({start:h(a),end:p(a)}).map(b=>{const _=u.formatMonthDropdown(b,d),A=S(b),R=s&&b<m(s)||r&&b>m(r)||!1;return{value:A,label:_,disabled:R}})}function B2(a,s={},r={}){let u={...s?.[re.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...r?.[d]}}),u}function H2(a,s,r,u){const d=u??a.today(),m=r?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),h=[];for(let p=0;p<7;p++){const y=a.addDays(m,p);h.push(y)}return h}function q2(a,s,r,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:y}=u,S=m(a),M=h(s),x=p({start:S,end:M});return d&&x.reverse(),x.map(b=>{const _=r.formatYearDropdown(b,u);return{value:y(b),label:_,disabled:!1}})}const gi=a=>a instanceof HTMLElement?a:null,Cc=a=>[...a.querySelectorAll("[data-animated-month]")??[]],L2=a=>gi(a.querySelector("[data-animated-month]")),Ec=a=>gi(a.querySelector("[data-animated-caption]")),wc=a=>gi(a.querySelector("[data-animated-weeks]")),Y2=a=>gi(a.querySelector("[data-animated-nav]")),G2=a=>gi(a.querySelector("[data-animated-weekdays]"));function K2(a,s,{classNames:r,months:u,focused:d,dateLib:m}){const h=v.useRef(null),p=v.useRef(u),y=v.useRef(!1);v.useLayoutEffect(()=>{const S=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||S.length===0||u.length!==S.length)return;const M=m.isSameMonth(u[0].date,S[0].date),x=m.isAfter(u[0].date,S[0].date),b=x?r[nn.caption_after_enter]:r[nn.caption_before_enter],_=x?r[nn.weeks_after_enter]:r[nn.weeks_before_enter],A=h.current,R=a.current.cloneNode(!0);if(R instanceof HTMLElement?(Cc(R).forEach(q=>{if(!(q instanceof HTMLElement))return;const Q=L2(q);Q&&q.contains(Q)&&q.removeChild(Q);const k=Ec(q);k&&k.classList.remove(b);const j=wc(q);j&&j.classList.remove(_)}),h.current=R):h.current=null,y.current||M||d)return;const B=A instanceof HTMLElement?Cc(A):[],w=Cc(a.current);if(w?.every(Y=>Y instanceof HTMLElement)&&B&&B.every(Y=>Y instanceof HTMLElement)){y.current=!0,a.current.style.isolation="isolate";const Y=Y2(a.current);Y&&(Y.style.zIndex="1"),w.forEach((q,Q)=>{const k=B[Q];if(!k)return;q.style.position="relative",q.style.overflow="hidden";const j=Ec(q);j&&j.classList.add(b);const L=wc(q);L&&L.classList.add(_);const J=()=>{y.current=!1,a.current&&(a.current.style.isolation=""),Y&&(Y.style.zIndex=""),j&&j.classList.remove(b),L&&L.classList.remove(_),q.style.position="",q.style.overflow="",q.contains(k)&&q.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const ee=G2(k);ee&&(ee.style.opacity="0");const de=Ec(k);de&&(de.classList.add(x?r[nn.caption_before_exit]:r[nn.caption_after_exit]),de.addEventListener("animationend",J));const ve=wc(k);ve&&ve.classList.add(x?r[nn.weeks_before_exit]:r[nn.weeks_after_exit]),q.insertBefore(k,q.firstChild)})}})}function Q2(a,s,r,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:y}=r??{},{addDays:S,differenceInCalendarDays:M,differenceInCalendarMonths:x,endOfBroadcastWeek:b,endOfISOWeek:_,endOfMonth:A,endOfWeek:R,isAfter:B,startOfBroadcastWeek:w,startOfISOWeek:Y,startOfWeek:q}=u,Q=y?w(d,u):h?Y(d):q(d),k=y?b(m):h?_(A(m)):R(A(m)),j=s&&(y?b(s):h?_(s):R(s)),L=j&&B(k,j)?j:k,J=M(L,Q),ee=x(m,d)+1,de=[];for(let Ye=0;Ye<=J;Ye++){const Se=S(Q,Ye);de.push(Se)}const oe=(y?35:42)*ee;if(p&&de.length<oe){const Ye=oe-de.length;for(let Se=0;Se<Ye;Se++){const $=S(de[de.length-1],1);de.push($)}}return de}function V2(a){const s=[];return a.reduce((r,u)=>{const d=u.weeks.reduce((m,h)=>m.concat(h.days.slice()),s.slice());return r.concat(d.slice())},s.slice())}function X2(a,s,r,u){const{numberOfMonths:d=1}=r,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 _p(a,s,r,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let y=d||m||h;const{differenceInCalendarMonths:S,addMonths:M,startOfMonth:x}=u;if(r&&S(r,y)<p-1){const b=-1*(p-1);y=M(r,b)}return s&&S(y,s)<0&&(y=s),x(y)}function Z2(a,s,r,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:y,getISOWeek:S,getWeek:M,startOfBroadcastWeek:x,startOfISOWeek:b,startOfWeek:_}=u,A=a.reduce((R,B)=>{const w=r.broadcastCalendar?x(B,u):r.ISOWeek?b(B):_(B),Y=r.broadcastCalendar?m(B):r.ISOWeek?h(p(B)):y(p(B)),q=s.filter(L=>L>=w&&L<=Y),Q=r.broadcastCalendar?35:42;if(r.fixedWeeks&&q.length<Q){const L=s.filter(J=>{const ee=Q-q.length;return J>Y&&J<=d(Y,ee)});q.push(...L)}const k=q.reduce((L,J)=>{const ee=r.ISOWeek?S(J):M(J),de=L.find(oe=>oe.weekNumber===ee),ve=new ny(J,B,u);return de?de.days.push(ve):L.push(new Kj(ee,[ve])),L},[]),j=new Gj(B,k);return R.push(j),R},[]);return r.reverseMonths?A.reverse():A}function W2(a,s){let{startMonth:r,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:y,endOfYear:S,newDate:M,today:x}=s,{fromYear:b,toYear:_,fromMonth:A,toMonth:R}=a;!r&&A&&(r=A),!r&&b&&(r=s.newDate(b,0,1)),!u&&R&&(u=R),!u&&_&&(u=M(_,11,31));const B=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return r?r=h(r):b?r=M(b,0,1):!r&&B&&(r=d(y(a.today??x(),-100))),u?u=p(u):_?u=M(_,11,31):!u&&B&&(u=S(a.today??x())),[r&&m(r),u&&m(u)]}function J2(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=r,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:y}=u,S=d?m:1,M=h(a);if(!s)return p(M,S);if(!(y(s,a)<m))return p(M,S)}function $2(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=r,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:y}=u,S=d?m??1:1,M=h(a);if(!s)return p(M,-S);if(!(y(M,s)<=0))return p(M,-S)}function F2(a){const s=[];return a.reduce((r,u)=>r.concat(u.weeks.slice()),s.slice())}function lr(a,s){const[r,u]=v.useState(a);return[s===void 0?r:s,u]}function I2(a,s){const[r,u]=W2(a,s),{startOfMonth:d,endOfMonth:m}=s,h=_p(a,r,u,s),[p,y]=lr(h,a.month?h:void 0);v.useEffect(()=>{const Q=_p(a,r,u,s);y(Q)},[a.timeZone]);const{months:S,weeks:M,days:x,previousMonth:b,nextMonth:_}=v.useMemo(()=>{const Q=X2(p,u,{numberOfMonths:a.numberOfMonths},s),k=Q2(Q,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),j=Z2(Q,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),L=F2(j),J=V2(j),ee=$2(p,r,a,s),de=J2(p,u,a,s);return{months:j,weeks:L,days:J,previousMonth:ee,nextMonth:de}},[s,p.getTime(),u?.getTime(),r?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:A,onMonthChange:R}=a,B=Q=>M.some(k=>k.days.some(j=>j.isEqualTo(Q))),w=Q=>{if(A)return;let k=d(Q);r&&k<d(r)&&(k=d(r)),u&&k>d(u)&&(k=d(u)),y(k),R?.(k)};return{months:S,weeks:M,days:x,navStart:r,navEnd:u,previousMonth:b,nextMonth:_,goToMonth:w,goToDay:Q=>{B(Q)||w(Q.date)}}}var _n;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(_n||(_n={}));function kp(a){return!a[at.disabled]&&!a[at.hidden]&&!a[at.outside]}function P2(a,s,r,u){let d,m=-1;for(const h of a){const p=s(h);kp(p)&&(p[at.focused]&&m<_n.FocusedModifier?(d=h,m=_n.FocusedModifier):u?.isEqualTo(h)&&m<_n.LastFocused?(d=h,m=_n.LastFocused):r(h.date)&&m<_n.Selected?(d=h,m=_n.Selected):p[at.today]&&m<_n.Today&&(d=h,m=_n.Today))}return d||(d=a.find(h=>kp(s(h)))),d}function eC(a,s,r,u,d,m,h){const{ISOWeek:p,broadcastCalendar:y}=m,{addDays:S,addMonths:M,addWeeks:x,addYears:b,endOfBroadcastWeek:_,endOfISOWeek:A,endOfWeek:R,max:B,min:w,startOfBroadcastWeek:Y,startOfISOWeek:q,startOfWeek:Q}=h;let j={day:S,week:x,month:M,year:b,startOfWeek:L=>y?Y(L,h):p?q(L):Q(L),endOfWeek:L=>y?_(L):p?A(L):R(L)}[a](r,s==="after"?1:-1);return s==="before"&&u?j=B([u,j]):s==="after"&&d&&(j=w([d,j])),j}function yy(a,s,r,u,d,m,h,p=0){if(p>365)return;const y=eC(a,s,r.date,u,d,m,h),S=!!(m.disabled&&ua(y,m.disabled,h)),M=!!(m.hidden&&ua(y,m.hidden,h)),x=y,b=new ny(y,x,h);return!S&&!M?b:yy(a,s,b,u,d,m,h,p+1)}function tC(a,s,r,u,d){const{autoFocus:m}=a,[h,p]=v.useState(),y=P2(s.days,r,u||(()=>!1),h),[S,M]=v.useState(m?y:void 0);return{isFocusTarget:R=>!!y?.isEqualTo(R),setFocused:M,focused:S,blur:()=>{p(S),M(void 0)},moveFocus:(R,B)=>{if(!S)return;const w=yy(R,B,S,s.navStart,s.navEnd,a,d);w&&(a.disableNavigation&&!s.days.some(q=>q.isEqualTo(w))||(s.goToDay(w),M(w)))}}}function nC(a,s){const{selected:r,required:u,onSelect:d}=a,[m,h]=lr(r,d?r:void 0),p=d?r:m,{isSameDay:y}=s,S=_=>p?.some(A=>y(A,_))??!1,{min:M,max:x}=a;return{selected:p,select:(_,A,R)=>{let B=[...p??[]];if(S(_)){if(p?.length===M||u&&p?.length===1)return;B=p?.filter(w=>!y(w,_))}else p?.length===x?B=[_]:B=[...B,_];return d||h(B),d?.(B,_,A,R),B},isSelected:S}}function aC(a,s,r=0,u=0,d=!1,m=Rn){const{from:h,to:p}=s||{},{isSameDay:y,isAfter:S,isBefore:M}=m;let x;if(!h&&!p)x={from:a,to:r>0?void 0:a};else if(h&&!p)y(h,a)?r===0?x={from:h,to:a}:d?x={from:h,to:void 0}:x=void 0:M(a,h)?x={from:a,to:h}:x={from:h,to:a};else if(h&&p)if(y(h,a)&&y(p,a))d?x={from:h,to:p}:x=void 0;else if(y(h,a))x={from:h,to:r>0?void 0:a};else if(y(p,a))x={from:a,to:r>0?void 0:a};else if(M(a,h))x={from:a,to:p};else if(S(a,h))x={from:h,to:a};else if(S(a,p))x={from:h,to:a};else throw new Error("Invalid range");if(x?.from&&x?.to){const b=m.differenceInCalendarDays(x.to,x.from);u>0&&b>u?x={from:a,to:void 0}:r>1&&b<r&&(x={from:a,to:void 0})}return x}function lC(a,s,r=Rn){const u=Array.isArray(s)?s:[s];let d=a.from;const m=r.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=r.addDays(d,1)}return!1}function Rp(a,s,r=Rn){return ra(a,s.from,!1,r)||ra(a,s.to,!1,r)||ra(s,a.from,!1,r)||ra(s,a.to,!1,r)}function sC(a,s,r=Rn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:r.isDate(p)?ra(a,p,!1,r):sy(p,r)?p.some(y=>ra(a,y,!1,r)):ar(p)?p.from&&p.to?Rp(a,{from:p.from,to:p.to},r):!1:ly(p)?lC(a,p.dayOfWeek,r):Pc(p)?r.isAfter(p.before,p.after)?Rp(a,{from:r.addDays(p.after,1),to:r.addDays(p.before,-1)},r):ua(a.from,p,r)||ua(a.to,p,r):ed(p)||td(p)?ua(a.from,p,r)||ua(a.to,p,r):!1))return!0;const h=u.filter(p=>typeof p=="function");if(h.length){let p=a.from;const y=r.differenceInCalendarDays(a.to,a.from);for(let S=0;S<=y;S++){if(h.some(M=>M(p)))return!0;p=r.addDays(p,1)}}return!1}function iC(a,s){const{disabled:r,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,y]=lr(d,h?d:void 0),S=h?d:p;return{selected:S,select:(b,_,A)=>{const{min:R,max:B}=a,w=b?aC(b,S,R,B,m,s):void 0;return u&&r&&w?.from&&w.to&&sC({from:w.from,to:w.to},r,s)&&(w.from=b,w.to=void 0),h||y(w),h?.(w,b,_,A),w},isSelected:b=>S&&ra(S,b,!1,s)}}function oC(a,s){const{selected:r,required:u,onSelect:d}=a,[m,h]=lr(r,d?r:void 0),p=d?r:m,{isSameDay:y}=s;return{selected:p,select:(x,b,_)=>{let A=x;return!u&&p&&p&&y(x,p)&&(A=void 0),d||h(A),d?.(A,x,b,_),A},isSelected:x=>p?y(p,x):!1}}function rC(a,s){const r=oC(a,s),u=nC(a,s),d=iC(a,s);switch(a.mode){case"single":return r;case"multiple":return u;case"range":return d;default:return}}function Mt(a,s){return a instanceof oa&&a.timeZone===s?a:new oa(a,s)}function Up(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Mt(a,s):Array.isArray(a)?a.map(r=>r instanceof Date?Mt(r,s):r):ar(a)?{...a,from:a.from?Mt(a.from,s):a.from,to:a.to?Mt(a.to,s):a.to}:Pc(a)?{before:Mt(a.before,s),after:Mt(a.after,s)}:ed(a)?{after:Mt(a.after,s)}:td(a)?{before:Mt(a.before,s)}:a}function Mc(a,s){return a&&(Array.isArray(a)?a.map(r=>Up(r,s)):Up(a,s))}function uC(a){let s=a;const r=s.timeZone;if(r&&(s={...a,timeZone:r},s.today&&(s.today=Mt(s.today,r)),s.month&&(s.month=Mt(s.month,r)),s.defaultMonth&&(s.defaultMonth=Mt(s.defaultMonth,r)),s.startMonth&&(s.startMonth=Mt(s.startMonth,r)),s.endMonth&&(s.endMonth=Mt(s.endMonth,r)),s.mode==="single"&&s.selected?s.selected=Mt(s.selected,r):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(ie=>Mt(ie,r)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Mt(s.selected.from,r):s.selected.from,to:s.selected.to?Mt(s.selected.to,r):s.selected.to}),s.disabled!==void 0&&(s.disabled=Mc(s.disabled,r)),s.hidden!==void 0&&(s.hidden=Mc(s.hidden,r)),s.modifiers)){const ie={};Object.keys(s.modifiers).forEach(be=>{ie[be]=Mc(s.modifiers?.[be],r)}),s.modifiers=ie}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:y}=v.useMemo(()=>{const ie={...ty,...s.locale},be=new an({locale:ie,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:be,components:v2(s.components),formatters:O2(s.formatters),labels:R2(s.labels,be.options),locale:ie,classNames:{...S2(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:h.today()});const{captionLayout:S,mode:M,navLayout:x,numberOfMonths:b=1,onDayBlur:_,onDayClick:A,onDayFocus:R,onDayKeyDown:B,onDayMouseEnter:w,onDayMouseLeave:Y,onNextClick:q,onPrevClick:Q,showWeekNumber:k,styles:j}=s,{formatCaption:L,formatDay:J,formatMonthDropdown:ee,formatWeekNumber:de,formatWeekNumberHeader:ve,formatWeekdayName:oe,formatYearDropdown:Ye}=d,Se=I2(s,h),{days:$,months:T,navStart:Z,navEnd:ae,previousMonth:ye,nextMonth:xe,goToMonth:Ae}=Se,ce=y2($,s,Z,ae,h),{isSelected:X,select:F,selected:le}=rC(s,h)??{},{blur:I,focused:ne,isFocusTarget:ge,moveFocus:De,setFocused:Ge}=tC(s,Se,ce,X??(()=>!1),h),{labelDayButton:pt,labelGridcell:gt,labelGrid:Qe,labelMonthDropdown:et,labelNav:Dt,labelPrevious:Kt,labelNext:Un,labelWeekday:je,labelWeekNumber:Qt,labelWeekNumberHeader:En,labelYearDropdown:Vt}=m,ca=v.useMemo(()=>H2(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Bn=M!==void 0||A!==void 0,ot=v.useCallback(()=>{ye&&(Ae(ye),Q?.(ye))},[ye,Ae,Q]),Xt=v.useCallback(()=>{xe&&(Ae(xe),q?.(xe))},[Ae,xe,q]),Hn=v.useCallback((ie,be)=>me=>{me.preventDefault(),me.stopPropagation(),Ge(ie),!be.disabled&&(F?.(ie.date,be,me),A?.(ie.date,be,me))},[F,A,Ge]),qa=v.useCallback((ie,be)=>me=>{Ge(ie),R?.(ie.date,be,me)},[R,Ge]),wn=v.useCallback((ie,be)=>me=>{I(),_?.(ie.date,be,me)},[I,_]),Mn=v.useCallback((ie,be)=>me=>{const ze={ArrowLeft:[me.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[me.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[me.shiftKey?"year":"week","after"],ArrowUp:[me.shiftKey?"year":"week","before"],PageUp:[me.shiftKey?"year":"month","before"],PageDown:[me.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ze[me.key]){me.preventDefault(),me.stopPropagation();const[Fe,pe]=ze[me.key];De(Fe,pe)}B?.(ie.date,be,me)},[De,B,s.dir]),fl=v.useCallback((ie,be)=>me=>{w?.(ie.date,be,me)},[w]),ls=v.useCallback((ie,be)=>me=>{Y?.(ie.date,be,me)},[Y]),ss=v.useCallback(ie=>be=>{const me=Number(be.target.value),ze=h.setMonth(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),qn=v.useCallback(ie=>be=>{const me=Number(be.target.value),ze=h.setYear(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),{className:W,style:Me}=v.useMemo(()=>({className:[y[re.Root],s.className].filter(Boolean).join(" "),style:{...j?.[re.Root],...s.style}}),[y,s.className,s.style,j]),fe=b2(s),Te=v.useRef(null);K2(Te,!!s.animate,{classNames:y,months:T,focused:ne,dateLib:h});const tt={dayPickerProps:s,selected:le,select:F,isSelected:X,months:T,nextMonth:xe,previousMonth:ye,goToMonth:Ae,getModifiers:ce,components:u,classNames:y,styles:j,labels:m,formatters:d};return P.createElement(ay.Provider,{value:tt},P.createElement(u.Root,{rootRef:s.animate?Te:void 0,className:W,style:Me,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...fe},P.createElement(u.Months,{className:y[re.Months],style:j?.[re.Months]},!s.hideNavigation&&!x&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:y[re.Nav],style:j?.[re.Nav],"aria-label":Dt(),onPreviousClick:ot,onNextClick:Xt,previousMonth:ye,nextMonth:xe}),T.map((ie,be)=>P.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:y[re.Month],style:j?.[re.Month],key:be,displayIndex:be,calendarMonth:ie},x==="around"&&!s.hideNavigation&&be===0&&P.createElement(u.PreviousMonthButton,{type:"button",className:y[re.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Kt(ye),onClick:ot,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:ye?void 0:!0,className:y[re.Chevron],orientation:s.dir==="rtl"?"right":"left"})),P.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:y[re.MonthCaption],style:j?.[re.MonthCaption],calendarMonth:ie,displayIndex:be},S?.startsWith("dropdown")?P.createElement(u.DropdownNav,{className:y[re.Dropdowns],style:j?.[re.Dropdowns]},(()=>{const me=S==="dropdown"||S==="dropdown-months"?P.createElement(u.MonthsDropdown,{key:"month",className:y[re.MonthsDropdown],"aria-label":et(),classNames:y,components:u,disabled:!!s.disableNavigation,onChange:ss(ie.date),options:U2(ie.date,Z,ae,d,h),style:j?.[re.Dropdown],value:h.getMonth(ie.date)}):P.createElement("span",{key:"month"},ee(ie.date,h)),ze=S==="dropdown"||S==="dropdown-years"?P.createElement(u.YearsDropdown,{key:"year",className:y[re.YearsDropdown],"aria-label":Vt(h.options),classNames:y,components:u,disabled:!!s.disableNavigation,onChange:qn(ie.date),options:q2(Z,ae,d,h,!!s.reverseYears),style:j?.[re.Dropdown],value:h.getYear(ie.date)}):P.createElement("span",{key:"year"},Ye(ie.date,h));return h.getMonthYearOrder()==="year-first"?[ze,me]:[me,ze]})(),P.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},L(ie.date,h.options,h))):P.createElement(u.CaptionLabel,{className:y[re.CaptionLabel],role:"status","aria-live":"polite"},L(ie.date,h.options,h))),x==="around"&&!s.hideNavigation&&be===b-1&&P.createElement(u.NextMonthButton,{type:"button",className:y[re.NextMonthButton],tabIndex:xe?void 0:-1,"aria-disabled":xe?void 0:!0,"aria-label":Un(xe),onClick:Xt,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:xe?void 0:!0,className:y[re.Chevron],orientation:s.dir==="rtl"?"left":"right"})),be===b-1&&x==="after"&&!s.hideNavigation&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:y[re.Nav],style:j?.[re.Nav],"aria-label":Dt(),onPreviousClick:ot,onNextClick:Xt,previousMonth:ye,nextMonth:xe}),P.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":M==="multiple"||M==="range","aria-label":Qe(ie.date,h.options,h)||void 0,className:y[re.MonthGrid],style:j?.[re.MonthGrid]},!s.hideWeekdays&&P.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:y[re.Weekdays],style:j?.[re.Weekdays]},k&&P.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:y[re.WeekNumberHeader],style:j?.[re.WeekNumberHeader],scope:"col"},ve()),ca.map(me=>P.createElement(u.Weekday,{"aria-label":je(me,h.options,h),className:y[re.Weekday],key:String(me),style:j?.[re.Weekday],scope:"col"},oe(me,h.options,h)))),P.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:y[re.Weeks],style:j?.[re.Weeks]},ie.weeks.map(me=>P.createElement(u.Week,{className:y[re.Week],key:me.weekNumber,style:j?.[re.Week],week:me},k&&P.createElement(u.WeekNumber,{week:me,style:j?.[re.WeekNumber],"aria-label":Qt(me.weekNumber,{locale:p}),className:y[re.WeekNumber],scope:"row",role:"rowheader"},de(me.weekNumber,h)),me.days.map(ze=>{const{date:Fe}=ze,pe=ce(ze);if(pe[at.focused]=!pe.hidden&&!!ne?.isEqualTo(ze),pe[jn.selected]=X?.(Fe)||pe.selected,ar(le)){const{from:Zt,to:yn}=le;pe[jn.range_start]=!!(Zt&&yn&&h.isSameDay(Fe,Zt)),pe[jn.range_end]=!!(Zt&&yn&&h.isSameDay(Fe,yn)),pe[jn.range_middle]=ra(le,Fe,!0,h)}const Tt=B2(pe,j,s.modifiersStyles),Ln=x2(pe,y,s.modifiersClassNames),xt=!Bn&&!pe.hidden?gt(Fe,pe,h.options,h):void 0;return P.createElement(u.Day,{key:`${ze.isoDate}_${ze.displayMonthId}`,day:ze,modifiers:pe,className:Ln.join(" "),style:Tt,role:"gridcell","aria-selected":pe.selected||void 0,"aria-label":xt,"data-day":ze.isoDate,"data-month":ze.outside?ze.dateMonthId:void 0,"data-selected":pe.selected||void 0,"data-disabled":pe.disabled||void 0,"data-hidden":pe.hidden||void 0,"data-outside":ze.outside||void 0,"data-focused":pe.focused||void 0,"data-today":pe.today||void 0},!pe.hidden&&Bn?P.createElement(u.DayButton,{className:y[re.DayButton],style:j?.[re.DayButton],type:"button",day:ze,modifiers:pe,disabled:!pe.focused&&pe.disabled||void 0,"aria-disabled":pe.focused&&pe.disabled||void 0,tabIndex:ge(ze)?0:-1,"aria-label":pt(Fe,pe,h.options,h),onClick:Hn(ze,pe),onBlur:wn(ze,pe),onFocus:qa(ze,pe),onKeyDown:Mn(ze,pe),onMouseEnter:fl(ze,pe),onMouseLeave:ls(ze,pe)},J(Fe,h.options,h)):!pe.hidden&&J(ze.date,h.options,h))})))))))),s.footer&&P.createElement(u.Footer,{className:y[re.Footer],style:j?.[re.Footer],role:"status","aria-live":"polite"},s.footer)))}function cC({className:a,classNames:s,showOutsideDays:r=!0,...u}){return o.jsx(uC,{showOutsideDays:r,className:V("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:V(ko({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:V(ko({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:V("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:V(ko({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:V("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:V("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:V("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:V("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"?xb:d==="right"?Ko:d==="up"?Bc:Jo;return o.jsx(p,{className:V("h-4 w-4",m),...h})}},...u})}cC.displayName="Calendar";const dC=v.lazy(()=>At(()=>import("./index-DrXzuIu0.js"),__vite__mapDeps([13,1,2,14,4,5,7,15,6,8,9])).then(a=>({default:a.AnalyticsPage}))),fC=v.lazy(()=>At(()=>import("./api-9506vRxR.js"),__vite__mapDeps([16,1,2,5,17,18,6,4,14,7,8,9])).then(a=>({default:a.ApiPage}))),mC=v.lazy(()=>At(()=>import("./cliproxy-BXDGSpjs.js"),__vite__mapDeps([19,1,2,5,6,4,14,17,18,3,7,8,9])).then(a=>({default:a.CliproxyPage}))),hC=v.lazy(()=>At(()=>import("./cliproxy-control-panel-Dr76Wi8D.js"),__vite__mapDeps([20,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),pC=v.lazy(()=>At(()=>import("./copilot-CVl7HYuu.js"),__vite__mapDeps([21,1,2,5,17,18,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),gC=v.lazy(()=>At(()=>import("./accounts-C8We5aGM.js"),__vite__mapDeps([22,1,2,5,18,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),yC=v.lazy(()=>At(()=>Promise.resolve().then(()=>_j),void 0).then(a=>({default:a.SettingsPage}))),xC=v.lazy(()=>At(()=>import("./health-BP6tpJjs.js"),__vite__mapDeps([23,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),vC=v.lazy(()=>At(()=>import("./shared-1FiVmFEu.js"),__vite__mapDeps([24,1,2,14,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function bC(){return o.jsx(fv,{client:_b,children:o.jsx(Rb,{defaultTheme:"system",storageKey:"vite-ui-theme",children:o.jsx(Ub,{children:o.jsxs(uv,{children:[o.jsx(cv,{children:o.jsxs(Sn,{element:o.jsx(QS,{}),children:[o.jsx(Sn,{path:"/",element:o.jsx(RN,{})}),o.jsx(Sn,{path:"/analytics",element:o.jsx(dC,{})}),o.jsx(Sn,{path:"/providers",element:o.jsx(fC,{})}),o.jsx(Sn,{path:"/cliproxy",element:o.jsx(mC,{})}),o.jsx(Sn,{path:"/cliproxy/control-panel",element:o.jsx(hC,{})}),o.jsx(Sn,{path:"/copilot",element:o.jsx(pC,{})}),o.jsx(Sn,{path:"/accounts",element:o.jsx(gC,{})}),o.jsx(Sn,{path:"/settings",element:o.jsx(yC,{})}),o.jsx(Sn,{path:"/health",element:o.jsx(xC,{})}),o.jsx(Sn,{path:"/shared",element:o.jsx(vC,{})})]})}),o.jsx(mv,{position:"top-right"})]})})})})}const xy=document.getElementById("root");if(!xy)throw new Error("Root element not found. Failed to mount React application.");Ob.createRoot(xy).render(o.jsx(v.StrictMode,{children:o.jsx(bC,{})}));export{Lc as $,xS as A,Ha as B,cC as C,Gg as D,Fc as E,il as F,Dc as G,FC as H,Ra as I,PC as J,eE as K,Dn as L,Vg as M,tE as N,nE as O,hg as P,ij as Q,IC as R,Le as S,fi as T,lE as U,oj as V,uj as W,w1 as X,AC as Y,RC as Z,UC as _,St as a,Yc as a0,Gc as a1,Kc as a2,Qc as a3,BC as a4,aE as a5,rj as a6,US as a7,g1 as a8,Yb as a9,Yg as aA,Ig as aB,Nj as aC,Cj as aD,$g as aE,Lb as aa,Fo as ab,fj as ac,Hb as ad,qb as ae,ht as af,HC as ag,qC as ah,LC as ai,YC as aj,sE as ak,GC as al,VC as am,KC as an,QC as ao,OC as ap,_C as aq,kC as ar,DC as as,Xg as at,At as au,ko as av,DN as aw,XC as ax,qg as ay,Lg as az,iE as b,V as c,oE as d,kj as e,u1 as f,zC as g,c1 as h,dl as i,rE as j,mi as k,hi as l,jp as m,$N as n,$C as o,XN as p,ZC as q,JC as r,LN as s,BN as t,qc as u,QN as v,ZN as w,WC as x,gS as y,yS as z};
47
+ `);return{valid:!1,error:u,line:h.length}}return{valid:!1,error:u}}}function Jg({value:a,onChange:s,language:r="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=yg(),[p,y]=v.useState(!1),[S,M]=v.useState(!0),x=v.useMemo(()=>r==="json"?xj(a):{valid:!0},[a,r]),b=v.useCallback(_=>o.jsx(Eb,{theme:h?ap.nightOwl:ap.github,code:_,language:r,children:({tokens:A,getLineProps:R,getTokenProps:B})=>{let w=!1;return o.jsx(o.Fragment,{children:A.map((Y,q)=>o.jsx("div",{...R({line:Y}),className:V(x.line===q+1&&"bg-destructive/20"),children:Y.map((Q,k)=>{let j=!1;if(Q.types.includes("property")){const J=Q.content.replace(/['"]/g,"");yj(J)?w=!0:w=!1}else(Q.types.includes("string")||Q.types.includes("number")||Q.types.includes("boolean"))&&w?(j=!0,w=!1):Q.types.includes("punctuation")&&Q.content!==":"&&Q.content!=="["&&Q.content!=="{"&&(w=!1);const L=B({token:Q});return j&&S&&(L.className=V(L.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),o.jsx("span",{...L},k)})},q))})}}),[h,r,x.line,S]);return o.jsxs("div",{className:V("flex flex-col",d),children:[o.jsxs("div",{className:V("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",!x.valid&&"border-destructive"),style:{minHeight:m},children:[o.jsx(pj,{value:a,onValueChange:u?()=>{}:s,highlight:b,padding:12,disabled:u,onFocus:()=>y(!0),onBlur:()=>y(!1),textareaClassName:V("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"),o.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:o.jsx(St,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>M(!S),title:S?"Reveal sensitive values":"Mask sensitive values",children:S?o.jsx(Vo,{className:"h-3 w-3"}):o.jsx(Qo,{className:"h-3 w-3"})})})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[x.valid?o.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[o.jsx(Xo,{className:"w-3 h-3 text-green-500"}),"Valid ",r.toUpperCase()]}):o.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[o.jsx(pb,{className:"w-3 h-3"}),x.error,x.line&&` (line ${x.line})`]}),u&&o.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const $g=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:Jg},Symbol.toStringTag,{value:"Module"})),vj={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 bj(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 Fg=v.createContext(null);function Sj({children:a}){const[s,r]=v.useReducer(bj,vj);return o.jsx(Fg.Provider,{value:{state:s,dispatch:r},children:a})}function Ig(){const a=v.useContext(Fg);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function Nj(){const{dispatch:a}=Ig(),s=v.useCallback(j=>a({type:"SET_WEBSEARCH_CONFIG",payload:j}),[a]),r=v.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS",payload:j}),[a]),u=v.useCallback(j=>a({type:"SET_WEBSEARCH_LOADING",payload:j}),[a]),d=v.useCallback(j=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:j}),[a]),m=v.useCallback(j=>a({type:"SET_WEBSEARCH_SAVING",payload:j}),[a]),h=v.useCallback(j=>a({type:"SET_WEBSEARCH_ERROR",payload:j}),[a]),p=v.useCallback(j=>a({type:"SET_WEBSEARCH_SUCCESS",payload:j}),[a]),y=v.useCallback(j=>a({type:"SET_GLOBALENV_CONFIG",payload:j}),[a]),S=v.useCallback(j=>a({type:"SET_GLOBALENV_LOADING",payload:j}),[a]),M=v.useCallback(j=>a({type:"SET_GLOBALENV_SAVING",payload:j}),[a]),x=v.useCallback(j=>a({type:"SET_GLOBALENV_ERROR",payload:j}),[a]),b=v.useCallback(j=>a({type:"SET_GLOBALENV_SUCCESS",payload:j}),[a]),_=v.useCallback(j=>a({type:"SET_PROXY_CONFIG",payload:j}),[a]),A=v.useCallback(j=>a({type:"SET_PROXY_LOADING",payload:j}),[a]),R=v.useCallback(j=>a({type:"SET_PROXY_SAVING",payload:j}),[a]),B=v.useCallback(j=>a({type:"SET_PROXY_ERROR",payload:j}),[a]),w=v.useCallback(j=>a({type:"SET_PROXY_SUCCESS",payload:j}),[a]),Y=v.useCallback(j=>a({type:"SET_PROXY_TEST_RESULT",payload:j}),[a]),q=v.useCallback(j=>a({type:"SET_PROXY_TESTING",payload:j}),[a]),Q=v.useCallback(j=>a({type:"SET_RAW_CONFIG",payload:j}),[a]),k=v.useCallback(j=>a({type:"SET_RAW_CONFIG_LOADING",payload:j}),[a]);return v.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:r,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:y,setGlobalEnvLoading:S,setGlobalEnvSaving:M,setGlobalEnvError:x,setGlobalEnvSuccess:b,setProxyConfig:_,setProxyLoading:A,setProxySaving:R,setProxyError:B,setProxySuccess:w,setProxyTestResult:Y,setProxyTesting:q,setRawConfig:Q,setRawConfigLoading:k}),[s,r,u,d,m,h,p,y,S,M,x,b,_,A,R,B,w,Y,q,Q,k])}function jj(){const[a,s]=rv(),r=a.get("tab"),u=r==="globalenv"?"globalenv":r==="proxy"?"proxy":r==="auth"?"auth":"websearch",d=v.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function Cj(){const{state:a}=Ig(),s=Nj(),[r,u]=v.useState(!1),d=v.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=v.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:r,fetchRawConfig:d,copyToClipboard:m}}function Ej({activeTab:a,onTabChange:s}){return o.jsx(Gg,{value:a,onValueChange:r=>s(r),children:o.jsxs(Fc,{className:"w-full",children:[o.jsxs(il,{value:"websearch",className:"flex-1 gap-2",children:[o.jsx(gb,{className:"w-4 h-4"}),"WebSearch"]}),o.jsxs(il,{value:"globalenv",className:"flex-1 gap-2",children:[o.jsx(Hc,{className:"w-4 h-4"}),"Global Env"]}),o.jsxs(il,{value:"proxy",className:"flex-1 gap-2",children:[o.jsx(yb,{className:"w-4 h-4"}),"Proxy"]}),o.jsxs(il,{value:"auth",className:"flex-1 gap-2",children:[o.jsx(ug,{className:"w-4 h-4"}),"Auth"]})]})})}function wj(){return o.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[o.jsx(Le,{className:"h-4 w-2/3"}),o.jsx("div",{className:"p-4 rounded-lg border",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Le,{className:"h-5 w-32"}),o.jsx(Le,{className:"h-4 w-48"})]}),o.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),o.jsxs("div",{className:"space-y-3",children:[o.jsx(Le,{className:"h-5 w-24"}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Le,{className:"h-20 w-full rounded-lg"}),o.jsx(Le,{className:"h-20 w-full rounded-lg"}),o.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}const Mj=v.lazy(()=>At(()=>import("./index-Cf72mW4U.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Tj=v.lazy(()=>At(()=>import("./globalenv-section-CGdnlj1K.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),zj=v.lazy(()=>At(()=>import("./index-4FYBhG16.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),Oj=v.lazy(()=>At(()=>import("./auth-section-3fqp84IR.js"),__vite__mapDeps([12,1,2,4,5,6,7,8,9])));function Aj(){const{activeTab:a,setActiveTab:s}=jj(),{rawConfig:r,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=Cj();v.useEffect(()=>{m()},[m]);const p=y=>{v.startTransition(()=>{s(y)})};return o.jsx("div",{className:"h-[calc(100vh-100px)]",children:o.jsxs(Jc,{direction:"horizontal",className:"h-full",children:[o.jsx(ri,{defaultSize:40,minSize:30,maxSize:55,children:o.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[o.jsx("div",{className:"p-5 border-b bg-background",children:o.jsx(Ej,{activeTab:a,onTabChange:p})}),o.jsxs(v.Suspense,{fallback:o.jsx(wj,{}),children:[a==="websearch"&&o.jsx(Mj,{}),a==="globalenv"&&o.jsx(Tj,{}),a==="proxy"&&o.jsx(zj,{}),a==="auth"&&o.jsx(Oj,{})]})]})}),o.jsx($c,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:o.jsx(Zo,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),o.jsx(ri,{defaultSize:60,minSize:35,children:o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ph,{className:"w-5 h-5 text-primary"}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold",children:"config.yaml"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(St,{variant:"outline",size:"sm",onClick:h,disabled:!r,children:d?o.jsxs(o.Fragment,{children:[o.jsx(ns,{className:"w-4 h-4 mr-1"}),"Copied"]}):o.jsxs(o.Fragment,{children:[o.jsx(Bo,{className:"w-4 h-4 mr-1"}),"Copy"]})}),o.jsx(St,{variant:"outline",size:"sm",onClick:m,disabled:u,children:o.jsx(ep,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:u?o.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[o.jsx(ep,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):r?o.jsx(Jg,{value:r,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):o.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:o.jsxs("div",{className:"text-center",children:[o.jsx(Ph,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{children:"Config file not found"}),o.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})})}function Dj(){return o.jsx(Sj,{children:o.jsx(Aj,{})})}const _j=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:Dj},Symbol.toStringTag,{value:"Module"})),iE=Px,oE=tv,rE=ev,kj=v.forwardRef(({className:a,align:s="center",sideOffset:r=4,...u},d)=>o.jsx(Ix,{children:o.jsx(ng,{ref:d,align:s,sideOffset:r,className:V("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})}));kj.displayName=ng.displayName;function Rj(a,s,r="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:r}).format(s).split(/\s/g).slice(2).join(" ")}const Uj={},ii={};function ol(a,s){try{const u=(Uj[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in ii?ii[u]:Op(u,u.split(":"))}catch{if(a in ii)return ii[a];const r=a?.match(Bj);return r?Op(a,r.slice(1)):NaN}}const Bj=/([+-]\d\d):?(\d\d)?/;function Op(a,s){const r=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return ii[a]=r*60+u>0?r*60+u+d:r*60-u-d}class kn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(ol(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)),Pg(this),kc(this)):this.setTime(Date.now())}static tz(s,...r){return r.length?new kn(...r,s):new kn(Date.now(),s)}withTimeZone(s){return new kn(+this,s)}getTimezoneOffset(){const s=-ol(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),kc(this),+this}[Symbol.for("constructDateFrom")](s){return new kn(+new Date(s),this.timeZone)}}const Ap=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!Ap.test(a))return;const s=a.replace(Ap,"$1UTC");kn.prototype[s]&&(a.startsWith("get")?kn.prototype[a]=function(){return this.internal[s]()}:(kn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),Hj(this),+this},kn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),kc(this),+this}))});function kc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-ol(a.timeZone,a)*60))}function Hj(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()),Pg(a)}function Pg(a){const s=ol(a.timeZone,a),r=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 y=d-r;y&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+y);const S=new Date(+a);S.setUTCSeconds(0);const M=d>0?S.getSeconds():(S.getSeconds()-60)%60,x=Math.round(-(ol(a.timeZone,a)*60))%60;(x||M)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+x),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+x+M));const b=ol(a.timeZone,a),_=b>0?Math.floor(b):Math.ceil(b),R=-new Date(+a).getTimezoneOffset()-_,B=_!==r,w=R-y;if(B&&w){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+w);const Y=ol(a.timeZone,a),q=Y>0?Math.floor(Y):Math.ceil(Y),Q=_-q;Q&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+Q),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+Q))}}class oa extends kn{static tz(s,...r){return r.length?new oa(...r,s):new oa(Date.now(),s)}toISOString(){const[s,r,u]=this.tzComponents(),d=`${s}${r}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,r,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${r} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[r,u,d]=this.tzComponents();return`${s} GMT${r}${u}${d} (${Rj(this.timeZone,this)})`}toLocaleString(s,r){return Date.prototype.toLocaleString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleDateString(s,r){return Date.prototype.toLocaleDateString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}toLocaleTimeString(s,r){return Date.prototype.toLocaleTimeString.call(this,s,{...r,timeZone:r?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),r=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[r,u,d]}withTimeZone(s){return new oa(+this,s)}[Symbol.for("constructDateFrom")](s){return new oa(+new Date(s),this.timeZone)}}const Dp=5,qj=4;function Lj(a,s){const r=s.startOfMonth(a),u=r.getDay()>0?r.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,Dp*7-1);return s.getMonth(a)===s.getMonth(m)?Dp:qj}function ey(a,s){const r=s.startOfMonth(a),u=r.getDay();return u===1?r:u===0?s.addDays(r,-6):s.addDays(r,-1*(u-1))}function Yj(a,s){const r=ey(a,s),u=Lj(a,s);return s.addDays(r,u*7-1)}const ty={...Ps,labels:{labelDayButton:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ni(h,p,{locale:Ps,...r});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,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,m)=>ni(d,m,{locale:Ps,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,r,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ni(h,p,{locale:Ps,...r});let m=d(a,"PPPP");return s?.today&&(m=`Today, ${m}`),m},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,r)=>{let u;return r&&typeof r.format=="function"?u=r.format.bind(r):u=(d,m)=>ni(d,m,{locale:Ps,...s}),u(a,"cccc")}}};class an{constructor(s,r){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?oa.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 oa(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):gv(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):yv(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):xv(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):vv(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):bv(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):Sv(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Nv(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):jv(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):Yj(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Cv(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):Ev(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):wv(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Mv(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ni(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):Tv(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):zv(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Ov(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Av(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Dv(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):_v(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):kv(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Rv(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Uv(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Bv(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Hv(u),this.min=u=>this.overrides?.min?this.overrides.min(u):qv(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Lv(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):Yv(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):ey(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Gv(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Kv(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Qv(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):Vv(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):Xv(u),this.options={locale:ty,...s},this.overrides=r}getDigitMap(){const{numerals:s="latn"}=this.options,r=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=r.format(d);return u}replaceDigits(s){const r=this.getDigitMap();return s.replace(/\d/g,u=>r[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&an.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:r,timeZone:u,numerals:d}=this.options,m=r?.code;if(m&&an.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)}}an.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 Rn=new an;class ny{constructor(s,r,u=Rn){this.date=s,this.displayMonth=r,this.outside=!!(r&&!u.isSameMonth(s,r)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(r,"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 Gj{constructor(s,r){this.date=s,this.weeks=r}}class Kj{constructor(s,r){this.days=r,this.weekNumber=s}}function Qj(a){return P.createElement("button",{...a})}function Vj(a){return P.createElement("span",{...a})}function Xj(a){const{size:s=24,orientation:r="left",className:u}=a;return P.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},r==="up"&&P.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),r==="down"&&P.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),r==="left"&&P.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),r==="right"&&P.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Zj(a){const{day:s,modifiers:r,...u}=a;return P.createElement("td",{...u})}function Wj(a){const{day:s,modifiers:r,...u}=a,d=P.useRef(null);return P.useEffect(()=>{r.focused&&d.current?.focus()},[r.focused]),P.createElement("button",{ref:d,...u})}var re;(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"})(re||(re={}));var at;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(at||(at={}));var jn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(jn||(jn={}));var nn;(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"})(nn||(nn={}));function Jj(a){const{options:s,className:r,components:u,classNames:d,...m}=a,h=[d[re.Dropdown],r].join(" "),p=s?.find(({value:y})=>y===m.value);return P.createElement("span",{"data-disabled":m.disabled,className:d[re.DropdownRoot]},P.createElement(u.Select,{className:h,...m},s?.map(({value:y,label:S,disabled:M})=>P.createElement(u.Option,{key:y,value:y,disabled:M},S))),P.createElement("span",{className:d[re.CaptionLabel],"aria-hidden":!0},p?.label,P.createElement(u.Chevron,{orientation:"down",size:18,className:d[re.Chevron]})))}function $j(a){return P.createElement("div",{...a})}function Fj(a){return P.createElement("div",{...a})}function Ij(a){const{calendarMonth:s,displayIndex:r,...u}=a;return P.createElement("div",{...u},a.children)}function Pj(a){const{calendarMonth:s,displayIndex:r,...u}=a;return P.createElement("div",{...u})}function e2(a){return P.createElement("table",{...a})}function t2(a){return P.createElement("div",{...a})}const ay=v.createContext(void 0);function pi(){const a=v.useContext(ay);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function n2(a){const{components:s}=pi();return P.createElement(s.Dropdown,{...a})}function a2(a){const{onPreviousClick:s,onNextClick:r,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:y,labelNext:S}}=pi(),M=v.useCallback(b=>{d&&r?.(b)},[d,r]),x=v.useCallback(b=>{u&&s?.(b)},[u,s]);return P.createElement("nav",{...m},P.createElement(h.PreviousMonthButton,{type:"button",className:p[re.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":y(u),onClick:x},P.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[re.Chevron],orientation:"left"})),P.createElement(h.NextMonthButton,{type:"button",className:p[re.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":S(d),onClick:M},P.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[re.Chevron]})))}function l2(a){const{components:s}=pi();return P.createElement(s.Button,{...a})}function s2(a){return P.createElement("option",{...a})}function i2(a){const{components:s}=pi();return P.createElement(s.Button,{...a})}function o2(a){const{rootRef:s,...r}=a;return P.createElement("div",{...r,ref:s})}function r2(a){return P.createElement("select",{...a})}function u2(a){const{week:s,...r}=a;return P.createElement("tr",{...r})}function c2(a){return P.createElement("th",{...a})}function d2(a){return P.createElement("thead",{"aria-hidden":!0},P.createElement("tr",{...a}))}function f2(a){const{week:s,...r}=a;return P.createElement("th",{...r})}function m2(a){return P.createElement("th",{...a})}function h2(a){return P.createElement("tbody",{...a})}function p2(a){const{components:s}=pi();return P.createElement(s.Dropdown,{...a})}const g2=Object.freeze(Object.defineProperty({__proto__:null,Button:Qj,CaptionLabel:Vj,Chevron:Xj,Day:Zj,DayButton:Wj,Dropdown:Jj,DropdownNav:$j,Footer:Fj,Month:Ij,MonthCaption:Pj,MonthGrid:e2,Months:t2,MonthsDropdown:n2,Nav:a2,NextMonthButton:l2,Option:s2,PreviousMonthButton:i2,Root:o2,Select:r2,Week:u2,WeekNumber:f2,WeekNumberHeader:m2,Weekday:c2,Weekdays:d2,Weeks:h2,YearsDropdown:p2},Symbol.toStringTag,{value:"Module"}));function ra(a,s,r=!1,u=Rn){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)>=(r?1:0)&&h(m,s)>=(r?1:0)):!r&&m?p(m,s):!r&&d?p(d,s):!1}function Pc(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function ar(a){return!!(a&&typeof a=="object"&&"from"in a)}function ed(a){return!!(a&&typeof a=="object"&&"after"in a)}function td(a){return!!(a&&typeof a=="object"&&"before"in a)}function ly(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function sy(a,s){return Array.isArray(a)&&a.every(s.isDate)}function ua(a,s,r=Rn){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:m,isAfter:h}=r;return u.some(p=>{if(typeof p=="boolean")return p;if(r.isDate(p))return d(a,p);if(sy(p,r))return p.some(y=>d(a,y));if(ar(p))return ra(p,a,!1,r);if(ly(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(Pc(p)){const y=m(p.before,a),S=m(p.after,a),M=y>0,x=S<0;return h(p.before,p.after)?x&&M:M||x}return ed(p)?m(a,p.after)>0:td(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function y2(a,s,r,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:y,broadcastCalendar:S,today:M=d.today()}=s,{isSameDay:x,isSameMonth:b,startOfMonth:_,isBefore:A,endOfMonth:R,isAfter:B}=d,w=r&&_(r),Y=u&&R(u),q={[at.focused]:[],[at.outside]:[],[at.disabled]:[],[at.hidden]:[],[at.today]:[]},Q={};for(const k of a){const{date:j,displayMonth:L}=k,J=!!(L&&!b(j,L)),ee=!!(w&&A(j,w)),de=!!(Y&&B(j,Y)),ve=!!(m&&ua(j,m,d)),oe=!!(h&&ua(j,h,d))||ee||de||!S&&!y&&J||S&&y===!1&&J,Ye=x(j,M);J&&q.outside.push(k),ve&&q.disabled.push(k),oe&&q.hidden.push(k),Ye&&q.today.push(k),p&&Object.keys(p).forEach(Se=>{const $=p?.[Se];$&&ua(j,$,d)&&(Q[Se]?Q[Se].push(k):Q[Se]=[k])})}return k=>{const j={[at.focused]:!1,[at.disabled]:!1,[at.hidden]:!1,[at.outside]:!1,[at.today]:!1},L={};for(const J in q){const ee=q[J];j[J]=ee.some(de=>de===k)}for(const J in Q)L[J]=Q[J].some(ee=>ee===k);return{...j,...L}}}function x2(a,s,r={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[m])=>(r[m]?d.push(r[m]):s[at[m]]?d.push(s[at[m]]):s[jn[m]]&&d.push(s[jn[m]]),d),[s[re.Day]])}function v2(a){return{...g2,...a}}function b2(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(([r,u])=>{r.startsWith("data-")&&(s[r]=u)}),s}function S2(){const a={};for(const s in re)a[re[s]]=`rdp-${re[s]}`;for(const s in at)a[at[s]]=`rdp-${at[s]}`;for(const s in jn)a[jn[s]]=`rdp-${jn[s]}`;for(const s in nn)a[nn[s]]=`rdp-${nn[s]}`;return a}function iy(a,s,r){return(r??new an(s)).formatMonthYear(a)}const N2=iy;function j2(a,s,r){return(r??new an(s)).format(a,"d")}function C2(a,s=Rn){return s.format(a,"LLLL")}function E2(a,s,r){return(r??new an(s)).format(a,"cccccc")}function w2(a,s=Rn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function M2(){return""}function oy(a,s=Rn){return s.format(a,"yyyy")}const T2=oy,z2=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:iy,formatDay:j2,formatMonthCaption:N2,formatMonthDropdown:C2,formatWeekNumber:w2,formatWeekNumberHeader:M2,formatWeekdayName:E2,formatYearCaption:T2,formatYearDropdown:oy},Symbol.toStringTag,{value:"Module"}));function O2(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...z2,...a}}function nd(a,s,r,u){let d=(u??new an(r)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const A2=nd;function ad(a,s,r){return(r??new an(s)).formatMonthYear(a)}const D2=ad;function ry(a,s,r,u){let d=(u??new an(r)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function uy(a){return"Choose the Month"}function cy(){return""}const _2="Go to the Next Month";function dy(a,s){return _2}function fy(a){return"Go to the Previous Month"}function my(a,s,r){return(r??new an(s)).format(a,"cccc")}function hy(a,s){return`Week ${a}`}function py(a){return"Week Number"}function gy(a){return"Choose the Year"}const k2=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:D2,labelDay:A2,labelDayButton:nd,labelGrid:ad,labelGridcell:ry,labelMonthDropdown:uy,labelNav:cy,labelNext:dy,labelPrevious:fy,labelWeekNumber:hy,labelWeekNumberHeader:py,labelWeekday:my,labelYearDropdown:gy},Symbol.toStringTag,{value:"Module"})),Nn=(a,s,r)=>s||(r?typeof r=="function"?r:(...u)=>r:a);function R2(a,s){const r=s.locale?.labels??{};return{...k2,...a??{},labelDayButton:Nn(nd,a?.labelDayButton,r.labelDayButton),labelMonthDropdown:Nn(uy,a?.labelMonthDropdown,r.labelMonthDropdown),labelNext:Nn(dy,a?.labelNext,r.labelNext),labelPrevious:Nn(fy,a?.labelPrevious,r.labelPrevious),labelWeekNumber:Nn(hy,a?.labelWeekNumber,r.labelWeekNumber),labelYearDropdown:Nn(gy,a?.labelYearDropdown,r.labelYearDropdown),labelGrid:Nn(ad,a?.labelGrid,r.labelGrid),labelGridcell:Nn(ry,a?.labelGridcell,r.labelGridcell),labelNav:Nn(cy,a?.labelNav,r.labelNav),labelWeekNumberHeader:Nn(py,a?.labelWeekNumberHeader,r.labelWeekNumberHeader),labelWeekday:Nn(my,a?.labelWeekday,r.labelWeekday)}}function U2(a,s,r,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:y,getMonth:S}=d;return y({start:h(a),end:p(a)}).map(b=>{const _=u.formatMonthDropdown(b,d),A=S(b),R=s&&b<m(s)||r&&b>m(r)||!1;return{value:A,label:_,disabled:R}})}function B2(a,s={},r={}){let u={...s?.[re.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...r?.[d]}}),u}function H2(a,s,r,u){const d=u??a.today(),m=r?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),h=[];for(let p=0;p<7;p++){const y=a.addDays(m,p);h.push(y)}return h}function q2(a,s,r,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:y}=u,S=m(a),M=h(s),x=p({start:S,end:M});return d&&x.reverse(),x.map(b=>{const _=r.formatYearDropdown(b,u);return{value:y(b),label:_,disabled:!1}})}const gi=a=>a instanceof HTMLElement?a:null,Cc=a=>[...a.querySelectorAll("[data-animated-month]")??[]],L2=a=>gi(a.querySelector("[data-animated-month]")),Ec=a=>gi(a.querySelector("[data-animated-caption]")),wc=a=>gi(a.querySelector("[data-animated-weeks]")),Y2=a=>gi(a.querySelector("[data-animated-nav]")),G2=a=>gi(a.querySelector("[data-animated-weekdays]"));function K2(a,s,{classNames:r,months:u,focused:d,dateLib:m}){const h=v.useRef(null),p=v.useRef(u),y=v.useRef(!1);v.useLayoutEffect(()=>{const S=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||S.length===0||u.length!==S.length)return;const M=m.isSameMonth(u[0].date,S[0].date),x=m.isAfter(u[0].date,S[0].date),b=x?r[nn.caption_after_enter]:r[nn.caption_before_enter],_=x?r[nn.weeks_after_enter]:r[nn.weeks_before_enter],A=h.current,R=a.current.cloneNode(!0);if(R instanceof HTMLElement?(Cc(R).forEach(q=>{if(!(q instanceof HTMLElement))return;const Q=L2(q);Q&&q.contains(Q)&&q.removeChild(Q);const k=Ec(q);k&&k.classList.remove(b);const j=wc(q);j&&j.classList.remove(_)}),h.current=R):h.current=null,y.current||M||d)return;const B=A instanceof HTMLElement?Cc(A):[],w=Cc(a.current);if(w?.every(Y=>Y instanceof HTMLElement)&&B&&B.every(Y=>Y instanceof HTMLElement)){y.current=!0,a.current.style.isolation="isolate";const Y=Y2(a.current);Y&&(Y.style.zIndex="1"),w.forEach((q,Q)=>{const k=B[Q];if(!k)return;q.style.position="relative",q.style.overflow="hidden";const j=Ec(q);j&&j.classList.add(b);const L=wc(q);L&&L.classList.add(_);const J=()=>{y.current=!1,a.current&&(a.current.style.isolation=""),Y&&(Y.style.zIndex=""),j&&j.classList.remove(b),L&&L.classList.remove(_),q.style.position="",q.style.overflow="",q.contains(k)&&q.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const ee=G2(k);ee&&(ee.style.opacity="0");const de=Ec(k);de&&(de.classList.add(x?r[nn.caption_before_exit]:r[nn.caption_after_exit]),de.addEventListener("animationend",J));const ve=wc(k);ve&&ve.classList.add(x?r[nn.weeks_before_exit]:r[nn.weeks_after_exit]),q.insertBefore(k,q.firstChild)})}})}function Q2(a,s,r,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:y}=r??{},{addDays:S,differenceInCalendarDays:M,differenceInCalendarMonths:x,endOfBroadcastWeek:b,endOfISOWeek:_,endOfMonth:A,endOfWeek:R,isAfter:B,startOfBroadcastWeek:w,startOfISOWeek:Y,startOfWeek:q}=u,Q=y?w(d,u):h?Y(d):q(d),k=y?b(m):h?_(A(m)):R(A(m)),j=s&&(y?b(s):h?_(s):R(s)),L=j&&B(k,j)?j:k,J=M(L,Q),ee=x(m,d)+1,de=[];for(let Ye=0;Ye<=J;Ye++){const Se=S(Q,Ye);de.push(Se)}const oe=(y?35:42)*ee;if(p&&de.length<oe){const Ye=oe-de.length;for(let Se=0;Se<Ye;Se++){const $=S(de[de.length-1],1);de.push($)}}return de}function V2(a){const s=[];return a.reduce((r,u)=>{const d=u.weeks.reduce((m,h)=>m.concat(h.days.slice()),s.slice());return r.concat(d.slice())},s.slice())}function X2(a,s,r,u){const{numberOfMonths:d=1}=r,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 _p(a,s,r,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let y=d||m||h;const{differenceInCalendarMonths:S,addMonths:M,startOfMonth:x}=u;if(r&&S(r,y)<p-1){const b=-1*(p-1);y=M(r,b)}return s&&S(y,s)<0&&(y=s),x(y)}function Z2(a,s,r,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:y,getISOWeek:S,getWeek:M,startOfBroadcastWeek:x,startOfISOWeek:b,startOfWeek:_}=u,A=a.reduce((R,B)=>{const w=r.broadcastCalendar?x(B,u):r.ISOWeek?b(B):_(B),Y=r.broadcastCalendar?m(B):r.ISOWeek?h(p(B)):y(p(B)),q=s.filter(L=>L>=w&&L<=Y),Q=r.broadcastCalendar?35:42;if(r.fixedWeeks&&q.length<Q){const L=s.filter(J=>{const ee=Q-q.length;return J>Y&&J<=d(Y,ee)});q.push(...L)}const k=q.reduce((L,J)=>{const ee=r.ISOWeek?S(J):M(J),de=L.find(oe=>oe.weekNumber===ee),ve=new ny(J,B,u);return de?de.days.push(ve):L.push(new Kj(ee,[ve])),L},[]),j=new Gj(B,k);return R.push(j),R},[]);return r.reverseMonths?A.reverse():A}function W2(a,s){let{startMonth:r,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:y,endOfYear:S,newDate:M,today:x}=s,{fromYear:b,toYear:_,fromMonth:A,toMonth:R}=a;!r&&A&&(r=A),!r&&b&&(r=s.newDate(b,0,1)),!u&&R&&(u=R),!u&&_&&(u=M(_,11,31));const B=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return r?r=h(r):b?r=M(b,0,1):!r&&B&&(r=d(y(a.today??x(),-100))),u?u=p(u):_?u=M(_,11,31):!u&&B&&(u=S(a.today??x())),[r&&m(r),u&&m(u)]}function J2(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=r,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:y}=u,S=d?m:1,M=h(a);if(!s)return p(M,S);if(!(y(s,a)<m))return p(M,S)}function $2(a,s,r,u){if(r.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=r,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:y}=u,S=d?m??1:1,M=h(a);if(!s)return p(M,-S);if(!(y(M,s)<=0))return p(M,-S)}function F2(a){const s=[];return a.reduce((r,u)=>r.concat(u.weeks.slice()),s.slice())}function lr(a,s){const[r,u]=v.useState(a);return[s===void 0?r:s,u]}function I2(a,s){const[r,u]=W2(a,s),{startOfMonth:d,endOfMonth:m}=s,h=_p(a,r,u,s),[p,y]=lr(h,a.month?h:void 0);v.useEffect(()=>{const Q=_p(a,r,u,s);y(Q)},[a.timeZone]);const{months:S,weeks:M,days:x,previousMonth:b,nextMonth:_}=v.useMemo(()=>{const Q=X2(p,u,{numberOfMonths:a.numberOfMonths},s),k=Q2(Q,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),j=Z2(Q,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),L=F2(j),J=V2(j),ee=$2(p,r,a,s),de=J2(p,u,a,s);return{months:j,weeks:L,days:J,previousMonth:ee,nextMonth:de}},[s,p.getTime(),u?.getTime(),r?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:A,onMonthChange:R}=a,B=Q=>M.some(k=>k.days.some(j=>j.isEqualTo(Q))),w=Q=>{if(A)return;let k=d(Q);r&&k<d(r)&&(k=d(r)),u&&k>d(u)&&(k=d(u)),y(k),R?.(k)};return{months:S,weeks:M,days:x,navStart:r,navEnd:u,previousMonth:b,nextMonth:_,goToMonth:w,goToDay:Q=>{B(Q)||w(Q.date)}}}var _n;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(_n||(_n={}));function kp(a){return!a[at.disabled]&&!a[at.hidden]&&!a[at.outside]}function P2(a,s,r,u){let d,m=-1;for(const h of a){const p=s(h);kp(p)&&(p[at.focused]&&m<_n.FocusedModifier?(d=h,m=_n.FocusedModifier):u?.isEqualTo(h)&&m<_n.LastFocused?(d=h,m=_n.LastFocused):r(h.date)&&m<_n.Selected?(d=h,m=_n.Selected):p[at.today]&&m<_n.Today&&(d=h,m=_n.Today))}return d||(d=a.find(h=>kp(s(h)))),d}function eC(a,s,r,u,d,m,h){const{ISOWeek:p,broadcastCalendar:y}=m,{addDays:S,addMonths:M,addWeeks:x,addYears:b,endOfBroadcastWeek:_,endOfISOWeek:A,endOfWeek:R,max:B,min:w,startOfBroadcastWeek:Y,startOfISOWeek:q,startOfWeek:Q}=h;let j={day:S,week:x,month:M,year:b,startOfWeek:L=>y?Y(L,h):p?q(L):Q(L),endOfWeek:L=>y?_(L):p?A(L):R(L)}[a](r,s==="after"?1:-1);return s==="before"&&u?j=B([u,j]):s==="after"&&d&&(j=w([d,j])),j}function yy(a,s,r,u,d,m,h,p=0){if(p>365)return;const y=eC(a,s,r.date,u,d,m,h),S=!!(m.disabled&&ua(y,m.disabled,h)),M=!!(m.hidden&&ua(y,m.hidden,h)),x=y,b=new ny(y,x,h);return!S&&!M?b:yy(a,s,b,u,d,m,h,p+1)}function tC(a,s,r,u,d){const{autoFocus:m}=a,[h,p]=v.useState(),y=P2(s.days,r,u||(()=>!1),h),[S,M]=v.useState(m?y:void 0);return{isFocusTarget:R=>!!y?.isEqualTo(R),setFocused:M,focused:S,blur:()=>{p(S),M(void 0)},moveFocus:(R,B)=>{if(!S)return;const w=yy(R,B,S,s.navStart,s.navEnd,a,d);w&&(a.disableNavigation&&!s.days.some(q=>q.isEqualTo(w))||(s.goToDay(w),M(w)))}}}function nC(a,s){const{selected:r,required:u,onSelect:d}=a,[m,h]=lr(r,d?r:void 0),p=d?r:m,{isSameDay:y}=s,S=_=>p?.some(A=>y(A,_))??!1,{min:M,max:x}=a;return{selected:p,select:(_,A,R)=>{let B=[...p??[]];if(S(_)){if(p?.length===M||u&&p?.length===1)return;B=p?.filter(w=>!y(w,_))}else p?.length===x?B=[_]:B=[...B,_];return d||h(B),d?.(B,_,A,R),B},isSelected:S}}function aC(a,s,r=0,u=0,d=!1,m=Rn){const{from:h,to:p}=s||{},{isSameDay:y,isAfter:S,isBefore:M}=m;let x;if(!h&&!p)x={from:a,to:r>0?void 0:a};else if(h&&!p)y(h,a)?r===0?x={from:h,to:a}:d?x={from:h,to:void 0}:x=void 0:M(a,h)?x={from:a,to:h}:x={from:h,to:a};else if(h&&p)if(y(h,a)&&y(p,a))d?x={from:h,to:p}:x=void 0;else if(y(h,a))x={from:h,to:r>0?void 0:a};else if(y(p,a))x={from:a,to:r>0?void 0:a};else if(M(a,h))x={from:a,to:p};else if(S(a,h))x={from:h,to:a};else if(S(a,p))x={from:h,to:a};else throw new Error("Invalid range");if(x?.from&&x?.to){const b=m.differenceInCalendarDays(x.to,x.from);u>0&&b>u?x={from:a,to:void 0}:r>1&&b<r&&(x={from:a,to:void 0})}return x}function lC(a,s,r=Rn){const u=Array.isArray(s)?s:[s];let d=a.from;const m=r.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=r.addDays(d,1)}return!1}function Rp(a,s,r=Rn){return ra(a,s.from,!1,r)||ra(a,s.to,!1,r)||ra(s,a.from,!1,r)||ra(s,a.to,!1,r)}function sC(a,s,r=Rn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:r.isDate(p)?ra(a,p,!1,r):sy(p,r)?p.some(y=>ra(a,y,!1,r)):ar(p)?p.from&&p.to?Rp(a,{from:p.from,to:p.to},r):!1:ly(p)?lC(a,p.dayOfWeek,r):Pc(p)?r.isAfter(p.before,p.after)?Rp(a,{from:r.addDays(p.after,1),to:r.addDays(p.before,-1)},r):ua(a.from,p,r)||ua(a.to,p,r):ed(p)||td(p)?ua(a.from,p,r)||ua(a.to,p,r):!1))return!0;const h=u.filter(p=>typeof p=="function");if(h.length){let p=a.from;const y=r.differenceInCalendarDays(a.to,a.from);for(let S=0;S<=y;S++){if(h.some(M=>M(p)))return!0;p=r.addDays(p,1)}}return!1}function iC(a,s){const{disabled:r,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,y]=lr(d,h?d:void 0),S=h?d:p;return{selected:S,select:(b,_,A)=>{const{min:R,max:B}=a,w=b?aC(b,S,R,B,m,s):void 0;return u&&r&&w?.from&&w.to&&sC({from:w.from,to:w.to},r,s)&&(w.from=b,w.to=void 0),h||y(w),h?.(w,b,_,A),w},isSelected:b=>S&&ra(S,b,!1,s)}}function oC(a,s){const{selected:r,required:u,onSelect:d}=a,[m,h]=lr(r,d?r:void 0),p=d?r:m,{isSameDay:y}=s;return{selected:p,select:(x,b,_)=>{let A=x;return!u&&p&&p&&y(x,p)&&(A=void 0),d||h(A),d?.(A,x,b,_),A},isSelected:x=>p?y(p,x):!1}}function rC(a,s){const r=oC(a,s),u=nC(a,s),d=iC(a,s);switch(a.mode){case"single":return r;case"multiple":return u;case"range":return d;default:return}}function Mt(a,s){return a instanceof oa&&a.timeZone===s?a:new oa(a,s)}function Up(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Mt(a,s):Array.isArray(a)?a.map(r=>r instanceof Date?Mt(r,s):r):ar(a)?{...a,from:a.from?Mt(a.from,s):a.from,to:a.to?Mt(a.to,s):a.to}:Pc(a)?{before:Mt(a.before,s),after:Mt(a.after,s)}:ed(a)?{after:Mt(a.after,s)}:td(a)?{before:Mt(a.before,s)}:a}function Mc(a,s){return a&&(Array.isArray(a)?a.map(r=>Up(r,s)):Up(a,s))}function uC(a){let s=a;const r=s.timeZone;if(r&&(s={...a,timeZone:r},s.today&&(s.today=Mt(s.today,r)),s.month&&(s.month=Mt(s.month,r)),s.defaultMonth&&(s.defaultMonth=Mt(s.defaultMonth,r)),s.startMonth&&(s.startMonth=Mt(s.startMonth,r)),s.endMonth&&(s.endMonth=Mt(s.endMonth,r)),s.mode==="single"&&s.selected?s.selected=Mt(s.selected,r):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(ie=>Mt(ie,r)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Mt(s.selected.from,r):s.selected.from,to:s.selected.to?Mt(s.selected.to,r):s.selected.to}),s.disabled!==void 0&&(s.disabled=Mc(s.disabled,r)),s.hidden!==void 0&&(s.hidden=Mc(s.hidden,r)),s.modifiers)){const ie={};Object.keys(s.modifiers).forEach(be=>{ie[be]=Mc(s.modifiers?.[be],r)}),s.modifiers=ie}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:y}=v.useMemo(()=>{const ie={...ty,...s.locale},be=new an({locale:ie,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:be,components:v2(s.components),formatters:O2(s.formatters),labels:R2(s.labels,be.options),locale:ie,classNames:{...S2(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:h.today()});const{captionLayout:S,mode:M,navLayout:x,numberOfMonths:b=1,onDayBlur:_,onDayClick:A,onDayFocus:R,onDayKeyDown:B,onDayMouseEnter:w,onDayMouseLeave:Y,onNextClick:q,onPrevClick:Q,showWeekNumber:k,styles:j}=s,{formatCaption:L,formatDay:J,formatMonthDropdown:ee,formatWeekNumber:de,formatWeekNumberHeader:ve,formatWeekdayName:oe,formatYearDropdown:Ye}=d,Se=I2(s,h),{days:$,months:T,navStart:Z,navEnd:ae,previousMonth:ye,nextMonth:xe,goToMonth:Ae}=Se,ce=y2($,s,Z,ae,h),{isSelected:X,select:F,selected:le}=rC(s,h)??{},{blur:I,focused:ne,isFocusTarget:ge,moveFocus:De,setFocused:Ge}=tC(s,Se,ce,X??(()=>!1),h),{labelDayButton:pt,labelGridcell:gt,labelGrid:Qe,labelMonthDropdown:et,labelNav:Dt,labelPrevious:Kt,labelNext:Un,labelWeekday:je,labelWeekNumber:Qt,labelWeekNumberHeader:En,labelYearDropdown:Vt}=m,ca=v.useMemo(()=>H2(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Bn=M!==void 0||A!==void 0,ot=v.useCallback(()=>{ye&&(Ae(ye),Q?.(ye))},[ye,Ae,Q]),Xt=v.useCallback(()=>{xe&&(Ae(xe),q?.(xe))},[Ae,xe,q]),Hn=v.useCallback((ie,be)=>me=>{me.preventDefault(),me.stopPropagation(),Ge(ie),!be.disabled&&(F?.(ie.date,be,me),A?.(ie.date,be,me))},[F,A,Ge]),qa=v.useCallback((ie,be)=>me=>{Ge(ie),R?.(ie.date,be,me)},[R,Ge]),wn=v.useCallback((ie,be)=>me=>{I(),_?.(ie.date,be,me)},[I,_]),Mn=v.useCallback((ie,be)=>me=>{const ze={ArrowLeft:[me.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[me.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[me.shiftKey?"year":"week","after"],ArrowUp:[me.shiftKey?"year":"week","before"],PageUp:[me.shiftKey?"year":"month","before"],PageDown:[me.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ze[me.key]){me.preventDefault(),me.stopPropagation();const[Fe,pe]=ze[me.key];De(Fe,pe)}B?.(ie.date,be,me)},[De,B,s.dir]),fl=v.useCallback((ie,be)=>me=>{w?.(ie.date,be,me)},[w]),ls=v.useCallback((ie,be)=>me=>{Y?.(ie.date,be,me)},[Y]),ss=v.useCallback(ie=>be=>{const me=Number(be.target.value),ze=h.setMonth(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),qn=v.useCallback(ie=>be=>{const me=Number(be.target.value),ze=h.setYear(h.startOfMonth(ie),me);Ae(ze)},[h,Ae]),{className:W,style:Me}=v.useMemo(()=>({className:[y[re.Root],s.className].filter(Boolean).join(" "),style:{...j?.[re.Root],...s.style}}),[y,s.className,s.style,j]),fe=b2(s),Te=v.useRef(null);K2(Te,!!s.animate,{classNames:y,months:T,focused:ne,dateLib:h});const tt={dayPickerProps:s,selected:le,select:F,isSelected:X,months:T,nextMonth:xe,previousMonth:ye,goToMonth:Ae,getModifiers:ce,components:u,classNames:y,styles:j,labels:m,formatters:d};return P.createElement(ay.Provider,{value:tt},P.createElement(u.Root,{rootRef:s.animate?Te:void 0,className:W,style:Me,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...fe},P.createElement(u.Months,{className:y[re.Months],style:j?.[re.Months]},!s.hideNavigation&&!x&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:y[re.Nav],style:j?.[re.Nav],"aria-label":Dt(),onPreviousClick:ot,onNextClick:Xt,previousMonth:ye,nextMonth:xe}),T.map((ie,be)=>P.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:y[re.Month],style:j?.[re.Month],key:be,displayIndex:be,calendarMonth:ie},x==="around"&&!s.hideNavigation&&be===0&&P.createElement(u.PreviousMonthButton,{type:"button",className:y[re.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Kt(ye),onClick:ot,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:ye?void 0:!0,className:y[re.Chevron],orientation:s.dir==="rtl"?"right":"left"})),P.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:y[re.MonthCaption],style:j?.[re.MonthCaption],calendarMonth:ie,displayIndex:be},S?.startsWith("dropdown")?P.createElement(u.DropdownNav,{className:y[re.Dropdowns],style:j?.[re.Dropdowns]},(()=>{const me=S==="dropdown"||S==="dropdown-months"?P.createElement(u.MonthsDropdown,{key:"month",className:y[re.MonthsDropdown],"aria-label":et(),classNames:y,components:u,disabled:!!s.disableNavigation,onChange:ss(ie.date),options:U2(ie.date,Z,ae,d,h),style:j?.[re.Dropdown],value:h.getMonth(ie.date)}):P.createElement("span",{key:"month"},ee(ie.date,h)),ze=S==="dropdown"||S==="dropdown-years"?P.createElement(u.YearsDropdown,{key:"year",className:y[re.YearsDropdown],"aria-label":Vt(h.options),classNames:y,components:u,disabled:!!s.disableNavigation,onChange:qn(ie.date),options:q2(Z,ae,d,h,!!s.reverseYears),style:j?.[re.Dropdown],value:h.getYear(ie.date)}):P.createElement("span",{key:"year"},Ye(ie.date,h));return h.getMonthYearOrder()==="year-first"?[ze,me]:[me,ze]})(),P.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},L(ie.date,h.options,h))):P.createElement(u.CaptionLabel,{className:y[re.CaptionLabel],role:"status","aria-live":"polite"},L(ie.date,h.options,h))),x==="around"&&!s.hideNavigation&&be===b-1&&P.createElement(u.NextMonthButton,{type:"button",className:y[re.NextMonthButton],tabIndex:xe?void 0:-1,"aria-disabled":xe?void 0:!0,"aria-label":Un(xe),onClick:Xt,"data-animated-button":s.animate?"true":void 0},P.createElement(u.Chevron,{disabled:xe?void 0:!0,className:y[re.Chevron],orientation:s.dir==="rtl"?"left":"right"})),be===b-1&&x==="after"&&!s.hideNavigation&&P.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:y[re.Nav],style:j?.[re.Nav],"aria-label":Dt(),onPreviousClick:ot,onNextClick:Xt,previousMonth:ye,nextMonth:xe}),P.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":M==="multiple"||M==="range","aria-label":Qe(ie.date,h.options,h)||void 0,className:y[re.MonthGrid],style:j?.[re.MonthGrid]},!s.hideWeekdays&&P.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:y[re.Weekdays],style:j?.[re.Weekdays]},k&&P.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:y[re.WeekNumberHeader],style:j?.[re.WeekNumberHeader],scope:"col"},ve()),ca.map(me=>P.createElement(u.Weekday,{"aria-label":je(me,h.options,h),className:y[re.Weekday],key:String(me),style:j?.[re.Weekday],scope:"col"},oe(me,h.options,h)))),P.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:y[re.Weeks],style:j?.[re.Weeks]},ie.weeks.map(me=>P.createElement(u.Week,{className:y[re.Week],key:me.weekNumber,style:j?.[re.Week],week:me},k&&P.createElement(u.WeekNumber,{week:me,style:j?.[re.WeekNumber],"aria-label":Qt(me.weekNumber,{locale:p}),className:y[re.WeekNumber],scope:"row",role:"rowheader"},de(me.weekNumber,h)),me.days.map(ze=>{const{date:Fe}=ze,pe=ce(ze);if(pe[at.focused]=!pe.hidden&&!!ne?.isEqualTo(ze),pe[jn.selected]=X?.(Fe)||pe.selected,ar(le)){const{from:Zt,to:yn}=le;pe[jn.range_start]=!!(Zt&&yn&&h.isSameDay(Fe,Zt)),pe[jn.range_end]=!!(Zt&&yn&&h.isSameDay(Fe,yn)),pe[jn.range_middle]=ra(le,Fe,!0,h)}const Tt=B2(pe,j,s.modifiersStyles),Ln=x2(pe,y,s.modifiersClassNames),xt=!Bn&&!pe.hidden?gt(Fe,pe,h.options,h):void 0;return P.createElement(u.Day,{key:`${ze.isoDate}_${ze.displayMonthId}`,day:ze,modifiers:pe,className:Ln.join(" "),style:Tt,role:"gridcell","aria-selected":pe.selected||void 0,"aria-label":xt,"data-day":ze.isoDate,"data-month":ze.outside?ze.dateMonthId:void 0,"data-selected":pe.selected||void 0,"data-disabled":pe.disabled||void 0,"data-hidden":pe.hidden||void 0,"data-outside":ze.outside||void 0,"data-focused":pe.focused||void 0,"data-today":pe.today||void 0},!pe.hidden&&Bn?P.createElement(u.DayButton,{className:y[re.DayButton],style:j?.[re.DayButton],type:"button",day:ze,modifiers:pe,disabled:!pe.focused&&pe.disabled||void 0,"aria-disabled":pe.focused&&pe.disabled||void 0,tabIndex:ge(ze)?0:-1,"aria-label":pt(Fe,pe,h.options,h),onClick:Hn(ze,pe),onBlur:wn(ze,pe),onFocus:qa(ze,pe),onKeyDown:Mn(ze,pe),onMouseEnter:fl(ze,pe),onMouseLeave:ls(ze,pe)},J(Fe,h.options,h)):!pe.hidden&&J(ze.date,h.options,h))})))))))),s.footer&&P.createElement(u.Footer,{className:y[re.Footer],style:j?.[re.Footer],role:"status","aria-live":"polite"},s.footer)))}function cC({className:a,classNames:s,showOutsideDays:r=!0,...u}){return o.jsx(uC,{showOutsideDays:r,className:V("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:V(ko({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:V(ko({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:V("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:V(ko({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:V("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:V("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:V("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:V("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"?xb:d==="right"?Ko:d==="up"?Bc:Jo;return o.jsx(p,{className:V("h-4 w-4",m),...h})}},...u})}cC.displayName="Calendar";const dC=v.lazy(()=>At(()=>import("./index-CV_o8KZD.js"),__vite__mapDeps([13,1,2,14,4,5,7,15,6,8,9])).then(a=>({default:a.AnalyticsPage}))),fC=v.lazy(()=>At(()=>import("./api-Bi24p47r.js"),__vite__mapDeps([16,1,2,5,17,18,6,4,14,7,8,9])).then(a=>({default:a.ApiPage}))),mC=v.lazy(()=>At(()=>import("./cliproxy-CsE7HKWc.js"),__vite__mapDeps([19,1,2,5,6,4,14,17,18,3,7,8,9])).then(a=>({default:a.CliproxyPage}))),hC=v.lazy(()=>At(()=>import("./cliproxy-control-panel-Cahd6g6e.js"),__vite__mapDeps([20,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),pC=v.lazy(()=>At(()=>import("./copilot-B4AE6FGx.js"),__vite__mapDeps([21,1,2,5,17,18,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),gC=v.lazy(()=>At(()=>import("./accounts-CYPk9fa-.js"),__vite__mapDeps([22,1,2,5,18,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),yC=v.lazy(()=>At(()=>Promise.resolve().then(()=>_j),void 0).then(a=>({default:a.SettingsPage}))),xC=v.lazy(()=>At(()=>import("./health-BINs7JKH.js"),__vite__mapDeps([23,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),vC=v.lazy(()=>At(()=>import("./shared-bCN7WjG_.js"),__vite__mapDeps([24,1,2,14,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function bC(){return o.jsx(fv,{client:_b,children:o.jsx(Rb,{defaultTheme:"system",storageKey:"vite-ui-theme",children:o.jsx(Ub,{children:o.jsxs(uv,{children:[o.jsx(cv,{children:o.jsxs(Sn,{element:o.jsx(QS,{}),children:[o.jsx(Sn,{path:"/",element:o.jsx(RN,{})}),o.jsx(Sn,{path:"/analytics",element:o.jsx(dC,{})}),o.jsx(Sn,{path:"/providers",element:o.jsx(fC,{})}),o.jsx(Sn,{path:"/cliproxy",element:o.jsx(mC,{})}),o.jsx(Sn,{path:"/cliproxy/control-panel",element:o.jsx(hC,{})}),o.jsx(Sn,{path:"/copilot",element:o.jsx(pC,{})}),o.jsx(Sn,{path:"/accounts",element:o.jsx(gC,{})}),o.jsx(Sn,{path:"/settings",element:o.jsx(yC,{})}),o.jsx(Sn,{path:"/health",element:o.jsx(xC,{})}),o.jsx(Sn,{path:"/shared",element:o.jsx(vC,{})})]})}),o.jsx(mv,{position:"top-right"})]})})})})}const xy=document.getElementById("root");if(!xy)throw new Error("Root element not found. Failed to mount React application.");Ob.createRoot(xy).render(o.jsx(v.StrictMode,{children:o.jsx(bC,{})}));export{Lc as $,xS as A,Ha as B,cC as C,Gg as D,Fc as E,il as F,Dc as G,FC as H,Ra as I,PC as J,eE as K,Dn as L,Vg as M,tE as N,nE as O,hg as P,ij as Q,IC as R,Le as S,fi as T,lE as U,oj as V,uj as W,w1 as X,AC as Y,RC as Z,UC as _,St as a,Yc as a0,Gc as a1,Kc as a2,Qc as a3,BC as a4,aE as a5,rj as a6,US as a7,g1 as a8,Yb as a9,Yg as aA,Ig as aB,Nj as aC,Cj as aD,$g as aE,Lb as aa,Fo as ab,fj as ac,Hb as ad,qb as ae,ht as af,HC as ag,qC as ah,LC as ai,YC as aj,sE as ak,GC as al,VC as am,KC as an,QC as ao,OC as ap,_C as aq,kC as ar,DC as as,Xg as at,At as au,ko as av,DN as aw,XC as ax,qg as ay,Lg as az,iE as b,V as c,oE as d,kj as e,u1 as f,zC as g,c1 as h,dl as i,rE as j,mi as k,hi as l,jp as m,$N as n,$C as o,XN as p,ZC as q,JC as r,LN as s,BN as t,qc as u,QN as v,ZN as w,WC as x,gS as y,yS as z};