@kaitranntt/ccs 7.37.1 → 7.38.0-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.
- package/config/base-qwen.settings.json +2 -2
- package/dist/api/services/provider-presets.js +1 -1
- package/dist/api/services/provider-presets.js.map +1 -1
- package/dist/cliproxy/catalog-cache.d.ts +39 -0
- package/dist/cliproxy/catalog-cache.d.ts.map +1 -0
- package/dist/cliproxy/catalog-cache.js +246 -0
- package/dist/cliproxy/catalog-cache.js.map +1 -0
- package/dist/cliproxy/config/extended-context-config.d.ts +39 -0
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -0
- package/dist/cliproxy/config/extended-context-config.js +114 -0
- package/dist/cliproxy/config/extended-context-config.js.map +1 -0
- package/dist/cliproxy/config/generator.d.ts +3 -2
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +87 -5
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/config/index.d.ts +1 -0
- package/dist/cliproxy/config/index.d.ts.map +1 -1
- package/dist/cliproxy/config/index.js +1 -0
- package/dist/cliproxy/config/index.js.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +2 -0
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +5 -1
- package/dist/cliproxy/executor/env-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +22 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/index.d.ts +2 -1
- package/dist/cliproxy/index.d.ts.map +1 -1
- package/dist/cliproxy/index.js +10 -1
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/management-api-client.d.ts +6 -1
- package/dist/cliproxy/management-api-client.d.ts.map +1 -1
- package/dist/cliproxy/management-api-client.js +9 -0
- package/dist/cliproxy/management-api-client.js.map +1 -1
- package/dist/cliproxy/management-api-types.d.ts +30 -0
- package/dist/cliproxy/management-api-types.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +12 -0
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +53 -3
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/platform-detector.d.ts +4 -4
- package/dist/cliproxy/platform-detector.d.ts.map +1 -1
- package/dist/cliproxy/platform-detector.js +2 -2
- package/dist/cliproxy/platform-detector.js.map +1 -1
- package/dist/commands/cliproxy/catalog-subcommand.d.ts +7 -0
- package/dist/commands/cliproxy/catalog-subcommand.d.ts.map +1 -0
- package/dist/commands/cliproxy/catalog-subcommand.js +123 -0
- package/dist/commands/cliproxy/catalog-subcommand.js.map +1 -0
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +8 -0
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +15 -0
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +13 -0
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/version-command.js +1 -1
- package/dist/commands/version-command.js.map +1 -1
- package/dist/ui/assets/{accounts-D0KU1a-4.js → accounts-ResKjvou.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BNRDV_Kh.js → alert-dialog-BnSvEwhd.js} +1 -1
- package/dist/ui/assets/{api-ClkFu9LY.js → api-ClPWraVr.js} +1 -1
- package/dist/ui/assets/{auth-section-CNhNN1Jp.js → auth-section-CZmgtezT.js} +1 -1
- package/dist/ui/assets/{backups-section-CZ721HIu.js → backups-section-CcQsXemH.js} +1 -1
- package/dist/ui/assets/cliproxy-C0JgtLfO.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel-T9i_Ldh0.js → cliproxy-control-panel-CBO7xTqe.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-Cy1__gRc.js → confirm-dialog-Cjs1FPCy.js} +1 -1
- package/dist/ui/assets/{copilot-Cdqs2Jbh.js → copilot-DCA0pQV3.js} +2 -2
- package/dist/ui/assets/{globalenv-section-BEKtYN6I.js → globalenv-section-D_GVHsDN.js} +1 -1
- package/dist/ui/assets/{health-BaHazGgS.js → health-riN3OSz-.js} +1 -1
- package/dist/ui/assets/{index-CiULLjNI.js → index-7gcYb5Oq.js} +3 -3
- package/dist/ui/assets/{index-PjscK1jS.js → index-BXTtPkoG.js} +1 -1
- package/dist/ui/assets/{index-BZn6kF0u.js → index-BjiZGSfI.js} +1 -1
- package/dist/ui/assets/{index-BTBpI5th.js → index-CK0URaBN.js} +1 -1
- package/dist/ui/assets/{index-C2MS84sf.js → index-sdtPg8Gr.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-BY6Lnr80.js → proxy-status-widget-B-LQxeOH.js} +1 -1
- package/dist/ui/assets/{shared-dZGNvBe9.js → shared-PuUIRrgy.js} +1 -1
- package/dist/ui/assets/{switch-BCFbehJz.js → switch-CCYYFslZ.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/utils/shell-executor.d.ts +6 -0
- package/dist/utils/shell-executor.d.ts.map +1 -1
- package/dist/utils/shell-executor.js +42 -4
- package/dist/utils/shell-executor.js.map +1 -1
- package/dist/utils/ui/init.d.ts +1 -1
- package/dist/utils/ui/init.d.ts.map +1 -1
- package/dist/utils/ui/init.js +25 -36
- package/dist/utils/ui/init.js.map +1 -1
- package/dist/web-server/routes/catalog-routes.d.ts +3 -0
- package/dist/web-server/routes/catalog-routes.d.ts.map +1 -0
- package/dist/web-server/routes/catalog-routes.js +27 -0
- package/dist/web-server/routes/catalog-routes.js.map +1 -0
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +2 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/code-reviewer.ts +1 -1
- package/dist/ui/assets/cliproxy-DeGucfVg.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CK0URaBN.js","assets/radix-ui-qEZD5MMp.js","assets/react-vendor-CNOkPC89.js","assets/switch-CCYYFslZ.js","assets/icons-D5eAI-GR.js","assets/tanstack-De4wvi8X.js","assets/notifications-B2HqRBj7.js","assets/utils-CzKF5WmX.js","assets/form-utils-C-pVd1--.js","assets/code-highlight-BRUf_pqB.js","assets/globalenv-section-D_GVHsDN.js","assets/index-sdtPg8Gr.js","assets/index-BjiZGSfI.js","assets/proxy-status-widget-B-LQxeOH.js","assets/alert-dialog-BnSvEwhd.js","assets/auth-section-CZmgtezT.js","assets/backups-section-CcQsXemH.js","assets/index-BXTtPkoG.js","assets/charts-BBPXh0Ar.js","assets/api-ClPWraVr.js","assets/confirm-dialog-Cjs1FPCy.js","assets/cliproxy-C0JgtLfO.js","assets/cliproxy-control-panel-CBO7xTqe.js","assets/copilot-DCA0pQV3.js","assets/accounts-ResKjvou.js","assets/health-riN3OSz-.js","assets/shared-PuUIRrgy.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{j as i,S as Qr,R as ug,C as cg,a as dg,T as fg,D as mg,P as hg,O as pg,b as nv,c as av,d as lv,e as sv,f as iv,A as rv,g as ov,h as uv,i as cv,k as dv,l as fv,m as mv,n as hv,I as pv,o as gg,V as gv,p as xv,q as xg,r as yv,L as yg,s as vg,t as bg,u as vv,v as bv,w as Sg,x as Sv,y as jg,z as Ng,B as jv,E as Cg,F as Nv,G as wg,H as Eg,J as Cv,K as wv,M as Mg,N as Ev,Q as Mv,U as Tv,W as Ov,X as Tg,Y as Av,Z as zv,_ as Dv}from"./radix-ui-qEZD5MMp.js";import{e as Og,f as _v,r as y,u as Yc,O as _c,N as kv,h as Gc,L as kc,R as Rv,g as Uv,i as qv,c as I,B as Bv,j as Hv,k as nn}from"./react-vendor-CNOkPC89.js";import{Q as Lv,u as At,a as ut,b as mt,c as Yv}from"./tanstack-De4wvi8X.js";import{t as le,T as Gv}from"./notifications-B2HqRBj7.js";import{L as Un,X as xi,P as Kv,H as Qv,C as Vv,K as Ag,G as Xv,Z as zg,a as Dg,F as _g,U as kg,A as fi,S as Zv,b as Vr,c as Wv,M as $v,E as Xr,d as Zr,B as Jv,R as mi,W as Pv,e as Fv,f as Iv,g as eb,h as mp,i as hp,j as rs,k as Kc,l as Hr,m as Rg,n as tb,o as nb,p as Qc,q as Wr,r as Vc,s as ab,t as lb,u as $r,v as sb,T as Qa,w as ib,x as rb,I as Jr,y as ob,z as ub,D as cb,J as db,N as fb,O as mb,Q as hb,V as Xc,Y as Pr,_ as Zc,$ as pp,a0 as pb,a1 as Wc,a2 as gb,a3 as xb,a4 as yb,a5 as vb,a6 as gp,a7 as bb,a8 as Sb}from"./icons-D5eAI-GR.js";import{t as jb,c as Nb,a as Fr,e as li,f as ri,b as Cb,d as wb,g as Eb,h as Mb,i as Tb,j as Ob,k as Ab,l as zb,m as Db,n as _b,o as kb,p as Rb,q as Ub,r as qb,s as Bb,u as Hb,v as Lb,w as Yb,x as Gb,y as Kb,z as Qb,A as Vb,B as Xb,C as Zb,D as Wb,E as $b,F as Jb,G as Pb,H as Fb,I as Ib,J as eS}from"./utils-CzKF5WmX.js";import{o as xp,s as yp,p as tS,a as nS,$ as aS,b as Ug,c as lS,d as cl,u as sS,e as iS}from"./form-utils-C-pVd1--.js";import{H as rS,t as vp}from"./code-highlight-BRUf_pqB.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))u(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const h of m.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&u(h)}).observe(document,{childList:!0,subtree:!0});function o(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function u(d){if(d.ep)return;d.ep=!0;const m=o(d);fetch(d.href,m)}})();var xc={exports:{}},si={},yc={exports:{}},vc={};var bp;function oS(){return bp||(bp=1,(function(a){function s(O,W){var se=O.length;O.push(W);e:for(;0<se;){var ye=se-1>>>1,ve=O[ye];if(0<d(ve,W))O[ye]=W,O[se]=ve,se=ye;else break e}}function o(O){return O.length===0?null:O[0]}function u(O){if(O.length===0)return null;var W=O[0],se=O.pop();if(se!==W){O[0]=se;e:for(var ye=0,ve=O.length,De=ve>>>1;ye<De;){var ze=2*(ye+1)-1,X=O[ze],J=ze+1,ne=O[J];if(0>d(X,se))J<ve&&0>d(ne,X)?(O[ye]=ne,O[J]=se,ye=J):(O[ye]=X,O[ze]=se,ye=ze);else if(J<ve&&0>d(ne,se))O[ye]=ne,O[J]=se,ye=J;else break e}}return W}function d(O,W){var se=O.sortIndex-W.sortIndex;return se!==0?se:O.id-W.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;a.unstable_now=function(){return m.now()}}else{var h=Date,p=h.now();a.unstable_now=function(){return h.now()-p}}var x=[],b=[],w=1,v=null,S=3,M=!1,A=!1,U=!1,_=!1,T=typeof setTimeout=="function"?setTimeout:null,K=typeof clearTimeout=="function"?clearTimeout:null,B=typeof setImmediate<"u"?setImmediate:null;function L(O){for(var W=o(b);W!==null;){if(W.callback===null)u(b);else if(W.startTime<=O)u(b),W.sortIndex=W.expirationTime,s(x,W);else break;W=o(b)}}function k(O){if(U=!1,L(O),!A)if(o(x)!==null)A=!0,N||(N=!0,oe());else{var W=o(b);W!==null&&P(k,W.startTime-O)}}var N=!1,H=-1,Z=5,te=-1;function ce(){return _?!0:!(a.unstable_now()-te<Z)}function be(){if(_=!1,N){var O=a.unstable_now();te=O;var W=!0;try{e:{A=!1,U&&(U=!1,K(H),H=-1),M=!0;var se=S;try{t:{for(L(O),v=o(x);v!==null&&!(v.expirationTime>O&&ce());){var ye=v.callback;if(typeof ye=="function"){v.callback=null,S=v.priorityLevel;var ve=ye(v.expirationTime<=O);if(O=a.unstable_now(),typeof ve=="function"){v.callback=ve,L(O),W=!0;break t}v===o(x)&&u(x),L(O)}else u(x);v=o(x)}if(v!==null)W=!0;else{var De=o(b);De!==null&&P(k,De.startTime-O),W=!1}}break e}finally{v=null,S=se,M=!1}W=void 0}}finally{W?oe():N=!1}}}var oe;if(typeof B=="function")oe=function(){B(be)};else if(typeof MessageChannel<"u"){var Ye=new MessageChannel,je=Ye.port2;Ye.port1.onmessage=be,oe=function(){je.postMessage(null)}}else oe=function(){T(be,0)};function P(O,W){H=T(function(){O(a.unstable_now())},W)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(O){O.callback=null},a.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Z=0<O?Math.floor(1e3/O):5},a.unstable_getCurrentPriorityLevel=function(){return S},a.unstable_next=function(O){switch(S){case 1:case 2:case 3:var W=3;break;default:W=S}var se=S;S=W;try{return O()}finally{S=se}},a.unstable_requestPaint=function(){_=!0},a.unstable_runWithPriority=function(O,W){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var se=S;S=O;try{return W()}finally{S=se}},a.unstable_scheduleCallback=function(O,W,se){var ye=a.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0<se?ye+se:ye):se=ye,O){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=se+ve,O={id:w++,callback:W,priorityLevel:O,startTime:se,expirationTime:ve,sortIndex:-1},se>ye?(O.sortIndex=se,s(b,O),o(x)===null&&O===o(b)&&(U?(K(H),H=-1):U=!0,P(k,se-ye))):(O.sortIndex=ve,s(x,O),A||M||(A=!0,N||(N=!0,oe()))),O},a.unstable_shouldYield=ce,a.unstable_wrapCallback=function(O){var W=S;return function(){var se=S;S=W;try{return O.apply(this,arguments)}finally{S=se}}}})(vc)),vc}var Sp;function uS(){return Sp||(Sp=1,yc.exports=oS()),yc.exports}var jp;function cS(){if(jp)return si;jp=1;var a=uS(),s=Og(),o=_v();function u(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function m(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(m(e)!==e)throw Error(u(188))}function b(e){var t=e.alternate;if(!t){if(t=m(e),t===null)throw Error(u(188));return t!==e?null:e}for(var n=e,l=t;;){var r=n.return;if(r===null)break;var c=r.alternate;if(c===null){if(l=r.return,l!==null){n=l;continue}break}if(r.child===c.child){for(c=r.child;c;){if(c===n)return x(r),e;if(c===l)return x(r),t;c=c.sibling}throw Error(u(188))}if(n.return!==l.return)n=r,l=c;else{for(var f=!1,g=r.child;g;){if(g===n){f=!0,n=r,l=c;break}if(g===l){f=!0,l=r,n=c;break}g=g.sibling}if(!f){for(g=c.child;g;){if(g===n){f=!0,n=c,l=r;break}if(g===l){f=!0,l=c,n=r;break}g=g.sibling}if(!f)throw Error(u(189))}}if(n.alternate!==l)throw Error(u(190))}if(n.tag!==3)throw Error(u(188));return n.stateNode.current===n?e:t}function w(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=w(e),t!==null)return t;e=e.sibling}return null}var v=Object.assign,S=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),U=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),K=Symbol.for("react.consumer"),B=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),te=Symbol.for("react.activity"),ce=Symbol.for("react.memo_cache_sentinel"),be=Symbol.iterator;function oe(e){return e===null||typeof e!="object"?null:(e=be&&e[be]||e["@@iterator"],typeof e=="function"?e:null)}var Ye=Symbol.for("react.client.reference");function je(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Ye?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case U:return"Fragment";case T:return"Profiler";case _:return"StrictMode";case k:return"Suspense";case N:return"SuspenseList";case te:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case A:return"Portal";case B:return e.displayName||"Context";case K:return(e._context.displayName||"Context")+".Consumer";case L:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return t=e.displayName||null,t!==null?t:je(e.type)||"Memo";case Z:t=e._payload,e=e._init;try{return je(e(t))}catch{}}return null}var P=Array.isArray,O=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ye=[],ve=-1;function De(e){return{current:e}}function ze(e){0>ve||(e.current=ye[ve],ye[ve]=null,ve--)}function X(e,t){ve++,ye[ve]=e.current,e.current=t}var J=De(null),ne=De(null),F=De(null),ee=De(null);function fe(e,t){switch(X(F,t),X(ne,e),X(J,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Uh(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Uh(t),e=qh(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ze(J),X(J,e)}function Ae(){ze(J),ze(ne),ze(F)}function Ge(e){e.memoizedState!==null&&X(ee,e);var t=J.current,n=qh(t,e.type);t!==n&&(X(ne,e),X(J,n))}function yt(e){ne.current===e&&(ze(J),ze(ne)),ee.current===e&&(ze(ee),ei._currentValue=se)}var vt,Qe;function tt(e){if(vt===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);vt=t&&t[1]||"",Qe=-1<n.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+vt+e+Qe}var kt=!1;function Qt(e,t){if(!e||kt)return"";kt=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var V=function(){throw Error()};if(Object.defineProperty(V.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(V,[])}catch(q){var R=q}Reflect.construct(e,[],V)}else{try{V.call()}catch(q){R=q}e.call(V.prototype)}}else{try{throw Error()}catch(q){R=q}(V=e())&&typeof V.catch=="function"&&V.catch(function(){})}}catch(q){if(q&&R&&typeof q.stack=="string")return[q.stack,R.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=l.DetermineComponentFrameRoot(),f=c[0],g=c[1];if(f&&g){var j=f.split(`
|
|
@@ -11,7 +11,7 @@ Error generating stack: `+l.message+`
|
|
|
11
11
|
`);for(const u of o){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 jN(a){const s={},o=a.split(`
|
|
12
12
|
`);for(const u of o){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 NN(a,s){const o=a.split(`
|
|
13
13
|
`);let u=!1;const d=[];for(const m of o){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(" ")||MN(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(),x=m.slice(h+1).trim();p&&(s.responseHeaders[p]=x)}}}s.responseBody=d.join(`
|
|
14
|
-
`).trim()}function CN(a){const s=a.url.match(/\/api\/provider\/([^/]+)/);s&&(a.provider=s[1]);const o=a.url.match(/\/api\/provider\/[^/]+\/(.+?)(?:\?|$)/);o&&(a.endpoint=o[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"),wN(a),a.statusCode===429&&EN(a)}function wN(a){if(a.requestBody)try{const s=JSON.parse(a.requestBody);typeof s.model=="string"&&(a.model=s.model)}catch{}}function EN(a){if(a.responseBody)try{const s=JSON.parse(a.responseBody),o=Uc(s);o!==null&&(a.quotaResetDelay=o);const u=qc(s);u&&(a.quotaResetTimestamp=u)}catch{}}function Uc(a){if(typeof a!="object"||a===null)return null;const s=a;if("quotaResetDelay"in s){const o=s.quotaResetDelay;if(typeof o=="number")return o;if(typeof o=="string"){const u=o.match(/^(\d+)s?$/);if(u)return parseInt(u[1],10)}}if("error"in s&&typeof s.error=="object"){const o=Uc(s.error);if(o!==null)return o}if("details"in s&&Array.isArray(s.details))for(const o of s.details){const u=Uc(o);if(u!==null)return u}return null}function qc(a){if(typeof a!="object"||a===null)return null;const s=a;for(const o of["quotaResetTimeStamp","quotaResetTimestamp","resetTime","reset_time"])if(o in s&&typeof s[o]=="string")return s[o];if("error"in s&&typeof s.error=="object"){const o=qc(s.error);if(o)return o}if("details"in s&&Array.isArray(s.details))for(const o of s.details){const u=qc(o);if(u)return u}return null}function MN(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 TN(a){const s=Date.now(),o=a*1e3,u=s-o,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(o).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function ON(a){return a>=500?"text-red-500":a===429?"text-orange-500":a>=400?"text-yellow-500":"text-gray-500"}function AN(a){return{rate_limit:"Rate Limited",auth:"Auth Error",not_found:"Not Found",server:"Server Error",timeout:"Timeout",unknown:"Error"}[a]||"Error"}function zN(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),o=Math.floor(a%3600/60);return o>0?`${s}h ${o}m`:`${s}h`}function DN(a){if(!a)return null;try{const s=new Date(a),o=new Date,u=s.getTime()-o.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 _N(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 kN(a){return a||""}function RN({name:a,size:s,modified:o,isSelected:u,onClick:d,statusCode:m,model:h}){const p=y.useMemo(()=>vN(a),[a]),x=y.useMemo(()=>kN(h),[h]);return i.jsxs("button",{onClick:d,className:G("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:[i.jsx("span",{className:G("shrink-0 text-[10px] font-bold px-1.5 py-0.5 rounded min-w-[32px] text-center",_N(m)),children:m||"???"}),i.jsx(rd,{provider:p.provider,size:18,withBackground:!0,className:"shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[i.jsx("span",{className:"text-[11px] font-medium text-foreground truncate",children:p.endpoint||"unknown"}),x&&i.jsx("span",{className:"text-[10px] text-muted-foreground truncate",title:x,children:x}),i.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-muted-foreground/60",children:[i.jsx(Qc,{className:"w-2.5 h-2.5"}),i.jsx("span",{children:TN(o)})]})]})]})}function Hp({value:a,className:s,variant:o="outline",size:u="icon",label:d="Copy to clipboard"}){const[m,h]=y.useState(!1),p=()=>{navigator.clipboard.writeText(a),h(!0),setTimeout(()=>h(!1),2e3)};return i.jsx(ml,{children:i.jsxs(Ya,{children:[i.jsx(Ga,{asChild:!0,children:i.jsxs(ot,{size:u,variant:o,className:G("relative z-10 text-muted-foreground hover:text-foreground",s),onClick:x=>{x.stopPropagation(),p()},children:[m?i.jsx(rs,{className:"h-3.5 w-3.5 text-green-500"}):i.jsx(Hr,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"sr-only",children:d})]})}),i.jsx(Ka,{children:i.jsx("p",{children:m?"Copied!":d})})]})})}function ii({active:a,onClick:s,children:o,icon:u}){return i.jsxs("button",{onClick:s,className:G("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&&i.jsx(u,{className:"w-3.5 h-3.5"}),o]})}function dx({code:a}){const s=ON(a);return i.jsx("span",{className:G("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 UN({parsed:a}){const s=zN(a.quotaResetDelay)||DN(a.quotaResetTimestamp);return i.jsx(gl,{className:"h-full",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(dx,{code:a.statusCode}),i.jsx("span",{className:"text-sm font-medium",children:a.statusText}),i.jsx("span",{className:"text-xs text-muted-foreground px-2 py-0.5 rounded bg-muted/50",children:AN(a.errorType)})]}),a.model&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-violet-500/10 border border-violet-500/20",children:[i.jsx(rb,{className:"w-4 h-4 text-violet-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Model: "}),i.jsx("span",{className:"font-semibold text-violet-600 dark:text-violet-400",children:a.model})]})]}),a.errorType==="rate_limit"&&s&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[i.jsx(Qc,{className:"w-4 h-4 text-amber-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Quota resets in "}),i.jsx("span",{className:"font-semibold text-amber-600 dark:text-amber-400",children:s})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3 text-xs",children:[i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Method"}),i.jsx("div",{className:"font-medium",children:a.method||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Provider"}),i.jsx("div",{className:"font-medium",children:a.provider||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Version"}),i.jsx("div",{className:"font-medium",children:a.version||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Endpoint"}),i.jsx("div",{className:"font-medium truncate",title:a.endpoint,children:a.endpoint||"N/A"})]})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"URL"}),i.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"})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"Timestamp"}),i.jsx("div",{className:"font-mono",children:a.timestamp||"N/A"})]}),a.errorType!=="unknown"&&i.jsxs("div",{className:G("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"?i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}):a.errorType==="auth"?i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-red-500 shrink-0"}):i.jsx(Jr,{className:"w-4 h-4 mt-0.5 text-blue-500 shrink-0"}),i.jsxs("div",{className:G("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"&&i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:"Rate Limited."})," Switch to a different account or wait for quota reset.",a.model&&i.jsxs(i.Fragment,{children:[" ","Model ",i.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 qN({headers:a}){const s=Object.entries(a);return s.length===0?i.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No headers available"}):i.jsx(gl,{className:"h-full",children:i.jsx("div",{className:"p-4 space-y-1",children:s.map(([o,u])=>i.jsxs("div",{className:"flex gap-3 text-xs font-mono py-1.5 border-b border-border/30 last:border-0",children:[i.jsxs("span",{className:"text-muted-foreground shrink-0 min-w-[140px]",children:[o,":"]}),i.jsx("span",{className:"break-all",children:u})]},o))})})}function Lp({content:a,label:s}){if(!a||a.trim()==="")return i.jsxs("div",{className:"p-4 text-xs text-muted-foreground",children:["No ",s.toLowerCase()," body"]});let o=a,u=!1;try{const d=JSON.parse(a);o=JSON.stringify(d,null,2),u=!0}catch{}return i.jsx(gl,{className:"h-full",children:i.jsx("pre",{className:G("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:o})})}function BN({content:a}){return i.jsx(gl,{className:"h-full",children:i.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 HN({name:a,absolutePath:s}){const[o,u]=y.useState("overview"),{data:d,isLoading:m,error:h}=jj(a),p=y.useMemo(()=>d?bN(d):null,[d]);return a?m?i.jsxs("div",{className:"flex-1 p-6 space-y-3",children:[i.jsx(Le,{className:"h-5 w-full"}),i.jsx(Le,{className:"h-5 w-3/4"}),i.jsx(Le,{className:"h-5 w-5/6"}),i.jsx(Le,{className:"h-5 w-2/3"})]}):h||!d||!p?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsx("p",{className:"text-sm",children:"Failed to load log content"})}):i.jsxs("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:[i.jsxs("div",{className:"px-4 py-3 border-b border-border bg-muted/30 flex items-center justify-between gap-3 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx(dx,{code:p.statusCode}),i.jsxs("span",{className:"text-xs font-semibold truncate text-foreground",children:[p.provider,"/",p.endpoint||"unknown"]}),a&&i.jsx(Hp,{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"})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d&&i.jsx(Hp,{value:d,label:"Copy raw log content",variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),i.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})]})]}),i.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:[i.jsx(ii,{active:o==="overview",onClick:()=>u("overview"),icon:Jr,children:"Overview"}),i.jsx(ii,{active:o==="headers",onClick:()=>u("headers"),icon:ub,children:"Headers"}),i.jsx(ii,{active:o==="request",onClick:()=>u("request"),icon:cb,children:"Request"}),i.jsx(ii,{active:o==="response",onClick:()=>u("response"),icon:db,children:"Response"}),i.jsx(ii,{active:o==="raw",onClick:()=>u("raw"),icon:fb,children:"Raw"})]}),i.jsxs("div",{className:"flex-1 overflow-hidden bg-card/30",children:[o==="overview"&&i.jsx(UN,{parsed:p}),o==="headers"&&i.jsx(qN,{headers:p.requestHeaders}),o==="request"&&i.jsx(Lp,{content:p.requestBody,label:"Request"}),o==="response"&&i.jsx(Lp,{content:p.responseBody,label:"Response"}),o==="raw"&&i.jsx(BN,{content:d})]})]}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx(ob,{className:"w-10 h-10 mx-auto opacity-40"}),i.jsx("p",{className:"text-sm",children:"Select a log to view details"})]})})}function LN(){const{data:a,isLoading:s}=xj(),{data:o,isLoading:u,error:d}=Sj(a?.running??!1),[m,h]=y.useState(500),[p,x]=y.useState(!1),b=y.useRef(null),w=y.useRef(null),v=()=>{w.current&&(clearInterval(w.current),w.current=null)};y.useEffect(()=>{if(!p)return;const B=k=>{const N=b.current;if(!N)return;const Z=N.getBoundingClientRect().top+window.scrollY,te=k.pageY-Z;h(Math.max(300,te));const be=window.innerHeight-k.clientY,oe=15;v(),be<50?w.current=setInterval(()=>{window.scrollBy(0,oe)},16):k.clientY<50&&(w.current=setInterval(()=>{window.scrollBy(0,-oe)},16))},L=()=>{x(!1),v(),document.body.style.cursor="default",document.body.style.userSelect="auto"};return document.addEventListener("mousemove",B),document.addEventListener("mouseup",L),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",L),document.body.style.cursor="default",document.body.style.userSelect="auto",v()}},[p]);const S=B=>{B.preventDefault(),x(!0)},M=y.useMemo(()=>o?.[0]?.name??null,[o]),[A,U]=y.useState(null),_=A??M,T=y.useMemo(()=>!_||!o?void 0:o.find(L=>L.name===_)?.absolutePath,[_,o]);if(s||!a?.running)return null;if(u)return i.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:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(B=>i.jsx(Le,{className:"h-12 w-full rounded-lg"},B))})]});if(!o||o.length===0)return null;const K=o.length;return i.jsxs("div",{ref:b,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:[i.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:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(Qa,{className:"w-4 h-4 text-amber-500"}),i.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Error Logs"}),i.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[K," failed request",K!==1?"s":""]})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsx(mb,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:"CLIProxy Diagnostics"})]})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsxs(dd,{direction:"horizontal",children:[i.jsx(hi,{defaultSize:30,minSize:20,maxSize:50,className:"flex flex-col min-w-0",children:i.jsxs(gl,{className:"h-full",children:[i.jsx("div",{className:"divide-y divide-border/50",children:o.slice(0,50).map(B=>i.jsx(RN,{name:B.name,size:B.size,modified:B.modified,isSelected:_===B.name,onClick:()=>U(B.name),statusCode:B.statusCode,model:B.model},B.name))}),o.length>50&&i.jsxs("div",{className:"px-3 py-3 text-center text-[10px] text-muted-foreground border-t border-border/50",children:["Showing 50 of ",o.length," logs"]})]})}),i.jsxs(fd,{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:[i.jsx("div",{className:"w-[1px] h-full bg-border group-hover:bg-primary/50 transition-colors"}),i.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:i.jsx($r,{className:"h-4 w-4 text-muted-foreground"})})]}),i.jsx(hi,{className:"flex flex-col min-w-0 bg-background/50",children:i.jsx(HN,{name:_,absolutePath:T})})]})}),d?i.jsx("div",{className:"px-4 py-2 border-t border-border text-xs text-destructive bg-destructive/5 shrink-0",children:d.message}):i.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:S,children:i.jsx(hb,{className:"w-8 h-3 text-border group-hover:text-primary/50 transition-colors"})})]})}const YN=Fr("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"}}),md=y.forwardRef(({className:a,variant:s,...o},u)=>i.jsx("div",{ref:u,role:"alert",className:G(YN({variant:s}),a),...o}));md.displayName="Alert";const fx=y.forwardRef(({className:a,...s},o)=>i.jsx("h5",{ref:o,className:G("mb-1 font-medium leading-none tracking-tight",a),...s}));fx.displayName="AlertTitle";const hd=y.forwardRef(({className:a,...s},o)=>i.jsx("div",{ref:o,className:G("text-sm [&_p]:leading-relaxed",a),...s}));hd.displayName="AlertDescription";function GN(){return At({queryKey:["overview"],queryFn:async()=>(await fetch("/api/overview")).json()})}function KN(){return At({queryKey:["shared","summary"],queryFn:async()=>(await fetch("/api/shared/summary")).json()})}function hE(a){return At({queryKey:["shared",a],queryFn:async()=>(await fetch(`/api/shared/${a}`)).json()})}const QN={ok:"success",warning:"warning",error:"error"},VN={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 kr({title:a,value:s,icon:o,variant:u="default",onClick:d}){const m=VN[u];return i.jsxs("button",{onClick:d,className:G("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:[i.jsx("div",{className:G("flex items-center justify-center w-9 h-9 rounded-md",m.iconBg),children:i.jsx(o,{className:G("w-4 h-4",m.iconColor)})}),i.jsxs("div",{className:"text-left",children:[i.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a}),i.jsx("p",{className:G("text-lg font-bold font-mono leading-tight",m.iconColor),children:s})]})]})}function XN(){const a=Gc(),{data:s,isLoading:o}=GN(),{data:u,isLoading:d}=KN();if(o||d)return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"rounded-xl border p-6 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(Le,{className:"h-12 w-12 rounded-lg"}),i.jsxs("div",{children:[i.jsx(Le,{className:"h-7 w-[180px] mb-2"}),i.jsx(Le,{className:"h-4 w-[220px]"})]})]}),i.jsx("div",{className:"flex items-center gap-3",children:[1,2,3,4].map(h=>i.jsx(Le,{className:"h-14 w-28 rounded-lg"},h))})]}),i.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[i.jsxs("div",{className:"px-4 py-2.5 border-b flex items-center justify-between",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"px-4 py-3 border-b",children:i.jsx(Le,{className:"h-2 w-full rounded-full"})}),[1,2,3].map(h=>i.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-3 border-b last:border-b-0",children:[i.jsx(Le,{className:"w-2.5 h-2.5 rounded-full"}),i.jsx(Le,{className:"h-4 flex-1"}),i.jsx(Le,{className:"h-1.5 w-24 rounded-full"}),i.jsx(Le,{className:"h-4 w-16"})]},h))]})]});const m=s?.health?QN[s.health.status]:void 0;return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"relative overflow-hidden rounded-xl border bg-gradient-to-br from-background via-background to-muted/30",children:[i.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:i.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),i.jsxs("div",{className:"relative p-6 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[i.jsx(F1,{version:s?.version}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i.jsx(kr,{title:"Profiles",value:s?.profiles??0,icon:Ag,variant:"accent",onClick:()=>a("/providers")}),i.jsx(kr,{title:"CLIProxy",value:s?.cliproxy??0,icon:zg,variant:"accent",onClick:()=>a("/cliproxy")}),i.jsx(kr,{title:"Accounts",value:s?.accounts??0,icon:kg,variant:"default",onClick:()=>a("/accounts")}),i.jsx(kr,{title:"Health",value:s?.health?`${s.health.passed}/${s.health.total}`:"-",icon:fi,variant:m,onClick:()=>a("/health")})]})]})]}),u?.symlinkStatus&&!u.symlinkStatus.valid&&i.jsxs(md,{variant:"warning",children:[i.jsx(Qa,{className:"h-4 w-4"}),i.jsx(fx,{children:"Configuration Required"}),i.jsx(hd,{children:u.symlinkStatus.message})]}),i.jsx(Qj,{}),i.jsx(LN,{})]})}const mx=vv,pd=y.forwardRef(({className:a,...s},o)=>i.jsx(yg,{ref:o,className:G("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",a),...s}));pd.displayName=yg.displayName;const Kr=y.forwardRef(({className:a,...s},o)=>i.jsx(vg,{ref:o,className:G("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}));Kr.displayName=vg.displayName;const Bc=y.forwardRef(({className:a,...s},o)=>i.jsx(bg,{ref:o,className:G("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...s}));Bc.displayName=bg.displayName;function yn({className:a,...s}){return i.jsx(bv,{"data-slot":"label",className:G("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 gd="ccs:openrouter-models",ZN=1440*60*1e3,hx="1";function Hc(a){const s=parseFloat(a);return isNaN(s)||s===0?0:s*1e6}function Yp(a){const s=Hc(a);return s===0?"Free":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:`$${s.toFixed(s<10?2:0)}`}function WN(a){const s=Yp(a.prompt),o=Yp(a.completion);return s==="Free"&&o==="Free"?"Free":`${s}/${o}`}function $N(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 JN(a){return{...a,category:$N(a),pricePerMillionPrompt:Hc(a.pricing.prompt),pricePerMillionCompletion:Hc(a.pricing.completion),isFree:a.pricing.prompt==="0"&&a.pricing.completion==="0",isExacto:a.id.includes(":exacto")}}function PN(a,s,o){const u=s.toLowerCase().trim();return a.filter(d=>o?.category&&d.category!==o.category||o?.freeOnly&&!d.isFree||o?.minContext&&d.context_length<o.minContext?!1:u?d.id.toLowerCase().includes(u)||d.name.toLowerCase().includes(u)||d.description?.toLowerCase().includes(u):!0)}function pE(a){return[...a].sort((s,o)=>{if(s.isFree&&!o.isFree)return-1;if(!s.isFree&&o.isFree)return 1;if(!s.isFree&&!o.isFree){if(s.isExacto&&!o.isExacto)return-1;if(!s.isExacto&&o.isExacto)return 1}return s.name.localeCompare(o.name)})}function FN(){try{const a=localStorage.getItem(gd);if(!a)return null;const s=JSON.parse(a);return s.version!==hx||Date.now()-s.fetchedAt>ZN?null:s.models}catch{return null}}function IN(a){try{localStorage.setItem(gd,JSON.stringify({models:a,fetchedAt:Date.now(),version:hx}))}catch{}}function e2(){localStorage.removeItem(gd)}function gE(a,s){const[o]=a.split("/");if(!o)return{};const u=s.filter(h=>h.id.startsWith(`${o}/`));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 t2(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${Math.round(a/1e3)}K`:String(a)}const xE={anthropic:"Anthropic (Claude)",openai:"OpenAI (GPT)",google:"Google (Gemini)",meta:"Meta (Llama)",mistral:"Mistral",opensource:"Open Source",other:"Other"},n2={anthropic:["anthropic/"],openai:["openai/"],google:["google/"],meta:["meta-llama/","meta/"],mistral:["mistralai/"],opensource:["deepseek/","qwen/","cohere/"],other:[]};function a2(a,s=2){const o=[],u=["anthropic","openai","google","meta","mistral","opensource"];for(const d of u){const m=n2[d];if(m.length===0)continue;const p=[...a.filter(x=>m.some(b=>x.id.toLowerCase().startsWith(b)))].sort((x,b)=>(b.created??0)-(x.created??0));o.push(...p.slice(0,s))}return o.sort((d,m)=>(m.created??0)-(d.created??0))}function l2(a){const o=Date.now()/1e3-a;return o<86400?"Today":o<172800?"Yesterday":o<604800?`${Math.floor(o/86400)}d ago`:o<2592e3?`${Math.floor(o/604800)}w ago`:o<31536e3?`${Math.floor(o/2592e3)}mo ago`:`${Math.floor(o/31536e3)}y ago`}const s2="https://openrouter.ai/api/v1/models",px=["openrouter-models"],Gp=1440*60*1e3;async function i2(){const a=await fetch(s2);if(!a.ok)throw new Error(`Failed to fetch OpenRouter models: ${a.status}`);const o=(await a.json()).data;return IN(o),o}function gx(){return At({queryKey:px,queryFn:i2,staleTime:Gp,gcTime:Gp,initialData:()=>FN()??void 0,refetchOnWindowFocus:!1})}function r2(){const a=gx(),s=(a.data??[]).map(JN);return{...a,models:s}}function yE(){const a=ut();return()=>(e2(),a.invalidateQueries({queryKey:px}))}function vE(){const{data:a,isLoading:s,isError:o}=gx();return{isReady:!!a&&a.length>0,isLoading:s,isError:o,modelCount:a?.length??0}}function xx({profileEnv:a={}}){const[s,o]=y.useState(null),[u,d]=y.useState(!0),[m,h]=y.useState(!1);y.useEffect(()=>{p()},[]);const p=async()=>{try{d(!0);const S=await fetch("/api/global-env");if(!S.ok)throw new Error("Failed to load");const M=await S.json();o(M)}catch{o(null)}finally{d(!1)}};if(u||!s?.enabled)return null;const x=s.env||{},b=Object.keys(x);if(b.length===0)return null;const w=b.filter(S=>!(S in a)),v=b.filter(S=>S in a);return i.jsxs("div",{className:"border-t bg-muted/20",children:[i.jsxs("button",{onClick:()=>h(!m),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",children:[i.jsx(Jr,{className:"w-4 h-4 text-blue-500"}),i.jsxs("span",{className:"text-xs text-muted-foreground flex-1 text-left",children:[i.jsx("span",{className:"font-medium text-foreground",children:w.length})," global env var",w.length!==1?"s":""," will be injected at runtime",v.length>0&&i.jsxs("span",{className:"text-amber-600 dark:text-amber-400 ml-1",children:["(",v.length," overridden by profile)"]})]}),m?i.jsx(Xc,{className:"w-4 h-4 text-muted-foreground"}):i.jsx(Pr,{className:"w-4 h-4 text-muted-foreground"})]}),m&&i.jsxs("div",{className:"px-4 pb-3 space-y-2",children:[w.length>0&&i.jsx("div",{className:"space-y-1",children:w.map(S=>i.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:[i.jsx("span",{className:"text-green-500",children:"+"}),i.jsxs("span",{className:"truncate",children:[S,"=",x[S]]})]},S))}),v.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"Skipped (profile already defines):"}),v.map(S=>i.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:[i.jsx("span",{className:"text-amber-500",children:"~"}),i.jsx("span",{className:"truncate",children:S})]},S))]}),i.jsx("div",{className:"pt-2 border-t border-border/50",children:i.jsx(ot,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 text-xs gap-1.5 -ml-2",children:i.jsxs(kc,{to:"/settings?tab=globalenv",children:[i.jsx(Zc,{className:"w-3.5 h-3.5"}),"Configure in Settings",i.jsx(Rg,{className:"w-3 h-3 opacity-50"})]})})})]})]})}const o2=y.lazy(()=>zt(()=>Promise.resolve().then(()=>Sx),void 0).then(a=>({default:a.CodeEditor})));function bE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:o,settings:u,onChange:d,missingRequiredFields:m=[]}){const h=m.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(Un,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&o!==null&&i.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:[i.jsx(xi,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&i.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:[i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(o2,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(xx,{profileEnv:u?.env})})})]})})}function Kp(a,s){try{var o=a()}catch(u){return s(u)}return o&&o.then?o.then(void 0,s):o}function u2(a,s){for(var o={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!o[h])if("unionErrors"in u){var p=u.unionErrors[0].errors[0];o[h]={message:p.message,type:p.code}}else o[h]={message:m,type:d};if("unionErrors"in u&&u.unionErrors.forEach(function(w){return w.errors.forEach(function(v){return a.push(v)})}),s){var x=o[h].types,b=x&&x[u.code];o[h]=Ug(h,s,o,d,b?[].concat(b,u.message):u.message)}a.shift()}return o}function c2(a,s){for(var o={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!o[h])if(u.code==="invalid_union"&&u.errors.length>0){var p=u.errors[0][0];o[h]={message:p.message,type:p.code}}else o[h]={message:m,type:d};if(u.code==="invalid_union"&&u.errors.forEach(function(w){return w.forEach(function(v){return a.push(v)})}),s){var x=o[h].types,b=x&&x[u.code];o[h]=Ug(h,s,o,d,b?[].concat(b,u.message):u.message)}a.shift()}return o}function d2(a,s,o){if(o===void 0&&(o={}),(function(u){return"_def"in u&&typeof u._def=="object"&&"typeName"in u._def})(a))return function(u,d,m){try{return Promise.resolve(Kp(function(){return Promise.resolve(a[o.mode==="sync"?"parse":"parseAsync"](u,s)).then(function(h){return m.shouldUseNativeValidation&&xp({},m),{errors:{},values:o.raw?Object.assign({},u):h}})},function(h){if((function(p){return Array.isArray(p?.issues)})(h))return{values:{},errors:yp(u2(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(Kp(function(){return Promise.resolve((o.mode==="sync"?tS:nS)(a,u,s)).then(function(h){return m.shouldUseNativeValidation&&xp({},m),{errors:{},values:o.raw?Object.assign({},u):h}})},function(h){if((function(p){return p instanceof aS})(h))return{values:{},errors:yp(c2(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 SE(){return At({queryKey:["profiles"],queryFn:()=>Ze.profiles.list()})}function f2(){const a=ut();return mt({mutationFn:s=>Ze.profiles.create(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile created successfully")},onError:s=>{le.error(s.message)}})}function jE(){const a=ut();return mt({mutationFn:s=>Ze.profiles.delete(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile deleted successfully")},onError:s=>{le.error(s.message)}})}const m2="https://openrouter.ai/api",Br=[{id:"openrouter",name:"OpenRouter",description:"349+ models from OpenAI, Anthropic, Google, Meta",baseUrl:m2,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:"ollama",name:"Ollama (Local)",description:"Local open-source models via Ollama (32K+ context)",baseUrl:"http://localhost:11434",defaultProfileName:"ollama",badge:"Local",featured:!0,icon:"/icons/ollama.svg",defaultModel:"qwen3-coder",requiresApiKey:!1,apiKeyPlaceholder:"",apiKeyHint:"No API key required for local Ollama",category:"recommended"},{id:"glm",name:"GLM",description:"Claude via Z.AI",baseUrl:"https://api.z.ai/api/anthropic",defaultProfileName:"glm",badge:"Z.AI",icon:"/icons/zai.svg",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",icon:"/icons/zai.svg",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",icon:"/icons/kimi.svg",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",icon:"/icons/azure.svg",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",icon:"/icons/minimax.svg",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",icon:"/icons/deepseek.svg",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",icon:"/assets/providers/qwen-color.svg",defaultModel:"qwen3-coder-plus",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Alibaba Cloud Model Studio",category:"alternative"},{id:"ollama-cloud",name:"Ollama Cloud",description:"Ollama cloud models via direct API (glm-4.7:cloud, minimax-m2.1:cloud)",baseUrl:"https://ollama.com",defaultProfileName:"ollama-cloud",badge:"Cloud",icon:"/icons/ollama.svg",defaultModel:"glm-4.7:cloud",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_OLLAMA_CLOUD_API_KEY",apiKeyHint:"Get your API key at ollama.com",category:"alternative"}];function Rr(a){return Br.filter(s=>s.category===a)}const h2=lS({name:cl().min(1,"Name is required").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Must start with letter, only letters/numbers/.-_"),baseUrl:cl().url("Invalid URL format"),apiKey:cl(),model:cl().optional(),opusModel:cl().optional(),sonnetModel:cl().optional(),haikuModel:cl().optional()}),p2=["/chat/completions","/v1/messages","/messages","/completions"];function NE({open:a,onOpenChange:s,onSuccess:o,initialMode:u="openrouter"}){const d=f2(),[m,h]=y.useState("basic"),[p,x]=y.useState(null),[b,w]=y.useState(!1),[v,S]=y.useState("openrouter"),[M,A]=y.useState(""),{models:U}=r2(),{register:_,handleSubmit:T,formState:{errors:K},control:B,reset:L,setValue:k}=sS({resolver:d2(h2),defaultValues:{name:"",baseUrl:"",apiKey:"",model:"",opusModel:"",sonnetModel:"",haikuModel:""}}),N=iS({control:B,name:"baseUrl"}),H=y.useMemo(()=>!v||v==="custom"?null:Br.find(P=>P.id===v),[v]),Z=y.useMemo(()=>M.trim()?[...PN(U,M)].sort((O,W)=>(W.created??0)-(O.created??0)).slice(0,20):a2(U,2),[U,M]);y.useEffect(()=>{if(a)if(L(),h("basic"),x(null),w(!1),A(""),u==="normal")S("custom"),setTimeout(()=>{k("name",""),k("baseUrl","")},0);else{S("openrouter");const P=Br.find(O=>O.id==="openrouter");P&&setTimeout(()=>{k("name",P.defaultProfileName),k("baseUrl",P.baseUrl)},0)}},[a,L,k,u]);const te=P=>{S(P);const O=Br.find(W=>W.id===P);O?(k("name",O.defaultProfileName),k("baseUrl",O.baseUrl),O.defaultModel&&(k("model",O.defaultModel),k("opusModel",O.defaultModel),k("sonnetModel",O.defaultModel),k("haikuModel",O.defaultModel))):(k("name",""),k("baseUrl",""),k("model",""))},ce=P=>{k("model",P.id),k("opusModel",P.id),k("sonnetModel",P.id),k("haikuModel",P.id),A(P.name),le.success(`Applied "${P.name}" to all model tiers`,{duration:2e3})};y.useEffect(()=>{if(N&&v==="custom"){const O=N.toLowerCase();for(const W of p2)if(O.endsWith(W)){const se=N.replace(new RegExp(W+"$","i"),"");x(`URL ends with "${W}" - Claude appends this automatically. You likely want: ${se}`);return}}x(null)},[N,v]);const be=async P=>{if(H?.requiresApiKey!==!1&&!P.apiKey){le.error("API key is required");return}const O={...P,apiKey:P.apiKey||""};try{await d.mutateAsync(O),le.success(`Profile "${O.name}" created`),o(O.name),s(!1)}catch(W){le.error(W.message||"Failed to create profile")}},oe=!!K.name||!!K.baseUrl||!!K.apiKey,Ye=!!K.model||!!K.opusModel||!!K.sonnetModel||!!K.haikuModel,je=v==="openrouter";return i.jsx(nd,{open:a,onOpenChange:s,children:i.jsxs(ad,{className:"sm:max-w-[700px] p-0 gap-0 overflow-hidden max-h-[90vh]",children:[i.jsxs(ld,{className:"p-6 pb-4 border-b",children:[i.jsxs(sd,{className:"flex items-center gap-2",children:[i.jsx(pp,{className:"w-5 h-5 text-primary"}),"Create API Profile"]}),i.jsx(id,{children:"Choose a provider or configure a custom API endpoint."})]}),i.jsxs("form",{onSubmit:T(be),className:"flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"px-6 py-3 border-b bg-muted/30 space-y-2",children:[i.jsxs("div",{children:[i.jsx(yn,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Provider"}),i.jsxs("div",{className:"flex gap-2",children:[Rr("recommended").map(P=>i.jsx(Qp,{preset:P,isSelected:v===P.id,onClick:()=>te(P.id)},P.id)),i.jsxs("button",{type:"button",onClick:()=>te("custom"),className:G("flex items-center gap-2 px-4 py-2 rounded-md border-2 transition-all text-sm font-medium",v==="custom"||Rr("alternative").some(P=>P.id===v)?"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:[i.jsx(Zc,{className:"w-4 h-4"}),i.jsx("span",{children:"Custom"})]})]})]}),(v==="custom"||Rr("alternative").some(P=>P.id===v))&&i.jsxs("div",{className:"pt-3 mt-2 border-t border-dashed border-muted-foreground/30",children:[i.jsx(yn,{className:"text-xs font-medium text-foreground/70 mb-2 block",children:"Quick Templates"}),i.jsx("div",{className:"flex gap-2 flex-wrap",children:Rr("alternative").map(P=>i.jsx(Qp,{preset:P,isSelected:v===P.id,onClick:()=>te(P.id)},P.id))})]})]}),i.jsxs(mx,{value:m,onValueChange:h,className:"flex flex-col flex-1 overflow-hidden",children:[i.jsx("div",{className:"px-6 pt-4",children:i.jsxs(pd,{className:"grid w-full grid-cols-2",children:[i.jsxs(Kr,{value:"basic",className:"relative",children:["Basic Information",oe&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]}),i.jsxs(Kr,{value:"models",className:"relative",children:["Model Configuration",Ye&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]})]})}),i.jsxs(gl,{className:"flex-1",children:[i.jsxs(Bc,{value:"basic",className:"p-6 space-y-4 mt-0",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"name",children:["Profile Name ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(_n,{id:"name",..._("name"),placeholder:"my-api",className:"font-mono"}),K.name?i.jsx("p",{className:"text-xs text-destructive",children:K.name.message}):i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in CLI:"," ",i.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:'ccs my-api "prompt"'})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"baseUrl",children:["API Base URL ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(_n,{id:"baseUrl",..._("baseUrl"),placeholder:"https://api.example.com/v1"}),K.baseUrl?i.jsx("p",{className:"text-xs text-destructive",children:K.baseUrl.message}):p?i.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:[i.jsx(Qa,{className:"w-4 h-4 shrink-0 mt-0.5"}),i.jsx("span",{children:p})]}):H?i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Pre-filled from ",H.name,". You can customize if needed."]}):i.jsx("p",{className:"text-xs text-muted-foreground",children:"The endpoint that accepts OpenAI-compatible and Anthropic requests"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"apiKey",children:["API Key"," ",H?.requiresApiKey!==!1&&i.jsx("span",{className:"text-destructive",children:"*"}),H?.requiresApiKey===!1&&i.jsx("span",{className:"text-muted-foreground text-xs font-normal",children:"(optional)"})]}),i.jsxs("div",{className:"relative",children:[i.jsx(_n,{id:"apiKey",type:b?"text":"password",..._("apiKey"),placeholder:H?.requiresApiKey===!1?"Optional - only if auth is enabled":H?.apiKeyPlaceholder??"sk-...",className:"pr-10"}),i.jsx(ot,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-9 w-9 text-muted-foreground hover:text-foreground",onClick:()=>w(!b),tabIndex:-1,children:b?i.jsx(Xr,{className:"h-4 w-4"}):i.jsx(Zr,{className:"h-4 w-4"})})]}),K.apiKey?i.jsx("p",{className:"text-xs text-destructive",children:K.apiKey.message}):H?.requiresApiKey===!1?i.jsx("p",{className:"text-xs text-muted-foreground",children:"Only needed if you have configured Ollama authentication"}):H?.apiKeyHint&&i.jsx("p",{className:"text-xs text-muted-foreground",children:H.apiKeyHint})]})]}),i.jsxs(Bc,{value:"models",className:"p-6 mt-0 space-y-4",children:[i.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:[i.jsx(Jr,{className:"w-5 h-5 shrink-0 mt-0.5"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium mb-1",children:"Model Mapping"}),i.jsx("p",{className:"text-xs opacity-90",children:"Map Claude Code tiers (Opus/Sonnet/Haiku) to models supported by your provider."})]})]}),je&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{children:"Search Models"}),i.jsx(_n,{value:M,onChange:P=>A(P.target.value),placeholder:"Type to search (e.g., opus, sonnet, gpt-4o)...",onKeyDown:P=>{P.key==="Enter"&&Z.length>0&&(P.preventDefault(),ce(Z[0]))}}),i.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:Z.length===0?i.jsx("p",{className:"text-sm text-muted-foreground p-3 text-center",children:M?`No models found for "${M}"`:"Loading models..."}):i.jsxs("div",{className:"p-1",children:[!M&&i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground",children:[i.jsx(pb,{className:"w-3 h-3 text-accent"}),i.jsx("span",{children:"Newest Models"})]}),Z.map(P=>i.jsx(g2,{model:P,onClick:()=>ce(P),showAge:!M},P.id))]})})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"model",children:["Default Model",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"ANTHROPIC_MODEL"})]}),i.jsx(_n,{id:"model",..._("model"),placeholder:H?.defaultModel??"claude-sonnet-4",className:"font-mono text-sm"})]}),i.jsxs("div",{className:"grid gap-3 pt-2 border-t",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"sonnetModel",className:"text-sm",children:["Sonnet Mapping",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_SONNET"})]}),i.jsx(_n,{id:"sonnetModel",..._("sonnetModel"),placeholder:"e.g. gpt-4o, claude-sonnet-4",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"opusModel",className:"text-sm",children:["Opus Mapping",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_OPUS"})]}),i.jsx(_n,{id:"opusModel",..._("opusModel"),placeholder:"e.g. o1, claude-opus-4.5",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"haikuModel",className:"text-sm",children:["Haiku Mapping",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_HAIKU"})]}),i.jsx(_n,{id:"haikuModel",..._("haikuModel"),placeholder:"e.g. gpt-4o-mini, claude-3.5-haiku",className:"font-mono text-sm h-9"})]})]})]})]})]}),i.jsxs(q1,{className:"p-6 pt-4 border-t bg-muted/10",children:[i.jsx(ot,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),i.jsx(ot,{type:"submit",disabled:d.isPending,className:G(d.isPending&&"opacity-80"),children:d.isPending?i.jsxs(i.Fragment,{children:[i.jsx(Un,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):i.jsxs(i.Fragment,{children:[i.jsx(pp,{className:"w-4 h-4 mr-2"}),"Create Profile"]})})]})]})]})]})})}function Qp({preset:a,isSelected:s,onClick:o}){return i.jsxs("button",{type:"button",onClick:o,className:G("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?i.jsx("img",{src:a.icon,alt:"",className:"w-4 h-4"}):i.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)}),i.jsx("span",{className:"font-medium",children:a.name}),a.badge&&i.jsx(La,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-0.5 bg-muted-foreground/10 text-muted-foreground",children:a.badge})]})}function g2({model:a,onClick:s,showAge:o}){return i.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:[i.jsx("span",{className:"flex-1 truncate",children:a.name}),i.jsxs("span",{className:"text-muted-foreground group-hover:text-accent-foreground/80 ml-2 flex items-center gap-2 text-xs",children:[o&&a.created&&i.jsx(La,{variant:"outline",className:"text-[10px] text-accent group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30",children:l2(a.created)}),a.isFree?i.jsx(La,{variant:"secondary",className:"text-xs group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground",children:"Free"}):i.jsx("span",{children:WN(a.pricing)}),i.jsx("span",{children:t2(a.context_length)})]})]})}function x2({className:a,...s}){return i.jsx("div",{"data-slot":"card",className:G("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...s})}function y2({className:a,...s}){return i.jsx("div",{"data-slot":"card-header",className:G("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...s})}function v2({className:a,...s}){return i.jsx("div",{"data-slot":"card-title",className:G("leading-none font-semibold",a),...s})}function b2({className:a,...s}){return i.jsx("div",{"data-slot":"card-description",className:G("text-muted-foreground text-sm",a),...s})}function S2({className:a,...s}){return i.jsx("div",{"data-slot":"card-content",className:G("px-6",a),...s})}const Vp={agy:{name:"Antigravity",description:"Antigravity AI models"},claude:{name:"Claude (Anthropic)",description:"Claude Opus/Sonnet models"},gemini:{name:"Google Gemini",description:"Gemini Pro/Flash models"},codex:{name:"OpenAI Codex",description:"GPT-4 and codex models"},qwen:{name:"Alibaba Qwen",description:"Qwen Code models"},iflow:{name:"iFlow",description:"iFlow AI models"},kiro:{name:"Kiro (AWS)",description:"AWS CodeWhisperer models"},ghcp:{name:"GitHub Copilot (OAuth)",description:"GitHub Copilot via OAuth"}},j2=["agy","claude","gemini","codex","qwen","iflow","kiro","ghcp"],CE=j2.map(a=>({id:a,name:Vp[a].name,description:Vp[a].description})),N2=["provider","auth","variant","success"];function wE(a){return a==="account"?1:N2.indexOf(a)}const EE=Ev,ME=Tv,TE=Mv,C2=y.forwardRef(({className:a,children:s,...o},u)=>i.jsxs(Sg,{ref:u,className:G("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),...o,children:[s,i.jsx(Sv,{asChild:!0,children:i.jsx(Pr,{className:"h-4 w-4 opacity-50"})})]}));C2.displayName=Sg.displayName;const yx=y.forwardRef(({className:a,...s},o)=>i.jsx(jg,{ref:o,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(Xc,{className:"h-4 w-4"})}));yx.displayName=jg.displayName;const vx=y.forwardRef(({className:a,...s},o)=>i.jsx(Ng,{ref:o,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(Pr,{className:"h-4 w-4"})}));vx.displayName=Ng.displayName;const w2=y.forwardRef(({className:a,children:s,position:o="popper",...u},d)=>i.jsx(jv,{children:i.jsxs(Cg,{ref:d,className:G("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",o==="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:o,...u,children:[i.jsx(yx,{}),i.jsx(Nv,{className:G("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),i.jsx(vx,{})]})}));w2.displayName=Cg.displayName;const E2=y.forwardRef(({className:a,...s},o)=>i.jsx(wg,{ref:o,className:G("px-2 py-1.5 text-sm font-semibold",a),...s}));E2.displayName=wg.displayName;const M2=y.forwardRef(({className:a,children:s,...o},u)=>i.jsxs(Eg,{ref:u,className:G("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),...o,children:[i.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Cv,{children:i.jsx(rs,{className:"h-4 w-4"})})}),i.jsx(wv,{children:s})]}));M2.displayName=Eg.displayName;const T2=y.forwardRef(({className:a,...s},o)=>i.jsx(Mg,{ref:o,className:G("-mx-1 my-1 h-px bg-muted",a),...s}));T2.displayName=Mg.displayName;const O2=y.lazy(()=>zt(()=>Promise.resolve().then(()=>Sx),void 0).then(a=>({default:a.CodeEditor})));function OE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:o,onRawJsonChange:u,profileEnv:d,missingRequiredFields:m=[]}){const h=m.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(Un,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&o!==null&&i.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:[i.jsx(xi,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&i.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:[i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),i.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."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(O2,{value:a,onChange:u,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(xx,{profileEnv:d})})})]})})}const A2=y.forwardRef(({className:a,value:s=0,max:o=100,indicatorClassName:u,...d},m)=>{const h=Math.min(Math.max(s/o*100,0),100);return i.jsx("div",{ref:m,role:"progressbar","aria-valuemin":0,"aria-valuemax":o,"aria-valuenow":s,className:G("relative h-2 w-full overflow-hidden rounded-full bg-secondary",a),...d,children:i.jsx("div",{className:G("h-full transition-all",u||"bg-primary"),style:{width:`${h}%`}})})});A2.displayName="Progress";var Gt={},Xp;function z2(){if(Xp)return Gt;Xp=1;var a=Gt&&Gt.__assign||function(){return a=Object.assign||function(k){for(var N,H=1,Z=arguments.length;H<Z;H++){N=arguments[H];for(var te in N)Object.prototype.hasOwnProperty.call(N,te)&&(k[te]=N[te])}return k},a.apply(this,arguments)},s=Gt&&Gt.__createBinding||(Object.create?(function(k,N,H,Z){Z===void 0&&(Z=H);var te=Object.getOwnPropertyDescriptor(N,H);(!te||("get"in te?!N.__esModule:te.writable||te.configurable))&&(te={enumerable:!0,get:function(){return N[H]}}),Object.defineProperty(k,Z,te)}):(function(k,N,H,Z){Z===void 0&&(Z=H),k[Z]=N[H]})),o=Gt&&Gt.__setModuleDefault||(Object.create?(function(k,N){Object.defineProperty(k,"default",{enumerable:!0,value:N})}):function(k,N){k.default=N}),u=Gt&&Gt.__importStar||function(k){if(k&&k.__esModule)return k;var N={};if(k!=null)for(var H in k)H!=="default"&&Object.prototype.hasOwnProperty.call(k,H)&&s(N,k,H);return o(N,k),N},d=Gt&&Gt.__rest||function(k,N){var H={};for(var Z in k)Object.prototype.hasOwnProperty.call(k,Z)&&N.indexOf(Z)<0&&(H[Z]=k[Z]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var te=0,Z=Object.getOwnPropertySymbols(k);te<Z.length;te++)N.indexOf(Z[te])<0&&Object.prototype.propertyIsEnumerable.call(k,Z[te])&&(H[Z[te]]=k[Z[te]]);return H};Object.defineProperty(Gt,"__esModule",{value:!0});var m=u(Og()),h=89,p=90,x=77,b=57,w=219,v=222,S=192,M=100,A=3e3,U=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),_=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),T="npm__react-simple-code-editor__textarea",K=`
|
|
14
|
+
`).trim()}function CN(a){const s=a.url.match(/\/api\/provider\/([^/]+)/);s&&(a.provider=s[1]);const o=a.url.match(/\/api\/provider\/[^/]+\/(.+?)(?:\?|$)/);o&&(a.endpoint=o[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"),wN(a),a.statusCode===429&&EN(a)}function wN(a){if(a.requestBody)try{const s=JSON.parse(a.requestBody);typeof s.model=="string"&&(a.model=s.model)}catch{}}function EN(a){if(a.responseBody)try{const s=JSON.parse(a.responseBody),o=Uc(s);o!==null&&(a.quotaResetDelay=o);const u=qc(s);u&&(a.quotaResetTimestamp=u)}catch{}}function Uc(a){if(typeof a!="object"||a===null)return null;const s=a;if("quotaResetDelay"in s){const o=s.quotaResetDelay;if(typeof o=="number")return o;if(typeof o=="string"){const u=o.match(/^(\d+)s?$/);if(u)return parseInt(u[1],10)}}if("error"in s&&typeof s.error=="object"){const o=Uc(s.error);if(o!==null)return o}if("details"in s&&Array.isArray(s.details))for(const o of s.details){const u=Uc(o);if(u!==null)return u}return null}function qc(a){if(typeof a!="object"||a===null)return null;const s=a;for(const o of["quotaResetTimeStamp","quotaResetTimestamp","resetTime","reset_time"])if(o in s&&typeof s[o]=="string")return s[o];if("error"in s&&typeof s.error=="object"){const o=qc(s.error);if(o)return o}if("details"in s&&Array.isArray(s.details))for(const o of s.details){const u=qc(o);if(u)return u}return null}function MN(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 TN(a){const s=Date.now(),o=a*1e3,u=s-o,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(o).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function ON(a){return a>=500?"text-red-500":a===429?"text-orange-500":a>=400?"text-yellow-500":"text-gray-500"}function AN(a){return{rate_limit:"Rate Limited",auth:"Auth Error",not_found:"Not Found",server:"Server Error",timeout:"Timeout",unknown:"Error"}[a]||"Error"}function zN(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),o=Math.floor(a%3600/60);return o>0?`${s}h ${o}m`:`${s}h`}function DN(a){if(!a)return null;try{const s=new Date(a),o=new Date,u=s.getTime()-o.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 _N(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 kN(a){return a||""}function RN({name:a,size:s,modified:o,isSelected:u,onClick:d,statusCode:m,model:h}){const p=y.useMemo(()=>vN(a),[a]),x=y.useMemo(()=>kN(h),[h]);return i.jsxs("button",{onClick:d,className:G("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:[i.jsx("span",{className:G("shrink-0 text-[10px] font-bold px-1.5 py-0.5 rounded min-w-[32px] text-center",_N(m)),children:m||"???"}),i.jsx(rd,{provider:p.provider,size:18,withBackground:!0,className:"shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[i.jsx("span",{className:"text-[11px] font-medium text-foreground truncate",children:p.endpoint||"unknown"}),x&&i.jsx("span",{className:"text-[10px] text-muted-foreground truncate",title:x,children:x}),i.jsxs("div",{className:"flex items-center gap-1 text-[9px] text-muted-foreground/60",children:[i.jsx(Qc,{className:"w-2.5 h-2.5"}),i.jsx("span",{children:TN(o)})]})]})]})}function Hp({value:a,className:s,variant:o="outline",size:u="icon",label:d="Copy to clipboard"}){const[m,h]=y.useState(!1),p=()=>{navigator.clipboard.writeText(a),h(!0),setTimeout(()=>h(!1),2e3)};return i.jsx(ml,{children:i.jsxs(Ya,{children:[i.jsx(Ga,{asChild:!0,children:i.jsxs(ot,{size:u,variant:o,className:G("relative z-10 text-muted-foreground hover:text-foreground",s),onClick:x=>{x.stopPropagation(),p()},children:[m?i.jsx(rs,{className:"h-3.5 w-3.5 text-green-500"}):i.jsx(Hr,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"sr-only",children:d})]})}),i.jsx(Ka,{children:i.jsx("p",{children:m?"Copied!":d})})]})})}function ii({active:a,onClick:s,children:o,icon:u}){return i.jsxs("button",{onClick:s,className:G("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&&i.jsx(u,{className:"w-3.5 h-3.5"}),o]})}function dx({code:a}){const s=ON(a);return i.jsx("span",{className:G("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 UN({parsed:a}){const s=zN(a.quotaResetDelay)||DN(a.quotaResetTimestamp);return i.jsx(gl,{className:"h-full",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(dx,{code:a.statusCode}),i.jsx("span",{className:"text-sm font-medium",children:a.statusText}),i.jsx("span",{className:"text-xs text-muted-foreground px-2 py-0.5 rounded bg-muted/50",children:AN(a.errorType)})]}),a.model&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-violet-500/10 border border-violet-500/20",children:[i.jsx(rb,{className:"w-4 h-4 text-violet-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Model: "}),i.jsx("span",{className:"font-semibold text-violet-600 dark:text-violet-400",children:a.model})]})]}),a.errorType==="rate_limit"&&s&&i.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20",children:[i.jsx(Qc,{className:"w-4 h-4 text-amber-500 shrink-0"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Quota resets in "}),i.jsx("span",{className:"font-semibold text-amber-600 dark:text-amber-400",children:s})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3 text-xs",children:[i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Method"}),i.jsx("div",{className:"font-medium",children:a.method||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Provider"}),i.jsx("div",{className:"font-medium",children:a.provider||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Version"}),i.jsx("div",{className:"font-medium",children:a.version||"N/A"})]}),i.jsxs("div",{className:"p-2.5 rounded bg-muted/30 border border-border/50",children:[i.jsx("div",{className:"text-muted-foreground mb-1",children:"Endpoint"}),i.jsx("div",{className:"font-medium truncate",title:a.endpoint,children:a.endpoint||"N/A"})]})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"URL"}),i.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"})]}),i.jsxs("div",{className:"text-xs",children:[i.jsx("div",{className:"text-muted-foreground mb-1.5",children:"Timestamp"}),i.jsx("div",{className:"font-mono",children:a.timestamp||"N/A"})]}),a.errorType!=="unknown"&&i.jsxs("div",{className:G("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"?i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}):a.errorType==="auth"?i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-red-500 shrink-0"}):i.jsx(Jr,{className:"w-4 h-4 mt-0.5 text-blue-500 shrink-0"}),i.jsxs("div",{className:G("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"&&i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:"Rate Limited."})," Switch to a different account or wait for quota reset.",a.model&&i.jsxs(i.Fragment,{children:[" ","Model ",i.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 qN({headers:a}){const s=Object.entries(a);return s.length===0?i.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No headers available"}):i.jsx(gl,{className:"h-full",children:i.jsx("div",{className:"p-4 space-y-1",children:s.map(([o,u])=>i.jsxs("div",{className:"flex gap-3 text-xs font-mono py-1.5 border-b border-border/30 last:border-0",children:[i.jsxs("span",{className:"text-muted-foreground shrink-0 min-w-[140px]",children:[o,":"]}),i.jsx("span",{className:"break-all",children:u})]},o))})})}function Lp({content:a,label:s}){if(!a||a.trim()==="")return i.jsxs("div",{className:"p-4 text-xs text-muted-foreground",children:["No ",s.toLowerCase()," body"]});let o=a,u=!1;try{const d=JSON.parse(a);o=JSON.stringify(d,null,2),u=!0}catch{}return i.jsx(gl,{className:"h-full",children:i.jsx("pre",{className:G("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:o})})}function BN({content:a}){return i.jsx(gl,{className:"h-full",children:i.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 HN({name:a,absolutePath:s}){const[o,u]=y.useState("overview"),{data:d,isLoading:m,error:h}=jj(a),p=y.useMemo(()=>d?bN(d):null,[d]);return a?m?i.jsxs("div",{className:"flex-1 p-6 space-y-3",children:[i.jsx(Le,{className:"h-5 w-full"}),i.jsx(Le,{className:"h-5 w-3/4"}),i.jsx(Le,{className:"h-5 w-5/6"}),i.jsx(Le,{className:"h-5 w-2/3"})]}):h||!d||!p?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsx("p",{className:"text-sm",children:"Failed to load log content"})}):i.jsxs("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:[i.jsxs("div",{className:"px-4 py-3 border-b border-border bg-muted/30 flex items-center justify-between gap-3 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx(dx,{code:p.statusCode}),i.jsxs("span",{className:"text-xs font-semibold truncate text-foreground",children:[p.provider,"/",p.endpoint||"unknown"]}),a&&i.jsx(Hp,{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"})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d&&i.jsx(Hp,{value:d,label:"Copy raw log content",variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground"}),i.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})]})]}),i.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:[i.jsx(ii,{active:o==="overview",onClick:()=>u("overview"),icon:Jr,children:"Overview"}),i.jsx(ii,{active:o==="headers",onClick:()=>u("headers"),icon:ub,children:"Headers"}),i.jsx(ii,{active:o==="request",onClick:()=>u("request"),icon:cb,children:"Request"}),i.jsx(ii,{active:o==="response",onClick:()=>u("response"),icon:db,children:"Response"}),i.jsx(ii,{active:o==="raw",onClick:()=>u("raw"),icon:fb,children:"Raw"})]}),i.jsxs("div",{className:"flex-1 overflow-hidden bg-card/30",children:[o==="overview"&&i.jsx(UN,{parsed:p}),o==="headers"&&i.jsx(qN,{headers:p.requestHeaders}),o==="request"&&i.jsx(Lp,{content:p.requestBody,label:"Request"}),o==="response"&&i.jsx(Lp,{content:p.responseBody,label:"Response"}),o==="raw"&&i.jsx(BN,{content:d})]})]}):i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx(ob,{className:"w-10 h-10 mx-auto opacity-40"}),i.jsx("p",{className:"text-sm",children:"Select a log to view details"})]})})}function LN(){const{data:a,isLoading:s}=xj(),{data:o,isLoading:u,error:d}=Sj(a?.running??!1),[m,h]=y.useState(500),[p,x]=y.useState(!1),b=y.useRef(null),w=y.useRef(null),v=()=>{w.current&&(clearInterval(w.current),w.current=null)};y.useEffect(()=>{if(!p)return;const B=k=>{const N=b.current;if(!N)return;const Z=N.getBoundingClientRect().top+window.scrollY,te=k.pageY-Z;h(Math.max(300,te));const be=window.innerHeight-k.clientY,oe=15;v(),be<50?w.current=setInterval(()=>{window.scrollBy(0,oe)},16):k.clientY<50&&(w.current=setInterval(()=>{window.scrollBy(0,-oe)},16))},L=()=>{x(!1),v(),document.body.style.cursor="default",document.body.style.userSelect="auto"};return document.addEventListener("mousemove",B),document.addEventListener("mouseup",L),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",L),document.body.style.cursor="default",document.body.style.userSelect="auto",v()}},[p]);const S=B=>{B.preventDefault(),x(!0)},M=y.useMemo(()=>o?.[0]?.name??null,[o]),[A,U]=y.useState(null),_=A??M,T=y.useMemo(()=>!_||!o?void 0:o.find(L=>L.name===_)?.absolutePath,[_,o]);if(s||!a?.running)return null;if(u)return i.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:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(B=>i.jsx(Le,{className:"h-12 w-full rounded-lg"},B))})]});if(!o||o.length===0)return null;const K=o.length;return i.jsxs("div",{ref:b,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:[i.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:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(Qa,{className:"w-4 h-4 text-amber-500"}),i.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Error Logs"}),i.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[K," failed request",K!==1?"s":""]})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsx(mb,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:"CLIProxy Diagnostics"})]})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsxs(dd,{direction:"horizontal",children:[i.jsx(hi,{defaultSize:30,minSize:20,maxSize:50,className:"flex flex-col min-w-0",children:i.jsxs(gl,{className:"h-full",children:[i.jsx("div",{className:"divide-y divide-border/50",children:o.slice(0,50).map(B=>i.jsx(RN,{name:B.name,size:B.size,modified:B.modified,isSelected:_===B.name,onClick:()=>U(B.name),statusCode:B.statusCode,model:B.model},B.name))}),o.length>50&&i.jsxs("div",{className:"px-3 py-3 text-center text-[10px] text-muted-foreground border-t border-border/50",children:["Showing 50 of ",o.length," logs"]})]})}),i.jsxs(fd,{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:[i.jsx("div",{className:"w-[1px] h-full bg-border group-hover:bg-primary/50 transition-colors"}),i.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:i.jsx($r,{className:"h-4 w-4 text-muted-foreground"})})]}),i.jsx(hi,{className:"flex flex-col min-w-0 bg-background/50",children:i.jsx(HN,{name:_,absolutePath:T})})]})}),d?i.jsx("div",{className:"px-4 py-2 border-t border-border text-xs text-destructive bg-destructive/5 shrink-0",children:d.message}):i.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:S,children:i.jsx(hb,{className:"w-8 h-3 text-border group-hover:text-primary/50 transition-colors"})})]})}const YN=Fr("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"}}),md=y.forwardRef(({className:a,variant:s,...o},u)=>i.jsx("div",{ref:u,role:"alert",className:G(YN({variant:s}),a),...o}));md.displayName="Alert";const fx=y.forwardRef(({className:a,...s},o)=>i.jsx("h5",{ref:o,className:G("mb-1 font-medium leading-none tracking-tight",a),...s}));fx.displayName="AlertTitle";const hd=y.forwardRef(({className:a,...s},o)=>i.jsx("div",{ref:o,className:G("text-sm [&_p]:leading-relaxed",a),...s}));hd.displayName="AlertDescription";function GN(){return At({queryKey:["overview"],queryFn:async()=>(await fetch("/api/overview")).json()})}function KN(){return At({queryKey:["shared","summary"],queryFn:async()=>(await fetch("/api/shared/summary")).json()})}function hE(a){return At({queryKey:["shared",a],queryFn:async()=>(await fetch(`/api/shared/${a}`)).json()})}const QN={ok:"success",warning:"warning",error:"error"},VN={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 kr({title:a,value:s,icon:o,variant:u="default",onClick:d}){const m=VN[u];return i.jsxs("button",{onClick:d,className:G("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:[i.jsx("div",{className:G("flex items-center justify-center w-9 h-9 rounded-md",m.iconBg),children:i.jsx(o,{className:G("w-4 h-4",m.iconColor)})}),i.jsxs("div",{className:"text-left",children:[i.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a}),i.jsx("p",{className:G("text-lg font-bold font-mono leading-tight",m.iconColor),children:s})]})]})}function XN(){const a=Gc(),{data:s,isLoading:o}=GN(),{data:u,isLoading:d}=KN();if(o||d)return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"rounded-xl border p-6 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(Le,{className:"h-12 w-12 rounded-lg"}),i.jsxs("div",{children:[i.jsx(Le,{className:"h-7 w-[180px] mb-2"}),i.jsx(Le,{className:"h-4 w-[220px]"})]})]}),i.jsx("div",{className:"flex items-center gap-3",children:[1,2,3,4].map(h=>i.jsx(Le,{className:"h-14 w-28 rounded-lg"},h))})]}),i.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[i.jsxs("div",{className:"px-4 py-2.5 border-b flex items-center justify-between",children:[i.jsx(Le,{className:"h-4 w-32"}),i.jsx(Le,{className:"h-4 w-20"})]}),i.jsx("div",{className:"px-4 py-3 border-b",children:i.jsx(Le,{className:"h-2 w-full rounded-full"})}),[1,2,3].map(h=>i.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-3 border-b last:border-b-0",children:[i.jsx(Le,{className:"w-2.5 h-2.5 rounded-full"}),i.jsx(Le,{className:"h-4 flex-1"}),i.jsx(Le,{className:"h-1.5 w-24 rounded-full"}),i.jsx(Le,{className:"h-4 w-16"})]},h))]})]});const m=s?.health?QN[s.health.status]:void 0;return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"relative overflow-hidden rounded-xl border bg-gradient-to-br from-background via-background to-muted/30",children:[i.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:i.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),i.jsxs("div",{className:"relative p-6 flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[i.jsx(F1,{version:s?.version}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i.jsx(kr,{title:"Profiles",value:s?.profiles??0,icon:Ag,variant:"accent",onClick:()=>a("/providers")}),i.jsx(kr,{title:"CLIProxy",value:s?.cliproxy??0,icon:zg,variant:"accent",onClick:()=>a("/cliproxy")}),i.jsx(kr,{title:"Accounts",value:s?.accounts??0,icon:kg,variant:"default",onClick:()=>a("/accounts")}),i.jsx(kr,{title:"Health",value:s?.health?`${s.health.passed}/${s.health.total}`:"-",icon:fi,variant:m,onClick:()=>a("/health")})]})]})]}),u?.symlinkStatus&&!u.symlinkStatus.valid&&i.jsxs(md,{variant:"warning",children:[i.jsx(Qa,{className:"h-4 w-4"}),i.jsx(fx,{children:"Configuration Required"}),i.jsx(hd,{children:u.symlinkStatus.message})]}),i.jsx(Qj,{}),i.jsx(LN,{})]})}const mx=vv,pd=y.forwardRef(({className:a,...s},o)=>i.jsx(yg,{ref:o,className:G("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",a),...s}));pd.displayName=yg.displayName;const Kr=y.forwardRef(({className:a,...s},o)=>i.jsx(vg,{ref:o,className:G("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}));Kr.displayName=vg.displayName;const Bc=y.forwardRef(({className:a,...s},o)=>i.jsx(bg,{ref:o,className:G("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),...s}));Bc.displayName=bg.displayName;function yn({className:a,...s}){return i.jsx(bv,{"data-slot":"label",className:G("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 gd="ccs:openrouter-models",ZN=1440*60*1e3,hx="1";function Hc(a){const s=parseFloat(a);return isNaN(s)||s===0?0:s*1e6}function Yp(a){const s=Hc(a);return s===0?"Free":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:`$${s.toFixed(s<10?2:0)}`}function WN(a){const s=Yp(a.prompt),o=Yp(a.completion);return s==="Free"&&o==="Free"?"Free":`${s}/${o}`}function $N(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 JN(a){return{...a,category:$N(a),pricePerMillionPrompt:Hc(a.pricing.prompt),pricePerMillionCompletion:Hc(a.pricing.completion),isFree:a.pricing.prompt==="0"&&a.pricing.completion==="0",isExacto:a.id.includes(":exacto")}}function PN(a,s,o){const u=s.toLowerCase().trim();return a.filter(d=>o?.category&&d.category!==o.category||o?.freeOnly&&!d.isFree||o?.minContext&&d.context_length<o.minContext?!1:u?d.id.toLowerCase().includes(u)||d.name.toLowerCase().includes(u)||d.description?.toLowerCase().includes(u):!0)}function pE(a){return[...a].sort((s,o)=>{if(s.isFree&&!o.isFree)return-1;if(!s.isFree&&o.isFree)return 1;if(!s.isFree&&!o.isFree){if(s.isExacto&&!o.isExacto)return-1;if(!s.isExacto&&o.isExacto)return 1}return s.name.localeCompare(o.name)})}function FN(){try{const a=localStorage.getItem(gd);if(!a)return null;const s=JSON.parse(a);return s.version!==hx||Date.now()-s.fetchedAt>ZN?null:s.models}catch{return null}}function IN(a){try{localStorage.setItem(gd,JSON.stringify({models:a,fetchedAt:Date.now(),version:hx}))}catch{}}function e2(){localStorage.removeItem(gd)}function gE(a,s){const[o]=a.split("/");if(!o)return{};const u=s.filter(h=>h.id.startsWith(`${o}/`));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 t2(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${Math.round(a/1e3)}K`:String(a)}const xE={anthropic:"Anthropic (Claude)",openai:"OpenAI (GPT)",google:"Google (Gemini)",meta:"Meta (Llama)",mistral:"Mistral",opensource:"Open Source",other:"Other"},n2={anthropic:["anthropic/"],openai:["openai/"],google:["google/"],meta:["meta-llama/","meta/"],mistral:["mistralai/"],opensource:["deepseek/","qwen/","cohere/"],other:[]};function a2(a,s=2){const o=[],u=["anthropic","openai","google","meta","mistral","opensource"];for(const d of u){const m=n2[d];if(m.length===0)continue;const p=[...a.filter(x=>m.some(b=>x.id.toLowerCase().startsWith(b)))].sort((x,b)=>(b.created??0)-(x.created??0));o.push(...p.slice(0,s))}return o.sort((d,m)=>(m.created??0)-(d.created??0))}function l2(a){const o=Date.now()/1e3-a;return o<86400?"Today":o<172800?"Yesterday":o<604800?`${Math.floor(o/86400)}d ago`:o<2592e3?`${Math.floor(o/604800)}w ago`:o<31536e3?`${Math.floor(o/2592e3)}mo ago`:`${Math.floor(o/31536e3)}y ago`}const s2="https://openrouter.ai/api/v1/models",px=["openrouter-models"],Gp=1440*60*1e3;async function i2(){const a=await fetch(s2);if(!a.ok)throw new Error(`Failed to fetch OpenRouter models: ${a.status}`);const o=(await a.json()).data;return IN(o),o}function gx(){return At({queryKey:px,queryFn:i2,staleTime:Gp,gcTime:Gp,initialData:()=>FN()??void 0,refetchOnWindowFocus:!1})}function r2(){const a=gx(),s=(a.data??[]).map(JN);return{...a,models:s}}function yE(){const a=ut();return()=>(e2(),a.invalidateQueries({queryKey:px}))}function vE(){const{data:a,isLoading:s,isError:o}=gx();return{isReady:!!a&&a.length>0,isLoading:s,isError:o,modelCount:a?.length??0}}function xx({profileEnv:a={}}){const[s,o]=y.useState(null),[u,d]=y.useState(!0),[m,h]=y.useState(!1);y.useEffect(()=>{p()},[]);const p=async()=>{try{d(!0);const S=await fetch("/api/global-env");if(!S.ok)throw new Error("Failed to load");const M=await S.json();o(M)}catch{o(null)}finally{d(!1)}};if(u||!s?.enabled)return null;const x=s.env||{},b=Object.keys(x);if(b.length===0)return null;const w=b.filter(S=>!(S in a)),v=b.filter(S=>S in a);return i.jsxs("div",{className:"border-t bg-muted/20",children:[i.jsxs("button",{onClick:()=>h(!m),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",children:[i.jsx(Jr,{className:"w-4 h-4 text-blue-500"}),i.jsxs("span",{className:"text-xs text-muted-foreground flex-1 text-left",children:[i.jsx("span",{className:"font-medium text-foreground",children:w.length})," global env var",w.length!==1?"s":""," will be injected at runtime",v.length>0&&i.jsxs("span",{className:"text-amber-600 dark:text-amber-400 ml-1",children:["(",v.length," overridden by profile)"]})]}),m?i.jsx(Xc,{className:"w-4 h-4 text-muted-foreground"}):i.jsx(Pr,{className:"w-4 h-4 text-muted-foreground"})]}),m&&i.jsxs("div",{className:"px-4 pb-3 space-y-2",children:[w.length>0&&i.jsx("div",{className:"space-y-1",children:w.map(S=>i.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:[i.jsx("span",{className:"text-green-500",children:"+"}),i.jsxs("span",{className:"truncate",children:[S,"=",x[S]]})]},S))}),v.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"Skipped (profile already defines):"}),v.map(S=>i.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:[i.jsx("span",{className:"text-amber-500",children:"~"}),i.jsx("span",{className:"truncate",children:S})]},S))]}),i.jsx("div",{className:"pt-2 border-t border-border/50",children:i.jsx(ot,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 text-xs gap-1.5 -ml-2",children:i.jsxs(kc,{to:"/settings?tab=globalenv",children:[i.jsx(Zc,{className:"w-3.5 h-3.5"}),"Configure in Settings",i.jsx(Rg,{className:"w-3 h-3 opacity-50"})]})})})]})]})}const o2=y.lazy(()=>zt(()=>Promise.resolve().then(()=>Sx),void 0).then(a=>({default:a.CodeEditor})));function bE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:o,settings:u,onChange:d,missingRequiredFields:m=[]}){const h=m.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(Un,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&o!==null&&i.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:[i.jsx(xi,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&i.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:[i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These fields will use default values at runtime."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(o2,{value:a,onChange:d,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(xx,{profileEnv:u?.env})})})]})})}function Kp(a,s){try{var o=a()}catch(u){return s(u)}return o&&o.then?o.then(void 0,s):o}function u2(a,s){for(var o={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!o[h])if("unionErrors"in u){var p=u.unionErrors[0].errors[0];o[h]={message:p.message,type:p.code}}else o[h]={message:m,type:d};if("unionErrors"in u&&u.unionErrors.forEach(function(w){return w.errors.forEach(function(v){return a.push(v)})}),s){var x=o[h].types,b=x&&x[u.code];o[h]=Ug(h,s,o,d,b?[].concat(b,u.message):u.message)}a.shift()}return o}function c2(a,s){for(var o={};a.length;){var u=a[0],d=u.code,m=u.message,h=u.path.join(".");if(!o[h])if(u.code==="invalid_union"&&u.errors.length>0){var p=u.errors[0][0];o[h]={message:p.message,type:p.code}}else o[h]={message:m,type:d};if(u.code==="invalid_union"&&u.errors.forEach(function(w){return w.forEach(function(v){return a.push(v)})}),s){var x=o[h].types,b=x&&x[u.code];o[h]=Ug(h,s,o,d,b?[].concat(b,u.message):u.message)}a.shift()}return o}function d2(a,s,o){if(o===void 0&&(o={}),(function(u){return"_def"in u&&typeof u._def=="object"&&"typeName"in u._def})(a))return function(u,d,m){try{return Promise.resolve(Kp(function(){return Promise.resolve(a[o.mode==="sync"?"parse":"parseAsync"](u,s)).then(function(h){return m.shouldUseNativeValidation&&xp({},m),{errors:{},values:o.raw?Object.assign({},u):h}})},function(h){if((function(p){return Array.isArray(p?.issues)})(h))return{values:{},errors:yp(u2(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(Kp(function(){return Promise.resolve((o.mode==="sync"?tS:nS)(a,u,s)).then(function(h){return m.shouldUseNativeValidation&&xp({},m),{errors:{},values:o.raw?Object.assign({},u):h}})},function(h){if((function(p){return p instanceof aS})(h))return{values:{},errors:yp(c2(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 SE(){return At({queryKey:["profiles"],queryFn:()=>Ze.profiles.list()})}function f2(){const a=ut();return mt({mutationFn:s=>Ze.profiles.create(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile created successfully")},onError:s=>{le.error(s.message)}})}function jE(){const a=ut();return mt({mutationFn:s=>Ze.profiles.delete(s),onSuccess:()=>{a.invalidateQueries({queryKey:["profiles"]}),le.success("Profile deleted successfully")},onError:s=>{le.error(s.message)}})}const m2="https://openrouter.ai/api",Br=[{id:"openrouter",name:"OpenRouter",description:"349+ models from OpenAI, Anthropic, Google, Meta",baseUrl:m2,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:"ollama",name:"Ollama (Local)",description:"Local open-source models via Ollama (32K+ context)",baseUrl:"http://localhost:11434",defaultProfileName:"ollama",badge:"Local",featured:!0,icon:"/icons/ollama.svg",defaultModel:"qwen3-coder",requiresApiKey:!1,apiKeyPlaceholder:"",apiKeyHint:"No API key required for local Ollama",category:"recommended"},{id:"glm",name:"GLM",description:"Claude via Z.AI",baseUrl:"https://api.z.ai/api/anthropic",defaultProfileName:"glm",badge:"Z.AI",icon:"/icons/zai.svg",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",icon:"/icons/zai.svg",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",icon:"/icons/kimi.svg",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",icon:"/icons/azure.svg",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",icon:"/icons/minimax.svg",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",icon:"/icons/deepseek.svg",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 models (256K-1M context, thinking support)",baseUrl:"https://dashscope-intl.aliyuncs.com/apps/anthropic",defaultProfileName:"qwen",badge:"Alibaba",icon:"/assets/providers/qwen-color.svg",defaultModel:"qwen3-coder-plus",requiresApiKey:!0,apiKeyPlaceholder:"sk-...",apiKeyHint:"Get your API key from Alibaba Cloud Model Studio",category:"alternative"},{id:"ollama-cloud",name:"Ollama Cloud",description:"Ollama cloud models via direct API (glm-4.7:cloud, minimax-m2.1:cloud)",baseUrl:"https://ollama.com",defaultProfileName:"ollama-cloud",badge:"Cloud",icon:"/icons/ollama.svg",defaultModel:"glm-4.7:cloud",requiresApiKey:!0,apiKeyPlaceholder:"YOUR_OLLAMA_CLOUD_API_KEY",apiKeyHint:"Get your API key at ollama.com",category:"alternative"}];function Rr(a){return Br.filter(s=>s.category===a)}const h2=lS({name:cl().min(1,"Name is required").regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/,"Must start with letter, only letters/numbers/.-_"),baseUrl:cl().url("Invalid URL format"),apiKey:cl(),model:cl().optional(),opusModel:cl().optional(),sonnetModel:cl().optional(),haikuModel:cl().optional()}),p2=["/chat/completions","/v1/messages","/messages","/completions"];function NE({open:a,onOpenChange:s,onSuccess:o,initialMode:u="openrouter"}){const d=f2(),[m,h]=y.useState("basic"),[p,x]=y.useState(null),[b,w]=y.useState(!1),[v,S]=y.useState("openrouter"),[M,A]=y.useState(""),{models:U}=r2(),{register:_,handleSubmit:T,formState:{errors:K},control:B,reset:L,setValue:k}=sS({resolver:d2(h2),defaultValues:{name:"",baseUrl:"",apiKey:"",model:"",opusModel:"",sonnetModel:"",haikuModel:""}}),N=iS({control:B,name:"baseUrl"}),H=y.useMemo(()=>!v||v==="custom"?null:Br.find(P=>P.id===v),[v]),Z=y.useMemo(()=>M.trim()?[...PN(U,M)].sort((O,W)=>(W.created??0)-(O.created??0)).slice(0,20):a2(U,2),[U,M]);y.useEffect(()=>{if(a)if(L(),h("basic"),x(null),w(!1),A(""),u==="normal")S("custom"),setTimeout(()=>{k("name",""),k("baseUrl","")},0);else{S("openrouter");const P=Br.find(O=>O.id==="openrouter");P&&setTimeout(()=>{k("name",P.defaultProfileName),k("baseUrl",P.baseUrl)},0)}},[a,L,k,u]);const te=P=>{S(P);const O=Br.find(W=>W.id===P);O?(k("name",O.defaultProfileName),k("baseUrl",O.baseUrl),O.defaultModel&&(k("model",O.defaultModel),k("opusModel",O.defaultModel),k("sonnetModel",O.defaultModel),k("haikuModel",O.defaultModel))):(k("name",""),k("baseUrl",""),k("model",""))},ce=P=>{k("model",P.id),k("opusModel",P.id),k("sonnetModel",P.id),k("haikuModel",P.id),A(P.name),le.success(`Applied "${P.name}" to all model tiers`,{duration:2e3})};y.useEffect(()=>{if(N&&v==="custom"){const O=N.toLowerCase();for(const W of p2)if(O.endsWith(W)){const se=N.replace(new RegExp(W+"$","i"),"");x(`URL ends with "${W}" - Claude appends this automatically. You likely want: ${se}`);return}}x(null)},[N,v]);const be=async P=>{if(H?.requiresApiKey!==!1&&!P.apiKey){le.error("API key is required");return}const O={...P,apiKey:P.apiKey||""};try{await d.mutateAsync(O),le.success(`Profile "${O.name}" created`),o(O.name),s(!1)}catch(W){le.error(W.message||"Failed to create profile")}},oe=!!K.name||!!K.baseUrl||!!K.apiKey,Ye=!!K.model||!!K.opusModel||!!K.sonnetModel||!!K.haikuModel,je=v==="openrouter";return i.jsx(nd,{open:a,onOpenChange:s,children:i.jsxs(ad,{className:"sm:max-w-[700px] p-0 gap-0 overflow-hidden max-h-[90vh]",children:[i.jsxs(ld,{className:"p-6 pb-4 border-b",children:[i.jsxs(sd,{className:"flex items-center gap-2",children:[i.jsx(pp,{className:"w-5 h-5 text-primary"}),"Create API Profile"]}),i.jsx(id,{children:"Choose a provider or configure a custom API endpoint."})]}),i.jsxs("form",{onSubmit:T(be),className:"flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"px-6 py-3 border-b bg-muted/30 space-y-2",children:[i.jsxs("div",{children:[i.jsx(yn,{className:"text-xs text-muted-foreground mb-1.5 block",children:"Provider"}),i.jsxs("div",{className:"flex gap-2",children:[Rr("recommended").map(P=>i.jsx(Qp,{preset:P,isSelected:v===P.id,onClick:()=>te(P.id)},P.id)),i.jsxs("button",{type:"button",onClick:()=>te("custom"),className:G("flex items-center gap-2 px-4 py-2 rounded-md border-2 transition-all text-sm font-medium",v==="custom"||Rr("alternative").some(P=>P.id===v)?"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:[i.jsx(Zc,{className:"w-4 h-4"}),i.jsx("span",{children:"Custom"})]})]})]}),(v==="custom"||Rr("alternative").some(P=>P.id===v))&&i.jsxs("div",{className:"pt-3 mt-2 border-t border-dashed border-muted-foreground/30",children:[i.jsx(yn,{className:"text-xs font-medium text-foreground/70 mb-2 block",children:"Quick Templates"}),i.jsx("div",{className:"flex gap-2 flex-wrap",children:Rr("alternative").map(P=>i.jsx(Qp,{preset:P,isSelected:v===P.id,onClick:()=>te(P.id)},P.id))})]})]}),i.jsxs(mx,{value:m,onValueChange:h,className:"flex flex-col flex-1 overflow-hidden",children:[i.jsx("div",{className:"px-6 pt-4",children:i.jsxs(pd,{className:"grid w-full grid-cols-2",children:[i.jsxs(Kr,{value:"basic",className:"relative",children:["Basic Information",oe&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]}),i.jsxs(Kr,{value:"models",className:"relative",children:["Model Configuration",Ye&&i.jsx("span",{className:"absolute top-1 right-2 w-2 h-2 rounded-full bg-destructive animate-pulse"})]})]})}),i.jsxs(gl,{className:"flex-1",children:[i.jsxs(Bc,{value:"basic",className:"p-6 space-y-4 mt-0",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"name",children:["Profile Name ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(_n,{id:"name",..._("name"),placeholder:"my-api",className:"font-mono"}),K.name?i.jsx("p",{className:"text-xs text-destructive",children:K.name.message}):i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in CLI:"," ",i.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:'ccs my-api "prompt"'})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"baseUrl",children:["API Base URL ",i.jsx("span",{className:"text-destructive",children:"*"})]}),i.jsx(_n,{id:"baseUrl",..._("baseUrl"),placeholder:"https://api.example.com/v1"}),K.baseUrl?i.jsx("p",{className:"text-xs text-destructive",children:K.baseUrl.message}):p?i.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:[i.jsx(Qa,{className:"w-4 h-4 shrink-0 mt-0.5"}),i.jsx("span",{children:p})]}):H?i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Pre-filled from ",H.name,". You can customize if needed."]}):i.jsx("p",{className:"text-xs text-muted-foreground",children:"The endpoint that accepts OpenAI-compatible and Anthropic requests"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"apiKey",children:["API Key"," ",H?.requiresApiKey!==!1&&i.jsx("span",{className:"text-destructive",children:"*"}),H?.requiresApiKey===!1&&i.jsx("span",{className:"text-muted-foreground text-xs font-normal",children:"(optional)"})]}),i.jsxs("div",{className:"relative",children:[i.jsx(_n,{id:"apiKey",type:b?"text":"password",..._("apiKey"),placeholder:H?.requiresApiKey===!1?"Optional - only if auth is enabled":H?.apiKeyPlaceholder??"sk-...",className:"pr-10"}),i.jsx(ot,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-9 w-9 text-muted-foreground hover:text-foreground",onClick:()=>w(!b),tabIndex:-1,children:b?i.jsx(Xr,{className:"h-4 w-4"}):i.jsx(Zr,{className:"h-4 w-4"})})]}),K.apiKey?i.jsx("p",{className:"text-xs text-destructive",children:K.apiKey.message}):H?.requiresApiKey===!1?i.jsx("p",{className:"text-xs text-muted-foreground",children:"Only needed if you have configured Ollama authentication"}):H?.apiKeyHint&&i.jsx("p",{className:"text-xs text-muted-foreground",children:H.apiKeyHint})]})]}),i.jsxs(Bc,{value:"models",className:"p-6 mt-0 space-y-4",children:[i.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:[i.jsx(Jr,{className:"w-5 h-5 shrink-0 mt-0.5"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium mb-1",children:"Model Mapping"}),i.jsx("p",{className:"text-xs opacity-90",children:"Map Claude Code tiers (Opus/Sonnet/Haiku) to models supported by your provider."})]})]}),je&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{children:"Search Models"}),i.jsx(_n,{value:M,onChange:P=>A(P.target.value),placeholder:"Type to search (e.g., opus, sonnet, gpt-4o)...",onKeyDown:P=>{P.key==="Enter"&&Z.length>0&&(P.preventDefault(),ce(Z[0]))}}),i.jsx("div",{className:"border rounded-md max-h-48 overflow-y-auto",children:Z.length===0?i.jsx("p",{className:"text-sm text-muted-foreground p-3 text-center",children:M?`No models found for "${M}"`:"Loading models..."}):i.jsxs("div",{className:"p-1",children:[!M&&i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground",children:[i.jsx(pb,{className:"w-3 h-3 text-accent"}),i.jsx("span",{children:"Newest Models"})]}),Z.map(P=>i.jsx(g2,{model:P,onClick:()=>ce(P),showAge:!M},P.id))]})})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"model",children:["Default Model",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"ANTHROPIC_MODEL"})]}),i.jsx(_n,{id:"model",..._("model"),placeholder:H?.defaultModel??"claude-sonnet-4",className:"font-mono text-sm"})]}),i.jsxs("div",{className:"grid gap-3 pt-2 border-t",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"sonnetModel",className:"text-sm",children:["Sonnet Mapping",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_SONNET"})]}),i.jsx(_n,{id:"sonnetModel",..._("sonnetModel"),placeholder:"e.g. gpt-4o, claude-sonnet-4",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"opusModel",className:"text-sm",children:["Opus Mapping",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_OPUS"})]}),i.jsx(_n,{id:"opusModel",..._("opusModel"),placeholder:"e.g. o1, claude-opus-4.5",className:"font-mono text-sm h-9"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(yn,{htmlFor:"haikuModel",className:"text-sm",children:["Haiku Mapping",i.jsx(La,{variant:"outline",className:"ml-2 text-[10px] font-mono",children:"DEFAULT_HAIKU"})]}),i.jsx(_n,{id:"haikuModel",..._("haikuModel"),placeholder:"e.g. gpt-4o-mini, claude-3.5-haiku",className:"font-mono text-sm h-9"})]})]})]})]})]}),i.jsxs(q1,{className:"p-6 pt-4 border-t bg-muted/10",children:[i.jsx(ot,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),i.jsx(ot,{type:"submit",disabled:d.isPending,className:G(d.isPending&&"opacity-80"),children:d.isPending?i.jsxs(i.Fragment,{children:[i.jsx(Un,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):i.jsxs(i.Fragment,{children:[i.jsx(pp,{className:"w-4 h-4 mr-2"}),"Create Profile"]})})]})]})]})]})})}function Qp({preset:a,isSelected:s,onClick:o}){return i.jsxs("button",{type:"button",onClick:o,className:G("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?i.jsx("img",{src:a.icon,alt:"",className:"w-4 h-4"}):i.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)}),i.jsx("span",{className:"font-medium",children:a.name}),a.badge&&i.jsx(La,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-0.5 bg-muted-foreground/10 text-muted-foreground",children:a.badge})]})}function g2({model:a,onClick:s,showAge:o}){return i.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:[i.jsx("span",{className:"flex-1 truncate",children:a.name}),i.jsxs("span",{className:"text-muted-foreground group-hover:text-accent-foreground/80 ml-2 flex items-center gap-2 text-xs",children:[o&&a.created&&i.jsx(La,{variant:"outline",className:"text-[10px] text-accent group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30",children:l2(a.created)}),a.isFree?i.jsx(La,{variant:"secondary",className:"text-xs group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground",children:"Free"}):i.jsx("span",{children:WN(a.pricing)}),i.jsx("span",{children:t2(a.context_length)})]})]})}function x2({className:a,...s}){return i.jsx("div",{"data-slot":"card",className:G("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...s})}function y2({className:a,...s}){return i.jsx("div",{"data-slot":"card-header",className:G("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...s})}function v2({className:a,...s}){return i.jsx("div",{"data-slot":"card-title",className:G("leading-none font-semibold",a),...s})}function b2({className:a,...s}){return i.jsx("div",{"data-slot":"card-description",className:G("text-muted-foreground text-sm",a),...s})}function S2({className:a,...s}){return i.jsx("div",{"data-slot":"card-content",className:G("px-6",a),...s})}const Vp={agy:{name:"Antigravity",description:"Antigravity AI models"},claude:{name:"Claude (Anthropic)",description:"Claude Opus/Sonnet models"},gemini:{name:"Google Gemini",description:"Gemini Pro/Flash models"},codex:{name:"OpenAI Codex",description:"GPT-4 and codex models"},qwen:{name:"Alibaba Qwen",description:"Qwen Code models"},iflow:{name:"iFlow",description:"iFlow AI models"},kiro:{name:"Kiro (AWS)",description:"AWS CodeWhisperer models"},ghcp:{name:"GitHub Copilot (OAuth)",description:"GitHub Copilot via OAuth"}},j2=["agy","claude","gemini","codex","qwen","iflow","kiro","ghcp"],CE=j2.map(a=>({id:a,name:Vp[a].name,description:Vp[a].description})),N2=["provider","auth","variant","success"];function wE(a){return a==="account"?1:N2.indexOf(a)}const EE=Ev,ME=Tv,TE=Mv,C2=y.forwardRef(({className:a,children:s,...o},u)=>i.jsxs(Sg,{ref:u,className:G("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),...o,children:[s,i.jsx(Sv,{asChild:!0,children:i.jsx(Pr,{className:"h-4 w-4 opacity-50"})})]}));C2.displayName=Sg.displayName;const yx=y.forwardRef(({className:a,...s},o)=>i.jsx(jg,{ref:o,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(Xc,{className:"h-4 w-4"})}));yx.displayName=jg.displayName;const vx=y.forwardRef(({className:a,...s},o)=>i.jsx(Ng,{ref:o,className:G("flex cursor-default items-center justify-center py-1",a),...s,children:i.jsx(Pr,{className:"h-4 w-4"})}));vx.displayName=Ng.displayName;const w2=y.forwardRef(({className:a,children:s,position:o="popper",...u},d)=>i.jsx(jv,{children:i.jsxs(Cg,{ref:d,className:G("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",o==="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:o,...u,children:[i.jsx(yx,{}),i.jsx(Nv,{className:G("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),i.jsx(vx,{})]})}));w2.displayName=Cg.displayName;const E2=y.forwardRef(({className:a,...s},o)=>i.jsx(wg,{ref:o,className:G("px-2 py-1.5 text-sm font-semibold",a),...s}));E2.displayName=wg.displayName;const M2=y.forwardRef(({className:a,children:s,...o},u)=>i.jsxs(Eg,{ref:u,className:G("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),...o,children:[i.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Cv,{children:i.jsx(rs,{className:"h-4 w-4"})})}),i.jsx(wv,{children:s})]}));M2.displayName=Eg.displayName;const T2=y.forwardRef(({className:a,...s},o)=>i.jsx(Mg,{ref:o,className:G("-mx-1 my-1 h-px bg-muted",a),...s}));T2.displayName=Mg.displayName;const O2=y.lazy(()=>zt(()=>Promise.resolve().then(()=>Sx),void 0).then(a=>({default:a.CodeEditor})));function OE({rawJsonContent:a,isRawJsonValid:s,rawJsonEdits:o,onRawJsonChange:u,profileEnv:d,missingRequiredFields:m=[]}){const h=m.length>0;return i.jsx(y.Suspense,{fallback:i.jsxs("div",{className:"flex items-center justify-center h-full",children:[i.jsx(Un,{className:"w-6 h-6 animate-spin text-muted-foreground"}),i.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:i.jsxs("div",{className:"h-full flex flex-col",children:[!s&&o!==null&&i.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:[i.jsx(xi,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),s&&h&&i.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:[i.jsx(Qa,{className:"w-4 h-4 mt-0.5 text-amber-500 shrink-0"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Missing required fields:"})," ",i.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.join(", ")}),i.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."})]})]}),i.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:i.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:i.jsx(O2,{value:a,onChange:u,language:"json",minHeight:"100%"})})}),i.jsx("div",{className:"mx-6 mb-4",children:i.jsx("div",{className:"border rounded-md overflow-hidden",children:i.jsx(xx,{profileEnv:d})})})]})})}const A2=y.forwardRef(({className:a,value:s=0,max:o=100,indicatorClassName:u,...d},m)=>{const h=Math.min(Math.max(s/o*100,0),100);return i.jsx("div",{ref:m,role:"progressbar","aria-valuemin":0,"aria-valuemax":o,"aria-valuenow":s,className:G("relative h-2 w-full overflow-hidden rounded-full bg-secondary",a),...d,children:i.jsx("div",{className:G("h-full transition-all",u||"bg-primary"),style:{width:`${h}%`}})})});A2.displayName="Progress";var Gt={},Xp;function z2(){if(Xp)return Gt;Xp=1;var a=Gt&&Gt.__assign||function(){return a=Object.assign||function(k){for(var N,H=1,Z=arguments.length;H<Z;H++){N=arguments[H];for(var te in N)Object.prototype.hasOwnProperty.call(N,te)&&(k[te]=N[te])}return k},a.apply(this,arguments)},s=Gt&&Gt.__createBinding||(Object.create?(function(k,N,H,Z){Z===void 0&&(Z=H);var te=Object.getOwnPropertyDescriptor(N,H);(!te||("get"in te?!N.__esModule:te.writable||te.configurable))&&(te={enumerable:!0,get:function(){return N[H]}}),Object.defineProperty(k,Z,te)}):(function(k,N,H,Z){Z===void 0&&(Z=H),k[Z]=N[H]})),o=Gt&&Gt.__setModuleDefault||(Object.create?(function(k,N){Object.defineProperty(k,"default",{enumerable:!0,value:N})}):function(k,N){k.default=N}),u=Gt&&Gt.__importStar||function(k){if(k&&k.__esModule)return k;var N={};if(k!=null)for(var H in k)H!=="default"&&Object.prototype.hasOwnProperty.call(k,H)&&s(N,k,H);return o(N,k),N},d=Gt&&Gt.__rest||function(k,N){var H={};for(var Z in k)Object.prototype.hasOwnProperty.call(k,Z)&&N.indexOf(Z)<0&&(H[Z]=k[Z]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var te=0,Z=Object.getOwnPropertySymbols(k);te<Z.length;te++)N.indexOf(Z[te])<0&&Object.prototype.propertyIsEnumerable.call(k,Z[te])&&(H[Z[te]]=k[Z[te]]);return H};Object.defineProperty(Gt,"__esModule",{value:!0});var m=u(Og()),h=89,p=90,x=77,b=57,w=219,v=222,S=192,M=100,A=3e3,U=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),_=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),T="npm__react-simple-code-editor__textarea",K=`
|
|
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(ms,hs){return hs>=Dt&&hs<=Gn?re+ms:ms}).join(`
|
|
45
45
|
`),selectionStart:xe&&/\S/.test(xe)?Me+re.length:Me,selectionEnd:nt+re.length*(Gn-Dt+1)})}else{var St=Me+re.length;Tn({value:me.substring(0,Me)+re+me.substring(nt),selectionStart:St,selectionEnd:St})}else if($.key==="Backspace"){var Wt=Me!==nt,vn=me.substring(0,Me);if(vn.endsWith(re)&&!Wt){$.preventDefault();var St=Me-re.length;Tn({value:me.substring(0,Me-re.length)+me.substring(nt),selectionStart:St,selectionEnd:St})}}else if($.key==="Enter"){if(Me===nt){var ds=Zt(me,Me).pop(),Xa=ds?.match(/^\s+/);if(Xa?.[0]){$.preventDefault();var fs=`
|
|
46
46
|
`+Xa[0],St=Me+fs.length;Tn({value:me.substring(0,Me)+fs+me.substring(nt),selectionStart:St,selectionEnd:St})}}}else if($.keyCode===b||$.keyCode===w||$.keyCode===v||$.keyCode===S){var rn=void 0;$.keyCode===b&&$.shiftKey?rn=["(",")"]:$.keyCode===w?$.shiftKey?rn=["{","}"]:rn=["[","]"]:$.keyCode===v?$.shiftKey?rn=['"','"']:rn=["'","'"]:$.keyCode===S&&!$.shiftKey&&(rn=["`","`"]),Me!==nt&&rn&&($.preventDefault(),Tn({value:me.substring(0,Me)+rn[0]+me.substring(Me,nt)+rn[1]+me.substring(nt),selectionStart:Me,selectionEnd:nt+2}))}else(_?$.metaKey&&$.keyCode===p:$.ctrlKey&&$.keyCode===p)&&!$.shiftKey&&!$.altKey?($.preventDefault(),xl()):(_?$.metaKey&&$.keyCode===p&&$.shiftKey:U?$.ctrlKey&&$.keyCode===h:$.ctrlKey&&$.keyCode===p&&$.shiftKey)&&!$.altKey?($.preventDefault(),us()):$.keyCode===x&&$.ctrlKey&&(!_||$.shiftKey)&&($.preventDefault(),ma(function(Kn){return!Kn}))}},Yn=function($){var Ee=$.currentTarget,me=Ee.value,Me=Ee.selectionStart,nt=Ee.selectionEnd;Ln({value:me,selectionStart:Me,selectionEnd:nt},!0),J(me)};return m.useEffect(function(){Va()},[Va]),m.useImperativeHandle(H,function(){return{get session(){return{history:Ne.current}},set session($){Ne.current=$.history}}},[]),m.createElement("div",a({},Bn,{style:a(a({},L.container),yt)}),m.createElement("pre",a({className:fe,"aria-hidden":"true",style:a(a(a({},L.editor),L.highlight),Hn)},typeof ct=="string"?{dangerouslySetInnerHTML:{__html:ct+"<br />"}}:{children:ct})),m.createElement("textarea",{ref:function($){return Vt.current=$},style:a(a(a({},L.editor),L.textarea),Hn),className:T+(tt?" ".concat(tt):""),id:kt,value:Qt,onChange:Yn,onKeyDown:cs,onClick:ve,onKeyUp:X,onFocus:De,onBlur:ye,disabled:te,form:ce,maxLength:O,minLength:W,name:se,placeholder:ee,readOnly:Ae,required:Ge,autoFocus:Z,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),m.createElement("style",{dangerouslySetInnerHTML:{__html:K}}))}),L={container:{position:"relative",textAlign:"left",boxSizing:"border-box",padding:0,overflow:"hidden"},textarea:{position:"absolute",top:0,left:0,height:"100%",width:"100%",resize:"none",color:"inherit",overflow:"hidden",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased",WebkitTextFillColor:"transparent"},highlight:{position:"relative",pointerEvents:"none"},editor:{margin:0,border:0,background:"none",boxSizing:"inherit",display:"inherit",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontVariantLigatures:"inherit",fontWeight:"inherit",letterSpacing:"inherit",lineHeight:"inherit",tabSize:"inherit",textIndent:"inherit",textRendering:"inherit",textTransform:"inherit",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"break-word"}};return Gt.default=B,Gt}var D2=z2();const _2=Uv(D2),k2=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function R2(a){return k2.some(s=>s.test(a))}function U2(a){if(!a.trim())return{valid:!0};try{return JSON.parse(a),{valid:!0}}catch(s){const u=s.message,d=u.match(/position (\d+)/);if(d){const m=parseInt(d[1],10),h=a.substring(0,m).split(`
|
|
47
|
-
`);return{valid:!1,error:u,line:h.length}}return{valid:!1,error:u}}}function bx({value:a,onChange:s,language:o="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=Kg(),[p,x]=y.useState(!1),[b,w]=y.useState(!0),v=y.useMemo(()=>o==="json"?U2(a):{valid:!0},[a,o]),S=y.useCallback(M=>i.jsx(rS,{theme:h?vp.nightOwl:vp.github,code:M,language:o,children:({tokens:A,getLineProps:U,getTokenProps:_})=>{let T=!1;return i.jsx(i.Fragment,{children:A.map((K,B)=>i.jsx("div",{...U({line:K}),className:G(v.line===B+1&&"bg-destructive/20"),children:K.map((L,k)=>{let N=!1;if(L.types.includes("property")){const Z=L.content.replace(/['"]/g,"");R2(Z)?T=!0:T=!1}else(L.types.includes("string")||L.types.includes("number")||L.types.includes("boolean"))&&T?(N=!0,T=!1):L.types.includes("punctuation")&&L.content!==":"&&L.content!=="["&&L.content!=="{"&&(T=!1);const H=_({token:L});return N&&b&&(H.className=G(H.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...H},k)})},B))})}}),[h,o,v.line,b]);return i.jsxs("div",{className:G("flex flex-col",d),children:[i.jsxs("div",{className:G("relative rounded-md border overflow-hidden","bg-muted/30",p&&"ring-2 ring-ring ring-offset-2 ring-offset-background",u&&"opacity-70 cursor-not-allowed",!v.valid&&"border-destructive"),style:{minHeight:m},children:[i.jsx(_2,{value:a,onValueChange:u?()=>{}:s,highlight:S,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:G("focus:outline-none font-mono text-sm",u&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:m}},h?"dark-editor":"light-editor"),i.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:i.jsx(ot,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>w(!b),title:b?"Reveal sensitive values":"Mask sensitive values",children:b?i.jsx(Zr,{className:"h-3 w-3"}):i.jsx(Xr,{className:"h-3 w-3"})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[v.valid?i.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[i.jsx(Wr,{className:"w-3 h-3 text-green-500"}),"Valid ",o.toUpperCase()]}):i.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[i.jsx(Wc,{className:"w-3 h-3"}),v.error,v.line&&` (line ${v.line})`]}),u&&i.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const Sx=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:bx},Symbol.toStringTag,{value:"Module"})),q2={webSearchConfig:null,webSearchStatus:null,webSearchLoading:!0,webSearchStatusLoading:!0,webSearchSaving:!1,webSearchError:null,webSearchSuccess:!1,globalEnvConfig:null,globalEnvLoading:!0,globalEnvSaving:!1,globalEnvError:null,globalEnvSuccess:!1,proxyConfig:null,proxyLoading:!0,proxySaving:!1,proxyError:null,proxySuccess:!1,proxyTestResult:null,proxyTesting:!1,rawConfig:null,rawConfigLoading:!1};function B2(a,s){switch(s.type){case"SET_WEBSEARCH_CONFIG":return{...a,webSearchConfig:s.payload};case"SET_WEBSEARCH_STATUS":return{...a,webSearchStatus:s.payload};case"SET_WEBSEARCH_LOADING":return{...a,webSearchLoading:s.payload};case"SET_WEBSEARCH_STATUS_LOADING":return{...a,webSearchStatusLoading:s.payload};case"SET_WEBSEARCH_SAVING":return{...a,webSearchSaving:s.payload};case"SET_WEBSEARCH_ERROR":return{...a,webSearchError:s.payload};case"SET_WEBSEARCH_SUCCESS":return{...a,webSearchSuccess:s.payload};case"SET_GLOBALENV_CONFIG":return{...a,globalEnvConfig:s.payload};case"SET_GLOBALENV_LOADING":return{...a,globalEnvLoading:s.payload};case"SET_GLOBALENV_SAVING":return{...a,globalEnvSaving:s.payload};case"SET_GLOBALENV_ERROR":return{...a,globalEnvError:s.payload};case"SET_GLOBALENV_SUCCESS":return{...a,globalEnvSuccess:s.payload};case"SET_PROXY_CONFIG":return{...a,proxyConfig:s.payload};case"SET_PROXY_LOADING":return{...a,proxyLoading:s.payload};case"SET_PROXY_SAVING":return{...a,proxySaving:s.payload};case"SET_PROXY_ERROR":return{...a,proxyError:s.payload};case"SET_PROXY_SUCCESS":return{...a,proxySuccess:s.payload};case"SET_PROXY_TEST_RESULT":return{...a,proxyTestResult:s.payload};case"SET_PROXY_TESTING":return{...a,proxyTesting:s.payload};case"SET_RAW_CONFIG":return{...a,rawConfig:s.payload};case"SET_RAW_CONFIG_LOADING":return{...a,rawConfigLoading:s.payload};default:return a}}const jx=y.createContext(null);function H2({children:a}){const[s,o]=y.useReducer(B2,q2);return i.jsx(jx.Provider,{value:{state:s,dispatch:o},children:a})}function Nx(){const a=y.useContext(jx);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function L2(){const{dispatch:a}=Nx(),s=y.useCallback(N=>a({type:"SET_WEBSEARCH_CONFIG",payload:N}),[a]),o=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS",payload:N}),[a]),u=y.useCallback(N=>a({type:"SET_WEBSEARCH_LOADING",payload:N}),[a]),d=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:N}),[a]),m=y.useCallback(N=>a({type:"SET_WEBSEARCH_SAVING",payload:N}),[a]),h=y.useCallback(N=>a({type:"SET_WEBSEARCH_ERROR",payload:N}),[a]),p=y.useCallback(N=>a({type:"SET_WEBSEARCH_SUCCESS",payload:N}),[a]),x=y.useCallback(N=>a({type:"SET_GLOBALENV_CONFIG",payload:N}),[a]),b=y.useCallback(N=>a({type:"SET_GLOBALENV_LOADING",payload:N}),[a]),w=y.useCallback(N=>a({type:"SET_GLOBALENV_SAVING",payload:N}),[a]),v=y.useCallback(N=>a({type:"SET_GLOBALENV_ERROR",payload:N}),[a]),S=y.useCallback(N=>a({type:"SET_GLOBALENV_SUCCESS",payload:N}),[a]),M=y.useCallback(N=>a({type:"SET_PROXY_CONFIG",payload:N}),[a]),A=y.useCallback(N=>a({type:"SET_PROXY_LOADING",payload:N}),[a]),U=y.useCallback(N=>a({type:"SET_PROXY_SAVING",payload:N}),[a]),_=y.useCallback(N=>a({type:"SET_PROXY_ERROR",payload:N}),[a]),T=y.useCallback(N=>a({type:"SET_PROXY_SUCCESS",payload:N}),[a]),K=y.useCallback(N=>a({type:"SET_PROXY_TEST_RESULT",payload:N}),[a]),B=y.useCallback(N=>a({type:"SET_PROXY_TESTING",payload:N}),[a]),L=y.useCallback(N=>a({type:"SET_RAW_CONFIG",payload:N}),[a]),k=y.useCallback(N=>a({type:"SET_RAW_CONFIG_LOADING",payload:N}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:o,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:b,setGlobalEnvSaving:w,setGlobalEnvError:v,setGlobalEnvSuccess:S,setProxyConfig:M,setProxyLoading:A,setProxySaving:U,setProxyError:_,setProxySuccess:T,setProxyTestResult:K,setProxyTesting:B,setRawConfig:L,setRawConfigLoading:k}),[s,o,u,d,m,h,p,x,b,w,v,S,M,A,U,_,T,K,B,L,k])}function Y2(){const[a,s]=qv(),o=a.get("tab")?.toLowerCase(),u=o==="globalenv"?"globalenv":o==="proxy"?"proxy":o==="auth"?"auth":o==="thinking"?"thinking":o==="backups"?"backups":"websearch",d=y.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function G2(){const{state:a}=Nx(),s=L2(),[o,u]=y.useState(!1),d=y.useCallback(async()=>{try{s.setRawConfigLoading(!0);const h=await fetch("/api/config/raw");if(!h.ok){s.setRawConfig(null);return}const p=await h.text();s.setRawConfig(p)}catch{s.setRawConfig(null)}finally{s.setRawConfigLoading(!1)}},[s]),m=y.useCallback(async()=>{if(a.rawConfig)try{await navigator.clipboard.writeText(a.rawConfig),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[a.rawConfig]);return{rawConfig:a.rawConfig,loading:a.rawConfigLoading,copied:o,fetchRawConfig:d,copyToClipboard:m}}const K2=[{value:"websearch",label:"Web",icon:gb},{value:"globalenv",label:"Env",icon:Zc},{value:"thinking",label:"Think",icon:xb},{value:"proxy",label:"Proxy",icon:yb},{value:"auth",label:"Auth",icon:Kc},{value:"backups",label:"Backup",icon:vb}];function Zp({activeTab:a,onTabChange:s}){return i.jsx(mx,{value:a,onValueChange:o=>s(o),children:i.jsx(pd,{className:"grid w-full grid-cols-6",children:K2.map(({value:o,label:u,icon:d})=>i.jsxs(Kr,{value:o,className:"gap-1.5 px-1 text-xs",children:[i.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:u})]},o))})})}function Wp(){return i.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[i.jsx(Le,{className:"h-4 w-2/3"}),i.jsx("div",{className:"p-4 rounded-lg border",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-5 w-32"}),i.jsx(Le,{className:"h-4 w-48"})]}),i.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(Le,{className:"h-5 w-24"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}function Cx(a,s=3,o=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,o)).then(()=>Cx(a,s-1,o*2))})}function os(a){return y.lazy(()=>Cx(a))}const $p=os(()=>zt(()=>import("./index-BTBpI5th.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Jp=os(()=>zt(()=>import("./globalenv-section-BEKtYN6I.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),Pp=os(()=>zt(()=>import("./index-C2MS84sf.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),Fp=os(()=>zt(()=>import("./index-BZn6kF0u.js"),__vite__mapDeps([12,1,2,3,4,13,14,5,6,7,8,9]))),Ip=os(()=>zt(()=>import("./auth-section-CNhNN1Jp.js"),__vite__mapDeps([15,1,2,4,5,6,7,8,9]))),eg=os(()=>zt(()=>import("./backups-section-CZ721HIu.js"),__vite__mapDeps([16,1,2,14,4,5,6,7,8,9])));class tg extends y.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}render(){return this.state.hasError?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center p-6 max-w-md",children:[i.jsx(Wc,{className:"w-12 h-12 mx-auto mb-4 text-destructive"}),i.jsx("p",{className:"font-medium text-foreground mb-2",children:"Failed to load section"}),i.jsx("p",{className:"text-sm mb-4",children:this.state.error?.message||"Unknown error occurred"}),i.jsxs(ot,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(mi,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function Q2(){const{activeTab:a,setActiveTab:s}=Y2(),{rawConfig:o,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=G2();y.useEffect(()=>{m()},[m]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsxs("div",{className:"h-[calc(100vh-100px)]",children:[i.jsxs("div",{className:"md:hidden h-full flex flex-col",children:[i.jsx("div",{className:"border-b bg-background p-4",children:i.jsx(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]}),i.jsxs(dd,{direction:"horizontal",className:"h-full hidden md:flex",children:[i.jsx(hi,{defaultSize:40,minSize:30,maxSize:55,children:i.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[i.jsx("div",{className:"p-5 border-b bg-background",children:i.jsx(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]})}),i.jsx(fd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx($r,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(hi,{defaultSize:60,minSize:35,children:i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(gp,{className:"w-5 h-5 text-primary"}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-semibold",children:"config.yaml"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ot,{variant:"outline",size:"sm",onClick:h,disabled:!o,children:d?i.jsxs(i.Fragment,{children:[i.jsx(rs,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Hr,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(ot,{variant:"outline",size:"sm",onClick:m,disabled:u,children:i.jsx(mi,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),i.jsx("div",{className:"flex-1 overflow-auto",children:u?i.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[i.jsx(mi,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):o?i.jsx(bx,{value:o,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsxs("div",{className:"text-center",children:[i.jsx(gp,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{children:"Config file not found"}),i.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})]})}function V2(){return i.jsx(H2,{children:i.jsx(Q2,{})})}const X2=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:V2},Symbol.toStringTag,{value:"Module"})),AE=Av,zE=Dv,DE=zv,Z2=y.forwardRef(({className:a,align:s="center",sideOffset:o=4,...u},d)=>i.jsx(Ov,{children:i.jsx(Tg,{ref:d,align:s,sideOffset:o,className:G("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...u})}));Z2.displayName=Tg.displayName;function W2(a,s,o="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:o}).format(s).split(/\s/g).slice(2).join(" ")}const $2={},di={};function fl(a,s){try{const u=($2[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in di?di[u]:ng(u,u.split(":"))}catch{if(a in di)return di[a];const o=a?.match(J2);return o?ng(a,o.slice(1)):NaN}}const J2=/([+-]\d\d):?(\d\d)?/;function ng(a,s){const o=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return di[a]=o*60+u>0?o*60+u+d:o*60-u-d}class Rn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(fl(this.timeZone,this))?this.setTime(NaN):s.length?typeof s[0]=="number"&&(s.length===1||s.length===2&&typeof s[1]!="number")?this.setTime(s[0]):typeof s[0]=="string"?this.setTime(+new Date(s[0])):s[0]instanceof Date?this.setTime(+s[0]):(this.setTime(+new Date(...s)),wx(this),Lc(this)):this.setTime(Date.now())}static tz(s,...o){return o.length?new Rn(...o,s):new Rn(Date.now(),s)}withTimeZone(s){return new Rn(+this,s)}getTimezoneOffset(){const s=-fl(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Lc(this),+this}[Symbol.for("constructDateFrom")](s){return new Rn(+new Date(s),this.timeZone)}}const ag=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!ag.test(a))return;const s=a.replace(ag,"$1UTC");Rn.prototype[s]&&(a.startsWith("get")?Rn.prototype[a]=function(){return this.internal[s]()}:(Rn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),P2(this),+this},Rn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Lc(this),+this}))});function Lc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-fl(a.timeZone,a)*60))}function P2(a){Date.prototype.setFullYear.call(a,a.internal.getUTCFullYear(),a.internal.getUTCMonth(),a.internal.getUTCDate()),Date.prototype.setHours.call(a,a.internal.getUTCHours(),a.internal.getUTCMinutes(),a.internal.getUTCSeconds(),a.internal.getUTCMilliseconds()),wx(a)}function wx(a){const s=fl(a.timeZone,a),o=s>0?Math.floor(s):Math.ceil(s),u=new Date(+a);u.setUTCHours(u.getUTCHours()-1);const d=-new Date(+a).getTimezoneOffset(),m=-new Date(+u).getTimezoneOffset(),h=d-m,p=Date.prototype.getHours.apply(a)!==a.internal.getUTCHours();h&&p&&a.internal.setUTCMinutes(a.internal.getUTCMinutes()+h);const x=d-o;x&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+x);const b=new Date(+a);b.setUTCSeconds(0);const w=d>0?b.getSeconds():(b.getSeconds()-60)%60,v=Math.round(-(fl(a.timeZone,a)*60))%60;(v||w)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+w));const S=fl(a.timeZone,a),M=S>0?Math.floor(S):Math.ceil(S),U=-new Date(+a).getTimezoneOffset()-M,_=M!==o,T=U-x;if(_&&T){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+T);const K=fl(a.timeZone,a),B=K>0?Math.floor(K):Math.ceil(K),L=M-B;L&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+L),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+L))}}class ca extends Rn{static tz(s,...o){return o.length?new ca(...o,s):new ca(Date.now(),s)}toISOString(){const[s,o,u]=this.tzComponents(),d=`${s}${o}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,o,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${o} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[o,u,d]=this.tzComponents();return`${s} GMT${o}${u}${d} (${W2(this.timeZone,this)})`}toLocaleString(s,o){return Date.prototype.toLocaleString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleDateString(s,o){return Date.prototype.toLocaleDateString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleTimeString(s,o){return Date.prototype.toLocaleTimeString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),o=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[o,u,d]}withTimeZone(s){return new ca(+this,s)}[Symbol.for("constructDateFrom")](s){return new ca(+new Date(s),this.timeZone)}}const lg=5,F2=4;function I2(a,s){const o=s.startOfMonth(a),u=o.getDay()>0?o.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,lg*7-1);return s.getMonth(a)===s.getMonth(m)?lg:F2}function Ex(a,s){const o=s.startOfMonth(a),u=o.getDay();return u===1?o:u===0?s.addDays(o,-6):s.addDays(o,-1*(u-1))}function eC(a,s){const o=Ex(a,s),u=I2(a,s);return s.addDays(o,u*7-1)}const Mx={...li,labels:{labelDayButton:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ri(h,p,{locale:li,...o});let m=d(a,"PPPP");return s.today&&(m=`Today, ${m}`),s.selected&&(m=`${m}, selected`),m},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:a=>`Week ${a}`,labelYearDropdown:"Choose the Year",labelGrid:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ri(d,m,{locale:li,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ri(h,p,{locale:li,...o});let m=d(a,"PPPP");return s?.today&&(m=`Today, ${m}`),m},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ri(d,m,{locale:li,...s}),u(a,"cccc")}}};class sn{constructor(s,o){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ca.tz(this.options.timeZone):new this.Date,this.newDate=(u,d,m)=>this.overrides?.newDate?this.overrides.newDate(u,d,m):this.options.timeZone?new ca(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):Cb(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):wb(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):Eb(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):Mb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):Tb(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):Ob(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Ab(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):zb(u),m=new Set(d.map(p=>this.getYear(p)));if(m.size===d.length)return d;const h=[];return m.forEach(p=>{h.push(new Date(p,0,1))}),h},this.endOfBroadcastWeek=u=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(u):eC(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Db(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):_b(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):kb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Rb(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ri(u,d,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(h):h},this.getISOWeek=u=>this.overrides?.getISOWeek?this.overrides.getISOWeek(u):Ub(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):qb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Bb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Hb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Lb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):Yb(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Gb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Kb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Qb(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Vb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Xb(u),this.min=u=>this.overrides?.min?this.overrides.min(u):Zb(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Wb(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):$b(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):Ex(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Jb(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Pb(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Fb(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):Ib(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):eS(u),this.options={locale:Mx,...s},this.overrides=o}getDigitMap(){const{numerals:s="latn"}=this.options,o=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=o.format(d);return u}replaceDigits(s){const o=this.getDigitMap();return s.replace(/\d/g,u=>o[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&sn.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:o,timeZone:u,numerals:d}=this.options,m=o?.code;if(m&&sn.yearFirstLocales.has(m))try{return new Intl.DateTimeFormat(m,{month:"long",year:"numeric",timeZone:u,numberingSystem:d}).format(s)}catch{}const h=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(s,h)}}sn.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const qn=new sn;class Tx{constructor(s,o,u=qn){this.date=s,this.displayMonth=o,this.outside=!!(o&&!u.isSameMonth(s,o)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(o,"yyyy-MM"),this.dateMonthId=u.format(s,"yyyy-MM")}isEqualTo(s){return this.dateLib.isSameDay(s.date,this.date)&&this.dateLib.isSameMonth(s.displayMonth,this.displayMonth)}}class tC{constructor(s,o){this.date=s,this.weeks=o}}class nC{constructor(s,o){this.days=o,this.weekNumber=s}}function aC(a){return I.createElement("button",{...a})}function lC(a){return I.createElement("span",{...a})}function sC(a){const{size:s=24,orientation:o="left",className:u}=a;return I.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},o==="up"&&I.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),o==="down"&&I.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),o==="left"&&I.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),o==="right"&&I.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function iC(a){const{day:s,modifiers:o,...u}=a;return I.createElement("td",{...u})}function rC(a){const{day:s,modifiers:o,...u}=a,d=I.useRef(null);return I.useEffect(()=>{o.focused&&d.current?.focus()},[o.focused]),I.createElement("button",{ref:d,...u})}var ue;(function(a){a.Root="root",a.Chevron="chevron",a.Day="day",a.DayButton="day_button",a.CaptionLabel="caption_label",a.Dropdowns="dropdowns",a.Dropdown="dropdown",a.DropdownRoot="dropdown_root",a.Footer="footer",a.MonthGrid="month_grid",a.MonthCaption="month_caption",a.MonthsDropdown="months_dropdown",a.Month="month",a.Months="months",a.Nav="nav",a.NextMonthButton="button_next",a.PreviousMonthButton="button_previous",a.Week="week",a.Weeks="weeks",a.Weekday="weekday",a.Weekdays="weekdays",a.WeekNumber="week_number",a.WeekNumberHeader="week_number_header",a.YearsDropdown="years_dropdown"})(ue||(ue={}));var lt;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(lt||(lt={}));var Cn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(Cn||(Cn={}));var ln;(function(a){a.weeks_before_enter="weeks_before_enter",a.weeks_before_exit="weeks_before_exit",a.weeks_after_enter="weeks_after_enter",a.weeks_after_exit="weeks_after_exit",a.caption_after_enter="caption_after_enter",a.caption_after_exit="caption_after_exit",a.caption_before_enter="caption_before_enter",a.caption_before_exit="caption_before_exit"})(ln||(ln={}));function oC(a){const{options:s,className:o,components:u,classNames:d,...m}=a,h=[d[ue.Dropdown],o].join(" "),p=s?.find(({value:x})=>x===m.value);return I.createElement("span",{"data-disabled":m.disabled,className:d[ue.DropdownRoot]},I.createElement(u.Select,{className:h,...m},s?.map(({value:x,label:b,disabled:w})=>I.createElement(u.Option,{key:x,value:x,disabled:w},b))),I.createElement("span",{className:d[ue.CaptionLabel],"aria-hidden":!0},p?.label,I.createElement(u.Chevron,{orientation:"down",size:18,className:d[ue.Chevron]})))}function uC(a){return I.createElement("div",{...a})}function cC(a){return I.createElement("div",{...a})}function dC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u},a.children)}function fC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u})}function mC(a){return I.createElement("table",{...a})}function hC(a){return I.createElement("div",{...a})}const Ox=y.createContext(void 0);function yi(){const a=y.useContext(Ox);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function pC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}function gC(a){const{onPreviousClick:s,onNextClick:o,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:x,labelNext:b}}=yi(),w=y.useCallback(S=>{d&&o?.(S)},[d,o]),v=y.useCallback(S=>{u&&s?.(S)},[u,s]);return I.createElement("nav",{...m},I.createElement(h.PreviousMonthButton,{type:"button",className:p[ue.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},I.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[ue.Chevron],orientation:"left"})),I.createElement(h.NextMonthButton,{type:"button",className:p[ue.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":b(d),onClick:w},I.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[ue.Chevron]})))}function xC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function yC(a){return I.createElement("option",{...a})}function vC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function bC(a){const{rootRef:s,...o}=a;return I.createElement("div",{...o,ref:s})}function SC(a){return I.createElement("select",{...a})}function jC(a){const{week:s,...o}=a;return I.createElement("tr",{...o})}function NC(a){return I.createElement("th",{...a})}function CC(a){return I.createElement("thead",{"aria-hidden":!0},I.createElement("tr",{...a}))}function wC(a){const{week:s,...o}=a;return I.createElement("th",{...o})}function EC(a){return I.createElement("th",{...a})}function MC(a){return I.createElement("tbody",{...a})}function TC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}const OC=Object.freeze(Object.defineProperty({__proto__:null,Button:aC,CaptionLabel:lC,Chevron:sC,Day:iC,DayButton:rC,Dropdown:oC,DropdownNav:uC,Footer:cC,Month:dC,MonthCaption:fC,MonthGrid:mC,Months:hC,MonthsDropdown:pC,Nav:gC,NextMonthButton:xC,Option:yC,PreviousMonthButton:vC,Root:bC,Select:SC,Week:jC,WeekNumber:wC,WeekNumberHeader:EC,Weekday:NC,Weekdays:CC,Weeks:MC,YearsDropdown:TC},Symbol.toStringTag,{value:"Module"}));function da(a,s,o=!1,u=qn){let{from:d,to:m}=a;const{differenceInCalendarDays:h,isSameDay:p}=u;return d&&m?(h(m,d)<0&&([d,m]=[m,d]),h(s,d)>=(o?1:0)&&h(m,s)>=(o?1:0)):!o&&m?p(m,s):!o&&d?p(d,s):!1}function xd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function so(a){return!!(a&&typeof a=="object"&&"from"in a)}function yd(a){return!!(a&&typeof a=="object"&&"after"in a)}function vd(a){return!!(a&&typeof a=="object"&&"before"in a)}function Ax(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function zx(a,s){return Array.isArray(a)&&a.every(s.isDate)}function fa(a,s,o=qn){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:m,isAfter:h}=o;return u.some(p=>{if(typeof p=="boolean")return p;if(o.isDate(p))return d(a,p);if(zx(p,o))return p.some(x=>d(a,x));if(so(p))return da(p,a,!1,o);if(Ax(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(xd(p)){const x=m(p.before,a),b=m(p.after,a),w=x>0,v=b<0;return h(p.before,p.after)?v&&w:w||v}return yd(p)?m(a,p.after)>0:vd(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function AC(a,s,o,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:x,broadcastCalendar:b,today:w=d.today()}=s,{isSameDay:v,isSameMonth:S,startOfMonth:M,isBefore:A,endOfMonth:U,isAfter:_}=d,T=o&&M(o),K=u&&U(u),B={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},L={};for(const k of a){const{date:N,displayMonth:H}=k,Z=!!(H&&!S(N,H)),te=!!(T&&A(N,T)),ce=!!(K&&_(N,K)),be=!!(m&&fa(N,m,d)),oe=!!(h&&fa(N,h,d))||te||ce||!b&&!x&&Z||b&&x===!1&&Z,Ye=v(N,w);Z&&B.outside.push(k),be&&B.disabled.push(k),oe&&B.hidden.push(k),Ye&&B.today.push(k),p&&Object.keys(p).forEach(je=>{const P=p?.[je];P&&fa(N,P,d)&&(L[je]?L[je].push(k):L[je]=[k])})}return k=>{const N={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},H={};for(const Z in B){const te=B[Z];N[Z]=te.some(ce=>ce===k)}for(const Z in L)H[Z]=L[Z].some(te=>te===k);return{...N,...H}}}function zC(a,s,o={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[m])=>(o[m]?d.push(o[m]):s[lt[m]]?d.push(s[lt[m]]):s[Cn[m]]&&d.push(s[Cn[m]]),d),[s[ue.Day]])}function DC(a){return{...OC,...a}}function _C(a){const s={"data-mode":a.mode??void 0,"data-required":"required"in a?a.required:void 0,"data-multiple-months":a.numberOfMonths&&a.numberOfMonths>1||void 0,"data-week-numbers":a.showWeekNumber||void 0,"data-broadcast-calendar":a.broadcastCalendar||void 0,"data-nav-layout":a.navLayout||void 0};return Object.entries(a).forEach(([o,u])=>{o.startsWith("data-")&&(s[o]=u)}),s}function kC(){const a={};for(const s in ue)a[ue[s]]=`rdp-${ue[s]}`;for(const s in lt)a[lt[s]]=`rdp-${lt[s]}`;for(const s in Cn)a[Cn[s]]=`rdp-${Cn[s]}`;for(const s in ln)a[ln[s]]=`rdp-${ln[s]}`;return a}function Dx(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const RC=Dx;function UC(a,s,o){return(o??new sn(s)).format(a,"d")}function qC(a,s=qn){return s.format(a,"LLLL")}function BC(a,s,o){return(o??new sn(s)).format(a,"cccccc")}function HC(a,s=qn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function LC(){return""}function _x(a,s=qn){return s.format(a,"yyyy")}const YC=_x,GC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Dx,formatDay:UC,formatMonthCaption:RC,formatMonthDropdown:qC,formatWeekNumber:HC,formatWeekNumberHeader:LC,formatWeekdayName:BC,formatYearCaption:YC,formatYearDropdown:_x},Symbol.toStringTag,{value:"Module"}));function KC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...GC,...a}}function bd(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const QC=bd;function Sd(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const VC=Sd;function kx(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function Rx(a){return"Choose the Month"}function Ux(){return""}const XC="Go to the Next Month";function qx(a,s){return XC}function Bx(a){return"Go to the Previous Month"}function Hx(a,s,o){return(o??new sn(s)).format(a,"cccc")}function Lx(a,s){return`Week ${a}`}function Yx(a){return"Week Number"}function Gx(a){return"Choose the Year"}const ZC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:VC,labelDay:QC,labelDayButton:bd,labelGrid:Sd,labelGridcell:kx,labelMonthDropdown:Rx,labelNav:Ux,labelNext:qx,labelPrevious:Bx,labelWeekNumber:Lx,labelWeekNumberHeader:Yx,labelWeekday:Hx,labelYearDropdown:Gx},Symbol.toStringTag,{value:"Module"})),Nn=(a,s,o)=>s||(o?typeof o=="function"?o:(...u)=>o:a);function WC(a,s){const o=s.locale?.labels??{};return{...ZC,...a??{},labelDayButton:Nn(bd,a?.labelDayButton,o.labelDayButton),labelMonthDropdown:Nn(Rx,a?.labelMonthDropdown,o.labelMonthDropdown),labelNext:Nn(qx,a?.labelNext,o.labelNext),labelPrevious:Nn(Bx,a?.labelPrevious,o.labelPrevious),labelWeekNumber:Nn(Lx,a?.labelWeekNumber,o.labelWeekNumber),labelYearDropdown:Nn(Gx,a?.labelYearDropdown,o.labelYearDropdown),labelGrid:Nn(Sd,a?.labelGrid,o.labelGrid),labelGridcell:Nn(kx,a?.labelGridcell,o.labelGridcell),labelNav:Nn(Ux,a?.labelNav,o.labelNav),labelWeekNumberHeader:Nn(Yx,a?.labelWeekNumberHeader,o.labelWeekNumberHeader),labelWeekday:Nn(Hx,a?.labelWeekday,o.labelWeekday)}}function $C(a,s,o,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:x,getMonth:b}=d;return x({start:h(a),end:p(a)}).map(S=>{const M=u.formatMonthDropdown(S,d),A=b(S),U=s&&S<m(s)||o&&S>m(o)||!1;return{value:A,label:M,disabled:U}})}function JC(a,s={},o={}){let u={...s?.[ue.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...o?.[d]}}),u}function PC(a,s,o,u){const d=u??a.today(),m=o?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),h=[];for(let p=0;p<7;p++){const x=a.addDays(m,p);h.push(x)}return h}function FC(a,s,o,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:x}=u,b=m(a),w=h(s),v=p({start:b,end:w});return d&&v.reverse(),v.map(S=>{const M=o.formatYearDropdown(S,u);return{value:x(S),label:M,disabled:!1}})}const vi=a=>a instanceof HTMLElement?a:null,Oc=a=>[...a.querySelectorAll("[data-animated-month]")??[]],IC=a=>vi(a.querySelector("[data-animated-month]")),Ac=a=>vi(a.querySelector("[data-animated-caption]")),zc=a=>vi(a.querySelector("[data-animated-weeks]")),ew=a=>vi(a.querySelector("[data-animated-nav]")),tw=a=>vi(a.querySelector("[data-animated-weekdays]"));function nw(a,s,{classNames:o,months:u,focused:d,dateLib:m}){const h=y.useRef(null),p=y.useRef(u),x=y.useRef(!1);y.useLayoutEffect(()=>{const b=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||b.length===0||u.length!==b.length)return;const w=m.isSameMonth(u[0].date,b[0].date),v=m.isAfter(u[0].date,b[0].date),S=v?o[ln.caption_after_enter]:o[ln.caption_before_enter],M=v?o[ln.weeks_after_enter]:o[ln.weeks_before_enter],A=h.current,U=a.current.cloneNode(!0);if(U instanceof HTMLElement?(Oc(U).forEach(B=>{if(!(B instanceof HTMLElement))return;const L=IC(B);L&&B.contains(L)&&B.removeChild(L);const k=Ac(B);k&&k.classList.remove(S);const N=zc(B);N&&N.classList.remove(M)}),h.current=U):h.current=null,x.current||w||d)return;const _=A instanceof HTMLElement?Oc(A):[],T=Oc(a.current);if(T?.every(K=>K instanceof HTMLElement)&&_&&_.every(K=>K instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const K=ew(a.current);K&&(K.style.zIndex="1"),T.forEach((B,L)=>{const k=_[L];if(!k)return;B.style.position="relative",B.style.overflow="hidden";const N=Ac(B);N&&N.classList.add(S);const H=zc(B);H&&H.classList.add(M);const Z=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),K&&(K.style.zIndex=""),N&&N.classList.remove(S),H&&H.classList.remove(M),B.style.position="",B.style.overflow="",B.contains(k)&&B.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const te=tw(k);te&&(te.style.opacity="0");const ce=Ac(k);ce&&(ce.classList.add(v?o[ln.caption_before_exit]:o[ln.caption_after_exit]),ce.addEventListener("animationend",Z));const be=zc(k);be&&be.classList.add(v?o[ln.weeks_before_exit]:o[ln.weeks_after_exit]),B.insertBefore(k,B.firstChild)})}})}function aw(a,s,o,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:x}=o??{},{addDays:b,differenceInCalendarDays:w,differenceInCalendarMonths:v,endOfBroadcastWeek:S,endOfISOWeek:M,endOfMonth:A,endOfWeek:U,isAfter:_,startOfBroadcastWeek:T,startOfISOWeek:K,startOfWeek:B}=u,L=x?T(d,u):h?K(d):B(d),k=x?S(m):h?M(A(m)):U(A(m)),N=s&&(x?S(s):h?M(s):U(s)),H=N&&_(k,N)?N:k,Z=w(H,L),te=v(m,d)+1,ce=[];for(let Ye=0;Ye<=Z;Ye++){const je=b(L,Ye);ce.push(je)}const oe=(x?35:42)*te;if(p&&ce.length<oe){const Ye=oe-ce.length;for(let je=0;je<Ye;je++){const P=b(ce[ce.length-1],1);ce.push(P)}}return ce}function lw(a){const s=[];return a.reduce((o,u)=>{const d=u.weeks.reduce((m,h)=>m.concat(h.days.slice()),s.slice());return o.concat(d.slice())},s.slice())}function sw(a,s,o,u){const{numberOfMonths:d=1}=o,m=[];for(let h=0;h<d;h++){const p=u.addMonths(a,h);if(s&&p>s)break;m.push(p)}return m}function sg(a,s,o,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let x=d||m||h;const{differenceInCalendarMonths:b,addMonths:w,startOfMonth:v}=u;if(o&&b(o,x)<p-1){const S=-1*(p-1);x=w(o,S)}return s&&b(x,s)<0&&(x=s),v(x)}function iw(a,s,o,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:x,getISOWeek:b,getWeek:w,startOfBroadcastWeek:v,startOfISOWeek:S,startOfWeek:M}=u,A=a.reduce((U,_)=>{const T=o.broadcastCalendar?v(_,u):o.ISOWeek?S(_):M(_),K=o.broadcastCalendar?m(_):o.ISOWeek?h(p(_)):x(p(_)),B=s.filter(H=>H>=T&&H<=K),L=o.broadcastCalendar?35:42;if(o.fixedWeeks&&B.length<L){const H=s.filter(Z=>{const te=L-B.length;return Z>K&&Z<=d(K,te)});B.push(...H)}const k=B.reduce((H,Z)=>{const te=o.ISOWeek?b(Z):w(Z),ce=H.find(oe=>oe.weekNumber===te),be=new Tx(Z,_,u);return ce?ce.days.push(be):H.push(new nC(te,[be])),H},[]),N=new tC(_,k);return U.push(N),U},[]);return o.reverseMonths?A.reverse():A}function rw(a,s){let{startMonth:o,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:x,endOfYear:b,newDate:w,today:v}=s,{fromYear:S,toYear:M,fromMonth:A,toMonth:U}=a;!o&&A&&(o=A),!o&&S&&(o=s.newDate(S,0,1)),!u&&U&&(u=U),!u&&M&&(u=w(M,11,31));const _=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return o?o=h(o):S?o=w(S,0,1):!o&&_&&(o=d(x(a.today??v(),-100))),u?u=p(u):M?u=w(M,11,31):!u&&_&&(u=b(a.today??v())),[o&&m(o),u&&m(u)]}function ow(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m:1,w=h(a);if(!s)return p(w,b);if(!(x(s,a)<m))return p(w,b)}function uw(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m??1:1,w=h(a);if(!s)return p(w,-b);if(!(x(w,s)<=0))return p(w,-b)}function cw(a){const s=[];return a.reduce((o,u)=>o.concat(u.weeks.slice()),s.slice())}function io(a,s){const[o,u]=y.useState(a);return[s===void 0?o:s,u]}function dw(a,s){const[o,u]=rw(a,s),{startOfMonth:d,endOfMonth:m}=s,h=sg(a,o,u,s),[p,x]=io(h,a.month?h:void 0);y.useEffect(()=>{const L=sg(a,o,u,s);x(L)},[a.timeZone]);const{months:b,weeks:w,days:v,previousMonth:S,nextMonth:M}=y.useMemo(()=>{const L=sw(p,u,{numberOfMonths:a.numberOfMonths},s),k=aw(L,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),N=iw(L,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),H=cw(N),Z=lw(N),te=uw(p,o,a,s),ce=ow(p,u,a,s);return{months:N,weeks:H,days:Z,previousMonth:te,nextMonth:ce}},[s,p.getTime(),u?.getTime(),o?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:A,onMonthChange:U}=a,_=L=>w.some(k=>k.days.some(N=>N.isEqualTo(L))),T=L=>{if(A)return;let k=d(L);o&&k<d(o)&&(k=d(o)),u&&k>d(u)&&(k=d(u)),x(k),U?.(k)};return{months:b,weeks:w,days:v,navStart:o,navEnd:u,previousMonth:S,nextMonth:M,goToMonth:T,goToDay:L=>{_(L)||T(L.date)}}}var kn;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(kn||(kn={}));function ig(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function fw(a,s,o,u){let d,m=-1;for(const h of a){const p=s(h);ig(p)&&(p[lt.focused]&&m<kn.FocusedModifier?(d=h,m=kn.FocusedModifier):u?.isEqualTo(h)&&m<kn.LastFocused?(d=h,m=kn.LastFocused):o(h.date)&&m<kn.Selected?(d=h,m=kn.Selected):p[lt.today]&&m<kn.Today&&(d=h,m=kn.Today))}return d||(d=a.find(h=>ig(s(h)))),d}function mw(a,s,o,u,d,m,h){const{ISOWeek:p,broadcastCalendar:x}=m,{addDays:b,addMonths:w,addWeeks:v,addYears:S,endOfBroadcastWeek:M,endOfISOWeek:A,endOfWeek:U,max:_,min:T,startOfBroadcastWeek:K,startOfISOWeek:B,startOfWeek:L}=h;let N={day:b,week:v,month:w,year:S,startOfWeek:H=>x?K(H,h):p?B(H):L(H),endOfWeek:H=>x?M(H):p?A(H):U(H)}[a](o,s==="after"?1:-1);return s==="before"&&u?N=_([u,N]):s==="after"&&d&&(N=T([d,N])),N}function Kx(a,s,o,u,d,m,h,p=0){if(p>365)return;const x=mw(a,s,o.date,u,d,m,h),b=!!(m.disabled&&fa(x,m.disabled,h)),w=!!(m.hidden&&fa(x,m.hidden,h)),v=x,S=new Tx(x,v,h);return!b&&!w?S:Kx(a,s,S,u,d,m,h,p+1)}function hw(a,s,o,u,d){const{autoFocus:m}=a,[h,p]=y.useState(),x=fw(s.days,o,u||(()=>!1),h),[b,w]=y.useState(m?x:void 0);return{isFocusTarget:U=>!!x?.isEqualTo(U),setFocused:w,focused:b,blur:()=>{p(b),w(void 0)},moveFocus:(U,_)=>{if(!b)return;const T=Kx(U,_,b,s.navStart,s.navEnd,a,d);T&&(a.disableNavigation&&!s.days.some(B=>B.isEqualTo(T))||(s.goToDay(T),w(T)))}}}function pw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s,b=M=>p?.some(A=>x(A,M))??!1,{min:w,max:v}=a;return{selected:p,select:(M,A,U)=>{let _=[...p??[]];if(b(M)){if(p?.length===w||u&&p?.length===1)return;_=p?.filter(T=>!x(T,M))}else p?.length===v?_=[M]:_=[..._,M];return d||h(_),d?.(_,M,A,U),_},isSelected:b}}function gw(a,s,o=0,u=0,d=!1,m=qn){const{from:h,to:p}=s||{},{isSameDay:x,isAfter:b,isBefore:w}=m;let v;if(!h&&!p)v={from:a,to:o>0?void 0:a};else if(h&&!p)x(h,a)?o===0?v={from:h,to:a}:d?v={from:h,to:void 0}:v=void 0:w(a,h)?v={from:a,to:h}:v={from:h,to:a};else if(h&&p)if(x(h,a)&&x(p,a))d?v={from:h,to:p}:v=void 0;else if(x(h,a))v={from:h,to:o>0?void 0:a};else if(x(p,a))v={from:a,to:o>0?void 0:a};else if(w(a,h))v={from:a,to:p};else if(b(a,h))v={from:h,to:a};else if(b(a,p))v={from:h,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const S=m.differenceInCalendarDays(v.to,v.from);u>0&&S>u?v={from:a,to:void 0}:o>1&&S<o&&(v={from:a,to:void 0})}return v}function xw(a,s,o=qn){const u=Array.isArray(s)?s:[s];let d=a.from;const m=o.differenceInCalendarDays(a.to,a.from),h=Math.min(m,6);for(let p=0;p<=h;p++){if(u.includes(d.getDay()))return!0;d=o.addDays(d,1)}return!1}function rg(a,s,o=qn){return da(a,s.from,!1,o)||da(a,s.to,!1,o)||da(s,a.from,!1,o)||da(s,a.to,!1,o)}function yw(a,s,o=qn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:o.isDate(p)?da(a,p,!1,o):zx(p,o)?p.some(x=>da(a,x,!1,o)):so(p)?p.from&&p.to?rg(a,{from:p.from,to:p.to},o):!1:Ax(p)?xw(a,p.dayOfWeek,o):xd(p)?o.isAfter(p.before,p.after)?rg(a,{from:o.addDays(p.after,1),to:o.addDays(p.before,-1)},o):fa(a.from,p,o)||fa(a.to,p,o):yd(p)||vd(p)?fa(a.from,p,o)||fa(a.to,p,o):!1))return!0;const h=u.filter(p=>typeof p=="function");if(h.length){let p=a.from;const x=o.differenceInCalendarDays(a.to,a.from);for(let b=0;b<=x;b++){if(h.some(w=>w(p)))return!0;p=o.addDays(p,1)}}return!1}function vw(a,s){const{disabled:o,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,x]=io(d,h?d:void 0),b=h?d:p;return{selected:b,select:(S,M,A)=>{const{min:U,max:_}=a,T=S?gw(S,b,U,_,m,s):void 0;return u&&o&&T?.from&&T.to&&yw({from:T.from,to:T.to},o,s)&&(T.from=S,T.to=void 0),h||x(T),h?.(T,S,M,A),T},isSelected:S=>b&&da(b,S,!1,s)}}function bw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s;return{selected:p,select:(v,S,M)=>{let A=v;return!u&&p&&p&&x(v,p)&&(A=void 0),d||h(A),d?.(A,v,S,M),A},isSelected:v=>p?x(p,v):!1}}function Sw(a,s){const o=bw(a,s),u=pw(a,s),d=vw(a,s);switch(a.mode){case"single":return o;case"multiple":return u;case"range":return d;default:return}}function Ot(a,s){return a instanceof ca&&a.timeZone===s?a:new ca(a,s)}function og(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Ot(a,s):Array.isArray(a)?a.map(o=>o instanceof Date?Ot(o,s):o):so(a)?{...a,from:a.from?Ot(a.from,s):a.from,to:a.to?Ot(a.to,s):a.to}:xd(a)?{before:Ot(a.before,s),after:Ot(a.after,s)}:yd(a)?{after:Ot(a.after,s)}:vd(a)?{before:Ot(a.before,s)}:a}function Dc(a,s){return a&&(Array.isArray(a)?a.map(o=>og(o,s)):og(a,s))}function jw(a){let s=a;const o=s.timeZone;if(o&&(s={...a,timeZone:o},s.today&&(s.today=Ot(s.today,o)),s.month&&(s.month=Ot(s.month,o)),s.defaultMonth&&(s.defaultMonth=Ot(s.defaultMonth,o)),s.startMonth&&(s.startMonth=Ot(s.startMonth,o)),s.endMonth&&(s.endMonth=Ot(s.endMonth,o)),s.mode==="single"&&s.selected?s.selected=Ot(s.selected,o):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(re=>Ot(re,o)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Ot(s.selected.from,o):s.selected.from,to:s.selected.to?Ot(s.selected.to,o):s.selected.to}),s.disabled!==void 0&&(s.disabled=Dc(s.disabled,o)),s.hidden!==void 0&&(s.hidden=Dc(s.hidden,o)),s.modifiers)){const re={};Object.keys(s.modifiers).forEach(Se=>{re[Se]=Dc(s.modifiers?.[Se],o)}),s.modifiers=re}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:x}=y.useMemo(()=>{const re={...Mx,...s.locale},Se=new sn({locale:re,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:Se,components:DC(s.components),formatters:KC(s.formatters),labels:WC(s.labels,Se.options),locale:re,classNames:{...kC(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:h.today()});const{captionLayout:b,mode:w,navLayout:v,numberOfMonths:S=1,onDayBlur:M,onDayClick:A,onDayFocus:U,onDayKeyDown:_,onDayMouseEnter:T,onDayMouseLeave:K,onNextClick:B,onPrevClick:L,showWeekNumber:k,styles:N}=s,{formatCaption:H,formatDay:Z,formatMonthDropdown:te,formatWeekNumber:ce,formatWeekNumberHeader:be,formatWeekdayName:oe,formatYearDropdown:Ye}=d,je=dw(s,h),{days:P,months:O,navStart:W,navEnd:se,previousMonth:ye,nextMonth:ve,goToMonth:De}=je,ze=AC(P,s,W,se,h),{isSelected:X,select:J,selected:ne}=Sw(s,h)??{},{blur:F,focused:ee,isFocusTarget:fe,moveFocus:Ae,setFocused:Ge}=hw(s,je,ze,X??(()=>!1),h),{labelDayButton:yt,labelGridcell:vt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Qt,labelNext:Bn,labelWeekday:Ne,labelWeekNumber:Vt,labelWeekNumberHeader:En,labelYearDropdown:Xt}=m,ma=y.useMemo(()=>PC(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Hn=w!==void 0||A!==void 0,ct=y.useCallback(()=>{ye&&(De(ye),L?.(ye))},[ye,De,L]),Zt=y.useCallback(()=>{ve&&(De(ve),B?.(ve))},[De,ve,B]),Ln=y.useCallback((re,Se)=>he=>{he.preventDefault(),he.stopPropagation(),Ge(re),!Se.disabled&&(J?.(re.date,Se,he),A?.(re.date,Se,he))},[J,A,Ge]),Va=y.useCallback((re,Se)=>he=>{Ge(re),U?.(re.date,Se,he)},[U,Ge]),Mn=y.useCallback((re,Se)=>he=>{F(),M?.(re.date,Se,he)},[F,M]),Tn=y.useCallback((re,Se)=>he=>{const Te={ArrowLeft:[he.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[he.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[he.shiftKey?"year":"week","after"],ArrowUp:[he.shiftKey?"year":"week","before"],PageUp:[he.shiftKey?"year":"month","before"],PageDown:[he.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Te[he.key]){he.preventDefault(),he.stopPropagation();const[Fe,xe]=Te[he.key];Ae(Fe,xe)}_?.(re.date,Se,he)},[Ae,_,s.dir]),xl=y.useCallback((re,Se)=>he=>{T?.(re.date,Se,he)},[T]),us=y.useCallback((re,Se)=>he=>{K?.(re.date,Se,he)},[K]),cs=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setMonth(h.startOfMonth(re),he);De(Te)},[h,De]),Yn=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setYear(h.startOfMonth(re),he);De(Te)},[h,De]),{className:$,style:Ee}=y.useMemo(()=>({className:[x[ue.Root],s.className].filter(Boolean).join(" "),style:{...N?.[ue.Root],...s.style}}),[x,s.className,s.style,N]),me=_C(s),Me=y.useRef(null);nw(Me,!!s.animate,{classNames:x,months:O,focused:ee,dateLib:h});const nt={dayPickerProps:s,selected:ne,select:J,isSelected:X,months:O,nextMonth:ve,previousMonth:ye,goToMonth:De,getModifiers:ze,components:u,classNames:x,styles:N,labels:m,formatters:d};return I.createElement(Ox.Provider,{value:nt},I.createElement(u.Root,{rootRef:s.animate?Me:void 0,className:$,style:Ee,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...me},I.createElement(u.Months,{className:x[ue.Months],style:N?.[ue.Months]},!s.hideNavigation&&!v&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),O.map((re,Se)=>I.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[ue.Month],style:N?.[ue.Month],key:Se,displayIndex:Se,calendarMonth:re},v==="around"&&!s.hideNavigation&&Se===0&&I.createElement(u.PreviousMonthButton,{type:"button",className:x[ue.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Qt(ye),onClick:ct,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"right":"left"})),I.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[ue.MonthCaption],style:N?.[ue.MonthCaption],calendarMonth:re,displayIndex:Se},b?.startsWith("dropdown")?I.createElement(u.DropdownNav,{className:x[ue.Dropdowns],style:N?.[ue.Dropdowns]},(()=>{const he=b==="dropdown"||b==="dropdown-months"?I.createElement(u.MonthsDropdown,{key:"month",className:x[ue.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:cs(re.date),options:$C(re.date,W,se,d,h),style:N?.[ue.Dropdown],value:h.getMonth(re.date)}):I.createElement("span",{key:"month"},te(re.date,h)),Te=b==="dropdown"||b==="dropdown-years"?I.createElement(u.YearsDropdown,{key:"year",className:x[ue.YearsDropdown],"aria-label":Xt(h.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Yn(re.date),options:FC(W,se,d,h,!!s.reverseYears),style:N?.[ue.Dropdown],value:h.getYear(re.date)}):I.createElement("span",{key:"year"},Ye(re.date,h));return h.getMonthYearOrder()==="year-first"?[Te,he]:[he,Te]})(),I.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},H(re.date,h.options,h))):I.createElement(u.CaptionLabel,{className:x[ue.CaptionLabel],role:"status","aria-live":"polite"},H(re.date,h.options,h))),v==="around"&&!s.hideNavigation&&Se===S-1&&I.createElement(u.NextMonthButton,{type:"button",className:x[ue.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":Bn(ve),onClick:Zt,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Se===S-1&&v==="after"&&!s.hideNavigation&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),I.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":w==="multiple"||w==="range","aria-label":Qe(re.date,h.options,h)||void 0,className:x[ue.MonthGrid],style:N?.[ue.MonthGrid]},!s.hideWeekdays&&I.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[ue.Weekdays],style:N?.[ue.Weekdays]},k&&I.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:x[ue.WeekNumberHeader],style:N?.[ue.WeekNumberHeader],scope:"col"},be()),ma.map(he=>I.createElement(u.Weekday,{"aria-label":Ne(he,h.options,h),className:x[ue.Weekday],key:String(he),style:N?.[ue.Weekday],scope:"col"},oe(he,h.options,h)))),I.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[ue.Weeks],style:N?.[ue.Weeks]},re.weeks.map(he=>I.createElement(u.Week,{className:x[ue.Week],key:he.weekNumber,style:N?.[ue.Week],week:he},k&&I.createElement(u.WeekNumber,{week:he,style:N?.[ue.WeekNumber],"aria-label":Vt(he.weekNumber,{locale:p}),className:x[ue.WeekNumber],scope:"row",role:"rowheader"},ce(he.weekNumber,h)),he.days.map(Te=>{const{date:Fe}=Te,xe=ze(Te);if(xe[lt.focused]=!xe.hidden&&!!ee?.isEqualTo(Te),xe[Cn.selected]=X?.(Fe)||xe.selected,so(ne)){const{from:Wt,to:vn}=ne;xe[Cn.range_start]=!!(Wt&&vn&&h.isSameDay(Fe,Wt)),xe[Cn.range_end]=!!(Wt&&vn&&h.isSameDay(Fe,vn)),xe[Cn.range_middle]=da(ne,Fe,!0,h)}const Dt=JC(xe,N,s.modifiersStyles),Gn=zC(xe,x,s.modifiersClassNames),St=!Hn&&!xe.hidden?vt(Fe,xe,h.options,h):void 0;return I.createElement(u.Day,{key:`${Te.isoDate}_${Te.displayMonthId}`,day:Te,modifiers:xe,className:Gn.join(" "),style:Dt,role:"gridcell","aria-selected":xe.selected||void 0,"aria-label":St,"data-day":Te.isoDate,"data-month":Te.outside?Te.dateMonthId:void 0,"data-selected":xe.selected||void 0,"data-disabled":xe.disabled||void 0,"data-hidden":xe.hidden||void 0,"data-outside":Te.outside||void 0,"data-focused":xe.focused||void 0,"data-today":xe.today||void 0},!xe.hidden&&Hn?I.createElement(u.DayButton,{className:x[ue.DayButton],style:N?.[ue.DayButton],type:"button",day:Te,modifiers:xe,disabled:!xe.focused&&xe.disabled||void 0,"aria-disabled":xe.focused&&xe.disabled||void 0,tabIndex:fe(Te)?0:-1,"aria-label":yt(Fe,xe,h.options,h),onClick:Ln(Te,xe),onBlur:Mn(Te,xe),onFocus:Va(Te,xe),onKeyDown:Tn(Te,xe),onMouseEnter:xl(Te,xe),onMouseLeave:us(Te,xe)},Z(Fe,h.options,h)):!xe.hidden&&Z(Te.date,h.options,h))})))))))),s.footer&&I.createElement(u.Footer,{className:x[ue.Footer],style:N?.[ue.Footer],role:"status","aria-live":"polite"},s.footer)))}function Nw({className:a,classNames:s,showOutsideDays:o=!0,...u}){return i.jsx(jw,{showOutsideDays:o,className:G("p-2",a),classNames:{root:"relative",months:"flex flex-col sm:flex-row gap-2 sm:gap-4",month:"flex flex-col gap-2",month_caption:"flex justify-center pt-1 relative items-center h-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-2 flex items-center justify-between px-1 z-10",button_previous:G(Ur({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:G(Ur({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),month_grid:"w-full border-collapse",weekdays:"flex w-full",weekday:"text-muted-foreground w-8 font-normal text-xs text-center",weeks:"flex flex-col",week:"flex w-full",day:G("relative h-8 w-8 p-0 text-center text-xs font-normal focus-within:relative focus-within:z-20","hover:bg-accent hover:text-accent-foreground rounded-full select-none"),day_button:G(Ur({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-l-full aria-selected:rounded-r-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_end:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-r-full aria-selected:rounded-l-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_middle:G("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:G("bg-primary text-primary-foreground rounded-full","hover:bg-primary hover:text-primary-foreground","focus:bg-primary focus:text-primary-foreground"),today:"bg-accent text-accent-foreground rounded-full",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...s},components:{Chevron:({orientation:d,className:m,...h})=>{const p=d==="left"?bb:d==="right"?Vr:d==="up"?Xc:Pr;return i.jsx(p,{className:G("h-4 w-4",m),...h})}},...u})}Nw.displayName="Calendar";function Cw(){const[a,s]=y.useState(""),[o,u]=y.useState(""),[d,m]=y.useState(null),[h,p]=y.useState(!1),{login:x,authRequired:b,isAuthenticated:w}=Pc(),v=Gc(),M=Yc().state?.from?.pathname||"/";if(y.useEffect(()=>{(w||!b)&&v(M,{replace:!0})},[w,b,v,M]),w||!b)return null;const A=async U=>{U.preventDefault(),m(null),p(!0);try{await x(a,o),v(M,{replace:!0})}catch(_){m(_ instanceof Error?_.message:"Login failed")}finally{p(!1)}};return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs(x2,{className:"w-full max-w-sm",children:[i.jsxs(y2,{className:"space-y-1 text-center",children:[i.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:i.jsx(Sb,{className:"h-6 w-6 text-primary"})}),i.jsx(v2,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(b2,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(S2,{children:i.jsxs("form",{onSubmit:A,className:"space-y-4",children:[d&&i.jsxs(md,{variant:"destructive",children:[i.jsx(Wc,{className:"h-4 w-4"}),i.jsx(hd,{children:d})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"username",children:"Username"}),i.jsx(_n,{id:"username",type:"text",value:a,onChange:U=>s(U.target.value),placeholder:"Enter username",autoComplete:"username",disabled:h,required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"password",children:"Password"}),i.jsx(_n,{id:"password",type:"password",value:o,onChange:U=>u(U.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:h,required:!0})]}),i.jsx(ot,{type:"submit",className:"w-full",disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsx(Un,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const ww=y.lazy(()=>zt(()=>import("./index-PjscK1jS.js"),__vite__mapDeps([17,1,2,4,5,7,18,6,8,9])).then(a=>({default:a.AnalyticsPage}))),Ew=y.lazy(()=>zt(()=>import("./api-ClkFu9LY.js"),__vite__mapDeps([19,1,2,5,20,14,6,4,7,8,9])).then(a=>({default:a.ApiPage}))),Mw=y.lazy(()=>zt(()=>import("./cliproxy-DeGucfVg.js"),__vite__mapDeps([21,1,2,5,6,4,20,14,3,13,7,8,9])).then(a=>({default:a.CliproxyPage}))),Tw=y.lazy(()=>zt(()=>import("./cliproxy-control-panel-T9i_Ldh0.js"),__vite__mapDeps([22,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),Ow=y.lazy(()=>zt(()=>import("./copilot-Cdqs2Jbh.js"),__vite__mapDeps([23,1,2,5,20,14,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),Aw=y.lazy(()=>zt(()=>import("./accounts-D0KU1a-4.js"),__vite__mapDeps([24,1,2,5,14,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),zw=y.lazy(()=>zt(()=>Promise.resolve().then(()=>X2),void 0).then(a=>({default:a.SettingsPage}))),Dw=y.lazy(()=>zt(()=>import("./health-BaHazGgS.js"),__vite__mapDeps([25,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),_w=y.lazy(()=>zt(()=>import("./shared-dZGNvBe9.js"),__vite__mapDeps([26,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function oa(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(Un,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function kw(){return i.jsx(Yv,{client:pS,children:i.jsx(xS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(yS,{children:i.jsx(NS,{children:i.jsxs(Bv,{children:[i.jsxs(Hv,{children:[i.jsx(nn,{path:"/login",element:i.jsx(Cw,{})}),i.jsx(nn,{element:i.jsx(CS,{}),children:i.jsxs(nn,{element:i.jsx(J1,{}),children:[i.jsx(nn,{path:"/",element:i.jsx(XN,{})}),i.jsx(nn,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(ww,{})})}),i.jsx(nn,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ew,{})})}),i.jsx(nn,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Mw,{})})}),i.jsx(nn,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Tw,{})})}),i.jsx(nn,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ow,{})})}),i.jsx(nn,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Aw,{})})}),i.jsx(nn,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(zw,{})})}),i.jsx(nn,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Dw,{})})}),i.jsx(nn,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(_w,{})})})]})})]}),i.jsx(Gv,{position:"top-right"})]})})})})})}const Qx=document.getElementById("root");if(!Qx)throw new Error("Root element not found. Failed to mount React application.");fS.createRoot(Qx).render(i.jsx(y.StrictMode,{children:i.jsx(kw,{})}));export{M2 as $,l2 as A,La as B,x2 as C,gE as D,x1 as E,y1 as F,v1 as G,mx as H,_n as I,pd as J,Kr as K,yn as L,Bc as M,vE as N,b2 as O,Hg as P,SE as Q,bE as R,Le as S,Ya as T,jE as U,gx as V,NE as W,EE as X,C2 as Y,TE as Z,w2 as _,S2 as a,Sx as a$,m1 as a0,Vw as a1,Fw as a2,Iw as a3,nd as a4,ad as a5,ld as a6,sd as a7,id as a8,CE as a9,g1 as aA,Zw as aB,Ww as aC,h1 as aD,p1 as aE,$w as aF,Jw as aG,Pw as aH,Xw as aI,xx as aJ,zt as aK,KN as aL,hE as aM,md as aN,fx as aO,hd as aP,Nx as aQ,L2 as aR,G2 as aS,oE as aT,sE as aU,uE as aV,iE as aW,rE as aX,dE as aY,cE as aZ,Ur as a_,N2 as aa,wE as ab,fE as ac,mE as ad,Ze as ae,eE as af,ME as ag,E2 as ah,q1 as ai,Mj as aj,qS as ak,BS as al,ml as am,G1 as an,K1 as ao,Q1 as ap,V1 as aq,A2 as ar,Tj as as,Vg as at,tE as au,nE as av,aE as aw,lE as ax,OE as ay,Qw as az,ot as b,G as c,AE as d,zE as e,Z2 as f,Nw as g,Kw as h,y2 as i,v2 as j,xj as k,yj as l,gl as m,DE as n,Ga as o,Ka as p,Hp as q,r2 as r,yE as s,PN as t,$c as u,a2 as v,pE as w,xE as x,WN as y,t2 as z};
|
|
47
|
+
`);return{valid:!1,error:u,line:h.length}}return{valid:!1,error:u}}}function bx({value:a,onChange:s,language:o="json",readonly:u=!1,className:d,minHeight:m="300px"}){const{isDark:h}=Kg(),[p,x]=y.useState(!1),[b,w]=y.useState(!0),v=y.useMemo(()=>o==="json"?U2(a):{valid:!0},[a,o]),S=y.useCallback(M=>i.jsx(rS,{theme:h?vp.nightOwl:vp.github,code:M,language:o,children:({tokens:A,getLineProps:U,getTokenProps:_})=>{let T=!1;return i.jsx(i.Fragment,{children:A.map((K,B)=>i.jsx("div",{...U({line:K}),className:G(v.line===B+1&&"bg-destructive/20"),children:K.map((L,k)=>{let N=!1;if(L.types.includes("property")){const Z=L.content.replace(/['"]/g,"");R2(Z)?T=!0:T=!1}else(L.types.includes("string")||L.types.includes("number")||L.types.includes("boolean"))&&T?(N=!0,T=!1):L.types.includes("punctuation")&&L.content!==":"&&L.content!=="["&&L.content!=="{"&&(T=!1);const H=_({token:L});return N&&b&&(H.className=G(H.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),i.jsx("span",{...H},k)})},B))})}}),[h,o,v.line,b]);return i.jsxs("div",{className:G("flex flex-col",d),children:[i.jsxs("div",{className:G("relative rounded-md border overflow-hidden","bg-muted/30",p&&"ring-2 ring-ring ring-offset-2 ring-offset-background",u&&"opacity-70 cursor-not-allowed",!v.valid&&"border-destructive"),style:{minHeight:m},children:[i.jsx(_2,{value:a,onValueChange:u?()=>{}:s,highlight:S,padding:12,disabled:u,onFocus:()=>x(!0),onBlur:()=>x(!1),textareaClassName:G("focus:outline-none font-mono text-sm",u&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:m}},h?"dark-editor":"light-editor"),i.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:i.jsx(ot,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>w(!b),title:b?"Reveal sensitive values":"Mask sensitive values",children:b?i.jsx(Zr,{className:"h-3 w-3"}):i.jsx(Xr,{className:"h-3 w-3"})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[v.valid?i.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[i.jsx(Wr,{className:"w-3 h-3 text-green-500"}),"Valid ",o.toUpperCase()]}):i.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[i.jsx(Wc,{className:"w-3 h-3"}),v.error,v.line&&` (line ${v.line})`]}),u&&i.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}const Sx=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:bx},Symbol.toStringTag,{value:"Module"})),q2={webSearchConfig:null,webSearchStatus:null,webSearchLoading:!0,webSearchStatusLoading:!0,webSearchSaving:!1,webSearchError:null,webSearchSuccess:!1,globalEnvConfig:null,globalEnvLoading:!0,globalEnvSaving:!1,globalEnvError:null,globalEnvSuccess:!1,proxyConfig:null,proxyLoading:!0,proxySaving:!1,proxyError:null,proxySuccess:!1,proxyTestResult:null,proxyTesting:!1,rawConfig:null,rawConfigLoading:!1};function B2(a,s){switch(s.type){case"SET_WEBSEARCH_CONFIG":return{...a,webSearchConfig:s.payload};case"SET_WEBSEARCH_STATUS":return{...a,webSearchStatus:s.payload};case"SET_WEBSEARCH_LOADING":return{...a,webSearchLoading:s.payload};case"SET_WEBSEARCH_STATUS_LOADING":return{...a,webSearchStatusLoading:s.payload};case"SET_WEBSEARCH_SAVING":return{...a,webSearchSaving:s.payload};case"SET_WEBSEARCH_ERROR":return{...a,webSearchError:s.payload};case"SET_WEBSEARCH_SUCCESS":return{...a,webSearchSuccess:s.payload};case"SET_GLOBALENV_CONFIG":return{...a,globalEnvConfig:s.payload};case"SET_GLOBALENV_LOADING":return{...a,globalEnvLoading:s.payload};case"SET_GLOBALENV_SAVING":return{...a,globalEnvSaving:s.payload};case"SET_GLOBALENV_ERROR":return{...a,globalEnvError:s.payload};case"SET_GLOBALENV_SUCCESS":return{...a,globalEnvSuccess:s.payload};case"SET_PROXY_CONFIG":return{...a,proxyConfig:s.payload};case"SET_PROXY_LOADING":return{...a,proxyLoading:s.payload};case"SET_PROXY_SAVING":return{...a,proxySaving:s.payload};case"SET_PROXY_ERROR":return{...a,proxyError:s.payload};case"SET_PROXY_SUCCESS":return{...a,proxySuccess:s.payload};case"SET_PROXY_TEST_RESULT":return{...a,proxyTestResult:s.payload};case"SET_PROXY_TESTING":return{...a,proxyTesting:s.payload};case"SET_RAW_CONFIG":return{...a,rawConfig:s.payload};case"SET_RAW_CONFIG_LOADING":return{...a,rawConfigLoading:s.payload};default:return a}}const jx=y.createContext(null);function H2({children:a}){const[s,o]=y.useReducer(B2,q2);return i.jsx(jx.Provider,{value:{state:s,dispatch:o},children:a})}function Nx(){const a=y.useContext(jx);if(!a)throw new Error("useSettingsContext must be used within a SettingsProvider");return a}function L2(){const{dispatch:a}=Nx(),s=y.useCallback(N=>a({type:"SET_WEBSEARCH_CONFIG",payload:N}),[a]),o=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS",payload:N}),[a]),u=y.useCallback(N=>a({type:"SET_WEBSEARCH_LOADING",payload:N}),[a]),d=y.useCallback(N=>a({type:"SET_WEBSEARCH_STATUS_LOADING",payload:N}),[a]),m=y.useCallback(N=>a({type:"SET_WEBSEARCH_SAVING",payload:N}),[a]),h=y.useCallback(N=>a({type:"SET_WEBSEARCH_ERROR",payload:N}),[a]),p=y.useCallback(N=>a({type:"SET_WEBSEARCH_SUCCESS",payload:N}),[a]),x=y.useCallback(N=>a({type:"SET_GLOBALENV_CONFIG",payload:N}),[a]),b=y.useCallback(N=>a({type:"SET_GLOBALENV_LOADING",payload:N}),[a]),w=y.useCallback(N=>a({type:"SET_GLOBALENV_SAVING",payload:N}),[a]),v=y.useCallback(N=>a({type:"SET_GLOBALENV_ERROR",payload:N}),[a]),S=y.useCallback(N=>a({type:"SET_GLOBALENV_SUCCESS",payload:N}),[a]),M=y.useCallback(N=>a({type:"SET_PROXY_CONFIG",payload:N}),[a]),A=y.useCallback(N=>a({type:"SET_PROXY_LOADING",payload:N}),[a]),U=y.useCallback(N=>a({type:"SET_PROXY_SAVING",payload:N}),[a]),_=y.useCallback(N=>a({type:"SET_PROXY_ERROR",payload:N}),[a]),T=y.useCallback(N=>a({type:"SET_PROXY_SUCCESS",payload:N}),[a]),K=y.useCallback(N=>a({type:"SET_PROXY_TEST_RESULT",payload:N}),[a]),B=y.useCallback(N=>a({type:"SET_PROXY_TESTING",payload:N}),[a]),L=y.useCallback(N=>a({type:"SET_RAW_CONFIG",payload:N}),[a]),k=y.useCallback(N=>a({type:"SET_RAW_CONFIG_LOADING",payload:N}),[a]);return y.useMemo(()=>({setWebSearchConfig:s,setWebSearchStatus:o,setWebSearchLoading:u,setWebSearchStatusLoading:d,setWebSearchSaving:m,setWebSearchError:h,setWebSearchSuccess:p,setGlobalEnvConfig:x,setGlobalEnvLoading:b,setGlobalEnvSaving:w,setGlobalEnvError:v,setGlobalEnvSuccess:S,setProxyConfig:M,setProxyLoading:A,setProxySaving:U,setProxyError:_,setProxySuccess:T,setProxyTestResult:K,setProxyTesting:B,setRawConfig:L,setRawConfigLoading:k}),[s,o,u,d,m,h,p,x,b,w,v,S,M,A,U,_,T,K,B,L,k])}function Y2(){const[a,s]=qv(),o=a.get("tab")?.toLowerCase(),u=o==="globalenv"?"globalenv":o==="proxy"?"proxy":o==="auth"?"auth":o==="thinking"?"thinking":o==="backups"?"backups":"websearch",d=y.useCallback(m=>{s({tab:m},{replace:!0})},[s]);return{activeTab:u,setActiveTab:d}}function G2(){const{state:a}=Nx(),s=L2(),[o,u]=y.useState(!1),d=y.useCallback(async()=>{try{s.setRawConfigLoading(!0);const h=await fetch("/api/config/raw");if(!h.ok){s.setRawConfig(null);return}const p=await h.text();s.setRawConfig(p)}catch{s.setRawConfig(null)}finally{s.setRawConfigLoading(!1)}},[s]),m=y.useCallback(async()=>{if(a.rawConfig)try{await navigator.clipboard.writeText(a.rawConfig),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[a.rawConfig]);return{rawConfig:a.rawConfig,loading:a.rawConfigLoading,copied:o,fetchRawConfig:d,copyToClipboard:m}}const K2=[{value:"websearch",label:"Web",icon:gb},{value:"globalenv",label:"Env",icon:Zc},{value:"thinking",label:"Think",icon:xb},{value:"proxy",label:"Proxy",icon:yb},{value:"auth",label:"Auth",icon:Kc},{value:"backups",label:"Backup",icon:vb}];function Zp({activeTab:a,onTabChange:s}){return i.jsx(mx,{value:a,onValueChange:o=>s(o),children:i.jsx(pd,{className:"grid w-full grid-cols-6",children:K2.map(({value:o,label:u,icon:d})=>i.jsxs(Kr,{value:o,className:"gap-1.5 px-1 text-xs",children:[i.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:u})]},o))})})}function Wp(){return i.jsxs("div",{className:"flex-1 p-5 space-y-6",children:[i.jsx(Le,{className:"h-4 w-2/3"}),i.jsx("div",{className:"p-4 rounded-lg border",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-5 w-32"}),i.jsx(Le,{className:"h-4 w-48"})]}),i.jsx(Le,{className:"h-6 w-10 rounded-full"})]})}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(Le,{className:"h-5 w-24"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"}),i.jsx(Le,{className:"h-20 w-full rounded-lg"})]})]})]})}function Cx(a,s=3,o=1e3){return a().catch(u=>{if(s<=0)throw u;return new Promise(d=>setTimeout(d,o)).then(()=>Cx(a,s-1,o*2))})}function os(a){return y.lazy(()=>Cx(a))}const $p=os(()=>zt(()=>import("./index-CK0URaBN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Jp=os(()=>zt(()=>import("./globalenv-section-D_GVHsDN.js"),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9]))),Pp=os(()=>zt(()=>import("./index-sdtPg8Gr.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9]))),Fp=os(()=>zt(()=>import("./index-BjiZGSfI.js"),__vite__mapDeps([12,1,2,3,4,13,14,5,6,7,8,9]))),Ip=os(()=>zt(()=>import("./auth-section-CZmgtezT.js"),__vite__mapDeps([15,1,2,4,5,6,7,8,9]))),eg=os(()=>zt(()=>import("./backups-section-CcQsXemH.js"),__vite__mapDeps([16,1,2,14,4,5,6,7,8,9])));class tg extends y.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}render(){return this.state.hasError?i.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:i.jsxs("div",{className:"text-center p-6 max-w-md",children:[i.jsx(Wc,{className:"w-12 h-12 mx-auto mb-4 text-destructive"}),i.jsx("p",{className:"font-medium text-foreground mb-2",children:"Failed to load section"}),i.jsx("p",{className:"text-sm mb-4",children:this.state.error?.message||"Unknown error occurred"}),i.jsxs(ot,{variant:"outline",onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2",children:[i.jsx(mi,{className:"w-4 h-4"}),"Reload page"]})]})}):this.props.children}}function Q2(){const{activeTab:a,setActiveTab:s}=Y2(),{rawConfig:o,loading:u,copied:d,fetchRawConfig:m,copyToClipboard:h}=G2();y.useEffect(()=>{m()},[m]);const p=x=>{y.startTransition(()=>{s(x)})};return i.jsxs("div",{className:"h-[calc(100vh-100px)]",children:[i.jsxs("div",{className:"md:hidden h-full flex flex-col",children:[i.jsx("div",{className:"border-b bg-background p-4",children:i.jsx(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]}),i.jsxs(dd,{direction:"horizontal",className:"h-full hidden md:flex",children:[i.jsx(hi,{defaultSize:40,minSize:30,maxSize:55,children:i.jsxs("div",{className:"h-full border-r flex flex-col bg-muted/30 relative",children:[i.jsx("div",{className:"p-5 border-b bg-background",children:i.jsx(Zp,{activeTab:a,onTabChange:p})}),i.jsx(tg,{children:i.jsxs(y.Suspense,{fallback:i.jsx(Wp,{}),children:[a==="websearch"&&i.jsx($p,{}),a==="globalenv"&&i.jsx(Jp,{}),a==="thinking"&&i.jsx(Pp,{}),a==="proxy"&&i.jsx(Fp,{}),a==="auth"&&i.jsx(Ip,{}),a==="backups"&&i.jsx(eg,{})]})})]})}),i.jsx(fd,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:i.jsx($r,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),i.jsx(hi,{defaultSize:60,minSize:35,children:i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(gp,{className:"w-5 h-5 text-primary"}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-semibold",children:"config.yaml"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"~/.ccs/config.yaml"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ot,{variant:"outline",size:"sm",onClick:h,disabled:!o,children:d?i.jsxs(i.Fragment,{children:[i.jsx(rs,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Hr,{className:"w-4 h-4 mr-1"}),"Copy"]})}),i.jsx(ot,{variant:"outline",size:"sm",onClick:m,disabled:u,children:i.jsx(mi,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),i.jsx("div",{className:"flex-1 overflow-auto",children:u?i.jsxs("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:[i.jsx(mi,{className:"w-5 h-5 animate-spin mr-2"}),"Loading..."]}):o?i.jsx(bx,{value:o,onChange:()=>{},language:"yaml",readonly:!0,minHeight:"auto",className:"min-h-full"}):i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsxs("div",{className:"text-center",children:[i.jsx(gp,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),i.jsx("p",{children:"Config file not found"}),i.jsx("code",{className:"text-sm bg-muted px-2 py-1 rounded mt-2 inline-block",children:"ccs migrate"})]})})})]})})]})]})}function V2(){return i.jsx(H2,{children:i.jsx(Q2,{})})}const X2=Object.freeze(Object.defineProperty({__proto__:null,SettingsPage:V2},Symbol.toStringTag,{value:"Module"})),AE=Av,zE=Dv,DE=zv,Z2=y.forwardRef(({className:a,align:s="center",sideOffset:o=4,...u},d)=>i.jsx(Ov,{children:i.jsx(Tg,{ref:d,align:s,sideOffset:o,className:G("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...u})}));Z2.displayName=Tg.displayName;function W2(a,s,o="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:a,timeZoneName:o}).format(s).split(/\s/g).slice(2).join(" ")}const $2={},di={};function fl(a,s){try{const u=($2[a]||=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return u in di?di[u]:ng(u,u.split(":"))}catch{if(a in di)return di[a];const o=a?.match(J2);return o?ng(a,o.slice(1)):NaN}}const J2=/([+-]\d\d):?(\d\d)?/;function ng(a,s){const o=+(s[0]||0),u=+(s[1]||0),d=+(s[2]||0)/60;return di[a]=o*60+u>0?o*60+u+d:o*60-u-d}class Rn extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(fl(this.timeZone,this))?this.setTime(NaN):s.length?typeof s[0]=="number"&&(s.length===1||s.length===2&&typeof s[1]!="number")?this.setTime(s[0]):typeof s[0]=="string"?this.setTime(+new Date(s[0])):s[0]instanceof Date?this.setTime(+s[0]):(this.setTime(+new Date(...s)),wx(this),Lc(this)):this.setTime(Date.now())}static tz(s,...o){return o.length?new Rn(...o,s):new Rn(Date.now(),s)}withTimeZone(s){return new Rn(+this,s)}getTimezoneOffset(){const s=-fl(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),Lc(this),+this}[Symbol.for("constructDateFrom")](s){return new Rn(+new Date(s),this.timeZone)}}const ag=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(a=>{if(!ag.test(a))return;const s=a.replace(ag,"$1UTC");Rn.prototype[s]&&(a.startsWith("get")?Rn.prototype[a]=function(){return this.internal[s]()}:(Rn.prototype[a]=function(){return Date.prototype[s].apply(this.internal,arguments),P2(this),+this},Rn.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),Lc(this),+this}))});function Lc(a){a.internal.setTime(+a),a.internal.setUTCSeconds(a.internal.getUTCSeconds()-Math.round(-fl(a.timeZone,a)*60))}function P2(a){Date.prototype.setFullYear.call(a,a.internal.getUTCFullYear(),a.internal.getUTCMonth(),a.internal.getUTCDate()),Date.prototype.setHours.call(a,a.internal.getUTCHours(),a.internal.getUTCMinutes(),a.internal.getUTCSeconds(),a.internal.getUTCMilliseconds()),wx(a)}function wx(a){const s=fl(a.timeZone,a),o=s>0?Math.floor(s):Math.ceil(s),u=new Date(+a);u.setUTCHours(u.getUTCHours()-1);const d=-new Date(+a).getTimezoneOffset(),m=-new Date(+u).getTimezoneOffset(),h=d-m,p=Date.prototype.getHours.apply(a)!==a.internal.getUTCHours();h&&p&&a.internal.setUTCMinutes(a.internal.getUTCMinutes()+h);const x=d-o;x&&Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+x);const b=new Date(+a);b.setUTCSeconds(0);const w=d>0?b.getSeconds():(b.getSeconds()-60)%60,v=Math.round(-(fl(a.timeZone,a)*60))%60;(v||w)&&(a.internal.setUTCSeconds(a.internal.getUTCSeconds()+v),Date.prototype.setUTCSeconds.call(a,Date.prototype.getUTCSeconds.call(a)+v+w));const S=fl(a.timeZone,a),M=S>0?Math.floor(S):Math.ceil(S),U=-new Date(+a).getTimezoneOffset()-M,_=M!==o,T=U-x;if(_&&T){Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+T);const K=fl(a.timeZone,a),B=K>0?Math.floor(K):Math.ceil(K),L=M-B;L&&(a.internal.setUTCMinutes(a.internal.getUTCMinutes()+L),Date.prototype.setUTCMinutes.call(a,Date.prototype.getUTCMinutes.call(a)+L))}}class ca extends Rn{static tz(s,...o){return o.length?new ca(...o,s):new ca(Date.now(),s)}toISOString(){const[s,o,u]=this.tzComponents(),d=`${s}${o}:${u}`;return this.internal.toISOString().slice(0,-1)+d}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,o,u,d]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${u} ${o} ${d}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[o,u,d]=this.tzComponents();return`${s} GMT${o}${u}${d} (${W2(this.timeZone,this)})`}toLocaleString(s,o){return Date.prototype.toLocaleString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleDateString(s,o){return Date.prototype.toLocaleDateString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}toLocaleTimeString(s,o){return Date.prototype.toLocaleTimeString.call(this,s,{...o,timeZone:o?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),o=s>0?"-":"+",u=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),d=String(Math.abs(s)%60).padStart(2,"0");return[o,u,d]}withTimeZone(s){return new ca(+this,s)}[Symbol.for("constructDateFrom")](s){return new ca(+new Date(s),this.timeZone)}}const lg=5,F2=4;function I2(a,s){const o=s.startOfMonth(a),u=o.getDay()>0?o.getDay():7,d=s.addDays(a,-u+1),m=s.addDays(d,lg*7-1);return s.getMonth(a)===s.getMonth(m)?lg:F2}function Ex(a,s){const o=s.startOfMonth(a),u=o.getDay();return u===1?o:u===0?s.addDays(o,-6):s.addDays(o,-1*(u-1))}function eC(a,s){const o=Ex(a,s),u=I2(a,s);return s.addDays(o,u*7-1)}const Mx={...li,labels:{labelDayButton:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ri(h,p,{locale:li,...o});let m=d(a,"PPPP");return s.today&&(m=`Today, ${m}`),s.selected&&(m=`${m}, selected`),m},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:a=>`Week ${a}`,labelYearDropdown:"Choose the Year",labelGrid:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ri(d,m,{locale:li,...s}),u(a,"LLLL yyyy")},labelGridcell:(a,s,o,u)=>{let d;u&&typeof u.format=="function"?d=u.format.bind(u):d=(h,p)=>ri(h,p,{locale:li,...o});let m=d(a,"PPPP");return s?.today&&(m=`Today, ${m}`),m},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(a,s,o)=>{let u;return o&&typeof o.format=="function"?u=o.format.bind(o):u=(d,m)=>ri(d,m,{locale:li,...s}),u(a,"cccc")}}};class sn{constructor(s,o){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ca.tz(this.options.timeZone):new this.Date,this.newDate=(u,d,m)=>this.overrides?.newDate?this.overrides.newDate(u,d,m):this.options.timeZone?new ca(u,d,m,this.options.timeZone):new Date(u,d,m),this.addDays=(u,d)=>this.overrides?.addDays?this.overrides.addDays(u,d):Cb(u,d),this.addMonths=(u,d)=>this.overrides?.addMonths?this.overrides.addMonths(u,d):wb(u,d),this.addWeeks=(u,d)=>this.overrides?.addWeeks?this.overrides.addWeeks(u,d):Eb(u,d),this.addYears=(u,d)=>this.overrides?.addYears?this.overrides.addYears(u,d):Mb(u,d),this.differenceInCalendarDays=(u,d)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(u,d):Tb(u,d),this.differenceInCalendarMonths=(u,d)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(u,d):Ob(u,d),this.eachMonthOfInterval=u=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(u):Ab(u),this.eachYearOfInterval=u=>{const d=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(u):zb(u),m=new Set(d.map(p=>this.getYear(p)));if(m.size===d.length)return d;const h=[];return m.forEach(p=>{h.push(new Date(p,0,1))}),h},this.endOfBroadcastWeek=u=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(u):eC(u,this),this.endOfISOWeek=u=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(u):Db(u),this.endOfMonth=u=>this.overrides?.endOfMonth?this.overrides.endOfMonth(u):_b(u),this.endOfWeek=(u,d)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(u,d):kb(u,this.options),this.endOfYear=u=>this.overrides?.endOfYear?this.overrides.endOfYear(u):Rb(u),this.format=(u,d,m)=>{const h=this.overrides?.format?this.overrides.format(u,d,this.options):ri(u,d,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(h):h},this.getISOWeek=u=>this.overrides?.getISOWeek?this.overrides.getISOWeek(u):Ub(u),this.getMonth=(u,d)=>this.overrides?.getMonth?this.overrides.getMonth(u,this.options):qb(u,this.options),this.getYear=(u,d)=>this.overrides?.getYear?this.overrides.getYear(u,this.options):Bb(u,this.options),this.getWeek=(u,d)=>this.overrides?.getWeek?this.overrides.getWeek(u,this.options):Hb(u,this.options),this.isAfter=(u,d)=>this.overrides?.isAfter?this.overrides.isAfter(u,d):Lb(u,d),this.isBefore=(u,d)=>this.overrides?.isBefore?this.overrides.isBefore(u,d):Yb(u,d),this.isDate=u=>this.overrides?.isDate?this.overrides.isDate(u):Gb(u),this.isSameDay=(u,d)=>this.overrides?.isSameDay?this.overrides.isSameDay(u,d):Kb(u,d),this.isSameMonth=(u,d)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(u,d):Qb(u,d),this.isSameYear=(u,d)=>this.overrides?.isSameYear?this.overrides.isSameYear(u,d):Vb(u,d),this.max=u=>this.overrides?.max?this.overrides.max(u):Xb(u),this.min=u=>this.overrides?.min?this.overrides.min(u):Zb(u),this.setMonth=(u,d)=>this.overrides?.setMonth?this.overrides.setMonth(u,d):Wb(u,d),this.setYear=(u,d)=>this.overrides?.setYear?this.overrides.setYear(u,d):$b(u,d),this.startOfBroadcastWeek=(u,d)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(u,this):Ex(u,this),this.startOfDay=u=>this.overrides?.startOfDay?this.overrides.startOfDay(u):Jb(u),this.startOfISOWeek=u=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(u):Pb(u),this.startOfMonth=u=>this.overrides?.startOfMonth?this.overrides.startOfMonth(u):Fb(u),this.startOfWeek=(u,d)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(u,this.options):Ib(u,this.options),this.startOfYear=u=>this.overrides?.startOfYear?this.overrides.startOfYear(u):eS(u),this.options={locale:Mx,...s},this.overrides=o}getDigitMap(){const{numerals:s="latn"}=this.options,o=new Intl.NumberFormat("en-US",{numberingSystem:s}),u={};for(let d=0;d<10;d++)u[d.toString()]=o.format(d);return u}replaceDigits(s){const o=this.getDigitMap();return s.replace(/\d/g,u=>o[u]||u)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&sn.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:o,timeZone:u,numerals:d}=this.options,m=o?.code;if(m&&sn.yearFirstLocales.has(m))try{return new Intl.DateTimeFormat(m,{month:"long",year:"numeric",timeZone:u,numberingSystem:d}).format(s)}catch{}const h=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(s,h)}}sn.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const qn=new sn;class Tx{constructor(s,o,u=qn){this.date=s,this.displayMonth=o,this.outside=!!(o&&!u.isSameMonth(s,o)),this.dateLib=u,this.isoDate=u.format(s,"yyyy-MM-dd"),this.displayMonthId=u.format(o,"yyyy-MM"),this.dateMonthId=u.format(s,"yyyy-MM")}isEqualTo(s){return this.dateLib.isSameDay(s.date,this.date)&&this.dateLib.isSameMonth(s.displayMonth,this.displayMonth)}}class tC{constructor(s,o){this.date=s,this.weeks=o}}class nC{constructor(s,o){this.days=o,this.weekNumber=s}}function aC(a){return I.createElement("button",{...a})}function lC(a){return I.createElement("span",{...a})}function sC(a){const{size:s=24,orientation:o="left",className:u}=a;return I.createElement("svg",{className:u,width:s,height:s,viewBox:"0 0 24 24"},o==="up"&&I.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),o==="down"&&I.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),o==="left"&&I.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),o==="right"&&I.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function iC(a){const{day:s,modifiers:o,...u}=a;return I.createElement("td",{...u})}function rC(a){const{day:s,modifiers:o,...u}=a,d=I.useRef(null);return I.useEffect(()=>{o.focused&&d.current?.focus()},[o.focused]),I.createElement("button",{ref:d,...u})}var ue;(function(a){a.Root="root",a.Chevron="chevron",a.Day="day",a.DayButton="day_button",a.CaptionLabel="caption_label",a.Dropdowns="dropdowns",a.Dropdown="dropdown",a.DropdownRoot="dropdown_root",a.Footer="footer",a.MonthGrid="month_grid",a.MonthCaption="month_caption",a.MonthsDropdown="months_dropdown",a.Month="month",a.Months="months",a.Nav="nav",a.NextMonthButton="button_next",a.PreviousMonthButton="button_previous",a.Week="week",a.Weeks="weeks",a.Weekday="weekday",a.Weekdays="weekdays",a.WeekNumber="week_number",a.WeekNumberHeader="week_number_header",a.YearsDropdown="years_dropdown"})(ue||(ue={}));var lt;(function(a){a.disabled="disabled",a.hidden="hidden",a.outside="outside",a.focused="focused",a.today="today"})(lt||(lt={}));var Cn;(function(a){a.range_end="range_end",a.range_middle="range_middle",a.range_start="range_start",a.selected="selected"})(Cn||(Cn={}));var ln;(function(a){a.weeks_before_enter="weeks_before_enter",a.weeks_before_exit="weeks_before_exit",a.weeks_after_enter="weeks_after_enter",a.weeks_after_exit="weeks_after_exit",a.caption_after_enter="caption_after_enter",a.caption_after_exit="caption_after_exit",a.caption_before_enter="caption_before_enter",a.caption_before_exit="caption_before_exit"})(ln||(ln={}));function oC(a){const{options:s,className:o,components:u,classNames:d,...m}=a,h=[d[ue.Dropdown],o].join(" "),p=s?.find(({value:x})=>x===m.value);return I.createElement("span",{"data-disabled":m.disabled,className:d[ue.DropdownRoot]},I.createElement(u.Select,{className:h,...m},s?.map(({value:x,label:b,disabled:w})=>I.createElement(u.Option,{key:x,value:x,disabled:w},b))),I.createElement("span",{className:d[ue.CaptionLabel],"aria-hidden":!0},p?.label,I.createElement(u.Chevron,{orientation:"down",size:18,className:d[ue.Chevron]})))}function uC(a){return I.createElement("div",{...a})}function cC(a){return I.createElement("div",{...a})}function dC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u},a.children)}function fC(a){const{calendarMonth:s,displayIndex:o,...u}=a;return I.createElement("div",{...u})}function mC(a){return I.createElement("table",{...a})}function hC(a){return I.createElement("div",{...a})}const Ox=y.createContext(void 0);function yi(){const a=y.useContext(Ox);if(a===void 0)throw new Error("useDayPicker() must be used within a custom component.");return a}function pC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}function gC(a){const{onPreviousClick:s,onNextClick:o,previousMonth:u,nextMonth:d,...m}=a,{components:h,classNames:p,labels:{labelPrevious:x,labelNext:b}}=yi(),w=y.useCallback(S=>{d&&o?.(S)},[d,o]),v=y.useCallback(S=>{u&&s?.(S)},[u,s]);return I.createElement("nav",{...m},I.createElement(h.PreviousMonthButton,{type:"button",className:p[ue.PreviousMonthButton],tabIndex:u?void 0:-1,"aria-disabled":u?void 0:!0,"aria-label":x(u),onClick:v},I.createElement(h.Chevron,{disabled:u?void 0:!0,className:p[ue.Chevron],orientation:"left"})),I.createElement(h.NextMonthButton,{type:"button",className:p[ue.NextMonthButton],tabIndex:d?void 0:-1,"aria-disabled":d?void 0:!0,"aria-label":b(d),onClick:w},I.createElement(h.Chevron,{disabled:d?void 0:!0,orientation:"right",className:p[ue.Chevron]})))}function xC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function yC(a){return I.createElement("option",{...a})}function vC(a){const{components:s}=yi();return I.createElement(s.Button,{...a})}function bC(a){const{rootRef:s,...o}=a;return I.createElement("div",{...o,ref:s})}function SC(a){return I.createElement("select",{...a})}function jC(a){const{week:s,...o}=a;return I.createElement("tr",{...o})}function NC(a){return I.createElement("th",{...a})}function CC(a){return I.createElement("thead",{"aria-hidden":!0},I.createElement("tr",{...a}))}function wC(a){const{week:s,...o}=a;return I.createElement("th",{...o})}function EC(a){return I.createElement("th",{...a})}function MC(a){return I.createElement("tbody",{...a})}function TC(a){const{components:s}=yi();return I.createElement(s.Dropdown,{...a})}const OC=Object.freeze(Object.defineProperty({__proto__:null,Button:aC,CaptionLabel:lC,Chevron:sC,Day:iC,DayButton:rC,Dropdown:oC,DropdownNav:uC,Footer:cC,Month:dC,MonthCaption:fC,MonthGrid:mC,Months:hC,MonthsDropdown:pC,Nav:gC,NextMonthButton:xC,Option:yC,PreviousMonthButton:vC,Root:bC,Select:SC,Week:jC,WeekNumber:wC,WeekNumberHeader:EC,Weekday:NC,Weekdays:CC,Weeks:MC,YearsDropdown:TC},Symbol.toStringTag,{value:"Module"}));function da(a,s,o=!1,u=qn){let{from:d,to:m}=a;const{differenceInCalendarDays:h,isSameDay:p}=u;return d&&m?(h(m,d)<0&&([d,m]=[m,d]),h(s,d)>=(o?1:0)&&h(m,s)>=(o?1:0)):!o&&m?p(m,s):!o&&d?p(d,s):!1}function xd(a){return!!(a&&typeof a=="object"&&"before"in a&&"after"in a)}function so(a){return!!(a&&typeof a=="object"&&"from"in a)}function yd(a){return!!(a&&typeof a=="object"&&"after"in a)}function vd(a){return!!(a&&typeof a=="object"&&"before"in a)}function Ax(a){return!!(a&&typeof a=="object"&&"dayOfWeek"in a)}function zx(a,s){return Array.isArray(a)&&a.every(s.isDate)}function fa(a,s,o=qn){const u=Array.isArray(s)?s:[s],{isSameDay:d,differenceInCalendarDays:m,isAfter:h}=o;return u.some(p=>{if(typeof p=="boolean")return p;if(o.isDate(p))return d(a,p);if(zx(p,o))return p.some(x=>d(a,x));if(so(p))return da(p,a,!1,o);if(Ax(p))return Array.isArray(p.dayOfWeek)?p.dayOfWeek.includes(a.getDay()):p.dayOfWeek===a.getDay();if(xd(p)){const x=m(p.before,a),b=m(p.after,a),w=x>0,v=b<0;return h(p.before,p.after)?v&&w:w||v}return yd(p)?m(a,p.after)>0:vd(p)?m(p.before,a)>0:typeof p=="function"?p(a):!1})}function AC(a,s,o,u,d){const{disabled:m,hidden:h,modifiers:p,showOutsideDays:x,broadcastCalendar:b,today:w=d.today()}=s,{isSameDay:v,isSameMonth:S,startOfMonth:M,isBefore:A,endOfMonth:U,isAfter:_}=d,T=o&&M(o),K=u&&U(u),B={[lt.focused]:[],[lt.outside]:[],[lt.disabled]:[],[lt.hidden]:[],[lt.today]:[]},L={};for(const k of a){const{date:N,displayMonth:H}=k,Z=!!(H&&!S(N,H)),te=!!(T&&A(N,T)),ce=!!(K&&_(N,K)),be=!!(m&&fa(N,m,d)),oe=!!(h&&fa(N,h,d))||te||ce||!b&&!x&&Z||b&&x===!1&&Z,Ye=v(N,w);Z&&B.outside.push(k),be&&B.disabled.push(k),oe&&B.hidden.push(k),Ye&&B.today.push(k),p&&Object.keys(p).forEach(je=>{const P=p?.[je];P&&fa(N,P,d)&&(L[je]?L[je].push(k):L[je]=[k])})}return k=>{const N={[lt.focused]:!1,[lt.disabled]:!1,[lt.hidden]:!1,[lt.outside]:!1,[lt.today]:!1},H={};for(const Z in B){const te=B[Z];N[Z]=te.some(ce=>ce===k)}for(const Z in L)H[Z]=L[Z].some(te=>te===k);return{...N,...H}}}function zC(a,s,o={}){return Object.entries(a).filter(([,d])=>d===!0).reduce((d,[m])=>(o[m]?d.push(o[m]):s[lt[m]]?d.push(s[lt[m]]):s[Cn[m]]&&d.push(s[Cn[m]]),d),[s[ue.Day]])}function DC(a){return{...OC,...a}}function _C(a){const s={"data-mode":a.mode??void 0,"data-required":"required"in a?a.required:void 0,"data-multiple-months":a.numberOfMonths&&a.numberOfMonths>1||void 0,"data-week-numbers":a.showWeekNumber||void 0,"data-broadcast-calendar":a.broadcastCalendar||void 0,"data-nav-layout":a.navLayout||void 0};return Object.entries(a).forEach(([o,u])=>{o.startsWith("data-")&&(s[o]=u)}),s}function kC(){const a={};for(const s in ue)a[ue[s]]=`rdp-${ue[s]}`;for(const s in lt)a[lt[s]]=`rdp-${lt[s]}`;for(const s in Cn)a[Cn[s]]=`rdp-${Cn[s]}`;for(const s in ln)a[ln[s]]=`rdp-${ln[s]}`;return a}function Dx(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const RC=Dx;function UC(a,s,o){return(o??new sn(s)).format(a,"d")}function qC(a,s=qn){return s.format(a,"LLLL")}function BC(a,s,o){return(o??new sn(s)).format(a,"cccccc")}function HC(a,s=qn){return a<10?s.formatNumber(`0${a.toLocaleString()}`):s.formatNumber(`${a.toLocaleString()}`)}function LC(){return""}function _x(a,s=qn){return s.format(a,"yyyy")}const YC=_x,GC=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Dx,formatDay:UC,formatMonthCaption:RC,formatMonthDropdown:qC,formatWeekNumber:HC,formatWeekNumberHeader:LC,formatWeekdayName:BC,formatYearCaption:YC,formatYearDropdown:_x},Symbol.toStringTag,{value:"Module"}));function KC(a){return a?.formatMonthCaption&&!a.formatCaption&&(a.formatCaption=a.formatMonthCaption),a?.formatYearCaption&&!a.formatYearDropdown&&(a.formatYearDropdown=a.formatYearCaption),{...GC,...a}}function bd(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s.today&&(d=`Today, ${d}`),s.selected&&(d=`${d}, selected`),d}const QC=bd;function Sd(a,s,o){return(o??new sn(s)).formatMonthYear(a)}const VC=Sd;function kx(a,s,o,u){let d=(u??new sn(o)).format(a,"PPPP");return s?.today&&(d=`Today, ${d}`),d}function Rx(a){return"Choose the Month"}function Ux(){return""}const XC="Go to the Next Month";function qx(a,s){return XC}function Bx(a){return"Go to the Previous Month"}function Hx(a,s,o){return(o??new sn(s)).format(a,"cccc")}function Lx(a,s){return`Week ${a}`}function Yx(a){return"Week Number"}function Gx(a){return"Choose the Year"}const ZC=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:VC,labelDay:QC,labelDayButton:bd,labelGrid:Sd,labelGridcell:kx,labelMonthDropdown:Rx,labelNav:Ux,labelNext:qx,labelPrevious:Bx,labelWeekNumber:Lx,labelWeekNumberHeader:Yx,labelWeekday:Hx,labelYearDropdown:Gx},Symbol.toStringTag,{value:"Module"})),Nn=(a,s,o)=>s||(o?typeof o=="function"?o:(...u)=>o:a);function WC(a,s){const o=s.locale?.labels??{};return{...ZC,...a??{},labelDayButton:Nn(bd,a?.labelDayButton,o.labelDayButton),labelMonthDropdown:Nn(Rx,a?.labelMonthDropdown,o.labelMonthDropdown),labelNext:Nn(qx,a?.labelNext,o.labelNext),labelPrevious:Nn(Bx,a?.labelPrevious,o.labelPrevious),labelWeekNumber:Nn(Lx,a?.labelWeekNumber,o.labelWeekNumber),labelYearDropdown:Nn(Gx,a?.labelYearDropdown,o.labelYearDropdown),labelGrid:Nn(Sd,a?.labelGrid,o.labelGrid),labelGridcell:Nn(kx,a?.labelGridcell,o.labelGridcell),labelNav:Nn(Ux,a?.labelNav,o.labelNav),labelWeekNumberHeader:Nn(Yx,a?.labelWeekNumberHeader,o.labelWeekNumberHeader),labelWeekday:Nn(Hx,a?.labelWeekday,o.labelWeekday)}}function $C(a,s,o,u,d){const{startOfMonth:m,startOfYear:h,endOfYear:p,eachMonthOfInterval:x,getMonth:b}=d;return x({start:h(a),end:p(a)}).map(S=>{const M=u.formatMonthDropdown(S,d),A=b(S),U=s&&S<m(s)||o&&S>m(o)||!1;return{value:A,label:M,disabled:U}})}function JC(a,s={},o={}){let u={...s?.[ue.Day]};return Object.entries(a).filter(([,d])=>d===!0).forEach(([d])=>{u={...u,...o?.[d]}}),u}function PC(a,s,o,u){const d=u??a.today(),m=o?a.startOfBroadcastWeek(d,a):s?a.startOfISOWeek(d):a.startOfWeek(d),h=[];for(let p=0;p<7;p++){const x=a.addDays(m,p);h.push(x)}return h}function FC(a,s,o,u,d=!1){if(!a||!s)return;const{startOfYear:m,endOfYear:h,eachYearOfInterval:p,getYear:x}=u,b=m(a),w=h(s),v=p({start:b,end:w});return d&&v.reverse(),v.map(S=>{const M=o.formatYearDropdown(S,u);return{value:x(S),label:M,disabled:!1}})}const vi=a=>a instanceof HTMLElement?a:null,Oc=a=>[...a.querySelectorAll("[data-animated-month]")??[]],IC=a=>vi(a.querySelector("[data-animated-month]")),Ac=a=>vi(a.querySelector("[data-animated-caption]")),zc=a=>vi(a.querySelector("[data-animated-weeks]")),ew=a=>vi(a.querySelector("[data-animated-nav]")),tw=a=>vi(a.querySelector("[data-animated-weekdays]"));function nw(a,s,{classNames:o,months:u,focused:d,dateLib:m}){const h=y.useRef(null),p=y.useRef(u),x=y.useRef(!1);y.useLayoutEffect(()=>{const b=p.current;if(p.current=u,!s||!a.current||!(a.current instanceof HTMLElement)||u.length===0||b.length===0||u.length!==b.length)return;const w=m.isSameMonth(u[0].date,b[0].date),v=m.isAfter(u[0].date,b[0].date),S=v?o[ln.caption_after_enter]:o[ln.caption_before_enter],M=v?o[ln.weeks_after_enter]:o[ln.weeks_before_enter],A=h.current,U=a.current.cloneNode(!0);if(U instanceof HTMLElement?(Oc(U).forEach(B=>{if(!(B instanceof HTMLElement))return;const L=IC(B);L&&B.contains(L)&&B.removeChild(L);const k=Ac(B);k&&k.classList.remove(S);const N=zc(B);N&&N.classList.remove(M)}),h.current=U):h.current=null,x.current||w||d)return;const _=A instanceof HTMLElement?Oc(A):[],T=Oc(a.current);if(T?.every(K=>K instanceof HTMLElement)&&_&&_.every(K=>K instanceof HTMLElement)){x.current=!0,a.current.style.isolation="isolate";const K=ew(a.current);K&&(K.style.zIndex="1"),T.forEach((B,L)=>{const k=_[L];if(!k)return;B.style.position="relative",B.style.overflow="hidden";const N=Ac(B);N&&N.classList.add(S);const H=zc(B);H&&H.classList.add(M);const Z=()=>{x.current=!1,a.current&&(a.current.style.isolation=""),K&&(K.style.zIndex=""),N&&N.classList.remove(S),H&&H.classList.remove(M),B.style.position="",B.style.overflow="",B.contains(k)&&B.removeChild(k)};k.style.pointerEvents="none",k.style.position="absolute",k.style.overflow="hidden",k.setAttribute("aria-hidden","true");const te=tw(k);te&&(te.style.opacity="0");const ce=Ac(k);ce&&(ce.classList.add(v?o[ln.caption_before_exit]:o[ln.caption_after_exit]),ce.addEventListener("animationend",Z));const be=zc(k);be&&be.classList.add(v?o[ln.weeks_before_exit]:o[ln.weeks_after_exit]),B.insertBefore(k,B.firstChild)})}})}function aw(a,s,o,u){const d=a[0],m=a[a.length-1],{ISOWeek:h,fixedWeeks:p,broadcastCalendar:x}=o??{},{addDays:b,differenceInCalendarDays:w,differenceInCalendarMonths:v,endOfBroadcastWeek:S,endOfISOWeek:M,endOfMonth:A,endOfWeek:U,isAfter:_,startOfBroadcastWeek:T,startOfISOWeek:K,startOfWeek:B}=u,L=x?T(d,u):h?K(d):B(d),k=x?S(m):h?M(A(m)):U(A(m)),N=s&&(x?S(s):h?M(s):U(s)),H=N&&_(k,N)?N:k,Z=w(H,L),te=v(m,d)+1,ce=[];for(let Ye=0;Ye<=Z;Ye++){const je=b(L,Ye);ce.push(je)}const oe=(x?35:42)*te;if(p&&ce.length<oe){const Ye=oe-ce.length;for(let je=0;je<Ye;je++){const P=b(ce[ce.length-1],1);ce.push(P)}}return ce}function lw(a){const s=[];return a.reduce((o,u)=>{const d=u.weeks.reduce((m,h)=>m.concat(h.days.slice()),s.slice());return o.concat(d.slice())},s.slice())}function sw(a,s,o,u){const{numberOfMonths:d=1}=o,m=[];for(let h=0;h<d;h++){const p=u.addMonths(a,h);if(s&&p>s)break;m.push(p)}return m}function sg(a,s,o,u){const{month:d,defaultMonth:m,today:h=u.today(),numberOfMonths:p=1}=a;let x=d||m||h;const{differenceInCalendarMonths:b,addMonths:w,startOfMonth:v}=u;if(o&&b(o,x)<p-1){const S=-1*(p-1);x=w(o,S)}return s&&b(x,s)<0&&(x=s),v(x)}function iw(a,s,o,u){const{addDays:d,endOfBroadcastWeek:m,endOfISOWeek:h,endOfMonth:p,endOfWeek:x,getISOWeek:b,getWeek:w,startOfBroadcastWeek:v,startOfISOWeek:S,startOfWeek:M}=u,A=a.reduce((U,_)=>{const T=o.broadcastCalendar?v(_,u):o.ISOWeek?S(_):M(_),K=o.broadcastCalendar?m(_):o.ISOWeek?h(p(_)):x(p(_)),B=s.filter(H=>H>=T&&H<=K),L=o.broadcastCalendar?35:42;if(o.fixedWeeks&&B.length<L){const H=s.filter(Z=>{const te=L-B.length;return Z>K&&Z<=d(K,te)});B.push(...H)}const k=B.reduce((H,Z)=>{const te=o.ISOWeek?b(Z):w(Z),ce=H.find(oe=>oe.weekNumber===te),be=new Tx(Z,_,u);return ce?ce.days.push(be):H.push(new nC(te,[be])),H},[]),N=new tC(_,k);return U.push(N),U},[]);return o.reverseMonths?A.reverse():A}function rw(a,s){let{startMonth:o,endMonth:u}=a;const{startOfYear:d,startOfDay:m,startOfMonth:h,endOfMonth:p,addYears:x,endOfYear:b,newDate:w,today:v}=s,{fromYear:S,toYear:M,fromMonth:A,toMonth:U}=a;!o&&A&&(o=A),!o&&S&&(o=s.newDate(S,0,1)),!u&&U&&(u=U),!u&&M&&(u=w(M,11,31));const _=a.captionLayout==="dropdown"||a.captionLayout==="dropdown-years";return o?o=h(o):S?o=w(S,0,1):!o&&_&&(o=d(x(a.today??v(),-100))),u?u=p(u):M?u=w(M,11,31):!u&&_&&(u=b(a.today??v())),[o&&m(o),u&&m(u)]}function ow(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m=1}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m:1,w=h(a);if(!s)return p(w,b);if(!(x(s,a)<m))return p(w,b)}function uw(a,s,o,u){if(o.disableNavigation)return;const{pagedNavigation:d,numberOfMonths:m}=o,{startOfMonth:h,addMonths:p,differenceInCalendarMonths:x}=u,b=d?m??1:1,w=h(a);if(!s)return p(w,-b);if(!(x(w,s)<=0))return p(w,-b)}function cw(a){const s=[];return a.reduce((o,u)=>o.concat(u.weeks.slice()),s.slice())}function io(a,s){const[o,u]=y.useState(a);return[s===void 0?o:s,u]}function dw(a,s){const[o,u]=rw(a,s),{startOfMonth:d,endOfMonth:m}=s,h=sg(a,o,u,s),[p,x]=io(h,a.month?h:void 0);y.useEffect(()=>{const L=sg(a,o,u,s);x(L)},[a.timeZone]);const{months:b,weeks:w,days:v,previousMonth:S,nextMonth:M}=y.useMemo(()=>{const L=sw(p,u,{numberOfMonths:a.numberOfMonths},s),k=aw(L,a.endMonth?m(a.endMonth):void 0,{ISOWeek:a.ISOWeek,fixedWeeks:a.fixedWeeks,broadcastCalendar:a.broadcastCalendar},s),N=iw(L,k,{broadcastCalendar:a.broadcastCalendar,fixedWeeks:a.fixedWeeks,ISOWeek:a.ISOWeek,reverseMonths:a.reverseMonths},s),H=cw(N),Z=lw(N),te=uw(p,o,a,s),ce=ow(p,u,a,s);return{months:N,weeks:H,days:Z,previousMonth:te,nextMonth:ce}},[s,p.getTime(),u?.getTime(),o?.getTime(),a.disableNavigation,a.broadcastCalendar,a.endMonth?.getTime(),a.fixedWeeks,a.ISOWeek,a.numberOfMonths,a.pagedNavigation,a.reverseMonths]),{disableNavigation:A,onMonthChange:U}=a,_=L=>w.some(k=>k.days.some(N=>N.isEqualTo(L))),T=L=>{if(A)return;let k=d(L);o&&k<d(o)&&(k=d(o)),u&&k>d(u)&&(k=d(u)),x(k),U?.(k)};return{months:b,weeks:w,days:v,navStart:o,navEnd:u,previousMonth:S,nextMonth:M,goToMonth:T,goToDay:L=>{_(L)||T(L.date)}}}var kn;(function(a){a[a.Today=0]="Today",a[a.Selected=1]="Selected",a[a.LastFocused=2]="LastFocused",a[a.FocusedModifier=3]="FocusedModifier"})(kn||(kn={}));function ig(a){return!a[lt.disabled]&&!a[lt.hidden]&&!a[lt.outside]}function fw(a,s,o,u){let d,m=-1;for(const h of a){const p=s(h);ig(p)&&(p[lt.focused]&&m<kn.FocusedModifier?(d=h,m=kn.FocusedModifier):u?.isEqualTo(h)&&m<kn.LastFocused?(d=h,m=kn.LastFocused):o(h.date)&&m<kn.Selected?(d=h,m=kn.Selected):p[lt.today]&&m<kn.Today&&(d=h,m=kn.Today))}return d||(d=a.find(h=>ig(s(h)))),d}function mw(a,s,o,u,d,m,h){const{ISOWeek:p,broadcastCalendar:x}=m,{addDays:b,addMonths:w,addWeeks:v,addYears:S,endOfBroadcastWeek:M,endOfISOWeek:A,endOfWeek:U,max:_,min:T,startOfBroadcastWeek:K,startOfISOWeek:B,startOfWeek:L}=h;let N={day:b,week:v,month:w,year:S,startOfWeek:H=>x?K(H,h):p?B(H):L(H),endOfWeek:H=>x?M(H):p?A(H):U(H)}[a](o,s==="after"?1:-1);return s==="before"&&u?N=_([u,N]):s==="after"&&d&&(N=T([d,N])),N}function Kx(a,s,o,u,d,m,h,p=0){if(p>365)return;const x=mw(a,s,o.date,u,d,m,h),b=!!(m.disabled&&fa(x,m.disabled,h)),w=!!(m.hidden&&fa(x,m.hidden,h)),v=x,S=new Tx(x,v,h);return!b&&!w?S:Kx(a,s,S,u,d,m,h,p+1)}function hw(a,s,o,u,d){const{autoFocus:m}=a,[h,p]=y.useState(),x=fw(s.days,o,u||(()=>!1),h),[b,w]=y.useState(m?x:void 0);return{isFocusTarget:U=>!!x?.isEqualTo(U),setFocused:w,focused:b,blur:()=>{p(b),w(void 0)},moveFocus:(U,_)=>{if(!b)return;const T=Kx(U,_,b,s.navStart,s.navEnd,a,d);T&&(a.disableNavigation&&!s.days.some(B=>B.isEqualTo(T))||(s.goToDay(T),w(T)))}}}function pw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s,b=M=>p?.some(A=>x(A,M))??!1,{min:w,max:v}=a;return{selected:p,select:(M,A,U)=>{let _=[...p??[]];if(b(M)){if(p?.length===w||u&&p?.length===1)return;_=p?.filter(T=>!x(T,M))}else p?.length===v?_=[M]:_=[..._,M];return d||h(_),d?.(_,M,A,U),_},isSelected:b}}function gw(a,s,o=0,u=0,d=!1,m=qn){const{from:h,to:p}=s||{},{isSameDay:x,isAfter:b,isBefore:w}=m;let v;if(!h&&!p)v={from:a,to:o>0?void 0:a};else if(h&&!p)x(h,a)?o===0?v={from:h,to:a}:d?v={from:h,to:void 0}:v=void 0:w(a,h)?v={from:a,to:h}:v={from:h,to:a};else if(h&&p)if(x(h,a)&&x(p,a))d?v={from:h,to:p}:v=void 0;else if(x(h,a))v={from:h,to:o>0?void 0:a};else if(x(p,a))v={from:a,to:o>0?void 0:a};else if(w(a,h))v={from:a,to:p};else if(b(a,h))v={from:h,to:a};else if(b(a,p))v={from:h,to:a};else throw new Error("Invalid range");if(v?.from&&v?.to){const S=m.differenceInCalendarDays(v.to,v.from);u>0&&S>u?v={from:a,to:void 0}:o>1&&S<o&&(v={from:a,to:void 0})}return v}function xw(a,s,o=qn){const u=Array.isArray(s)?s:[s];let d=a.from;const m=o.differenceInCalendarDays(a.to,a.from),h=Math.min(m,6);for(let p=0;p<=h;p++){if(u.includes(d.getDay()))return!0;d=o.addDays(d,1)}return!1}function rg(a,s,o=qn){return da(a,s.from,!1,o)||da(a,s.to,!1,o)||da(s,a.from,!1,o)||da(s,a.to,!1,o)}function yw(a,s,o=qn){const u=Array.isArray(s)?s:[s];if(u.filter(p=>typeof p!="function").some(p=>typeof p=="boolean"?p:o.isDate(p)?da(a,p,!1,o):zx(p,o)?p.some(x=>da(a,x,!1,o)):so(p)?p.from&&p.to?rg(a,{from:p.from,to:p.to},o):!1:Ax(p)?xw(a,p.dayOfWeek,o):xd(p)?o.isAfter(p.before,p.after)?rg(a,{from:o.addDays(p.after,1),to:o.addDays(p.before,-1)},o):fa(a.from,p,o)||fa(a.to,p,o):yd(p)||vd(p)?fa(a.from,p,o)||fa(a.to,p,o):!1))return!0;const h=u.filter(p=>typeof p=="function");if(h.length){let p=a.from;const x=o.differenceInCalendarDays(a.to,a.from);for(let b=0;b<=x;b++){if(h.some(w=>w(p)))return!0;p=o.addDays(p,1)}}return!1}function vw(a,s){const{disabled:o,excludeDisabled:u,selected:d,required:m,onSelect:h}=a,[p,x]=io(d,h?d:void 0),b=h?d:p;return{selected:b,select:(S,M,A)=>{const{min:U,max:_}=a,T=S?gw(S,b,U,_,m,s):void 0;return u&&o&&T?.from&&T.to&&yw({from:T.from,to:T.to},o,s)&&(T.from=S,T.to=void 0),h||x(T),h?.(T,S,M,A),T},isSelected:S=>b&&da(b,S,!1,s)}}function bw(a,s){const{selected:o,required:u,onSelect:d}=a,[m,h]=io(o,d?o:void 0),p=d?o:m,{isSameDay:x}=s;return{selected:p,select:(v,S,M)=>{let A=v;return!u&&p&&p&&x(v,p)&&(A=void 0),d||h(A),d?.(A,v,S,M),A},isSelected:v=>p?x(p,v):!1}}function Sw(a,s){const o=bw(a,s),u=pw(a,s),d=vw(a,s);switch(a.mode){case"single":return o;case"multiple":return u;case"range":return d;default:return}}function Ot(a,s){return a instanceof ca&&a.timeZone===s?a:new ca(a,s)}function og(a,s){return typeof a=="boolean"||typeof a=="function"?a:a instanceof Date?Ot(a,s):Array.isArray(a)?a.map(o=>o instanceof Date?Ot(o,s):o):so(a)?{...a,from:a.from?Ot(a.from,s):a.from,to:a.to?Ot(a.to,s):a.to}:xd(a)?{before:Ot(a.before,s),after:Ot(a.after,s)}:yd(a)?{after:Ot(a.after,s)}:vd(a)?{before:Ot(a.before,s)}:a}function Dc(a,s){return a&&(Array.isArray(a)?a.map(o=>og(o,s)):og(a,s))}function jw(a){let s=a;const o=s.timeZone;if(o&&(s={...a,timeZone:o},s.today&&(s.today=Ot(s.today,o)),s.month&&(s.month=Ot(s.month,o)),s.defaultMonth&&(s.defaultMonth=Ot(s.defaultMonth,o)),s.startMonth&&(s.startMonth=Ot(s.startMonth,o)),s.endMonth&&(s.endMonth=Ot(s.endMonth,o)),s.mode==="single"&&s.selected?s.selected=Ot(s.selected,o):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(re=>Ot(re,o)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?Ot(s.selected.from,o):s.selected.from,to:s.selected.to?Ot(s.selected.to,o):s.selected.to}),s.disabled!==void 0&&(s.disabled=Dc(s.disabled,o)),s.hidden!==void 0&&(s.hidden=Dc(s.hidden,o)),s.modifiers)){const re={};Object.keys(s.modifiers).forEach(Se=>{re[Se]=Dc(s.modifiers?.[Se],o)}),s.modifiers=re}const{components:u,formatters:d,labels:m,dateLib:h,locale:p,classNames:x}=y.useMemo(()=>{const re={...Mx,...s.locale},Se=new sn({locale:re,weekStartsOn:s.broadcastCalendar?1:s.weekStartsOn,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},s.dateLib);return{dateLib:Se,components:DC(s.components),formatters:KC(s.formatters),labels:WC(s.labels,Se.options),locale:re,classNames:{...kC(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:h.today()});const{captionLayout:b,mode:w,navLayout:v,numberOfMonths:S=1,onDayBlur:M,onDayClick:A,onDayFocus:U,onDayKeyDown:_,onDayMouseEnter:T,onDayMouseLeave:K,onNextClick:B,onPrevClick:L,showWeekNumber:k,styles:N}=s,{formatCaption:H,formatDay:Z,formatMonthDropdown:te,formatWeekNumber:ce,formatWeekNumberHeader:be,formatWeekdayName:oe,formatYearDropdown:Ye}=d,je=dw(s,h),{days:P,months:O,navStart:W,navEnd:se,previousMonth:ye,nextMonth:ve,goToMonth:De}=je,ze=AC(P,s,W,se,h),{isSelected:X,select:J,selected:ne}=Sw(s,h)??{},{blur:F,focused:ee,isFocusTarget:fe,moveFocus:Ae,setFocused:Ge}=hw(s,je,ze,X??(()=>!1),h),{labelDayButton:yt,labelGridcell:vt,labelGrid:Qe,labelMonthDropdown:tt,labelNav:kt,labelPrevious:Qt,labelNext:Bn,labelWeekday:Ne,labelWeekNumber:Vt,labelWeekNumberHeader:En,labelYearDropdown:Xt}=m,ma=y.useMemo(()=>PC(h,s.ISOWeek,s.broadcastCalendar,s.today),[h,s.ISOWeek,s.broadcastCalendar,s.today]),Hn=w!==void 0||A!==void 0,ct=y.useCallback(()=>{ye&&(De(ye),L?.(ye))},[ye,De,L]),Zt=y.useCallback(()=>{ve&&(De(ve),B?.(ve))},[De,ve,B]),Ln=y.useCallback((re,Se)=>he=>{he.preventDefault(),he.stopPropagation(),Ge(re),!Se.disabled&&(J?.(re.date,Se,he),A?.(re.date,Se,he))},[J,A,Ge]),Va=y.useCallback((re,Se)=>he=>{Ge(re),U?.(re.date,Se,he)},[U,Ge]),Mn=y.useCallback((re,Se)=>he=>{F(),M?.(re.date,Se,he)},[F,M]),Tn=y.useCallback((re,Se)=>he=>{const Te={ArrowLeft:[he.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[he.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[he.shiftKey?"year":"week","after"],ArrowUp:[he.shiftKey?"year":"week","before"],PageUp:[he.shiftKey?"year":"month","before"],PageDown:[he.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Te[he.key]){he.preventDefault(),he.stopPropagation();const[Fe,xe]=Te[he.key];Ae(Fe,xe)}_?.(re.date,Se,he)},[Ae,_,s.dir]),xl=y.useCallback((re,Se)=>he=>{T?.(re.date,Se,he)},[T]),us=y.useCallback((re,Se)=>he=>{K?.(re.date,Se,he)},[K]),cs=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setMonth(h.startOfMonth(re),he);De(Te)},[h,De]),Yn=y.useCallback(re=>Se=>{const he=Number(Se.target.value),Te=h.setYear(h.startOfMonth(re),he);De(Te)},[h,De]),{className:$,style:Ee}=y.useMemo(()=>({className:[x[ue.Root],s.className].filter(Boolean).join(" "),style:{...N?.[ue.Root],...s.style}}),[x,s.className,s.style,N]),me=_C(s),Me=y.useRef(null);nw(Me,!!s.animate,{classNames:x,months:O,focused:ee,dateLib:h});const nt={dayPickerProps:s,selected:ne,select:J,isSelected:X,months:O,nextMonth:ve,previousMonth:ye,goToMonth:De,getModifiers:ze,components:u,classNames:x,styles:N,labels:m,formatters:d};return I.createElement(Ox.Provider,{value:nt},I.createElement(u.Root,{rootRef:s.animate?Me:void 0,className:$,style:Ee,dir:s.dir,id:s.id,lang:s.lang,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...me},I.createElement(u.Months,{className:x[ue.Months],style:N?.[ue.Months]},!s.hideNavigation&&!v&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),O.map((re,Se)=>I.createElement(u.Month,{"data-animated-month":s.animate?"true":void 0,className:x[ue.Month],style:N?.[ue.Month],key:Se,displayIndex:Se,calendarMonth:re},v==="around"&&!s.hideNavigation&&Se===0&&I.createElement(u.PreviousMonthButton,{type:"button",className:x[ue.PreviousMonthButton],tabIndex:ye?void 0:-1,"aria-disabled":ye?void 0:!0,"aria-label":Qt(ye),onClick:ct,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ye?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"right":"left"})),I.createElement(u.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:x[ue.MonthCaption],style:N?.[ue.MonthCaption],calendarMonth:re,displayIndex:Se},b?.startsWith("dropdown")?I.createElement(u.DropdownNav,{className:x[ue.Dropdowns],style:N?.[ue.Dropdowns]},(()=>{const he=b==="dropdown"||b==="dropdown-months"?I.createElement(u.MonthsDropdown,{key:"month",className:x[ue.MonthsDropdown],"aria-label":tt(),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:cs(re.date),options:$C(re.date,W,se,d,h),style:N?.[ue.Dropdown],value:h.getMonth(re.date)}):I.createElement("span",{key:"month"},te(re.date,h)),Te=b==="dropdown"||b==="dropdown-years"?I.createElement(u.YearsDropdown,{key:"year",className:x[ue.YearsDropdown],"aria-label":Xt(h.options),classNames:x,components:u,disabled:!!s.disableNavigation,onChange:Yn(re.date),options:FC(W,se,d,h,!!s.reverseYears),style:N?.[ue.Dropdown],value:h.getYear(re.date)}):I.createElement("span",{key:"year"},Ye(re.date,h));return h.getMonthYearOrder()==="year-first"?[Te,he]:[he,Te]})(),I.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},H(re.date,h.options,h))):I.createElement(u.CaptionLabel,{className:x[ue.CaptionLabel],role:"status","aria-live":"polite"},H(re.date,h.options,h))),v==="around"&&!s.hideNavigation&&Se===S-1&&I.createElement(u.NextMonthButton,{type:"button",className:x[ue.NextMonthButton],tabIndex:ve?void 0:-1,"aria-disabled":ve?void 0:!0,"aria-label":Bn(ve),onClick:Zt,"data-animated-button":s.animate?"true":void 0},I.createElement(u.Chevron,{disabled:ve?void 0:!0,className:x[ue.Chevron],orientation:s.dir==="rtl"?"left":"right"})),Se===S-1&&v==="after"&&!s.hideNavigation&&I.createElement(u.Nav,{"data-animated-nav":s.animate?"true":void 0,className:x[ue.Nav],style:N?.[ue.Nav],"aria-label":kt(),onPreviousClick:ct,onNextClick:Zt,previousMonth:ye,nextMonth:ve}),I.createElement(u.MonthGrid,{role:"grid","aria-multiselectable":w==="multiple"||w==="range","aria-label":Qe(re.date,h.options,h)||void 0,className:x[ue.MonthGrid],style:N?.[ue.MonthGrid]},!s.hideWeekdays&&I.createElement(u.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:x[ue.Weekdays],style:N?.[ue.Weekdays]},k&&I.createElement(u.WeekNumberHeader,{"aria-label":En(h.options),className:x[ue.WeekNumberHeader],style:N?.[ue.WeekNumberHeader],scope:"col"},be()),ma.map(he=>I.createElement(u.Weekday,{"aria-label":Ne(he,h.options,h),className:x[ue.Weekday],key:String(he),style:N?.[ue.Weekday],scope:"col"},oe(he,h.options,h)))),I.createElement(u.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:x[ue.Weeks],style:N?.[ue.Weeks]},re.weeks.map(he=>I.createElement(u.Week,{className:x[ue.Week],key:he.weekNumber,style:N?.[ue.Week],week:he},k&&I.createElement(u.WeekNumber,{week:he,style:N?.[ue.WeekNumber],"aria-label":Vt(he.weekNumber,{locale:p}),className:x[ue.WeekNumber],scope:"row",role:"rowheader"},ce(he.weekNumber,h)),he.days.map(Te=>{const{date:Fe}=Te,xe=ze(Te);if(xe[lt.focused]=!xe.hidden&&!!ee?.isEqualTo(Te),xe[Cn.selected]=X?.(Fe)||xe.selected,so(ne)){const{from:Wt,to:vn}=ne;xe[Cn.range_start]=!!(Wt&&vn&&h.isSameDay(Fe,Wt)),xe[Cn.range_end]=!!(Wt&&vn&&h.isSameDay(Fe,vn)),xe[Cn.range_middle]=da(ne,Fe,!0,h)}const Dt=JC(xe,N,s.modifiersStyles),Gn=zC(xe,x,s.modifiersClassNames),St=!Hn&&!xe.hidden?vt(Fe,xe,h.options,h):void 0;return I.createElement(u.Day,{key:`${Te.isoDate}_${Te.displayMonthId}`,day:Te,modifiers:xe,className:Gn.join(" "),style:Dt,role:"gridcell","aria-selected":xe.selected||void 0,"aria-label":St,"data-day":Te.isoDate,"data-month":Te.outside?Te.dateMonthId:void 0,"data-selected":xe.selected||void 0,"data-disabled":xe.disabled||void 0,"data-hidden":xe.hidden||void 0,"data-outside":Te.outside||void 0,"data-focused":xe.focused||void 0,"data-today":xe.today||void 0},!xe.hidden&&Hn?I.createElement(u.DayButton,{className:x[ue.DayButton],style:N?.[ue.DayButton],type:"button",day:Te,modifiers:xe,disabled:!xe.focused&&xe.disabled||void 0,"aria-disabled":xe.focused&&xe.disabled||void 0,tabIndex:fe(Te)?0:-1,"aria-label":yt(Fe,xe,h.options,h),onClick:Ln(Te,xe),onBlur:Mn(Te,xe),onFocus:Va(Te,xe),onKeyDown:Tn(Te,xe),onMouseEnter:xl(Te,xe),onMouseLeave:us(Te,xe)},Z(Fe,h.options,h)):!xe.hidden&&Z(Te.date,h.options,h))})))))))),s.footer&&I.createElement(u.Footer,{className:x[ue.Footer],style:N?.[ue.Footer],role:"status","aria-live":"polite"},s.footer)))}function Nw({className:a,classNames:s,showOutsideDays:o=!0,...u}){return i.jsx(jw,{showOutsideDays:o,className:G("p-2",a),classNames:{root:"relative",months:"flex flex-col sm:flex-row gap-2 sm:gap-4",month:"flex flex-col gap-2",month_caption:"flex justify-center pt-1 relative items-center h-8",caption_label:"text-sm font-medium",nav:"absolute inset-x-0 top-2 flex items-center justify-between px-1 z-10",button_previous:G(Ur({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),button_next:G(Ur({variant:"ghost"}),"h-7 w-7 bg-transparent p-0 opacity-70 hover:opacity-100 hover:bg-accent rounded-md"),month_grid:"w-full border-collapse",weekdays:"flex w-full",weekday:"text-muted-foreground w-8 font-normal text-xs text-center",weeks:"flex flex-col",week:"flex w-full",day:G("relative h-8 w-8 p-0 text-center text-xs font-normal focus-within:relative focus-within:z-20","hover:bg-accent hover:text-accent-foreground rounded-full select-none"),day_button:G(Ur({variant:"ghost"}),"h-8 w-8 p-0 font-normal rounded-full text-xs","aria-selected:opacity-100"),range_start:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-l-full aria-selected:rounded-r-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_end:G("aria-selected:bg-primary aria-selected:text-primary-foreground","aria-selected:rounded-r-full aria-selected:rounded-l-none","aria-selected:hover:bg-primary aria-selected:hover:text-primary-foreground"),range_middle:G("aria-selected:bg-accent aria-selected:text-accent-foreground","aria-selected:rounded-none"),selected:G("bg-primary text-primary-foreground rounded-full","hover:bg-primary hover:text-primary-foreground","focus:bg-primary focus:text-primary-foreground"),today:"bg-accent text-accent-foreground rounded-full",outside:"text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",disabled:"text-muted-foreground opacity-50",hidden:"invisible",...s},components:{Chevron:({orientation:d,className:m,...h})=>{const p=d==="left"?bb:d==="right"?Vr:d==="up"?Xc:Pr;return i.jsx(p,{className:G("h-4 w-4",m),...h})}},...u})}Nw.displayName="Calendar";function Cw(){const[a,s]=y.useState(""),[o,u]=y.useState(""),[d,m]=y.useState(null),[h,p]=y.useState(!1),{login:x,authRequired:b,isAuthenticated:w}=Pc(),v=Gc(),M=Yc().state?.from?.pathname||"/";if(y.useEffect(()=>{(w||!b)&&v(M,{replace:!0})},[w,b,v,M]),w||!b)return null;const A=async U=>{U.preventDefault(),m(null),p(!0);try{await x(a,o),v(M,{replace:!0})}catch(_){m(_ instanceof Error?_.message:"Login failed")}finally{p(!1)}};return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs(x2,{className:"w-full max-w-sm",children:[i.jsxs(y2,{className:"space-y-1 text-center",children:[i.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:i.jsx(Sb,{className:"h-6 w-6 text-primary"})}),i.jsx(v2,{className:"text-2xl",children:"CCS Dashboard"}),i.jsx(b2,{children:"Enter your credentials to access the dashboard"})]}),i.jsx(S2,{children:i.jsxs("form",{onSubmit:A,className:"space-y-4",children:[d&&i.jsxs(md,{variant:"destructive",children:[i.jsx(Wc,{className:"h-4 w-4"}),i.jsx(hd,{children:d})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"username",children:"Username"}),i.jsx(_n,{id:"username",type:"text",value:a,onChange:U=>s(U.target.value),placeholder:"Enter username",autoComplete:"username",disabled:h,required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(yn,{htmlFor:"password",children:"Password"}),i.jsx(_n,{id:"password",type:"password",value:o,onChange:U=>u(U.target.value),placeholder:"Enter password",autoComplete:"current-password",disabled:h,required:!0})]}),i.jsx(ot,{type:"submit",className:"w-full",disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsx(Un,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})})]})})}const ww=y.lazy(()=>zt(()=>import("./index-BXTtPkoG.js"),__vite__mapDeps([17,1,2,4,5,7,18,6,8,9])).then(a=>({default:a.AnalyticsPage}))),Ew=y.lazy(()=>zt(()=>import("./api-ClPWraVr.js"),__vite__mapDeps([19,1,2,5,20,14,6,4,7,8,9])).then(a=>({default:a.ApiPage}))),Mw=y.lazy(()=>zt(()=>import("./cliproxy-C0JgtLfO.js"),__vite__mapDeps([21,1,2,5,6,4,20,14,3,13,7,8,9])).then(a=>({default:a.CliproxyPage}))),Tw=y.lazy(()=>zt(()=>import("./cliproxy-control-panel-CBO7xTqe.js"),__vite__mapDeps([22,1,2,5,4,6,7,8,9])).then(a=>({default:a.CliproxyControlPanelPage}))),Ow=y.lazy(()=>zt(()=>import("./copilot-DCA0pQV3.js"),__vite__mapDeps([23,1,2,5,20,14,4,3,6,7,8,9])).then(a=>({default:a.CopilotPage}))),Aw=y.lazy(()=>zt(()=>import("./accounts-ResKjvou.js"),__vite__mapDeps([24,1,2,5,14,6,4,7,8,9])).then(a=>({default:a.AccountsPage}))),zw=y.lazy(()=>zt(()=>Promise.resolve().then(()=>X2),void 0).then(a=>({default:a.SettingsPage}))),Dw=y.lazy(()=>zt(()=>import("./health-riN3OSz-.js"),__vite__mapDeps([25,1,2,5,6,4,7,8,9])).then(a=>({default:a.HealthPage}))),_w=y.lazy(()=>zt(()=>import("./shared-PuUIRrgy.js"),__vite__mapDeps([26,1,2,4,5,6,7,8,9])).then(a=>({default:a.SharedPage})));function oa(){return i.jsx("div",{className:"flex h-64 items-center justify-center",children:i.jsx(Un,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function kw(){return i.jsx(Yv,{client:pS,children:i.jsx(xS,{defaultTheme:"system",storageKey:"vite-ui-theme",children:i.jsx(yS,{children:i.jsx(NS,{children:i.jsxs(Bv,{children:[i.jsxs(Hv,{children:[i.jsx(nn,{path:"/login",element:i.jsx(Cw,{})}),i.jsx(nn,{element:i.jsx(CS,{}),children:i.jsxs(nn,{element:i.jsx(J1,{}),children:[i.jsx(nn,{path:"/",element:i.jsx(XN,{})}),i.jsx(nn,{path:"/analytics",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(ww,{})})}),i.jsx(nn,{path:"/providers",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ew,{})})}),i.jsx(nn,{path:"/cliproxy",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Mw,{})})}),i.jsx(nn,{path:"/cliproxy/control-panel",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Tw,{})})}),i.jsx(nn,{path:"/copilot",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Ow,{})})}),i.jsx(nn,{path:"/accounts",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Aw,{})})}),i.jsx(nn,{path:"/settings",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(zw,{})})}),i.jsx(nn,{path:"/health",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(Dw,{})})}),i.jsx(nn,{path:"/shared",element:i.jsx(y.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(_w,{})})})]})})]}),i.jsx(Gv,{position:"top-right"})]})})})})})}const Qx=document.getElementById("root");if(!Qx)throw new Error("Root element not found. Failed to mount React application.");fS.createRoot(Qx).render(i.jsx(y.StrictMode,{children:i.jsx(kw,{})}));export{M2 as $,l2 as A,La as B,x2 as C,gE as D,x1 as E,y1 as F,v1 as G,mx as H,_n as I,pd as J,Kr as K,yn as L,Bc as M,vE as N,b2 as O,Hg as P,SE as Q,bE as R,Le as S,Ya as T,jE as U,gx as V,NE as W,EE as X,C2 as Y,TE as Z,w2 as _,S2 as a,Sx as a$,m1 as a0,Vw as a1,Fw as a2,Iw as a3,nd as a4,ad as a5,ld as a6,sd as a7,id as a8,CE as a9,g1 as aA,Zw as aB,Ww as aC,h1 as aD,p1 as aE,$w as aF,Jw as aG,Pw as aH,Xw as aI,xx as aJ,zt as aK,KN as aL,hE as aM,md as aN,fx as aO,hd as aP,Nx as aQ,L2 as aR,G2 as aS,oE as aT,sE as aU,uE as aV,iE as aW,rE as aX,dE as aY,cE as aZ,Ur as a_,N2 as aa,wE as ab,fE as ac,mE as ad,Ze as ae,eE as af,ME as ag,E2 as ah,q1 as ai,Mj as aj,qS as ak,BS as al,ml as am,G1 as an,K1 as ao,Q1 as ap,V1 as aq,A2 as ar,Tj as as,Vg as at,tE as au,nE as av,aE as aw,lE as ax,OE as ay,Qw as az,ot as b,G as c,AE as d,zE as e,Z2 as f,Nw as g,Kw as h,y2 as i,v2 as j,xj as k,yj as l,gl as m,DE as n,Ga as o,Ka as p,Hp as q,r2 as r,yE as s,PN as t,$c as u,a2 as v,pE as w,xE as x,WN as y,t2 as z};
|